19 declare(strict_types=1);
32 private int $mode = self::MODE_UNDEFINED;
72 parent::startParsing();
75 $this->
getWebLink()->setTitle($this->list_title ?? $this->first_item_title);
76 $this->
getWebLink()->setDescription($this->list_description ?? $this->first_item_description);
90 public function setMode(
int $a_mode): void
92 $this->mode = $a_mode;
102 $this->current_item_create =
false;
103 $this->current_item_update =
false;
104 $this->current_item_delete =
false;
106 $this->current_link_id =
null;
107 $this->current_title =
null;
108 $this->current_target =
null;
109 $this->current_active =
null;
110 $this->current_parameters = [];
111 $this->current_description =
null;
112 $this->current_internal =
null;
137 $this->current_sorting_position = (
int) ($a_attribs[
'position'] ?: 0);
141 $this->
getMode() == self::MODE_CREATE ||
142 ($a_attribs[
'action'] ??
null) ===
'Create' 144 $this->current_item_create =
true;
146 if (!($a_attribs[
'id'] ??
false)) {
148 'Updating or deleting not possible, no id was given for element "Weblink"' 152 $this->
getMode() == self::MODE_UPDATE &&
153 ($a_attribs[
'action'] ?? null) ===
'Delete' 155 $this->current_item_delete =
true;
156 $this->web_link_repo->deleteItemByLinkId($a_attribs[
'id']);
159 $this->
getMode() == self::MODE_UPDATE &&
160 (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Update')
162 $this->current_link_id = $a_attribs[
'id'];
163 $this->current_item_update =
true;
166 'Invalid action given for element "Weblink"' 172 $this->current_active = (bool) $a_attribs[
'active'];
175 if (isset($a_attribs[
'internal'])) {
176 $this->current_internal = (bool) $a_attribs[
'internal'];
187 switch ($a_attribs[
'type'] ?? null) {
200 $this->sorting_positions = array();
206 case 'ListDescription':
210 case 'DynamicParameter':
211 if (!($a_attribs[
'name'] ??
false)) {
213 'No attribute "name" given for element "Dynamic parameter". Aborting' 216 $name = $a_attribs[
'name'] ??
null;
218 switch ($a_attribs[
'type'] ?? null) {
227 case 'matriculation':
233 'Invalid attribute "type" given for element "Dynamic parameter". Aborting' 238 if ($this->current_item_update && ($a_attribs[
'id'] ?? null)) {
239 $item = $this->web_link_repo->getItemByLinkId($this->current_link_id);
240 $old_param = $this->web_link_repo->getParameterinItemByParamId(
244 $param->replaces($old_param);
246 $this->current_parameters[] =
$param;
251 $this->is_list =
true;
262 if ($this->is_list || !$this->web_link_repo->doesOnlyOneItemExist()) {
265 $this->list_description ?? $this->
getWebLink()->getDescription()
268 if (!$this->web_link_repo->doesListExist()) {
269 $this->web_link_repo->createList($list_draft);
271 $this->web_link_repo->updateList(
272 $this->web_link_repo->getList(),
282 $sorting->savePost($this->sorting_positions);
284 $this->sorting_positions
290 if ($this->current_item_delete) {
294 if (!$this->current_item_create && !$this->current_item_update) {
296 'Invalid xml structure given. Missing start tag "WebLink"' 299 if (!$this->current_title || !$this->current_target) {
301 'Missing required elements "Title, Target"' 305 if ($this->current_item_update) {
306 $item = $this->web_link_repo->getItemByLinkId($this->current_link_id);
308 $this->current_internal ?? $item->isInternal(),
309 $this->current_title ?? $item->getTitle(),
310 $this->current_description ?? $item->getDescription(),
311 $this->current_target ?? $item->getTarget(),
312 $this->current_active ?? $item->isActive(),
316 $this->web_link_repo->updateItem($item, $draft);
320 $this->current_title,
321 $this->current_description ??
null,
322 $this->current_target,
323 $this->current_active,
324 $this->current_parameters
326 $item = $this->web_link_repo->createItem($draft);
336 $this->current_title = trim($this->cdata);
337 if (!isset($this->first_item_title)) {
343 $this->current_description = trim($this->cdata);
344 if (!isset($this->first_item_description)) {
350 $this->current_target = trim($this->cdata);
354 $this->list_title = trim($this->cdata);
357 case 'ListDescription':
358 $this->list_description = trim($this->cdata);
368 if ($a_data !=
"\n") {
370 $a_data = preg_replace(
"/\t+/",
" ", $a_data);
371 $this->cdata .= $a_data;
378 foreach ($attribs as $k => $v) {
setThrowException(bool $throw_exception)
Draft class for creating and updating a parameter attached to Web Link items.
string $first_item_description
static getLogger(string $a_component_id)
Get component logger.
bool $current_item_update
bool $current_item_delete
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
trimAndStrip(string $input)
handlerEndTag($a_xml_parser, string $a_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setWebLink(ilObjLinkResource $webl)
array $current_parameters
trimAndStripAttribs(array $attribs)
int $current_sorting_position
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilObjLinkResource $webr, string $xml)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setHandlers($a_xml_parser)
const array VALUES
TODO Once the GUI is updated, undefined can be dropped.
handlerBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
bool $current_item_create
handlerCharacterData($a_xml_parser, string $a_data)
Draft class for creating or updating a Web Link list.
string $current_description
__construct(Container $dic, ilPlugin $plugin)
static _getInstance(int $a_obj_id)
ilWebLinkRepository $web_link_repo
Draft class for creating and updating a Web Link item.
setXMLContent(string $a_xml_content)