예제 #1
0
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng;
     $this->tpl->setVariable("VAL_TITLE", $a_set["title"]);
     $this->tpl->setVariable("PAGE_ID", $a_set["obj_id"]);
     $exp_id = ilLMPageObject::getExportId($this->parent_obj->object->getId(), $a_set["obj_id"], $a_set["type"]);
     if ($this->validation) {
         if (!preg_match("/^[a-zA-Z_]*\$/", trim($_POST["exportid"][$a_set["obj_id"]]))) {
             // @todo: move to style
             $this->tpl->setVariable("STYLE", " style='background-color: #FCEAEA;' ");
             $this->tpl->setVariable("ALERT_IMG", ilUtil::img(ilUtil::getImagePath("icon_alert.svg"), $lng->txt("alert")));
         }
         $this->tpl->setVariable("EXPORT_ID", ilUtil::prepareFormOutput(ilUtil::stripSlashes($_POST["exportid"][$a_set["obj_id"]])));
     } else {
         $this->tpl->setVariable("EXPORT_ID", ilUtil::prepareFormOutput($exp_id));
     }
     if ($this->cnt_exp_ids[$exp_id] > 1) {
         $this->tpl->setVariable("ITEM_ADD_TXT", $lng->txt("cont_exp_id_used_multiple"));
         $this->tpl->setVariable("ALERT_IMG", ilUtil::img(ilUtil::getImagePath("icon_alert.svg"), $lng->txt("alert")));
         if (!$this->dup_info_given) {
             ilUtil::sendInfo($lng->txt("content_some_export_ids_multiple_times"));
             $this->dup_info_given = true;
         }
     }
 }
예제 #2
0
 /**
  * copy page
  */
 function copy($a_target_lm)
 {
     // copy page
     $lm_page = new ilLMPageObject($a_target_lm);
     $lm_page->setTitle($this->getTitle());
     $lm_page->setLayout($this->getLayout());
     $lm_page->setLMId($a_target_lm->getId());
     $lm_page->setType($this->getType());
     $lm_page->setDescription($this->getDescription());
     $lm_page->setImportId("il__pg_" . $this->getId());
     $lm_page->create(true);
     // setting "upload" flag to true prevents creating of meta data
     // check whether export id already exists in the target lm
     $del_exp_id = false;
     $exp_id = ilLMPageObject::getExportId($this->getLMId(), $this->getId());
     if (trim($exp_id) != "") {
         if (ilLMPageObject::existsExportID($a_target_lm->getId(), $exp_id)) {
             $del_exp_id = true;
         }
     }
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
     $new_md = $md->cloneMD($a_target_lm->getId(), $lm_page->getId(), $this->getType());
     // check whether export id already exists in the target lm
     if ($del_exp_id) {
         ilLMPageObject::saveExportId($a_target_lm->getId(), $lm_page->getId(), "");
     } else {
         ilLMPageObject::saveExportId($a_target_lm->getId(), $lm_page->getId(), trim($exp_id));
     }
     // copy page content and activation
     $page = $lm_page->getPageObject();
     $this->page_object->copy($page->getId(), $page->getParentType(), $page->getParentId());
     /*$page->setXMLContent($this->page_object->copyXMLContent());
     		$page->setActive($this->page_object->getActive());
     		$page->setActivationStart($this->page_object->getActivationStart());
     		$page->setActivationEnd($this->page_object->getActivationEnd());
     		$page->buildDom();
     		$page->update();*/
     $lm_page->read();
     // this gets the updated page object into lm page
     // copy translations
     include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
     ilLMObjTranslation::copy($this->getId(), $lm_page->getId());
     return $lm_page;
 }
 /**
  * export all pages of learning module to html file
  */
 function exportHTMLPages(&$a_lm_gui, $a_target_dir)
 {
     global $tpl, $ilBench, $ilLocator;
     $pages = ilLMPageObject::getPageList($this->getId());
     $lm_tree =& $this->getLMTree();
     $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg");
     $this->first_page_id = $first_page["child"];
     // iterate all learning module pages
     $mobs = array();
     $int_links = array();
     $this->offline_files = array();
     include_once "./Services/COPage/classes/class.ilPageContentUsage.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     // get html export id mapping
     $lm_set = new ilSetting("lm");
     $exp_id_map = array();
     if ($lm_set->get("html_export_ids")) {
         foreach ($pages as $page) {
             $exp_id = ilLMPageObject::getExportId($this->getId(), $page["obj_id"]);
             if (trim($exp_id) != "") {
                 $exp_id_map[$page["obj_id"]] = trim($exp_id);
             }
         }
     }
     //exit;
     reset($pages);
     foreach ($pages as $page) {
         if (ilLMPage::_exists($this->getType(), $page["obj_id"])) {
             $ilLocator->clearItems();
             $ilBench->start("ExportHTML", "exportHTMLPage");
             $ilBench->start("ExportHTML", "exportPageHTML");
             $this->exportPageHTML($a_lm_gui, $a_target_dir, $page["obj_id"], "", $exp_id_map);
             $ilBench->stop("ExportHTML", "exportPageHTML");
             // get all snippets of page
             $pcs = ilPageContentUsage::getUsagesOfPage($page["obj_id"], $this->getType() . ":pg");
             foreach ($pcs as $pc) {
                 if ($pc["type"] == "incl") {
                     $incl_mobs = ilObjMediaObject::_getMobsOfObject("mep:pg", $pc["id"]);
                     foreach ($incl_mobs as $incl_mob) {
                         $mobs[$incl_mob] = $incl_mob;
                     }
                 }
             }
             // get all media objects of page
             $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType() . ":pg", $page["obj_id"]);
             foreach ($pg_mobs as $pg_mob) {
                 $mobs[$pg_mob] = $pg_mob;
             }
             // get all internal links of page
             $pg_links = ilInternalLink::_getTargetsOfSource($this->getType() . ":pg", $page["obj_id"]);
             $int_links = array_merge($int_links, $pg_links);
             // get all files of page
             include_once "./Modules/File/classes/class.ilObjFile.php";
             $pg_files = ilObjFile::_getFilesOfObject($this->getType() . ":pg", $page["obj_id"]);
             $this->offline_files = array_merge($this->offline_files, $pg_files);
             $ilBench->stop("ExportHTML", "exportHTMLPage");
         }
     }
     $this->offline_mobs = $mobs;
     $this->offline_int_links = $int_links;
 }
