/**
  * Fix container item group references after a container has been cloned
  *
  * @param
  * @return
  */
 static function fixContainerItemGroupRefsAfterCloning($a_source_container, $a_copy_id)
 {
     global $ilLog;
     $ilLog->write(__METHOD__ . ': Fix item group references in ' . $a_source_container->getType());
     include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
     $mappings = $cwo->getMappings();
     $new_container_ref_id = $mappings[$a_source_container->getRefId()];
     $ilLog->write(__METHOD__ . ': 2-' . $new_container_ref_id . '-');
     $new_container_obj_id = ilObject::_lookupObjId($new_container_ref_id);
     include_once "./Services/COPage/classes/class.ilPageObject.php";
     include_once "./Services/Container/classes/class.ilContainerPage.php";
     $ilLog->write(__METHOD__ . ': 3' . $new_container_obj_id . '-');
     if (ilPageObject::_exists("cont", $new_container_obj_id)) {
         $ilLog->write(__METHOD__ . ': 4');
         $new_page = new ilContainerPage($new_container_obj_id);
         $new_page->buildDom();
         include_once "./Services/COPage/classes/class.ilPCResources.php";
         ilPCResources::modifyItemGroupRefIdsByMapping($new_page, $mappings);
         $new_page->update();
     }
     $ilLog->write(__METHOD__ . ': 5');
 }
 /**
  * forward command to page object
  */
 function &forwardToPageObject()
 {
     global $lng, $ilTabs, $ilCtrl;
     $cmd = $ilCtrl->getCmd();
     if (in_array($cmd, array("displayMediaFullscreen", "downloadFile"))) {
         $this->checkPermission("read");
     } else {
         $this->checkPermission("write");
     }
     $ilTabs->clearTargets();
     if ($_GET["redirectSource"] == "ilinternallinkgui") {
         exit;
     }
     $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(), "xhtml_page");
     if ($xpage_id > 0) {
         $ilTabs->setBackTarget($lng->txt("cntr_back_to_old_editor"), $ilCtrl->getLinkTarget($this, "switchToOldEditor"), "_top");
     } else {
         $ilTabs->setBackTarget($lng->txt("back"), "./goto.php?target=" . $this->object->getType() . "_" . $this->object->getRefId(), "_top");
     }
     // page object
     include_once "./Services/Container/classes/class.ilContainerPage.php";
     include_once "./Services/Container/classes/class.ilContainerPageGUI.php";
     $lng->loadLanguageModule("content");
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
     $this->tpl->setCurrentBlock("SyntaxStyle");
     $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
     $this->tpl->parseCurrentBlock();
     if (!ilContainerPage::_exists("cont", $this->object->getId())) {
         // doesn't exist -> create new one
         $new_page_object = new ilContainerPage();
         $new_page_object->setParentId($this->object->getId());
         $new_page_object->setId($this->object->getId());
         $new_page_object->createFromXML();
     }
     // get page object
     $this->ctrl->setReturnByClass("ilcontainerpagegui", "edit");
     $page_gui = new ilContainerPageGUI($this->object->getId());
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId($this->object->getStyleSheetId(), $this->object->getType()));
     $page_gui->setTemplateTargetVar("ADM_CONTENT");
     $page_gui->setLinkXML($link_xml);
     $page_gui->setFileDownloadLink("");
     $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
     //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
     $page_gui->setPresentationTitle("");
     $page_gui->setTemplateOutput(false);
     // old editor information text
     $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(), "xhtml_page");
     if ($xpage_id > 0) {
         $wtpl = new ilTemplate("tpl.cntr_old_editor_message.html", true, true, "Services/Container");
         $wtpl->setVariable("ALT_WARNING", $lng->txt("warning"));
         $wtpl->setVariable("IMG_WARNING", ilUtil::getImagePath("icon_alert.svg"));
         $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
         $wtpl->setVariable("TXT_MIGRATION_INFO", $lng->txt("cntr_switch_to_new_editor_message"));
         $wtpl->setVariable("HREF_SWITCH_TO_NEW_EDITOR", $ilCtrl->getLinkTarget($this, "useNewEditor"));
         $wtpl->setVariable("TXT_MIGRATION_SWITCH", $lng->txt("cntr_switch_to_new_editor_cmd"));
         $page_gui->setPrependingHtml($wtpl->get());
     }
     // style tab
     $page_gui->setTabHook($this, "addPageTabs");
     $ret = $this->ctrl->forwardCommand($page_gui);
     //$ret =& $page_gui->executeCommand();
     return $ret;
 }
 /**
  * Clone container settings
  *
  * @access public
  * @param int target ref_id
  * @param int copy id
  * @return object new object 
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
     $sorting = new ilContainerSortingSettings($new_obj->getId());
     $sorting->setSortMode($this->getOrderType());
     $sorting->update();
     // copy content page
     include_once "./Services/Container/classes/class.ilContainerPage.php";
     if (ilContainerPage::_exists("cont", $this->getId())) {
         $orig_page = new ilContainerPage($this->getId());
         $orig_page->copy($new_obj->getId(), "cont", $new_obj->getId());
     }
     // #10271 - copy start objects page
     include_once "./Services/Container/classes/class.ilContainerStartObjectsPage.php";
     if (ilContainerStartObjectsPage::_exists("cstr", $this->getId())) {
         $orig_page = new ilContainerStartObjectsPage($this->getId());
         $orig_page->copy($new_obj->getId(), "cstr", $new_obj->getId());
     }
     // #10271
     foreach (self::_getContainerSettings($this->getId()) as $keyword => $value) {
         self::_writeContainerSetting($new_obj->getId(), $keyword, $value);
         // copy custom icons
         if ($keyword == "icon_custom" && $value) {
             // see saveIcons()
             $new_obj->createContainerDirectory();
             $tgt_dir = $new_obj->getContainerDirectory();
             $src_dir = $this->getContainerDirectory();
             $file = "icon_custom.svg";
             $src_file = $src_dir . "/" . $file;
             if (file_exists($src_file)) {
                 copy($src_file, $tgt_dir . "/" . $file);
             }
         }
     }
     return $new_obj;
 }
Exemple #4
0
 /**
  * Clone container settings
  *
  * @access public
  * @param int target ref_id
  * @param int copy id
  * @return object new object 
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
     $sorting = new ilContainerSortingSettings($new_obj->getId());
     $sorting->setSortMode($this->getOrderType());
     $sorting->update();
     // copy content page
     //		$ilLog->write("copy container, lookup page");
     include_once "./Services/Container/classes/class.ilContainerPage.php";
     if (ilContainerPage::_exists("cont", $this->getId())) {
         //$ilLog->write("...page found");
         $orig_page = new ilContainerPage($this->getId());
         $orig_page->copy($new_obj->getId(), "cont", $new_obj->getId());
         /*$new_page_object = new ilContainerPage();
         		$new_page_object->setParentId($new_obj->getId());
         		$new_page_object->setId($new_obj->getId());
         		$new_page_object->createFromXML();
         		$new_page_object->setXMLContent($orig_page->getXMLContent());
         		$new_page_object->buildDom(true);
         		$new_page_object->update();*/
         //$ilLog->write("...copy ml");
         // copy (page) multilang settings
         /*include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
         		$ml = new ilPageMultiLang("cont", $this->getId());
         		$ml->copy("cont", $new_obj->getId());*/
     }
     return $new_obj;
 }
 /**
  * Clone container settings
  *
  * @access public
  * @param int target ref_id
  * @param int copy id
  * @return object new object 
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     $new_obj = parent::cloneObject($a_target_id, $a_copy_id);
     include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
     $sorting = new ilContainerSortingSettings($new_obj->getId());
     $sorting->setSortMode($this->getOrderType());
     $sorting->update();
     // copy content page
     include_once "./Services/Container/classes/class.ilContainerPage.php";
     if (ilContainerPage::_exists("cont", $this->getId())) {
         $orig_page = new ilContainerPage($this->getId());
         $new_page_object = new ilContainerPage();
         $new_page_object->setParentId($new_obj->getId());
         $new_page_object->setId($new_obj->getId());
         $new_page_object->createFromXML();
         $new_page_object->setXMLContent($orig_page->getXMLContent());
         $new_page_object->buildDom(true);
         $new_page_object->update();
     }
     return $new_obj;
 }