/**
  * Constructor
  */
 function __construct($a_parent_obj, $a_parent_cmd, $a_lm)
 {
     global $ilCtrl, $lng, $ilAccess, $lng;
     $this->lm = $a_lm;
     $this->lm_set = new ilSetting("lm");
     parent::__construct($a_parent_obj, $a_parent_cmd);
     $this->setData(ilLMPageObject::getPageList($this->lm->getId()));
     $this->setTitle($lng->txt("cont_pages"));
     $this->addColumn($this->lng->txt(""), "", "1");
     $this->addColumn($this->lng->txt("type"), "", "1");
     $this->addColumn($this->lng->txt("title"));
     $this->addColumn($this->lng->txt("cont_usage"));
     $this->setSelectAllCheckbox("id[]");
     if ($this->lm->getLayoutPerPage()) {
         $this->addColumn($this->lng->txt("cont_layout"));
     }
     $this->setLimit(9999);
     $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
     $this->setRowTemplate("tpl.page_list_row.html", "Modules/LearningModule");
     if (ilEditClipboard::getContentObjectType() == "pg" && ilEditClipboard::getAction() == "copy") {
         $this->addMultiCommand("pastePage", $lng->txt("pastePage"));
     }
     if ($this->lm->getLayoutPerPage()) {
         $this->addMultiCommand("setPageLayout", $lng->txt("cont_set_layout"));
     }
     $this->addMultiCommand("activatePages", $lng->txt("cont_de_activate"));
     $this->addMultiCommand("movePage", $lng->txt("movePage"));
     $this->addMultiCommand("copyPage", $lng->txt("copyPage"));
     $this->addMultiCommand("delete", $lng->txt("delete"));
     $this->addMultiCommand("selectHeader", $lng->txt("selectHeader"));
     $this->addMultiCommand("selectFooter", $lng->txt("selectFooter"));
     //		$this->addCommandButton("", $lng->txt(""));
 }
 /**
  * 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;
         }
     }
 }
 /**
  * display locator
  */
 function display($a_gui_class)
 {
     global $lng;
     $this->tpl->addBlockFile($this->temp_var, "locator", "tpl.locator.html", "Services/Locator");
     if ($this->obj_id != 0 && $this->tree->isInTree($this->obj_id)) {
         $path = $this->tree->getPathFull($this->obj_id);
     } else {
         $path = $this->tree->getPathFull($this->tree->getRootId());
         if ($this->obj_id != 0) {
             $path[] = array("type" => "pg", "child" => $this->obj_id, "title" => ilLMPageObject::_getPresentationTitle($this->obj_id));
         }
     }
     $modifier = 1;
     foreach ($path as $key => $row) {
         if ($key < count($path) - $modifier) {
             $this->tpl->touchBlock("locator_separator");
         }
         $this->tpl->setCurrentBlock("locator_item");
         $transit = "";
         if ($row["child"] == 1) {
             $title = $this->cont_obj->getTitle();
             $cmd = "properties";
             $cmdClass = $a_gui_class;
         } else {
             $title = $row["title"];
             switch ($row["type"]) {
                 case "st":
                     $cmdClass = "ilStructureObjectGUI";
                     $cmd = "view";
                     if ($this->ctrl->getCmdClass() != "ilstructureobjectgui") {
                         $transit = array($a_gui_class);
                     }
                     break;
                 case "pg":
                     $cmdClass = "ilLMPageObjectGUI";
                     $cmd = "view";
                     if ($this->ctrl->getCmdClass() != "illmpageobjectgui") {
                         $transit = array($a_gui_class);
                     }
                     break;
             }
         }
         $this->tpl->setVariable("ITEM", $title);
         $obj_str = $row["child"] == 1 ? "" : "&obj_id=" . $row["child"];
         $this->ctrl->setParameterByClass($cmdClass, "obj_id", $row["child"]);
         $link = $this->ctrl->getLinkTargetByClass($cmdClass, $cmd, $transit);
         $this->ctrl->setParameterByClass($cmdClass, "obj_id", $_GET["obj_id"]);
         $this->tpl->setVariable("LINK_ITEM", $link);
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setCurrentBlock("locator");
     $this->tpl->parseCurrentBlock();
 }
 /**
  * standard implementation for title, maybe overwritten by derived classes
  */
 function buildTitle($a_title, $a_id, $a_type)
 {
     if ($a_type == "st") {
         return ilStructureObject::_getPresentationTitle($a_id, $this->lm_obj->isActiveNumbering(), false, $this->lm_obj->getId(), $this->lang);
     }
     if ($this->lm_obj->getTOCMode() == "chapters" || $a_type != "pg") {
         return $a_title;
     } else {
         if ($a_type == "pg") {
             return ilLMPageObject::_getPresentationTitle($a_id, $this->lm_obj->getPageHeader(), $this->lm_obj->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), true, $this->lm_obj->getId(), $this->lang);
         }
     }
 }
 /**
  * Get user items
  */
 function getItems()
 {
     global $lng;
     //if ($GLOBALS["kk"]++ == 1) nj();
     $this->determineOffsetAndOrder();
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     $questions = ilLMPageObject::queryQuestionsOfLearningModule($this->lm->getId(), ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()), ilUtil::stripSlashes($this->getOffset()), ilUtil::stripSlashes($this->getLimit()));
     if (count($questions["set"]) == 0 && $this->getOffset() > 0) {
         $this->resetOffset();
         $questions = ilLMPageObject::queryQuestionsOfLearningModule($this->lm->getId(), ilUtil::stripSlashes($this->getOrderField()), ilUtil::stripSlashes($this->getOrderDirection()), ilUtil::stripSlashes($this->getOffset()), ilUtil::stripSlashes($this->getLimit()));
     }
     $this->setMaxCount($questions["cnt"]);
     $this->setData($questions["set"]);
 }
 /**
  * list definitions of a term
  */
 function listDefinitions($a_ref_id = 0, $a_term_id = 0, $a_get_html = false)
 {
     global $ilUser, $ilAccess, $ilias, $lng, $ilCtrl;
     if ($a_ref_id == 0) {
         $ref_id = (int) $_GET["ref_id"];
     } else {
         $ref_id = $a_ref_id;
     }
     if ($a_term_id == 0) {
         $term_id = $this->term_id;
     } else {
         $term_id = $a_term_id;
     }
     if (!$ilAccess->checkAccess("read", "", $ref_id)) {
         $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
     }
     // tabs
     if ($this->glossary->getPresentationMode() != "full_def") {
         $this->showDefinitionTabs("content");
     }
     $term = new ilGlossaryTerm($term_id);
     if (!$a_get_html) {
         $tpl = $this->tpl;
         require_once "./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php";
         $tpl->getStandardTemplate();
         //			$this->setTabs();
         if ($this->offlineMode()) {
             $style_name = $ilUser->prefs["style"] . ".css";
             $tpl->setVariable("LOCATION_STYLESHEET", "./" . $style_name);
         } else {
             $this->setLocator();
         }
         // content style
         $tpl->setCurrentBlock("ContentStyle");
         if (!$this->offlineMode()) {
             $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
         } else {
             $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
         }
         $tpl->parseCurrentBlock();
         // syntax style
         $tpl->setCurrentBlock("SyntaxStyle");
         if (!$this->offlineMode()) {
             $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
         } else {
             $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", "syntaxhighlight.css");
         }
         $tpl->parseCurrentBlock();
         $tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.png"));
         $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm());
         // load template for table
         $tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", "Modules/Glossary");
     } else {
         // content style
         $this->tpl->setCurrentBlock("ContentStyle");
         if (!$this->offlineMode()) {
             $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
         } else {
             $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
         }
         $this->tpl->parseCurrentBlock();
         // syntax style
         $this->tpl->setCurrentBlock("SyntaxStyle");
         if (!$this->offlineMode()) {
             $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
         } else {
             $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", "syntaxhighlight.css");
         }
         $this->tpl->parseCurrentBlock();
         $tpl = new ilTemplate("tpl.glossary_definition_list.html", true, true, "Modules/Glossary");
     }
     $defs = ilGlossaryDefinition::getDefinitionList($term_id);
     $tpl->setVariable("TXT_TERM", $term->getTerm());
     $this->mobs = array();
     for ($j = 0; $j < count($defs); $j++) {
         $def = $defs[$j];
         $page_gui = new ilGlossaryDefPageGUI($def["id"]);
         $page_gui->setStyleId($this->glossary->getStyleSheetId());
         $page = $page_gui->getPageObject();
         // internal links
         $page->buildDom();
         $int_links = $page->getInternalLinks();
         $link_xml = $this->getLinkXML($int_links);
         $page_gui->setLinkXML($link_xml);
         if ($this->offlineMode()) {
             $page_gui->setOutputMode("offline");
             $page_gui->setOfflineDirectory($this->getOfflineDirectory());
         }
         $page_gui->setSourcecodeDownloadScript($this->getLink($ref_id));
         $page_gui->setFullscreenLink($this->getLink($ref_id, "fullscreen", $term_id, $def["id"]));
         $page_gui->setTemplateOutput(false);
         $page_gui->setRawPageContent(true);
         $page_gui->setFileDownloadLink($this->getLink($ref_id, "downloadFile"));
         if (!$this->offlineMode()) {
             $output = $page_gui->preview();
         } else {
             $output = $page_gui->presentation($page_gui->getOutputMode());
         }
         if (count($defs) > 1) {
             $tpl->setCurrentBlock("definition_header");
             $tpl->setVariable("TXT_DEFINITION", $this->lng->txt("cont_definition") . " " . ($j + 1));
             $tpl->parseCurrentBlock();
         }
         $tpl->setCurrentBlock("definition");
         $tpl->setVariable("PAGE_CONTENT", $output);
         $tpl->parseCurrentBlock();
     }
     // display possible backlinks
     $sources = ilInternalLink::_getSourcesOfTarget('git', $_GET['term_id'], 0);
     if ($sources) {
         $backlist_shown = false;
         foreach ($sources as $src) {
             $type = explode(':', $src['type']);
             if ($type[0] == 'lm') {
                 if ($type[1] == 'pg') {
                     $title = ilLMPageObject::_getPresentationTitle($src['id']);
                     $lm_id = ilLMObject::_lookupContObjID($src['id']);
                     $lm_title = ilObject::_lookupTitle($lm_id);
                     $tpl->setCurrentBlock('backlink_item');
                     $ref_ids = ilObject::_getAllReferences($lm_id);
                     $access = false;
                     foreach ($ref_ids as $rid) {
                         if ($ilAccess->checkAccess("read", "", $rid)) {
                             $access = true;
                         }
                     }
                     if ($access) {
                         $tpl->setCurrentBlock("backlink_item");
                         $tpl->setVariable("BACKLINK_LINK", ILIAS_HTTP_PATH . "/goto.php?target=" . $type[1] . "_" . $src['id']);
                         $tpl->setVariable("BACKLINK_ITEM", $lm_title . ": " . $title);
                         $tpl->parseCurrentBlock();
                         $backlist_shown = true;
                     }
                 }
             }
         }
         if ($backlist_shown) {
             $tpl->setCurrentBlock("backlink_list");
             $tpl->setVariable("BACKLINK_TITLE", $this->lng->txt('glo_term_used_in'));
             $tpl->parseCurrentBlock();
         }
     }
     if (!$a_get_html) {
         $tpl->setCurrentBlock("perma_link");
         $tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH . "/goto.php?target=" . "git" . "_" . $term_id . "_" . $ref_id . "&client_id=" . CLIENT_ID);
         $tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
         $tpl->setVariable("PERMA_TARGET", "_top");
         $tpl->parseCurrentBlock();
     }
     // highlighting?
     if ($_GET["srcstring"] != "" && !$this->offlineMode()) {
         include_once './Services/Search/classes/class.ilUserSearchCache.php';
         $cache = ilUserSearchCache::_getInstance($ilUser->getId());
         $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
         $search_string = $cache->getQuery();
         include_once "./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php";
         include_once "./Services/Search/classes/class.ilQueryParser.php";
         $p = new ilQueryParser($search_string);
         $p->parse();
         $words = $p->getQuotedWords();
         if (is_array($words)) {
             foreach ($words as $w) {
                 ilTextHighlighterGUI::highlight("ilGloContent", $w, $tpl);
             }
         }
         $this->fill_on_load_code = true;
     }
     if ($this->offlineMode() || $a_get_html) {
         return $tpl->get();
     }
 }