예제 #4
0
 /**
  * handles links for learning module presentation
  */
 function getLink($a_ref_id, $a_cmd = "", $a_obj_id = "", $a_frame = "", $a_type = "", $a_back_link = "append", $a_anchor = "", $a_srcstring = "")
 {
     global $ilCtrl;
     if ($a_cmd == "") {
         $a_cmd = "layout";
     }
     // handling of free pages
     $cur_page_id = $this->getCurrentPageId();
     $back_pg = $_GET["back_pg"];
     if ($a_obj_id != "" && !$this->lm_tree->isInTree($a_obj_id) && $cur_page_id != "" && $a_back_link == "append") {
         if ($back_pg != "") {
             $back_pg = $cur_page_id . ":" . $back_pg;
         } else {
             $back_pg = $cur_page_id;
         }
     } else {
         if ($a_back_link == "reduce") {
             $limpos = strpos($_GET["back_pg"], ":");
             if ($limpos > 0) {
                 $back_pg = substr($back_pg, strpos($back_pg, ":") + 1);
             } else {
                 $back_pg = "";
             }
         } else {
             if ($a_back_link != "keep") {
                 $back_pg = "";
             }
         }
     }
     // handle online links
     if (!$this->offlineMode()) {
         if ($_GET["from_page"] == "") {
             $this->ctrl->setParameter($this, "from_page", $cur_page_id);
         } else {
             // faq link on page (in faq frame) includes faq link on other page
             // if added due to bug #11007
             if (!in_array($a_frame, array("", "_blank"))) {
                 $this->ctrl->setParameter($this, "from_page", $_GET["from_page"]);
             }
         }
         if ($a_anchor != "") {
             $this->ctrl->setParameter($this, "anchor", rawurlencode($a_anchor));
         }
         if ($a_srcstring != "") {
             $this->ctrl->setParameter($this, "srcstring", $a_srcstring);
         }
         switch ($a_cmd) {
             case "fullscreen":
                 $link = $this->ctrl->getLinkTarget($this, "fullscreen", "", false, false);
                 break;
             default:
                 if ($back_pg != "") {
                     $this->ctrl->setParameter($this, "back_pg", $back_pg);
                 }
                 if ($a_frame != "") {
                     $this->ctrl->setParameter($this, "frame", $a_frame);
                 }
                 if ($a_obj_id != "") {
                     switch ($a_type) {
                         case "MediaObject":
                             $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
                             break;
                         default:
                             $this->ctrl->setParameter($this, "obj_id", $a_obj_id);
                             $link .= "&obj_id=" . $a_obj_id;
                             break;
                     }
                 }
                 if ($a_type != "") {
                     $this->ctrl->setParameter($this, "obj_type", $a_type);
                 }
                 $link = $this->ctrl->getLinkTarget($this, $a_cmd, $a_anchor);
                 //					$link = str_replace("&", "&", $link);
                 $this->ctrl->setParameter($this, "frame", "");
                 $this->ctrl->setParameter($this, "obj_id", "");
                 $this->ctrl->setParameter($this, "mob_id", "");
                 break;
         }
     } else {
         switch ($a_cmd) {
             case "downloadFile":
                 break;
             case "fullscreen":
                 $link = "fullscreen.html";
                 // id is handled by xslt
                 break;
             case "layout":
                 if ($a_obj_id == "") {
                     $a_obj_id = $this->lm_tree->getRootId();
                     $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
                     $a_obj_id = $pg_node["obj_id"];
                 }
                 if ($a_type == "StructureObject") {
                     $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
                     $a_obj_id = $pg_node["obj_id"];
                 }
                 if ($a_frame != "" && $a_frame != "_blank") {
                     if ($a_frame != "toc") {
                         $link = "frame_" . $a_obj_id . "_" . $a_frame . ".html";
                     } else {
                         $link = "frame_" . $a_frame . ".html";
                     }
                 } else {
                     //if ($nid = ilLMObject::_lookupNID($this->lm->getId(), $a_obj_id, "pg"))
                     if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_obj_id)) {
                         $link = "lm_pg_" . $nid . ".html";
                     } else {
                         $link = "lm_pg_" . $a_obj_id . ".html";
                     }
                 }
                 break;
             case "glossary":
                 $link = "term_" . $a_obj_id . ".html";
                 break;
             case "media":
                 $link = "media_" . $a_obj_id . ".html";
                 break;
             default:
                 break;
         }
     }
     $this->ctrl->clearParameters($this);
     return $link;
 }
