protected function afterSave(ilObject $a_new_object) { global $ilUser, $tree; // add default translation $a_new_object->addTranslation($a_new_object->getTitle(), $a_new_object->getDescription(), $ilUser->getPref("language"), true); // default: sort by title include_once 'Services/Container/classes/class.ilContainerSortingSettings.php'; $settings = new ilContainerSortingSettings($a_new_object->getId()); $settings->setSortMode(ilContainer::SORT_TITLE); $settings->save(); // inherit parents content style, if not individual $parent_ref_id = $tree->getParentId($a_new_object->getRefId()); $parent_id = ilObject::_lookupObjId($parent_ref_id); include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $style_id = ilObjStyleSheet::lookupObjectStyle($parent_id); if ($style_id > 0) { if (ilObjStyleSheet::_lookupStandard($style_id)) { ilObjStyleSheet::writeStyleUsage($a_new_object->getId(), $style_id); } } // always send a message ilUtil::sendSuccess($this->lng->txt("cat_added"), true); $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId()); $this->redirectToRefId($a_new_object->getRefId(), ""); }
/** * handler for begin of element * * @param resource $a_xml_parser xml parser * @param string $a_name element name * @param array $a_attribs element attributes array */ public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs) { global $ilErr; if ($this->in_metadata) { parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs); return; } switch ($a_name) { case "MetaData": $this->in_metadata = true; // Delete old meta data $md = new ilMD($this->getWebLink()->getId(), 0, 'webr'); $md->deleteAll(); parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs); break; case 'WebLink': $this->current_link_update = false; $this->current_link_delete = false; $this->current_parameters = array(); if ($this->getMode() == self::MODE_CREATE or isset($a_attribs['action']) and $a_attribs['action'] == 'Create') { // New weblink $this->current_link = new ilLinkResourceItems($this->getWebLink()->getId()); } elseif ($this->getMode() == self::MODE_UPDATE and $a_attribs['action'] == 'Delete') { $this->current_link_delete = true; $this->current_link = new ilLinkResourceItems($this->getWebLink()->getId()); $this->current_link->delete($a_attribs['id']); break; } elseif ($this->getMode() == self::MODE_UPDATE and ($a_attribs['action'] == 'Update' or !isset($a_attribs['action']))) { $this->current_link = new ilLinkResourceItems($this->getWebLink()->getId()); $this->current_link->readItem($a_attribs['id']); $this->current_link_update = true; // Delete all dynamic parameter include_once './Modules/WebResource/classes/class.ilParameterAppender.php'; foreach (ilParameterAppender::getParameterIds($this->getWebLink()->getId(), $a_attribs['id']) as $param_id) { $param = new ilParameterAppender($this->getWebLink()->getId()); $param->delete($param_id); } } else { throw new ilWebLinkXmlParserException('Invalid action given for element "Weblink"'); } // Active $this->current_link->setActiveStatus($a_attribs['active'] ? 1 : 0); // Valid if (!isset($a_attribs['valid'])) { $valid = 1; } else { $valid = $a_attribs['valid'] ? 1 : 0; } $this->current_link->setValidStatus($valid); // Disable check $this->current_link->setDisableCheckStatus($a_attribs['disableValidation'] ? 1 : 0); break; case 'Sorting': include_once './Services/Container/classes/class.ilContainerSortingSettings.php'; $sort = new ilContainerSortingSettings($this->getWebLink()->getId()); $sort->delete(); switch ($a_attribs['type']) { case 'Manual': $sort->setSortMode(ilContainer::SORT_MANUAL); break; case 'Title': default: $sort->setSortMode(ilContainer::SORT_TITLE); } $sort->save(); break; case 'WebLinks': case 'Title': case 'Description': case 'Target': // Nothing to do break; case 'DynamicParameter': $param = new ilParameterAppender($this->getWebLink()->getId()); $param->setName($a_attribs['name']); switch ($a_attribs['type']) { case 'userName': # $GLOBALS['ilLog']->write("VALUE: ".LINKS_LOGIN); $param->setValue(LINKS_LOGIN); break; case 'userId': # $GLOBALS['ilLog']->write("VALUE: ".LINKS_USER_ID); $param->setValue(LINKS_USER_ID); break; case 'matriculation': # $GLOBALS['ilLog']->write("VALUE: ".LINKS_MATRICULATION); $param->setValue(LINKS_MATRICULATION); break; default: throw new ilWebLinkXmlParserException('Invalid attribute "type" given for element "Dynamic parameter". Aborting'); break; } $this->current_parameters[] = $param; break; } }
/** * handler for begin of element * * @param resource $a_xml_parser xml parser * @param string $a_name element name * @param array $a_attribs element attributes array */ public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs) { global $ilErr; switch ($a_name) { case 'Folder': break; case 'Sorting': include_once './Services/Container/classes/class.ilContainerSortingSettings.php'; $sort = new ilContainerSortingSettings($this->getFolder()->getId()); $sort->delete(); switch ($a_attribs['type']) { case 'Manual': $sort->setSortMode(ilContainer::SORT_MANUAL); break; case 'Title': default: $sort->setSortMode(ilContainer::SORT_TITLE); } $sort->save(); break; case 'Title': case 'Description': break; } }