Example #7
0
 public static function getTranslatedValue($a_value)
 {
     global $lng;
     $value = explode("|", $a_value);
     switch ($value[0]) {
         case "media":
             $type = $lng->txt("obj_mob");
             $name = ilObject::_lookupTitle($value[1]);
             break;
         case "page":
             include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
             $type = $lng->txt("obj_pg");
             $name = ilLMPageObject::_lookupTitle($value[1]);
             break;
         case "term":
             include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
             $type = $lng->txt("term");
             $name = ilGlossaryTerm::_lookGlossaryTerm($value[1]);
             break;
         default:
             $type = $lng->txt("obj_" . $value[0]);
             $name = ilObject::_lookupTitle(ilObject::_lookupObjId($value[1]));
             break;
     }
     return array("type" => $type, "name" => $name);
 }
 /**
  * Save page layout
  */
 function savePageLayout()
 {
     global $lng, $ilCtrl;
     foreach ($_POST["id"] as $id) {
         $id = ilUtil::stripSlashes($id);
         ilLMPageObject::writeLayout(ilUtil::stripSlashes($id), ilUtil::stripSlashes($_POST["layout"]), $this->content_object);
     }
     ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
     $ilCtrl->redirect($this, "showHierarchy");
 }
 /**
  * export page objects of structure object (see ilias_co.dtd)
  *
  * @param	object		$a_xml_writer	ilXmlWriter object that receives the
  *										xml data
  */
 function exportFOPageObjects(&$a_xml_writer)
 {
     global $ilBench;
     $this->tree = new ilTree($this->getLmId());
     $this->tree->setTableNames('lm_tree', 'lm_data');
     $this->tree->setTreeTablePK("lm_id");
     $childs = $this->tree->getChilds($this->getId());
     foreach ($childs as $child) {
         if ($child["type"] != "pg") {
             continue;
         }
         // export xml to writer object
         //$ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
         $page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
         $page_obj->exportFO($a_xml_writer);
         //$ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
     }
 }
 /**
  * Get pages incl. links
  */
 function getLinks()
 {
     $pages = ilLMPageObject::getPagesWithLinksList($this->lm_id, $this->lm_type);
     $this->setData($pages);
 }
 function linkChilds()
 {
     global $ilTabs;
     $selectable_items = array();
     $source_id = $_GET["source_id"];
     switch ($_SESSION["search_link_type"]) {
         case "pg":
             include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
             include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php";
             $cont_obj_gui =& new ilObjContentObjectGUI("", $source_id, true);
             $cont_obj = $cont_obj_gui->object;
             $pages = ilLMPageObject::getPageList($cont_obj->getId());
             foreach ($pages as $page) {
                 if ($page["type"] == $_SESSION["search_link_type"]) {
                     $selectable_items[] = array("item_type" => $page["type"], "item_id" => $page["obj_id"], "title" => $page["title"]);
                 }
             }
             break;
         case "st":
             include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php";
             $cont_obj_gui =& new ilObjContentObjectGUI("", $source_id, true);
             $cont_obj = $cont_obj_gui->object;
             // get all chapters
             $ctree =& $cont_obj->getLMTree();
             $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
             foreach ($nodes as $node) {
                 if ($node["type"] == $_SESSION["search_link_type"]) {
                     $selectable_items[] = array("item_type" => $node["type"], "item_id" => $node["obj_id"], "title" => $node["title"]);
                 }
             }
             break;
         case "glo":
             include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
             $glossary =& new ilObjGlossary($source_id, true);
             // get all glossary items
             $terms = $glossary->getTermList();
             foreach ($terms as $term) {
                 $selectable_items[] = array("item_type" => "GIT", "item_id" => $term["id"], "title" => $term["term"]);
             }
             break;
         case "lm":
             $this->object->addInternalLink("il__lm_" . $source_id);
             break;
     }
     if (sizeof($selectable_items)) {
         $ilTabs->activateTab("material");
         $this->ctrl->setParameter($this, "q_id", $this->object->getId());
         $this->ctrl->setParameter($this, "source_id", $source_id);
         include_once "Modules/SurveyQuestionPool/classes/tables/class.SurveyMaterialsSourceTableGUI.php";
         $tbl = new SurveyMaterialsSourceTableGUI($this, "linkChilds", "addMaterial");
         $tbl->setData($selectable_items);
         $this->tpl->setContent($tbl->getHTML());
     } else {
         if ($_SESSION["search_link_type"] == "lm") {
             ilUtil::sendSuccess($this->lng->txt("material_added_successfully"), true);
             unset($_SESSION["link_new_type"]);
             unset($_SESSION["search_link_type"]);
             $this->ctrl->redirect($this, "material");
         } else {
             ilUtil::sendFailure($this->lng->txt("material_added_empty"), true);
             $this->ctrl->redirect($this, "addMaterial");
         }
     }
 }