예제 #5
0
 /**
  * Get href for node
  *
  * @param mixed $a_node node object/array
  * @return string href attribute
  */
 function getNodeHref($a_node)
 {
     if (!$this->getOfflineMode()) {
         return $this->lm_pres->getLink($this->lm->getRefId(), "", $a_node["child"]);
         //return parent::buildLinkTarget($a_node_id, $a_type);
     } else {
         if ($a_node["type"] != "pg") {
             // get next activated page
             $found = false;
             while (!$found) {
                 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
                 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
                 $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
                 if ($a_node["child"] > 0 && !$active) {
                     $found = false;
                 } else {
                     $found = true;
                 }
             }
         }
         include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
         if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_node["child"])) {
             return "lm_pg_" . $nid . ".html";
         }
         return "lm_pg_" . $a_node["child"] . ".html";
     }
 }
 /**
  * build link target
  */
 function buildLinkTarget($a_node_id, $a_type)
 {
     if (!$this->offlineMode()) {
         return parent::buildLinkTarget($a_node_id, $a_type);
     } else {
         if ($a_node_id < 1) {
             $a_node_id = $this->tree->getRootId();
         }
         if ($a_type != "pg") {
             // get next activated page
             $found = false;
             while (!$found) {
                 $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
                 $a_node_id = $a_node["child"];
                 include_once "./Services/COPage/classes/class.ilPageObject.php";
                 $active = ilPageObject::_lookupActive($a_node_id, $this->lm_obj->getType(), $this->lm_set->get("time_scheduled_page_activation"));
                 if ($a_node_id > 0 && !$active) {
                     $found = false;
                 } else {
                     $found = true;
                 }
             }
         }
         if ($nid = ilLMPageObject::getExportId($this->lm_obj->getId(), $a_node_id)) {
             return "lm_pg_" . $nid . ".html";
         } else {
             return "lm_pg_" . $a_node_id . ".html";
         }
     }
 }