Example #12
0
 /**
  * export page object to fo
  *
  * @param	object		$a_xml_writer	ilXmlWriter object that receives the
  *										xml data
  */
 function exportFO(&$a_xml_writer)
 {
     global $ilBench;
     //$attrs = array();
     //$a_xml_writer->xmlStartTag("PageObject", $attrs);
     $title = ilLMPageObject::_getPresentationTitle($this->getId());
     if ($title != "") {
         $attrs = array();
         $attrs["font-family"] = "Times";
         $attrs["font-size"] = "14pt";
         $a_xml_writer->xmlElement("fo:block", $attrs, $title);
     }
     // PageContent
     $this->page_object->buildDom();
     $fo = $this->page_object->getFO();
     $a_xml_writer->appendXML($fo);
     //$a_xml_writer->xmlEndTag("PageObject");
 }
 function outPageSelector()
 {
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php";
     $cont_obj_gui =& new ilObjContentObjectGUI("", $_GET["source_id"], true);
     $cont_obj = $cont_obj_gui->object;
     $pages = ilLMPageObject::getPageList($cont_obj->getId());
     $shownpages = array();
     $tree = $cont_obj->getLMTree();
     $chapters = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
     $this->ctrl->setParameter($this, "q_id", $this->object->getId());
     $color_class = array("tblrow1", "tblrow2");
     $counter = 0;
     $template = new ilTemplate("tpl.il_as_qpl_internallink_selection.html", TRUE, TRUE, "Modules/TestQuestionPool");
     foreach ($chapters as $chapter) {
         $chapterpages = $tree->getChildsByType($chapter["obj_id"], "pg");
         foreach ($chapterpages as $page) {
             if ($page["type"] == $_GET["search_link_type"]) {
                 array_push($shownpages, $page["obj_id"]);
                 $template->setCurrentBlock("linktable_row");
                 $template->setVariable("TEXT_LINK", $page["title"]);
                 $template->setVariable("TEXT_ADD", $this->lng->txt("add"));
                 $template->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($page["type"])) . "&" . $page["type"] . "=" . $page["obj_id"]);
                 $template->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
                 if ($tree->isInTree($page["obj_id"])) {
                     $path_str = $this->getContextPath($cont_obj, $page["obj_id"]);
                 } else {
                     $path_str = "---";
                 }
                 $template->setVariable("TEXT_DESCRIPTION", ilUtil::prepareFormOutput($path_str));
                 $template->parseCurrentBlock();
                 $counter++;
             }
         }
     }
     foreach ($pages as $page) {
         if (!in_array($page["obj_id"], $shownpages)) {
             $template->setCurrentBlock("linktable_row");
             $template->setVariable("TEXT_LINK", $page["title"]);
             $template->setVariable("TEXT_ADD", $this->lng->txt("add"));
             $template->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($page["type"])) . "&" . $page["type"] . "=" . $page["obj_id"]);
             $template->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
             $path_str = "---";
             $template->setVariable("TEXT_DESCRIPTION", ilUtil::prepareFormOutput($path_str));
             $template->parseCurrentBlock();
             $counter++;
         }
     }
     $template->setCurrentBlock("link_selection");
     $template->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
     $template->setVariable("TEXT_LINK_TYPE", $this->lng->txt("obj_" . $_GET["search_link_type"]));
     $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "cancelExplorer"));
     $template->parseCurrentBlock();
     $this->tpl->setVariable("ADM_CONTENT", $template->get());
 }
 /**
  * Paste item (tree) from clipboard to current lm
  */
 static function pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy = false, $a_source_lm = null)
 {
     global $ilUser, $ilias, $ilLog;
     include_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     $item_lm_id = ilLMObject::_lookupContObjID($a_item_id);
     $item_type = ilLMObject::_lookupType($a_item_id);
     $lm_obj = $ilias->obj_factory->getInstanceByObjId($item_lm_id);
     if ($item_type == "st") {
         $item = new ilStructureObject($lm_obj, $a_item_id);
     } else {
         if ($item_type == "pg") {
             $item = new ilLMPageObject($lm_obj, $a_item_id);
         }
     }
     $ilLog->write("Getting from clipboard type " . $item_type . ", " . "Item ID: " . $a_item_id . ", of original LM: " . $item_lm_id);
     if ($item_lm_id != $a_target_lm->getId() && !$a_as_copy) {
         // @todo: check whether st is NOT in tree
         // "move" metadata to new lm
         include_once "Services/MetaData/classes/class.ilMD.php";
         $md = new ilMD($item_lm_id, $item->getId(), $item->getType());
         $new_md = $md->cloneMD($a_target_lm->getId(), $item->getId(), $item->getType());
         // update lm object
         $item->setLMId($a_target_lm->getId());
         $item->setContentObject($a_target_lm);
         $item->update();
         // delete old meta data set
         $md->deleteAll();
         if ($item_type == "pg") {
             $page = $item->getPageObject();
             $page->buildDom();
             $page->setParentId($a_target_lm->getId());
             $page->update();
         }
     }
     if ($a_as_copy) {
         $target_item = $item->copy($a_target_lm);
         $a_copied_nodes[$item->getId()] = $target_item->getId();
     } else {
         $target_item = $item;
     }
     $ilLog->write("Putting into tree type " . $target_item->getType() . "Item ID: " . $target_item->getId() . ", Parent: " . $a_parent_id . ", " . "Target: " . $a_target . ", Item LM:" . $target_item->getContentObject()->getId());
     ilLMObject::putInTree($target_item, $a_parent_id, $a_target);
     if ($a_source_lm == null) {
         $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
     } else {
         $childs = $a_source_lm->lm_tree->getChilds($item->getId());
         foreach ($childs as $k => $child) {
             $childs[$k]["id"] = $childs[$k]["child"];
         }
     }
     foreach ($childs as $child) {
         ilLMObject::pasteTree($a_target_lm, $child["id"], $target_item->getId(), IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy, $a_source_lm);
     }
     return $target_item->getId();
     // @todo: write history (see pastePage)
 }
 /**
  * split page to next page at specified position
  */
 function splitPageNext()
 {
     global $ilErr;
     if ($this->pg_obj->getParentType() != "lm" && $this->pg_obj->getParentType() != "dbk") {
         $ilErr->raiseError("Split method called for wrong parent type (" . $this->pg_obj->getParentType() . ")", $ilErr->FATAL);
     } else {
         $succ_id = ilLMPageObject::_splitPageNext($this->pg_obj->getId(), $this->pg_obj->getParentType(), $this->hier_id);
         // jump to successor page
         if ($succ_id > 0) {
             $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $succ_id);
             $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
         }
     }
     $this->ctrl->returnToParent($this, "jump" . ($this->hier_id - 1));
 }
 /**
  * Save page layout
  */
 function savePageLayout()
 {
     global $lng, $ilCtrl;
     $ilCtrl->setParameter($this, "hierarchy", $_GET["hierarchy"]);
     foreach ($_POST["id"] as $id) {
         ilLMPageObject::writeLayout(ilUtil::stripSlashes($id), ilUtil::stripSlashes($_POST["layout"]), $this->object);
     }
     ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
     if ($_GET["hierarchy"] == 1) {
         $ilCtrl->redirect($this, "chapters");
     } else {
         $ilCtrl->redirect($this, "pages");
     }
 }
 /**
  * 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";
         }
     }
 }
Example #18
0
 /**
  * Get blocked users information
  *
  * @param
  * @return
  */
 function getBlockedUsersInformation()
 {
     global $ilDB, $lng, $ilPluginAdmin, $ilUser;
     $blocked_users = array();
     // load question/pages information
     $this->page_questions = array();
     $this->all_questions = array();
     $page_for_question = array();
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     $q = ilLMPageObject::queryQuestionsOfLearningModule($this->lm_obj_id, "", "", 0, 0);
     foreach ($q["set"] as $quest) {
         $this->page_questions[$quest["page_id"]][] = $quest["question_id"];
         $this->all_questions[] = $quest["question_id"];
         $page_for_question[$quest["question_id"]] = $quest["page_id"];
     }
     // get question information
     include_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionList.php";
     $qlist = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin);
     $qlist->setParentObjId(0);
     $qlist->addFieldFilter("question_id", $this->all_questions);
     $qlist->load();
     $qdata = $qlist->getQuestionDataArray();
     // load question answer information
     include_once "./Services/COPage/classes/class.ilPageQuestionProcessor.php";
     $this->answer_status = ilPageQuestionProcessor::getAnswerStatus($this->all_questions);
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     foreach ($this->answer_status as $as) {
         if ($as["try"] >= $qdata[$as["qst_id"]]["nr_of_tries"] && $qdata[$as["qst_id"]]["nr_of_tries"] > 0 && !$as["passed"]) {
             //var_dump($qdata[$as["qst_id"]]);
             $name = ilObjUser::_lookupName($as["user_id"]);
             $as["user_name"] = $name["lastname"] . ", " . $name["firstname"] . " [" . $name["login"] . "]";
             $as["question_text"] = $qdata[$as["qst_id"]]["question_text"];
             $as["page_id"] = $page_for_question[$as["qst_id"]];
             $as["page_title"] = ilLMPageObject::_lookupTitle($as["page_id"]);
             $blocked_users[] = $as;
         }
     }
     return $blocked_users;
 }
 /**
  * Copy all pages and chapters
  *
  * @param object $a_target_obj target learning module
  */
 function copyAllPagesAndChapters($a_target_obj, $a_copy_id = 0)
 {
     $parent_id = $a_target_obj->lm_tree->readRootId();
     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     // get all chapters of root lm
     $chapters = $this->lm_tree->getChildsByType($this->lm_tree->readRootId(), "st");
     $copied_nodes = array();
     //$time = time();
     foreach ($chapters as $chap) {
         $cid = ilLMObject::pasteTree($a_target_obj, $chap["child"], $parent_id, IL_LAST_NODE, $time, $copied_nodes, true, $this);
         $target = $cid;
     }
     // copy free pages
     $pages = ilLMPageObject::getPageList($this->getId());
     foreach ($pages as $p) {
         if (!$this->lm_tree->isInTree($p["obj_id"])) {
             $item = new ilLMPageObject($this, $p["obj_id"]);
             $target_item = $item->copy($a_target_obj);
             $copied_nodes[$item->getId()] = $target_item->getId();
         }
     }
     // Add mapping for pages and chapters
     include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
     $options = ilCopyWizardOptions::_getInstance($a_copy_id);
     foreach ($copied_nodes as $old_id => $new_id) {
         $options->appendMapping($this->getRefId() . '_' . $old_id, $a_target_obj->getRefId() . '_' . $new_id);
     }
     ilLMObject::updateInternalLinks($copied_nodes);
     $a_target_obj->checkTree();
 }
 /**
  * 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";
     }
 }
 function linkChilds()
 {
     switch ($_SESSION["search_link_type"]) {
         case "pg":
             include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
             include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php";
             $cont_obj_gui =& new ilObjContentObjectGUI("", $_GET["source_id"], true);
             $cont_obj = $cont_obj_gui->object;
             $pages = ilLMPageObject::getPageList($cont_obj->getId());
             $this->ctrl->setParameter($this, "q_id", $this->object->getId());
             $color_class = array("tblrow1", "tblrow2");
             $counter = 0;
             $this->tpl->addBlockFile("ADM_CONTENT", "link_selection", "tpl.il_svy_qpl_internallink_selection.html", "Modules/SurveyQuestionPool");
             foreach ($pages as $page) {
                 if ($page["type"] == $_SESSION["search_link_type"]) {
                     $this->tpl->setCurrentBlock("linktable_row");
                     $this->tpl->setVariable("TEXT_LINK", $page["title"]);
                     $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
                     $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($page["type"])) . "&" . $page["type"] . "=" . $page["obj_id"]);
                     $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
                     $this->tpl->parseCurrentBlock();
                     $counter++;
                 }
             }
             $this->tpl->setCurrentBlock("link_selection");
             $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
             $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("obj_" . $_SESSION["search_link_type"]));
             $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
             $this->tpl->parseCurrentBlock();
             break;
         case "st":
             $this->ctrl->setParameter($this, "q_id", $this->object->getId());
             $color_class = array("tblrow1", "tblrow2");
             $counter = 0;
             include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php";
             $cont_obj_gui =& new ilObjContentObjectGUI("", $_GET["source_id"], true);
             $cont_obj = $cont_obj_gui->object;
             // get all chapters
             $ctree =& $cont_obj->getLMTree();
             $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
             $this->tpl->addBlockFile("ADM_CONTENT", "link_selection", "tpl.il_svy_qpl_internallink_selection.html", "Modules/SurveyQuestionPool");
             foreach ($nodes as $node) {
                 if ($node["type"] == $_SESSION["search_link_type"]) {
                     $this->tpl->setCurrentBlock("linktable_row");
                     $this->tpl->setVariable("TEXT_LINK", $node["title"]);
                     $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
                     $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "add" . strtoupper($node["type"])) . "&" . $node["type"] . "=" . $node["obj_id"]);
                     $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
                     $this->tpl->parseCurrentBlock();
                     $counter++;
                 }
             }
             $this->tpl->setCurrentBlock("link_selection");
             $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
             $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("obj_" . $_SESSION["search_link_type"]));
             $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
             $this->tpl->parseCurrentBlock();
             break;
         case "glo":
             $this->ctrl->setParameter($this, "q_id", $this->object->getId());
             $color_class = array("tblrow1", "tblrow2");
             $counter = 0;
             $this->tpl->addBlockFile("ADM_CONTENT", "link_selection", "tpl.il_svy_qpl_internallink_selection.html", "Modules/SurveyQuestionPool");
             include_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
             $glossary =& new ilObjGlossary($_GET["source_id"], true);
             // get all glossary items
             $terms = $glossary->getTermList();
             foreach ($terms as $term) {
                 $this->tpl->setCurrentBlock("linktable_row");
                 $this->tpl->setVariable("TEXT_LINK", $term["term"]);
                 $this->tpl->setVariable("TEXT_ADD", $this->lng->txt("add"));
                 $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this), "addGIT") . "&git=" . $term["id"]);
                 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
                 $this->tpl->parseCurrentBlock();
                 $counter++;
             }
             $this->tpl->setCurrentBlock("link_selection");
             $this->tpl->setVariable("BUTTON_CANCEL", $this->lng->txt("cancel"));
             $this->tpl->setVariable("TEXT_LINK_TYPE", $this->lng->txt("glossary_term"));
             $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
             $this->tpl->parseCurrentBlock();
             break;
         case "lm":
             $this->object->addInternalLink("il__lm_" . $_GET["source_id"]);
             unset($_SESSION["link_new_type"]);
             unset($_SESSION["search_link_type"]);
             ilUtil::sendSuccess($this->lng->txt("material_added_successfully"), true);
             $this->ctrl->redirect($this, "material");
             break;
     }
 }
Example #22
0
 function outPageSelector()
 {
     require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionInternalLinkSelectionTableGUI.php';
     require_once 'Modules/LearningModule/classes/class.ilLMPageObject.php';
     require_once 'Modules/LearningModule/classes/class.ilObjContentObjectGUI.php';
     $this->ctrl->setParameter($this, 'q_id', $this->object->getId());
     $cont_obj_gui = new ilObjContentObjectGUI('', $_GET['source_id'], true);
     $cont_obj = $cont_obj_gui->object;
     $pages = ilLMPageObject::getPageList($cont_obj->getId());
     $shownpages = array();
     $tree = $cont_obj->getLMTree();
     $chapters = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
     $rows = array();
     foreach ($chapters as $chapter) {
         $chapterpages = $tree->getChildsByType($chapter['obj_id'], 'pg');
         foreach ($chapterpages as $page) {
             if ($page['type'] == $_GET['search_link_type']) {
                 array_push($shownpages, $page['obj_id']);
                 if ($tree->isInTree($page['obj_id'])) {
                     $path_str = $this->getContextPath($cont_obj, $page['obj_id']);
                 } else {
                     $path_str = '---';
                 }
                 $this->ctrl->setParameter($this, $page['type'], $page['obj_id']);
                 $rows[] = array('title' => $page['title'], 'description' => ilUtil::prepareFormOutput($path_str), 'text_add' => $this->lng->txt('add'), 'href_add' => $this->ctrl->getLinkTarget($this, 'add' . strtoupper($page['type'])));
             }
         }
     }
     foreach ($pages as $page) {
         if (!in_array($page['obj_id'], $shownpages)) {
             $this->ctrl->setParameter($this, $page['type'], $page['obj_id']);
             $rows[] = array('title' => $page['title'], 'description' => '---', 'text_add' => $this->lng->txt('add'), 'href_add' => $this->ctrl->getLinkTarget($this, 'add' . strtoupper($page['type'])));
         }
     }
     require_once 'Modules/TestQuestionPool/classes/tables/class.ilQuestionInternalLinkSelectionTableGUI.php';
     $table = new ilQuestionInternalLinkSelectionTableGUI($this, 'cancelExplorer', __METHOD__);
     $table->setTitle($this->lng->txt('obj_' . ilUtil::stripSlashes($_GET['search_link_type'])));
     $table->setData($rows);
     $this->tpl->setContent($table->getHTML());
 }
 /**
  * execute command
  */
 function &executeCommand()
 {
     global $tpl, $ilCtrl, $ilTabs, $ilSetting;
     $next_class = $this->ctrl->getNextClass($this);
     $cmd = $this->ctrl->getCmd();
     //echo "<br>:cmd:".$this->ctrl->getCmd().":cmdClass:".$this->ctrl->getCmdClass().":".
     //	":nextClass:".$next_class.":"; flush();
     switch ($next_class) {
         case "illmpagegui":
             // Determine whether the view of a learning resource should
             // be shown in the frameset of ilias, or in a separate window.
             //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
             $showViewInFrameset = true;
             $lm_set = new ilSetting("lm");
             $this->ctrl->setReturn($this, "edit");
             if (!ilPageObject::_exists("lm", $this->obj->getId(), $_GET["transl"]) && ilPageObject::_exists("lm", $this->obj->getId(), "-")) {
                 if ($_GET["totransl"] == "") {
                     $_GET["totransl"] = $_GET["transl"];
                     $ilCtrl->setCmd("switchToLanguage");
                 }
                 $ilCtrl->setCmdClass("illmpagegui");
                 $page_gui = new ilLMPageGUI($this->obj->getId(), 0, false, "-");
             } else {
                 $page_gui = new ilLMPageGUI($this->obj->getId());
             }
             $page_gui->setEditPreview(true);
             $page_gui->activateMetaDataEditor($this->content_object->getID(), $this->obj->getId(), $this->obj->getType(), $this->obj, "MDUpdateListener");
             if ($ilSetting->get("block_activated_news")) {
                 $page_gui->setEnabledNews(true, $this->obj->content_object->getId(), $this->obj->content_object->getType());
             }
             // set page view link
             if ($showViewInFrameset) {
                 $view_frame = ilFrameTargetInfo::_getFrame("MainContent");
             } else {
                 $view_frame = "ilContObj" . $this->content_object->getID();
             }
             $page_gui->setViewPageLink(ILIAS_HTTP_PATH . "/goto.php?target=pg_" . $this->obj->getId() . "_" . $_GET["ref_id"], $view_frame);
             include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
             $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId($this->content_object->getStyleSheetId(), "lm"));
             $page_gui->setTemplateTargetVar("ADM_CONTENT");
             $page_gui->getPageObject()->buildDom();
             $int_links = $page_gui->getPageObject()->getInternalLinks();
             $link_xml = $this->getLinkXML($int_links);
             $page_gui->setLinkXML($link_xml);
             $page_gui->enableChangeComments($this->content_object->isActiveHistoryUserComments());
             $page_gui->setFileDownloadLink("ilias.php?cmd=downloadFile&ref_id=" . $_GET["ref_id"] . "&baseClass=ilLMPresentationGUI");
             $page_gui->setFullscreenLink("ilias.php?cmd=fullscreen&ref_id=" . $_GET["ref_id"] . "&baseClass=ilLMPresentationGUI");
             $page_gui->setLinkParams("ref_id=" . $this->content_object->getRefId());
             $page_gui->setSourcecodeDownloadScript("ilias.php?ref_id=" . $_GET["ref_id"] . "&baseClass=ilLMPresentationGUI");
             $page_gui->setPresentationTitle(ilLMPageObject::_getPresentationTitle($this->obj->getId(), $this->content_object->getPageHeader(), $this->content_object->isActiveNumbering()));
             $page_gui->setLocator($contObjLocator);
             $page_gui->setHeader($this->lng->txt("page") . ": " . $this->obj->getTitle());
             $page_gui->setActivationListener($this, "activatePage");
             $up_gui = $this->content_object->getType() == "dbk" ? "ilobjdlbookgui" : "ilobjlearningmodulegui";
             $ilCtrl->setParameterByClass($up_gui, "active_node", $this->obj->getId());
             $page_gui->setExplorerUpdater("tree", "tree_div", $ilCtrl->getLinkTargetByClass($up_gui, "explorer", "", true));
             $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg_b.png"));
             $tpl->setTitle($this->lng->txt("page") . ": " . $this->obj->getTitle());
             if ($this->content_object->getLayoutPerPage()) {
                 $page_gui->setTabHook($this, "addPageTabs");
             }
             $ret = $this->ctrl->forwardCommand($page_gui);
             $tpl->setContent($ret);
             break;
         default:
             $ret =& $this->{$cmd}();
             break;
     }
 }
 /**
  * Show link help list
  */
 function showLinkHelp()
 {
     global $ilUser, $ilCtrl;
     // filter link types
     if (!$this->filter_white_list) {
         foreach ($this->filter_link_types as $link_type) {
             unset($this->ltypes[$link_type]);
         }
     } else {
         $ltypes = array();
         foreach ($this->ltypes as $k => $l) {
             if (in_array($k, $this->filter_link_types)) {
                 $ltypes[$k] = $l;
             }
         }
         $this->ltypes = $ltypes;
     }
     // determine link type and target
     $this->determineLinkType();
     $ltype = $this->link_target != "" ? $this->link_type . "_" . $this->link_target : $this->link_type;
     $def_type = ilObject::_lookupType($this->default_obj, true);
     // determine content object id
     switch ($this->link_type) {
         case "PageObject":
         case "StructureObject":
             if (empty($_SESSION["il_link_cont_obj"]) && ($def_type != "mep" && $def_type != "glo")) {
                 $_SESSION["il_link_cont_obj"] = $this->default_obj;
             }
             break;
         case "GlossaryItem":
             if (empty($_SESSION["il_link_glossary"]) && $def_type == "glo") {
                 $_SESSION["il_link_glossary"] = $this->default_obj;
             }
             break;
         case "Media":
             if (empty($_SESSION["il_link_mep"]) && $def_type == "mep") {
                 $_SESSION["il_link_mep"] = $this->default_obj;
             }
             break;
     }
     /*
     		$target_str = ($link_target == "")
     			? ""
     			: " target=\"".$link_target."\" ";*/
     $target_str = $this->link_target == "" ? "" : " target=\"" . $this->link_target . "\"";
     //echo "-".$this->link_type."-";
     if ($this->link_type == "GlossaryItem" && (empty($_SESSION["il_link_glossary"]) || !in_array(ilObject::_lookupType($_SESSION["il_link_glossary"], true), array("glo")))) {
         $this->changeTargetObject("glo");
     }
     if (($this->link_type == "PageObject" || $this->link_type == "StructureObject") && (empty($_SESSION["il_link_cont_obj"]) || !in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true), array("lm", "dbk")))) {
         $this->changeTargetObject("cont_obj");
     }
     if ($ilCtrl->isAsynch()) {
         $tpl = new ilTemplate("tpl.link_help_asynch.html", true, true, "Modules/LearningModule");
     } else {
         $tpl =& new ilTemplate("tpl.link_help.html", true, true, "Modules/LearningModule");
         $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     }
     switch ($this->link_type) {
         case "GlossaryItem":
             $this->ctrl->setParameter($this, "target_type", "glo");
             break;
         case "PageObject":
         case "StructureObject":
             $this->ctrl->setParameter($this, "target_type", "cont_obj");
             break;
         case "Media":
             $this->ctrl->setParameter($this, "target_type", "mep");
             break;
         default:
             break;
     }
     //echo "<br><br>:".$this->ctrl->getFormAction($this).":";
     //echo "<br>link_type:".$this->link_type;
     //echo "<br>cont_obj:".$_SESSION["il_link_cont_obj"];
     //echo "<br>link_mep".$_SESSION["il_link_mep"];
     //echo $this->ctrl->getFormAction($this, "", "", true);
     $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "changeLinkType", "", true));
     $tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
     $tpl->setVariable("TXT_HELP_HEADER", $this->lng->txt("cont_link_select"));
     $tpl->setVariable("TXT_TYPE", $this->lng->txt("cont_link_type"));
     //echo "<br><br>".$ltype;
     $select_ltype = ilUtil::formSelect($ltype, "ltype", $this->ltypes, false, true, "0", "", array("id" => "ilIntLinkTypeSelector"));
     $tpl->setVariable("SELECT_TYPE", $select_ltype);
     $tpl->setVariable("CMD_CHANGETYPE", "changeLinkType");
     $tpl->setVariable("BTN_CHANGETYPE", $this->lng->txt("cont_change_type"));
     /*		if ($this->isEnabledJavaScript())
     		{
     			$tpl->setVariable("BTN_CLOSE_JS", $this->lng->txt("close"));
     		}
     		else 
     		{*/
     $tpl->setVariable("CMD_CLOSE", "closeLinkHelp");
     $tpl->setVariable("BTN_CLOSE", $this->lng->txt("close"));
     //		}
     $chapterRowBlock = "chapter_row";
     $anchor_row_block = "anchor_link";
     if ($this->isEnabledJavaScript()) {
         $chapterRowBlock .= "_js";
         $anchor_row_block .= "_js";
     }
     $obj_id = ilObject::_lookupObjId($_SESSION["il_link_cont_obj"]);
     $type = ilObject::_lookupType($obj_id);
     // switch link type
     switch ($this->link_type) {
         // page link
         case "PageObject":
             require_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
             include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
             $cont_obj = new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
             // get all chapters
             $ctree = $cont_obj->getLMTree();
             $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
             $tpl->setCurrentBlock("chapter_list");
             $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
             $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
             $tpl->setCurrentBlock("change_cont_obj");
             $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
             $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
             $tpl->parseCurrentBlock();
             foreach ($nodes as $node) {
                 if ($node["type"] == "st") {
                     $tpl->setCurrentBlock("chapter_row");
                     $tpl->setVariable("TXT_CHAPTER", $node["title"]);
                     $tpl->setVariable("ROWCLASS", "tblrow1");
                     //$tpl->setVariable("LINK_CHAPTER",
                     //	"[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]");
                     $tpl->parseCurrentBlock();
                     $tpl->setCurrentBlock("row");
                     $tpl->parseCurrentBlock();
                 }
                 if ($node["type"] == "pg") {
                     include_once "./Services/COPage/classes/class.ilPCParagraph.php";
                     $this->renderLink($tpl, $node["title"], $node["obj_id"], "PageObject", "pg", "page", ilPCParagraph::_readAnchors($type, $node["obj_id"], ""));
                 }
             }
             // get all free pages
             $pages = ilLMPageObject::getPageList($cont_obj->getId());
             $free_pages = array();
             foreach ($pages as $page) {
                 if (!$ctree->isInTree($page["obj_id"])) {
                     $free_pages[] = $page;
                 }
             }
             if (count($free_pages) > 0) {
                 $tpl->setCurrentBlock(str_replace("_js", "", $chapterRowBlock));
                 $tpl->setVariable("TXT_CHAPTER", $this->lng->txt("cont_free_pages"));
                 $tpl->setVariable("ROWCLASS", "tblrow1");
                 $tpl->parseCurrentBlock();
                 foreach ($free_pages as $node) {
                     include_once "./Services/COPage/classes/class.ilPCParagraph.php";
                     $this->renderLink($tpl, $node["title"], $node["obj_id"], "PageObject", "pg", "page", ilPCParagraph::_readAnchors($type, $node["obj_id"], ""));
                 }
             }
             $tpl->setCurrentBlock("chapter_list");
             $tpl->parseCurrentBlock();
             break;
             // chapter link
         // chapter link
         case "StructureObject":
             // check whether current object matchs to type
             if (!in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true), array("lm", "dbk"))) {
                 $this->changeTargetObject("lm");
             }
             if ($type == "lm") {
                 require_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
                 $cont_obj = new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
             } else {
                 if ($type == "dbk") {
                     require_once "./Modules/LearningModule/classes/class.ilObjDlBook.php";
                     $cont_obj = new ilObjDlBook($_SESSION["il_link_cont_obj"], true);
                 }
             }
             // get all chapters
             $ctree =& $cont_obj->getLMTree();
             $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
             $tpl->setCurrentBlock("chapter_list");
             $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj"));
             $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
             $tpl->setCurrentBlock("change_cont_obj");
             $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
             $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
             $tpl->parseCurrentBlock();
             foreach ($nodes as $node) {
                 if ($node["type"] == "st") {
                     $this->renderLink($tpl, $node["title"], $node["obj_id"], "StructureObject", "st", "chap");
                 }
             }
             $tpl->setCurrentBlock("chapter_list");
             $tpl->parseCurrentBlock();
             break;
             // glossary item link
         // glossary item link
         case "GlossaryItem":
             require_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
             $glossary =& new ilObjGlossary($_SESSION["il_link_glossary"], true);
             // get all glossary items
             $terms = $glossary->getTermList();
             $tpl->setCurrentBlock("chapter_list");
             $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
             $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
             $tpl->setCurrentBlock("change_cont_obj");
             $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
             $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
             $tpl->parseCurrentBlock();
             foreach ($terms as $term) {
                 $this->renderLink($tpl, $term["term"], $term["id"], "GlossaryItem", "git", "term");
             }
             $tpl->setCurrentBlock("chapter_list");
             $tpl->parseCurrentBlock();
             break;
             // media object
         // media object
         case "Media":
             include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php";
             //$tpl->setVariable("TARGET2", " target=\"content\" ");
             // content object id = 0 --> get clipboard objects
             if ($_SESSION["il_link_mep"] == 0) {
                 $tpl->setCurrentBlock("change_cont_obj");
                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
                 $tpl->parseCurrentBlock();
                 $mobjs = $this->ilias->account->getClipboardObjects("mob");
                 // sort by name
                 $objs = array();
                 foreach ($mobjs as $obj) {
                     $objs[$obj["title"] . ":" . $obj["id"]] = $obj;
                 }
                 ksort($objs);
                 $tpl->setCurrentBlock("chapter_list");
                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source"));
                 $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard"));
                 $tpl->setVariable("COLSPAN", "2");
                 foreach ($objs as $obj) {
                     $this->renderLink($tpl, $obj["title"], $obj["id"], "MediaObject", "mob", "media");
                 }
                 $tpl->setCurrentBlock("chapter_list");
                 $tpl->parseCurrentBlock();
             } else {
                 require_once "./Modules/MediaPool/classes/class.ilObjMediaPool.php";
                 $med_pool =& new ilObjMediaPool($_SESSION["il_link_mep"], true);
                 // get current folders
                 $fobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "fold");
                 $f2objs = array();
                 foreach ($fobjs as $obj) {
                     $f2objs[$obj["title"] . ":" . $obj["child"]] = $obj;
                 }
                 ksort($f2objs);
                 // get current media objects
                 $mobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "mob");
                 $m2objs = array();
                 foreach ($mobjs as $obj) {
                     $m2objs[$obj["title"] . ":" . $obj["child"]] = $obj;
                 }
                 ksort($m2objs);
                 // merge everything together
                 $objs = array_merge($f2objs, $m2objs);
                 $tpl->setCurrentBlock("chapter_list");
                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
                 $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
                 $tpl->setCurrentBlock("change_cont_obj");
                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
                 $tpl->setVariable("COLSPAN", "2");
                 $tpl->parseCurrentBlock();
                 if ($parent_id = $med_pool->getParentId($_SESSION["il_link_mep_obj"])) {
                     $css_row = "tblrow1";
                     $tpl->setCurrentBlock("icon");
                     $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.png"));
                     $tpl->parseCurrentBlock();
                     $tpl->setCurrentBlock("link_row");
                     $tpl->setVariable("ROWCLASS", $css_row);
                     $tpl->setVariable("TXT_CHAPTER", "..");
                     $this->ctrl->setParameter($this, "mep_fold", $parent_id);
                     if ($ilCtrl->isAsynch()) {
                         $tpl->setVariable("LINK", "#");
                         $tpl->setVariable("LR_ONCLICK", " onclick=\"return il.IntLink.setMepPoolFolder('" . $parent_id . "');\" ");
                     } else {
                         $tpl->setVariable("LINK", $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
                     }
                     $tpl->parseCurrentBlock();
                     $tpl->setCurrentBlock("row");
                     $tpl->parseCurrentBlock();
                 }
                 foreach ($objs as $obj) {
                     if ($obj["type"] == "fold") {
                         $css_row = $css_row == "tblrow2" ? "tblrow1" : "tblrow2";
                         $tpl->setCurrentBlock("icon");
                         $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.png"));
                         $tpl->parseCurrentBlock();
                         $tpl->setCurrentBlock("link_row");
                         $tpl->setVariable("ROWCLASS", $css_row);
                         $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
                         $this->ctrl->setParameter($this, "mep_fold", $obj["child"]);
                         if ($ilCtrl->isAsynch()) {
                             $tpl->setVariable("LINK", "#");
                             $tpl->setVariable("LR_ONCLICK", " onclick=\"return il.IntLink.setMepPoolFolder('" . $obj["child"] . "');\" ");
                         } else {
                             $tpl->setVariable("LINK", $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
                         }
                         $tpl->parseCurrentBlock();
                     } else {
                         $fid = ilMediaPoolItem::lookupForeignId($obj["child"]);
                         if (ilObject::_lookupType($fid) == "mob") {
                             $this->renderLink($tpl, $obj["title"], $fid, "MediaObject", "mob", "media");
                         }
                     }
                     $tpl->setCurrentBlock("row");
                     $tpl->parseCurrentBlock();
                 }
                 $tpl->setCurrentBlock("chapter_list");
                 $tpl->parseCurrentBlock();
             }
             break;
             // repository item
         // repository item
         case "RepositoryItem":
             $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem());
             break;
             // file download link
         // file download link
         case "File":
             if (!is_object($this->uploaded_file)) {
                 $tpl->setVariable("LINK_HELP_CONTENT", $this->getFileLinkHTML());
             } else {
                 echo $this->getFileLinkHTML();
                 exit;
             }
             break;
     }
     if ($ilCtrl->isAsynch()) {
         echo $tpl->get();
         exit;
     }
     exit;
 }
 /**
  * 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 .= "&amp;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("&", "&amp;", $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;
 }
Example #26
0
 /**
  * Get affective title
  *
  * @param
  * @return
  */
 static function _getPresentationTitle($a_node, $a_mode = IL_PAGE_TITLE, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_force_content = false, $a_lm_id = 0, $a_lang = "-")
 {
     if ($a_lang == "") {
         $a_lang = "-";
     }
     if ($a_node["type"] == "st") {
         return ilStructureObject::_getPresentationTitle($a_node["child"], $a_include_numbers, $a_time_scheduled_activation, $a_lm_id, $a_lang);
     } else {
         return ilLMPageObject::_getPresentationTitle($a_node["child"], $a_mode, $a_include_numbers, $a_time_scheduled_activation, $a_force_content, $a_lm_id, $a_lang);
     }
 }
 /**
  * Copy all pages and chapters
  *
  * @param object $a_target_obj target learning module
  */
 function copyAllPagesAndChapters($a_target_obj)
 {
     $parent_id = $a_target_obj->lm_tree->readRootId();
     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     // get all chapters of root lm
     $chapters = $this->lm_tree->getChildsByType($this->lm_tree->readRootId(), "st");
     $copied_nodes = array();
     //$time = time();
     foreach ($chapters as $chap) {
         $cid = ilLMObject::pasteTree($a_target_obj, $chap["child"], $parent_id, IL_LAST_NODE, $time, $copied_nodes, true, $this);
         $target = $cid;
     }
     // copy free pages
     $pages = ilLMPageObject::getPageList($this->getId());
     foreach ($pages as $p) {
         if (!$this->lm_tree->isInTree($p["obj_id"])) {
             $item = new ilLMPageObject($this, $p["obj_id"]);
             $target_item = $item->copy($a_target_obj);
             $copied_nodes[$item->getId()] = $target_item->getId();
         }
     }
     ilLMObject::updateInternalLinks($copied_nodes);
     $a_target_obj->checkTree();
 }