/**
  * Get node content
  *
  * @param array $a_node node array
  * @return string node content
  */
 function getNodeContent($a_node)
 {
     if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
         return $this->lm->getTitle();
     }
     $lang = $_GET["transl"] != "" ? $_GET["transl"] : "-";
     return ilLMObject::_getPresentationTitle($a_node, IL_PAGE_TITLE, $this->lm->isActiveNumbering(), false, false, $this->lm->getId(), $lang);
 }
 /**
  * Constructor
  *
  * @param object $a_parent_obj parent gui object
  * @param string $a_parent_cmd parent cmd
  * @param ilLMPresentationGUI $a_lm_pres learning module presentation gui object
  * @param string $a_lang language
  */
 function __construct($a_parent_obj, $a_parent_cmd, ilLMPresentationGUI $a_lm_pres, $a_lang = "-")
 {
     parent::__construct($a_parent_obj, $a_parent_cmd, $a_lm_pres, $a_lang);
     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
     $chaps = ilLMObject::_getAllLMObjectsOfLM($this->lm->getId(), $a_type = "st");
     foreach ($chaps as $c) {
         $this->setNodeOpen($c);
     }
 }
 /**
  * get html 
  * @return
  */
 public function getHTML()
 {
     global $lng, $ilUser;
     include_once 'Modules/LearningModule/classes/class.ilLMObject.php';
     foreach ($this->getSubItemIds(true) as $sub_item) {
         if (is_object($this->getHighlighter()) and strlen($this->getHighlighter()->getContent($this->getObjId(), $sub_item))) {
             $this->tpl->setCurrentBlock('sea_fragment');
             $this->tpl->setVariable('TXT_FRAGMENT', $this->getHighlighter()->getContent($this->getObjId(), $sub_item));
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('subitem');
         $this->tpl->setVariable('SEPERATOR', ':');
         switch (ilLMObject::_lookupType($sub_item, $this->getObjId())) {
             case 'pg':
                 $this->getItemListGUI()->setChildId($sub_item);
                 $this->tpl->setVariable("SUBITEM_TYPE", $lng->txt('obj_pg'));
                 $link = $this->getItemListGUI()->getCommandLink('page');
                 include_once './Services/Search/classes/class.ilUserSearchCache.php';
                 $link .= '&srcstring=1';
                 $this->tpl->setVariable('LINK', $link);
                 $this->tpl->setVariable('TARGET', $this->getItemListGUI()->getCommandFrame('page'));
                 $this->tpl->setVariable('TITLE', ilLMObject::_lookupTitle($sub_item));
                 break;
             case 'st':
                 $this->getItemListGUI()->setChildId($sub_item);
                 $this->tpl->setVariable("SUBITEM_TYPE", $lng->txt('obj_st'));
                 $link = $this->getItemListGUI()->getCommandLink('page');
                 include_once './Services/Search/classes/class.ilUserSearchCache.php';
                 $link .= '&srcstring=1';
                 $this->tpl->setVariable('LINK', $link);
                 $this->tpl->setVariable('TARGET', $this->getItemListGUI()->getCommandFrame('page'));
                 $this->tpl->setVariable('TITLE', ilLMObject::_lookupTitle($sub_item));
                 break;
             default:
                 if (ilObject::_lookupType($sub_item) != 'file') {
                     return '';
                 }
                 $this->getItemListGUI()->setChildId('il__file_' . $sub_item);
                 $this->tpl->setVariable('SUBITEM_TYPE', $lng->txt('obj_file'));
                 $link = $this->getItemListGUI()->getCommandLink('downloadFile');
                 $this->tpl->setVariable('LINK', $link);
                 $this->tpl->setVariable('TITLE', ilObject::_lookupTitle($sub_item));
                 break;
         }
         if (count($this->getSubItemIds(true)) > 1) {
             $this->parseRelevance($sub_item);
         }
         $this->tpl->parseCurrentBlock();
     }
     $this->showDetailsLink();
     return $this->tpl->get();
 }
 /**
  * Delete sub tree
  */
 private function delete_rec(&$a_tree, $a_delete_meta_data = true)
 {
     $childs = $a_tree->getChilds($this->getId());
     foreach ($childs as $child) {
         $obj =& ilLMObjectFactory::getInstance($this->content_object, $child["obj_id"], false);
         if (is_object($obj)) {
             if ($obj->getType() == "st") {
                 $obj->delete_rec($a_tree, $a_delete_meta_data);
             }
             if ($obj->getType() == "pg") {
                 $obj->delete($a_delete_meta_data);
             }
         }
         unset($obj);
     }
     parent::delete($a_delete_meta_data);
 }
 /**
  * Get tail dependencies
  *
  * @param		string		entity
  * @param		string		target release
  * @param		array		ids
  * @return		array		array of array with keys "component", entity", "ids"
  */
 function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
 {
     if ($a_target_release == "4.3.0") {
         if ($a_entity == "help") {
             $lm_node_ids = array();
             include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
             foreach ($a_ids as $lm_id) {
                 $chaps = ilLMObject::getObjectList($lm_id, "st");
                 foreach ($chaps as $chap) {
                     $lm_node_ids[] = $chap["obj_id"];
                 }
             }
             return array(array("component" => "Services/Help", "entity" => "help_map", "ids" => $lm_node_ids), array("component" => "Services/Help", "entity" => "help_tooltip", "ids" => $a_ids));
         }
     }
     return array();
 }
 /**
  * check if links for certain object type are activated
  *
  * @param	string		$a_type			object type
  *
  * @return	boolean		true if linking is activated
  */
 function isClickable($a_type, $a_obj_id = 0)
 {
     global $ilUser;
     // in this standard implementation
     // only the type determines, wether an object should be clickable or not
     // but this method can be overwritten and make use of the ref id
     // (this happens e.g. in class ilRepositoryExplorerGUI)
     if ($this->is_clickable[$a_type] == "n") {
         return false;
     }
     // check public access
     include_once 'Services/Payment/classes/class.ilPaymentObject.php';
     if (($ilUser->getId() == ANONYMOUS_USER_ID || ilPaymentObject::_requiresPurchaseToAccess((int) $this->lm_obj->getRefId())) && !ilLMObject::_isPagePublic($a_obj_id, true)) {
         return false;
     }
     return true;
 }
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $ilCtrl, $lng;
     $this->tpl->setVariable("PAGE_TITLE", ilLMObject::_lookupTitle($a_set["page_id"]));
     $this->tpl->setVariable("QUESTION", assQuestion::_getQuestionText($a_set["question_id"]));
     include_once "./Services/COPage/classes/class.ilPageQuestionProcessor.php";
     $stats = ilPageQuestionProcessor::getQuestionStatistics($a_set["question_id"]);
     $this->tpl->setVariable("VAL_ANSWERED", (int) $stats["all"]);
     if ($stats["all"] == 0) {
         $this->tpl->setVariable("VAL_CORRECT_FIRST", 0);
         $this->tpl->setVariable("VAL_CORRECT_SECOND", 0);
         $this->tpl->setVariable("VAL_CORRECT_THIRD_OR_MORE", 0);
         $this->tpl->setVariable("VAL_NEVER", 0);
     } else {
         $this->tpl->setVariable("VAL_CORRECT_FIRST", $stats["first"] . " (" . 100 / $stats["all"] * $stats["first"] . " %)");
         $this->tpl->setVariable("VAL_CORRECT_SECOND", $stats["second"] . " (" . 100 / $stats["all"] * $stats["second"] . " %)");
         $this->tpl->setVariable("VAL_CORRECT_THIRD_AND_MORE", $stats["third_or_more"] . " (" . 100 / $stats["all"] * $stats["third_or_more"] . " %)");
         $nev = $stats["all"] - $stats["first"] - $stats["second"] - $stats["third_or_more"];
         $this->tpl->setVariable("VAL_NEVER", $nev . " (" . 100 / $stats["all"] * $nev . " %)");
     }
 }
 /**
  * Get's the repository object ID of a parent object, if possible
  * 
  * see ilWebAccessChecker 
  */
 function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false)
 {
     if (is_int(strpos($a_usage["type"], ":"))) {
         $us_arr = explode(":", $a_usage["type"]);
         $type = $us_arr[1];
         $cont_type = $us_arr[0];
     } else {
         $type = $a_usage["type"];
     }
     $id = $a_usage["id"];
     $obj_id = false;
     switch ($type) {
         // RTE / tiny mce
         case "html":
             switch ($cont_type) {
                 case "qpl":
                     // Question Pool *Question* Text (Test)
                     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                     $qinfo = assQuestion::_getQuestionInfo($id);
                     if ($qinfo["original_id"] > 0) {
                         include_once "./Modules/Test/classes/class.ilObjTest.php";
                         $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                         // usage in test
                     } else {
                         $obj_id = $qinfo["obj_fi"];
                         // usage in pool
                     }
                     break;
                 case "spl":
                     // Question Pool *Question* Text (Survey)
                     include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                     $quest = SurveyQuestion::_instanciateQuestion($id);
                     if ($quest) {
                         if ($quest->getOriginalId() > 0) {
                             $obj_id = $quest->getSurveyId();
                         } else {
                             $obj_id = $quest->getObjId();
                             // usage in pool
                         }
                         unset($quest);
                     }
                     break;
                 case "exca":
                     // Exercise assignment
                     $returned_pk = $a_usage['id'];
                     // we are just checking against exercise object
                     include_once 'Modules/Exercise/classes/class.ilObjExercise.php';
                     $obj_id = ilObjExercise::lookupExerciseIdForReturnedId($returned_pk);
                     break;
                 case "frm":
                     // Forum
                     $post_pk = $a_usage['id'];
                     include_once 'Modules/Forum/classes/class.ilForumPost.php';
                     include_once 'Modules/Forum/classes/class.ilForum.php';
                     $oPost = new ilForumPost($post_pk);
                     $frm_pk = $oPost->getForumId();
                     $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
                     break;
                     // temporary items (per user)
                 // temporary items (per user)
                 case "frm~":
                 case "exca~":
                     $obj_id = $a_usage['id'];
                     break;
                     // "old" category pages
                 // "old" category pages
                 case "cat":
                     // InfoScreen Text
                 // InfoScreen Text
                 case "tst":
                 case "svy":
                     // data collection
                 // data collection
                 case "dcl":
                     $obj_id = $id;
                     break;
             }
             break;
             // page editor
         // page editor
         case "pg":
             switch ($cont_type) {
                 case "qpl":
                     // Question Pool Question Pages
                     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                     $qinfo = assQuestion::_getQuestionInfo($id);
                     if ($qinfo["original_id"] > 0) {
                         include_once "./Modules/Test/classes/class.ilObjTest.php";
                         $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                         // usage in test
                     } else {
                         $obj_id = $qinfo["obj_fi"];
                         // usage in pool
                     }
                     break;
                 case "lm":
                 case "dbk":
                     // learning modules
                     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                     $obj_id = ilLMObject::_lookupContObjID($id);
                     break;
                 case "gdf":
                     // glossary definition
                     include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
                     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                     $term_id = ilGlossaryDefinition::_lookupTermId($id);
                     $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id);
                     break;
                 case "wpg":
                     // wiki page
                     include_once 'Modules/Wiki/classes/class.ilWikiPage.php';
                     $obj_id = ilWikiPage::lookupObjIdByPage($id);
                     break;
                 case "sahs":
                     // sahs page
                     // can this implementation be used for other content types, too?
                     include_once './Services/COPage/classes/class.ilPageObject.php';
                     $obj_id = ilPageObject::lookupParentId($id, 'sahs');
                     break;
                 case "prtf":
                     // portfolio
                     include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
                     $obj_id = ilPortfolioPage::findPortfolioForPage($id);
                     break;
                 case "prtt":
                     // portfolio template
                     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
                     $obj_id = ilPortfolioTemplatePage::findPortfolioForPage($id);
                     break;
                 case "blp":
                     // blog
                     include_once './Services/COPage/classes/class.ilPageObject.php';
                     $obj_id = ilPageObject::lookupParentId($id, 'blp');
                     break;
                 case "crs":
                 case "grp":
                 case "cat":
                 case "fold":
                 case "root":
                     // repository pages
                     $obj_id = $id;
                     break;
             }
             break;
             // Media Pool
         // Media Pool
         case "mep":
             $obj_id = $id;
             break;
             // News Context Object (e.g. MediaCast)
         // News Context Object (e.g. MediaCast)
         case "news":
             include_once "./Services/News/classes/class.ilNewsItem.php";
             $obj_id = ilNewsItem::_lookupContextObjId($id);
             break;
     }
     return $obj_id;
 }
 /**
  * Insert pages from clipboard
  */
 function insertPageClip()
 {
     global $ilCtrl, $ilUser;
     include_once "./Modules/LearningModule/classes/class.ilChapterHierarchyFormGUI.php";
     $node_id = ilChapterHierarchyFormGUI::getPostNodeId();
     $first_child = ilChapterHierarchyFormGUI::getPostFirstChild();
     if (!$first_child) {
         $parent_id = $this->tree->getParentId($node_id);
         $target = $node_id;
     } else {
         $parent_id = $node_id;
         $target = IL_FIRST_NODE;
     }
     // cut and paste
     $pages = $ilUser->getClipboardObjects("pg");
     $copied_nodes = array();
     foreach ($pages as $pg) {
         $cid = ilLMObject::pasteTree($this->content_object, $pg["id"], $parent_id, $target, $pg["insert_time"], $copied_nodes, ilEditClipboard::getAction() == "copy");
         $target = $cid;
     }
     ilLMObject::updateInternalLinks($copied_nodes);
     if (ilEditClipboard::getAction() == "cut") {
         $ilUser->clipboardDeleteObjectsOfType("pg");
         $ilUser->clipboardDeleteObjectsOfType("st");
         ilEditClipboard::clear();
     }
     $ilCtrl->redirect($this, "view");
 }
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     //var_dump($a_set);
     // icon...
     // check activation
     include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
     $active = ilLMPage::_lookupActive($a_set["obj_id"], $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
     // is page scheduled?
     $img_sc = $this->lm_set->get("time_scheduled_page_activation") && ilLMPage::_isScheduledActivation($a_set["obj_id"], $this->lm->getType()) ? "_sc" : "";
     if (!$active) {
         $img = "icon_pg_d" . $img_sc . ".svg";
         $alt = $lng->txt("cont_page_deactivated");
     } else {
         if (ilLMPage::_lookupContainsDeactivatedElements($a_set["obj_id"], $this->lm->getType())) {
             $img = "icon_pg_del" . $img_sc . ".svg";
             $alt = $lng->txt("cont_page_deactivated_elements");
         } else {
             $img = "icon_pg" . $img_sc . ".svg";
             $alt = $this->lng->txt("pg");
         }
     }
     $this->tpl->setVariable("ICON", ilUtil::img(ilUtil::getImagePath($img), $alt));
     // title/link
     $ilCtrl->setParameter($this, "backcmd", "");
     $ilCtrl->setParameterByClass("ilLMPageObjectGUI", "obj_id", $a_set["obj_id"]);
     $this->tpl->setVariable("HREF_TITLE", $ilCtrl->getLinkTargetByClass("ilLMPageObjectGUI", "edit"));
     $this->tpl->setVariable("TITLE", $a_set["title"]);
     $this->tpl->setVariable("ID", $a_set["obj_id"]);
     // context
     if ($this->lm->lm_tree->isInTree($a_set["obj_id"])) {
         $path_str = $this->parent_obj->getContextPath($a_set["obj_id"]);
     } else {
         $path_str = "---";
     }
     // check whether page is header or footer
     $add_str = "";
     if ($a_set["obj_id"] == $this->lm->getHeaderPage()) {
         $add_str = " <b>(" . $lng->txt("cont_header") . ")</b>";
     }
     if ($a_set["obj_id"] == $this->lm->getFooterPage()) {
         $add_str .= " <b>(" . $lng->txt("cont_footer") . ")</b>";
     }
     $this->tpl->setVariable("USAGE", $path_str . $add_str);
     // layout
     if ($this->lm->getLayoutPerPage()) {
         if (($l = ilLMObject::lookupLayout($a_set["obj_id"])) != "") {
             $this->tpl->setVariable("LAYOUT", $lng->txt("cont_layout_" . $l));
         }
     }
 }
 /**
  * render objective
  *
  * @access protected
  * @param int objective id
  * @param bool co page status
  * @param ilAccordionGUI $a_accordion 
  * @param array $a_lo_result 
  * @return string html
  */
 protected function renderObjective($a_objective_id, &$a_has_lo_page, ilAccordionGUI $a_accordion = null, array $a_lo_result = null)
 {
     global $ilUser, $lng;
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     $objective = new ilCourseObjective($this->getContainerObject(), $a_objective_id);
     include_once './Services/Container/classes/class.ilContainerSorting.php';
     include_once './Services/Object/classes/class.ilObjectActivation.php';
     $items = ilObjectActivation::getItemsByObjective($a_objective_id);
     // sorting is handled by ilCourseObjectiveMaterials
     // $items = ilContainerSorting::_getInstance($this->getContainerObject()->getId())->sortSubItems('lobj',$a_objective_id,$items);
     include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
     $objectives_lm_obj = new ilCourseObjectiveMaterials($a_objective_id);
     // #13381 - map material assignment to position
     $sort_map = array();
     foreach ($objectives_lm_obj->getMaterials() as $item) {
         $sort_map[$item["lm_ass_id"]] = $item["position"];
     }
     $is_manage = $this->getContainerGUI()->isActiveAdministrationPanel();
     $is_order = $this->getContainerGUI()->isActiveOrdering();
     $sort_content = array();
     foreach ($items as $item) {
         if ($this->getDetailsLevel($a_objective_id) < self::DETAILS_ALL) {
             continue;
         }
         $item_list_gui2 = $this->getItemGUI($item);
         $item_list_gui2->enableIcon(true);
         if ($is_order || $a_accordion) {
             $item_list_gui2->enableCommands(true, true);
             $item_list_gui2->enableProperties(false);
         }
         $chapters = $objectives_lm_obj->getChapters();
         if (count($chapters)) {
             $has_sections = false;
             foreach ($chapters as $chapter) {
                 if ($chapter['ref_id'] != $item['child']) {
                     continue;
                 }
                 $has_sections = true;
                 include_once './Modules/LearningModule/classes/class.ilLMObject.php';
                 $title = $item['title'] . " &rsaquo; " . ilLMObject::_lookupTitle($chapter['obj_id']) . " (" . $lng->txt('obj_' . $chapter['type']) . ")";
                 $item_list_gui2->setDefaultCommandParameters(array("obj_id" => $chapter['obj_id'], "focus_id" => $chapter['obj_id'], "focus_return" => $this->container_obj->getRefId()));
                 if ($is_order) {
                     $item_list_gui2->setPositionInputField("[lobj][" . $a_objective_id . "][" . $chapter['lm_ass_id'] . "]", sprintf('%d', $chapter['position'] * 10));
                 }
                 $sub_item_html = $item_list_gui2->getListItemHTML($item['ref_id'], $item['obj_id'], $title, $item['description']);
                 // #13381 - use materials order
                 $sort_key = str_pad($chapter['position'], 5, 0, STR_PAD_LEFT) . "_" . strtolower($title) . "_" . $chapter['lm_ass_id'];
                 $sort_content[$sort_key] = $sub_item_html;
             }
         }
         $this->rendered_items[$item['child']] = true;
         if ($lm_ass_id = $objectives_lm_obj->isAssigned($item['ref_id'], true)) {
             if ($is_order) {
                 $item_list_gui2->setPositionInputField("[lobj][" . $a_objective_id . "][" . $lm_ass_id . "]", sprintf('%d', $sort_map[$lm_ass_id] * 10));
             }
             $sub_item_html = $item_list_gui2->getListItemHTML($item['ref_id'], $item['obj_id'], $item['title'], $item['description']);
             // #13381 - use materials order
             $sort_key = str_pad($sort_map[$lm_ass_id], 5, 0, STR_PAD_LEFT) . "_" . strtolower($item['title']) . "_" . $lm_ass_id;
             $sort_content[$sort_key] = $sub_item_html;
         }
     }
     if ($this->getDetailsLevel($a_objective_id) == self::DETAILS_ALL) {
         $this->objective_list_gui->enableCommands(false);
     } else {
         $this->objective_list_gui->enableCommands(true);
     }
     if ($is_order) {
         $this->objective_list_gui->setPositionInputField("[lobj][" . $a_objective_id . "][0]", $objective->__getPosition() * 10);
     }
     ksort($sort_content);
     if (!$a_accordion) {
         foreach ($sort_content as $sub_item_html) {
             $this->objective_list_gui->addSubItemHTML($sub_item_html);
         }
         return $this->objective_list_gui->getListItemHTML(0, $a_objective_id, $objective->getTitle(), $objective->getDescription(), $is_manage || $is_order);
     } else {
         $acc_content = $sort_content;
         $initial_shown = false;
         if ($this->getSettings()->hasSeparateInitialTests() and !$a_lo_result['initial_status']) {
             $acc_content[] = $this->renderTest($this->getTestAssignments()->getTestByObjective($a_objective_id, ilLOSettings::TYPE_TEST_INITIAL), $a_objective_id, true, false, $a_lo_result);
             $initial_shown = TRUE;
         } elseif ($this->getSettings()->hasSeparateQualifiedTests()) {
             $acc_content[] = $this->renderTest($this->getTestAssignments()->getTestByObjective($a_objective_id, ilLOSettings::TYPE_TEST_QUALIFIED), $a_objective_id, false, false, $a_lo_result);
         }
         /*
         if($this->loc_settings->getInitialTest() &&
         	$this->loc_settings->getType() == ilLOSettings::LOC_INITIAL_SEL &&
         	!$a_lo_result["initial_status"])
         {
         	$acc_content[] = $this->renderTest($this->loc_settings->getInitialTest(), $a_objective_id, true, false, $a_lo_result);
         	$initial_shown = true;
         }	
         if(!$initial_shown &&
         	$this->loc_settings->getQualifiedTest() && 
         	$this->loc_settings->isQualifiedTestPerObjectiveVisible())
         {
         	$acc_content[] = $this->renderTest($this->loc_settings->getQualifiedTest(), $a_objective_id, false, false, $a_lo_result);
         }
         */
         $co_page = null;
         include_once "./Services/COPage/classes/class.ilPageUtil.php";
         if (ilPageUtil::_existsAndNotEmpty("lobj", $objective->getObjectiveId())) {
             $a_has_lo_page = true;
             include_once 'Modules/Course/classes/Objectives/class.ilLOPageGUI.php';
             $page_gui = new ilLOPageGUI($objective->getObjectiveId());
             include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
             $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0));
             $page_gui->setPresentationTitle("");
             $page_gui->setTemplateOutput(false);
             $page_gui->setHeader("");
             $co_page = "<div class='ilContObjectiveIntro'>" . $page_gui->showPage() . "</div>";
         }
         // patch optes start
         $a_accordion->addItem($this->buildAccordionTitle($objective, $a_lo_result), $co_page . $this->buildAccordionContent($acc_content), isset($_GET["oobj"]) && (int) $_GET["oobj"] == $objective->getObjectiveId());
         // patch optes end
     }
 }
Example #12
0
 function moveIntLinks($a_from_to)
 {
     $this->buildDom();
     $changed = false;
     // resolve normal internal links
     $xpc = xpath_new_context($this->dom);
     $path = "//IntLink";
     $res =& xpath_eval($xpc, $path);
     for ($i = 0; $i < count($res->nodeset); $i++) {
         $target = $res->nodeset[$i]->get_attribute("Target");
         $type = $res->nodeset[$i]->get_attribute("Type");
         $obj_id = ilInternalLink::_extractObjIdOfTarget($target);
         if ($a_from_to[$obj_id] > 0 && is_int(strpos($target, "__"))) {
             if ($type == "PageObject" && ilLMObject::_lookupType($a_from_to[$obj_id]) == "pg") {
                 $res->nodeset[$i]->set_attribute("Target", "il__pg_" . $a_from_to[$obj_id]);
                 $changed = true;
             }
             if ($type == "StructureObject" && ilLMObject::_lookupType($a_from_to[$obj_id]) == "st") {
                 $res->nodeset[$i]->set_attribute("Target", "il__st_" . $a_from_to[$obj_id]);
                 $changed = true;
             }
         }
     }
     unset($xpc);
     // map areas
     $this->addHierIDs();
     $xpc = xpath_new_context($this->dom);
     $path = "//MediaAlias";
     $res =& xpath_eval($xpc, $path);
     require_once "Services/MediaObjects/classes/class.ilMediaItem.php";
     require_once "Services/COPage/classes/class.ilMediaAliasItem.php";
     for ($i = 0; $i < count($res->nodeset); $i++) {
         $media_object_node = $res->nodeset[$i]->parent_node();
         $page_content_node = $media_object_node->parent_node();
         $c_hier_id = $page_content_node->get_attribute("HierId");
         // first check, wheter we got instance map areas -> take these
         $std_alias_item = new ilMediaAliasItem($this->dom, $c_hier_id, "Standard");
         $areas = $std_alias_item->getMapAreas();
         $correction_needed = false;
         if (count($areas) > 0) {
             // check if correction needed
             foreach ($areas as $area) {
                 if ($area["Type"] == "PageObject" || $area["Type"] == "StructureObject") {
                     $t = $area["Target"];
                     $tid = _extractObjIdOfTarget($t);
                     if ($a_from_to[$tid] > 0) {
                         $correction_needed = true;
                     }
                 }
             }
         } else {
             $areas = array();
             // get object map areas and check whether at least one must
             // be corrected
             $oid = $res->nodeset[$i]->get_attribute("OriginId");
             if (substr($oid, 0, 4) == "il__") {
                 $id_arr = explode("_", $oid);
                 $id = $id_arr[count($id_arr) - 1];
                 $mob = new ilObjMediaObject($id);
                 $med_item = $mob->getMediaItem("Standard");
                 $med_areas = $med_item->getMapAreas();
                 foreach ($med_areas as $area) {
                     $link_type = $area->getLinkType() == "int" ? "IntLink" : "ExtLink";
                     $areas[] = array("Nr" => $area->getNr(), "Shape" => $area->getShape(), "Coords" => $area->getCoords(), "Link" => array("LinkType" => $link_type, "Href" => $area->getHref(), "Title" => $area->getTitle(), "Target" => $area->getTarget(), "Type" => $area->getType(), "TargetFrame" => $area->getTargetFrame()));
                     if ($area->getType() == "PageObject" || $area->getType() == "StructureObject") {
                         $t = $area->getTarget();
                         $tid = ilInternalLink::_extractObjIdOfTarget($t);
                         if ($a_from_to[$tid] > 0) {
                             $correction_needed = true;
                         }
                         //var_dump($a_from_to);
                     }
                 }
             }
         }
         // correct map area links
         if ($correction_needed) {
             $changed = true;
             $std_alias_item->deleteAllMapAreas();
             foreach ($areas as $area) {
                 if ($area["Link"]["LinkType"] == "IntLink") {
                     $target = $area["Link"]["Target"];
                     $type = $area["Link"]["Type"];
                     $obj_id = ilInternalLink::_extractObjIdOfTarget($target);
                     if ($a_from_to[$obj_id] > 0) {
                         if ($type == "PageObject" && ilLMObject::_lookupType($a_from_to[$obj_id]) == "pg") {
                             $area["Link"]["Target"] = "il__pg_" . $a_from_to[$obj_id];
                         }
                         if ($type == "StructureObject" && ilLMObject::_lookupType($a_from_to[$obj_id]) == "st") {
                             $area["Link"]["Target"] = "il__st_" . $a_from_to[$obj_id];
                         }
                     }
                 }
                 $std_alias_item->addMapArea($area["Shape"], $area["Coords"], $area["Link"]["Title"], array("Type" => $area["Link"]["Type"], "TargetFrame" => $area["Link"]["TargetFrame"], "Target" => $area["Link"]["Target"], "Href" => $area["Link"]["Href"], "LinkType" => $area["Link"]["LinkType"]));
             }
         }
     }
     unset($xpc);
     return $changed;
 }
Example #13
0
 /**
  * Set standard link xml
  */
 function setDefaultLinkXml()
 {
     global $ilCtrl;
     $int_links = $this->getPageObject()->getInternalLinks();
     //var_dump($int_links);
     $link_info = "<IntLinkInfos>";
     $targetframe = "None";
     foreach ($int_links as $int_link) {
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             $ltarget = "_top";
             if ($targetframe != "None") {
                 $ltarget = "_blank";
             }
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             $href = "";
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     if ($type == "PageObject") {
                         $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                     } else {
                         $href = "./goto.php?target=st_" . $target_id;
                     }
                     break;
                 case "GlossaryItem":
                     if ($targetframe == "None") {
                         $targetframe = "Glossary";
                     }
                     $href = "./goto.php?target=git_" . $target_id;
                     break;
                 case "MediaObject":
                     $ilCtrl->setParameter($this, "mob_id", $target_id);
                     //$ilCtrl->setParameter($this, "pg_id", $this->obj->getId());
                     $href = $ilCtrl->getLinkTarget($this, "displayMedia");
                     $ilCtrl->setParameter($this, "mob_id", "");
                     break;
                 case "WikiPage":
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $href = ilWikiPage::getGotoForWikiPageTarget($target_id);
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . $anc_par . " " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" />";
         }
     }
     $link_info .= "</IntLinkInfos>";
     $this->setLinkXML($link_info);
 }
 function isClickable($a_type, $a_node_id)
 {
     global $ilUser;
     $orig_node_id = $a_node_id;
     if ($a_type == "st") {
         if (!$this->offlineMode()) {
             $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
             $a_node_id = $a_node["child"];
             if ($a_node_id == 0) {
                 return false;
             }
         } else {
             // 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 "./Modules/LearningModule/classes/class.ilLMPage.php";
                 $active = ilLMPage::_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 ($a_node_id <= 0) {
                 return false;
             } else {
                 $path = $this->tree->getPathId($a_node_id);
                 if (!in_array($orig_node_id, $path)) {
                     return false;
                 }
             }
         }
     }
     if ($a_type == "pg") {
         // check public area mode
         include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
         include_once 'Services/Payment/classes/class.ilPaymentObject.php';
         if (($ilUser->getId() == ANONYMOUS_USER_ID || ilPaymentObject::_requiresPurchaseToAccess((int) $this->lm_obj->getRefId())) && !ilLMObject::_isPagePublic($a_node_id, true)) {
             return false;
         }
     }
     return true;
 }
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl, $ilAccess;
     $usage = $a_set;
     //var_dump($usage);
     if (is_int(strpos($usage["type"], ":"))) {
         $us_arr = explode(":", $usage["type"]);
         $usage["type"] = $us_arr[1];
         $cont_type = $us_arr[0];
     }
     //var_dump($usage);
     include_once './Services/Link/classes/class.ilLink.php';
     switch ($usage["type"]) {
         case "pg":
             include_once "./Services/COPage/classes/class.ilPageObjectFactory.php";
             $page_obj = ilPageObjectFactory::getInstance($cont_type, $usage["id"]);
             $item = array();
             //$this->tpl->setVariable("TXT_OBJECT", $usage["type"].":".$usage["id"]);
             switch ($cont_type) {
                 case "lm":
                     require_once "./Modules/LearningModule/classes/class.ilObjContentObject.php";
                     require_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
                     require_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                     $lm_obj = new ilObjLearningModule($page_obj->getParentId(), false);
                     $item["obj_type_txt"] = $this->lng->txt("obj_" . $cont_type);
                     $item["obj_title"] = $lm_obj->getTitle();
                     $item["sub_txt"] = $this->lng->txt("pg");
                     $item["sub_title"] = ilLMObject::_lookupTitle($page_obj->getId());
                     $ref_id = $this->getFirstWritableRefId($lm_obj->getId());
                     if ($ref_id > 0) {
                         $item["obj_link"] = ilLink::_getStaticLink($page_obj->getId() . "_" . $ref_id, "pg");
                     }
                     break;
                 case "wpg":
                     require_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $item["obj_type_txt"] = $this->lng->txt("obj_wiki");
                     $item["obj_title"] = ilObject::_lookupTitle($page_obj->getParentId());
                     $item["sub_txt"] = $this->lng->txt("pg");
                     $item["sub_title"] = ilWikiPage::lookupTitle($page_obj->getId());
                     $ref_id = $this->getFirstWritableRefId($page_obj->getParentId());
                     if ($ref_id > 0) {
                         $item["obj_link"] = ilLink::_getStaticLink($ref_id, "wiki");
                     }
                     break;
                 case "gdf":
                     require_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                     require_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
                     $term_id = ilGlossaryDefinition::_lookupTermId($page_obj->getId());
                     $glo_id = ilGlossaryTerm::_lookGlossaryId($term_id);
                     $item["obj_type_txt"] = $this->lng->txt("obj_glo");
                     $item["obj_title"] = ilObject::_lookupTitle($glo_id);
                     $item["sub_txt"] = $this->lng->txt("cont_term");
                     $item["sub_title"] = ilGlossaryTerm::_lookGlossaryTerm($term_id);
                     $ref_id = $this->getFirstWritableRefId($page_obj->getParentId());
                     if ($ref_id > 0) {
                         $item["obj_link"] = ilLink::_getStaticLink($ref_id, "glo");
                     }
                     break;
                 case "cont":
                     $item["obj_type_txt"] = $this->lng->txt("obj_" . $cont_type);
                     $item["obj_title"] = ilObject::_lookupTitle($page_obj->getId());
                     $ref_id = $this->getFirstWritableRefId($page_obj->getId());
                     if ($ref_id > 0) {
                         $item["obj_link"] = ilLink::_getStaticLink($ref_id, $cont_type);
                     }
                     break;
             }
             break;
         case "mep":
             $item["obj_type_txt"] = $this->lng->txt("obj_mep");
             $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
             $ref_id = $this->getFirstWritableRefId($usage["id"]);
             if ($ref_id > 0) {
                 $item["obj_link"] = ilLink::_getStaticLink($ref_id, "mep");
             }
             break;
         case "map":
             $item["obj_type_txt"] = $this->lng->txt("obj_mob");
             $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
             $item["sub_txt"] = $this->lng->txt("cont_link_area");
             break;
     }
     // show versions
     if (is_array($usage["hist_nr"]) && (count($usage["hist_nr"]) > 1 || $usage["hist_nr"][0] > 0)) {
         asort($usage["hist_nr"]);
         $ver = $sep = "";
         if ($usage["hist_nr"][0] == 0) {
             array_shift($usage["hist_nr"]);
             $usage["hist_nr"][] = 0;
         }
         if (count($usage["hist_nr"]) > 5) {
             $ver .= "..., ";
             $cnt = count($usage["hist_nr"]) - 5;
             for ($i = 0; $i < $cnt; $i++) {
                 unset($usage["hist_nr"][$i]);
             }
         }
         foreach ($usage["hist_nr"] as $nr) {
             if ($nr > 0) {
                 $ver .= $sep . $nr;
             } else {
                 $ver .= $sep . $this->lng->txt("cont_current_version");
             }
             $sep = ", ";
         }
         $this->tpl->setCurrentBlock("versions");
         $this->tpl->setVariable("TXT_VERSIONS", $this->lng->txt("cont_versions"));
         $this->tpl->setVariable("VAL_VERSIONS", $ver);
         $this->tpl->parseCurrentBlock();
     }
     if ($item["obj_type_txt"] != "") {
         $this->tpl->setCurrentBlock("type");
         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("type"));
         $this->tpl->setVariable("VAL_TYPE", $item["obj_type_txt"]);
         $this->tpl->parseCurrentBlock();
     }
     if ($usage["type"] != "clip") {
         if ($item["obj_link"]) {
             $this->tpl->setCurrentBlock("linked_item");
             $this->tpl->setVariable("TXT_OBJECT", $item["obj_title"]);
             $this->tpl->setVariable("HREF_LINK", $item["obj_link"]);
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $item["obj_title"]);
         }
         if ($item["sub_txt"] != "") {
             $this->tpl->setVariable("SEP", ", ");
             $this->tpl->setVariable("SUB_TXT", $item["sub_txt"]);
             if ($item["sub_title"] != "") {
                 $this->tpl->setVariable("SEP2", ": ");
                 $this->tpl->setVariable("SUB_TITLE", $item["sub_title"]);
             }
         }
     } else {
         $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $this->lng->txt("cont_users_have_mob_in_clip1") . " " . $usage["cnt"] . " " . $this->lng->txt("cont_users_have_mob_in_clip2"));
     }
 }
 function __showLearningMaterials()
 {
     global $rbacsystem, $ilias, $ilUser, $ilObjDataCache;
     include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
     include_once './Services/Repository/classes/class.ilRepositoryExplorer.php';
     include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
     if (!count($lms = ilCourseObjectiveMaterials::_getAllAssignedMaterials($this->course_obj->getId()))) {
         return false;
     }
     if ($this->details_id) {
         $objectives_lm_obj =& new ilCourseObjectiveMaterials($this->details_id);
     }
     $lm_continue =& new ilCourseLMHistory($this->course_obj->getRefId(), $ilUser->getId());
     $continue_data = $lm_continue->getLMHistory();
     $this->tpl->addBlockfile('LM_BLOCK', 'lm_block', 'tpl.crs_objectives_view_lm_table.html', 'Modules/Course');
     $this->tpl->setVariable("TBL_TITLE_LMS", $this->lng->txt('crs_learning_materials'));
     $this->__showHideLinks('lms');
     if (isset($_SESSION['crs_hide_lms'])) {
         return true;
     }
     $this->tpl->setVariable("TBL_HEADER_LMS_TYPE", $this->lng->txt('type'));
     $this->tpl->setVariable("TBL_HEADER_NAME_LMS", $this->lng->txt('description'));
     $counter = 1;
     foreach ($lms as $lm_id) {
         $obj_id = $ilObjDataCache->lookupObjId($lm_id);
         $obj_type = $ilObjDataCache->lookupType($obj_id);
         $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($lm_id, $obj_id);
         $obj_link = ilRepositoryExplorer::buildLinkTarget($lm_id, $ilObjDataCache->lookupType($obj_id));
         $obj_frame = ilRepositoryExplorer::buildFrameTarget($ilObjDataCache->lookupType($obj_id), $lm_id, $obj_id);
         $obj_frame = $obj_frame ? $obj_frame : '';
         $contentObj = false;
         if (ilRepositoryExplorer::isClickable($obj_type, $lm_id, $obj_id)) {
             $this->tpl->setCurrentBlock("lm_read");
             $this->tpl->setVariable("READ_TITLE_LMS", $ilObjDataCache->lookupTitle($obj_id));
             $this->tpl->setVariable("READ_TARGET_LMS", $obj_frame);
             $this->tpl->setVariable("READ_LINK_LMS", $obj_link);
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setCurrentBlock("lm_visible");
             $this->tpl->setVariable("VISIBLE_LINK_LMS", $ilObjDataCache->lookupTitle($obj_id));
             $this->tpl->parseCurrentBlock();
         }
         // add to desktop link
         if (!$ilUser->isDesktopItem($lm_id, $obj_type) and $this->course_obj->getAboStatus() == $this->course_obj->ABO_ENABLED) {
             if ($rbacsystem->checkAccess('read', $lm_id)) {
                 $this->tpl->setCurrentBlock("lm_desklink");
                 $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_ref_id', $lm_id);
                 $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_id', $lm_id);
                 $this->ctrl->setParameterByClass(get_class($this->container_gui), 'type', $obj_type);
                 $this->tpl->setVariable("DESK_LINK_LMS", $this->ctrl->getLinkTarget($this->container_gui, 'addToDesk'));
                 $this->tpl->setVariable("TXT_DESK_LMS", $this->lng->txt("to_desktop"));
                 $this->tpl->parseCurrentBlock();
             }
         }
         // CONTINUE LINK
         if (isset($continue_data[$lm_id])) {
             $this->tpl->setCurrentBlock("lm_continuelink");
             $this->tpl->setVariable("CONTINUE_LINK_LMS", 'ilias.php?baseClass=ilLMPresentationGUI&ref_id=' . $lm_id . '&obj_id=' . $continue_data[$lm_id]['lm_page_id']);
             $target = '';
             $this->tpl->setVariable("CONTINUE_LINK_TARGET", $obj_frame);
             $this->tpl->setVariable("TXT_CONTINUE_LMS", $this->lng->txt('continue_work'));
             $this->tpl->parseCurrentBlock();
         }
         // Description
         if (strlen($ilObjDataCache->lookupDescription($obj_id))) {
             $this->tpl->setCurrentBlock("lms_description");
             $this->tpl->setVariable("DESCRIPTION_LMS", $ilObjDataCache->lookupDescription($obj_id));
             $this->tpl->parseCurrentBlock();
         }
         // LAST ACCESS
         if (isset($continue_data["{$lm_id}"])) {
             $this->tpl->setVariable("TEXT_INFO_LMS", $this->lng->txt('last_access'));
             $this->tpl->setVariable('INFO_LMS', ilDatePresentation::formatDate(new ilDateTime($continue_data[$lm_id]['last_access'], IL_CAL_UNIX)));
         } elseif ($obj_type == 'lm') {
             $this->tpl->setVariable("INFO_LMS", $this->lng->txt('not_accessed'));
         }
         if ($this->details_id) {
             $objectives_lm_obj->setLMRefId($lm_id);
             if ($objectives_lm_obj->checkExists()) {
                 $objectives_lm_obj =& new ilCourseObjectiveMaterials($this->details_id);
                 if ($conditions_ok) {
                     foreach ($objectives_lm_obj->getChapters() as $lm_obj_data) {
                         if ($lm_obj_data['ref_id'] != $lm_id) {
                             continue;
                         }
                         include_once './Modules/LearningModule/classes/class.ilLMObject.php';
                         $this->tpl->setCurrentBlock("chapters");
                         if ($lm_obj_data['type'] == 'st') {
                             $this->tpl->setVariable("TXT_CHAPTER", $this->lng->txt('chapter'));
                         } else {
                             $this->tpl->setVariable("TXT_CHAPTER", $this->lng->txt('page'));
                         }
                         $this->tpl->setVariable("CHAPTER_LINK_LMS", "ilias.php?baseClass=ilLMPresentationGUI&ref_id=" . $lm_obj_data['ref_id'] . '&obj_id=' . $lm_obj_data['obj_id']);
                         $this->tpl->setVariable("CHAPTER_LINK_TARGET_LMS", $obj_frame);
                         $this->tpl->setVariable("CHAPTER_TITLE", ilLMObject::_lookupTitle($lm_obj_data['obj_id']));
                         $this->tpl->parseCurrentBlock();
                     }
                 }
                 $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS", 'option_value_center_details');
                 $this->tpl->setVariable("OBJ_CLASS_LMS", 'option_value_details');
             } else {
                 $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS", 'option_value_center');
                 $this->tpl->setVariable("OBJ_CLASS_LMS", 'option_value');
             }
         } else {
             $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS", 'option_value_center');
             $this->tpl->setVariable("OBJ_CLASS_LMS", 'option_value');
         }
         $this->tpl->setCurrentBlock("lm_row");
         $this->tpl->setVariable('IMG_TYPE_MAT', ilUtil::getImagePath('icon_' . $obj_type . '.png'));
         $this->tpl->setVariable('TXT_IMG_MAT', $this->lng->txt('obj_' . $obj_type));
         $this->tpl->setVariable("OBJ_NR_LMS", $counter . '.');
         $this->tpl->parseCurrentBlock();
         ++$counter;
     }
 }
 /**
  * static
  */
 function getPageList($lm_id)
 {
     return ilLMObject::getObjectList($lm_id, "pg");
 }
 /**
  * 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();
 }
 /**
  * show print view
  */
 function showPrintView()
 {
     global $ilUser, $lng, $ilCtrl;
     include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
     if (!$this->lm->isActivePrintView()) {
         return;
     }
     $this->renderPageTitle();
     $c_obj_id = $this->getCurrentPageId();
     // set values according to selection
     if ($_POST["sel_type"] == "page") {
         if (!is_array($_POST["obj_id"]) || !in_array($c_obj_id, $_POST["obj_id"])) {
             $_POST["obj_id"][] = $c_obj_id;
         }
     }
     if ($_POST["sel_type"] == "chapter" && $c_obj_id > 0) {
         $path = $this->lm_tree->getPathFull($c_obj_id);
         $chap_id = $path[1]["child"];
         if ($chap_id > 0) {
             $_POST["obj_id"][] = $chap_id;
         }
     }
     //var_dump($_GET);
     //var_dump($_POST);
     // set style sheets
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
     } else {
         $style_name = $ilUser->getPref("style") . ".css";
         $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
     }
     // content style
     $this->tpl->setCurrentBlock("ContentStyle");
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
     } else {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
     }
     $this->tpl->parseCurrentBlock();
     // syntax style
     $this->tpl->setCurrentBlock("SyntaxStyle");
     $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
     $this->tpl->parseCurrentBlock();
     //$this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_print_view.html", true);
     // set title header
     $this->tpl->setVariable("HEADER", $this->lm->getTitle());
     $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
     include_once "./Modules/LearningModule/classes/class.ilLMPageGUI.php";
     include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
     include_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
     $act_level = 99999;
     $activated = false;
     $glossary_links = array();
     $output_header = false;
     $media_links = array();
     // get header and footer
     if ($this->lm->getFooterPage() > 0 && !$this->lm->getHideHeaderFooterPrint()) {
         if (ilLMObject::_exists($this->lm->getFooterPage())) {
             $page_object_gui = $this->getLMPageGUI($this->lm->getFooterPage());
             include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
             $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId($this->lm->getStyleSheetId(), "lm"));
             // determine target frames for internal links
             $page_object_gui->setLinkFrame($_GET["frame"]);
             $page_object_gui->setOutputMode("print");
             $page_object_gui->setPresentationTitle("");
             $page_object_gui->setFileDownloadLink("#");
             $page_object_gui->setFullscreenLink("#");
             $page_object_gui->setSourceCodeDownloadScript("#");
             $footer_page_content = $page_object_gui->showPage();
         }
     }
     if ($this->lm->getHeaderPage() > 0 && !$this->lm->getHideHeaderFooterPrint()) {
         if (ilLMObject::_exists($this->lm->getHeaderPage())) {
             $page_object_gui = $this->getLMPageGUI($this->lm->getHeaderPage());
             include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
             $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId($this->lm->getStyleSheetId(), "lm"));
             // determine target frames for internal links
             $page_object_gui->setLinkFrame($_GET["frame"]);
             $page_object_gui->setOutputMode("print");
             $page_object_gui->setPresentationTitle("");
             $page_object_gui->setFileDownloadLink("#");
             $page_object_gui->setFullscreenLink("#");
             $page_object_gui->setSourceCodeDownloadScript("#");
             $header_page_content = $page_object_gui->showPage();
         }
     }
     // add free selected pages
     if (is_array($_POST["obj_id"])) {
         foreach ($_POST["obj_id"] as $k) {
             if ($k > 0 && !$this->lm_tree->isInTree($k)) {
                 if (ilLMObject::_lookupType($k) == "pg") {
                     $nodes[] = array("obj_id" => $k, "type" => "pg", "free" => true);
                 }
             }
         }
     } else {
         ilUtil::sendFailure($lng->txt("cont_print_no_page_selected"), true);
         $ilCtrl->redirect($this, "showPrintViewSelection");
     }
     foreach ($nodes as $node_key => $node) {
         // check page activation
         $active = ilLMPage::_lookupActive($node["obj_id"], $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
         if ($node["type"] == "pg" && !$active) {
             continue;
         }
         // print all subchapters/subpages if higher chapter
         // has been selected
         if ($node["depth"] <= $act_level) {
             if (is_array($_POST["obj_id"]) && in_array($node["obj_id"], $_POST["obj_id"])) {
                 $act_level = $node["depth"];
                 $activated = true;
             } else {
                 $act_level = 99999;
                 $activated = false;
             }
         }
         if ($activated && ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $node["obj_id"])) {
             // output learning module header
             if ($node["type"] == "du") {
                 $output_header = true;
             }
             // output chapter title
             if ($node["type"] == "st") {
                 if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && $this->lm_gui->object->getPublicAccessMode() == "selected") {
                     if (!ilLMObject::_isPagePublic($node["obj_id"])) {
                         continue;
                     }
                 }
                 $chap = new ilStructureObject($this->lm, $node["obj_id"]);
                 $this->tpl->setCurrentBlock("print_chapter");
                 $chapter_title = $chap->_getPresentationTitle($node["obj_id"], $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), 0, $this->lang);
                 $this->tpl->setVariable("CHAP_TITLE", $chapter_title);
                 if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE) {
                     if ($nodes[$node_key + 1]["type"] == "pg") {
                         $this->tpl->setVariable("CHAP_HEADER", $header_page_content);
                         $did_chap_page_header = true;
                     }
                 }
                 $this->tpl->parseCurrentBlock();
                 $this->tpl->setCurrentBlock("print_block");
                 $this->tpl->parseCurrentBlock();
             }
             // output page
             if ($node["type"] == "pg") {
                 if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && $this->lm_gui->object->getPublicAccessMode() == "selected") {
                     if (!ilLMObject::_isPagePublic($node["obj_id"])) {
                         continue;
                     }
                 }
                 $this->tpl->setCurrentBlock("print_item");
                 // get page
                 $page_id = $node["obj_id"];
                 $page_object_gui = $this->getLMPageGUI($page_id);
                 $page_object = $page_object_gui->getPageObject();
                 include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
                 $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId($this->lm->getStyleSheetId(), "lm"));
                 // get lm page
                 $lm_pg_obj = new ilLMPageObject($this->lm, $page_id);
                 $lm_pg_obj->setLMId($this->lm->getId());
                 // determine target frames for internal links
                 $page_object_gui->setLinkFrame($_GET["frame"]);
                 $page_object_gui->setOutputMode("print");
                 $page_object_gui->setPresentationTitle("");
                 if ($this->lm->getPageHeader() == IL_PAGE_TITLE || $node["free"] === true) {
                     $page_title = ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(), $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lang);
                     // prevent page title after chapter title
                     // that have the same content
                     if ($this->lm->isActiveNumbering()) {
                         $chapter_title = trim(substr($chapter_title, strpos($chapter_title, " ")));
                     }
                     if ($page_title != $chapter_title) {
                         $page_object_gui->setPresentationTitle($page_title);
                     }
                 }
                 // handle header / footer
                 $hcont = $header_page_content;
                 $fcont = $footer_page_content;
                 if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE) {
                     if ($did_chap_page_header) {
                         $hcont = "";
                     }
                     if ($nodes[$node_key + 1]["type"] == "pg" && !($nodes[$node_key + 1]["depth"] <= $act_level && !in_array($nodes[$node_key + 1]["obj_id"], $_POST["obj_id"]))) {
                         $fcont = "";
                     }
                 }
                 $page_object_gui->setFileDownloadLink("#");
                 $page_object_gui->setFullscreenLink("#");
                 $page_object_gui->setSourceCodeDownloadScript("#");
                 $page_content = $page_object_gui->showPage();
                 if ($this->lm->getPageHeader() != IL_PAGE_TITLE) {
                     $this->tpl->setVariable("CONTENT", $hcont . $page_content . $fcont);
                 } else {
                     $this->tpl->setVariable("CONTENT", $hcont . $page_content . $fcont . "<br />");
                 }
                 $chapter_title = "";
                 $this->tpl->parseCurrentBlock();
                 $this->tpl->setCurrentBlock("print_block");
                 $this->tpl->parseCurrentBlock();
                 // get internal links
                 $int_links = ilInternalLink::_getTargetsOfSource($this->lm->getType() . ":pg", $node["obj_id"]);
                 $got_mobs = false;
                 foreach ($int_links as $key => $link) {
                     if ($link["type"] == "git" && ($link["inst"] == IL_INST_ID || $link["inst"] == 0)) {
                         $glossary_links[$key] = $link;
                     }
                     if ($link["type"] == "mob" && ($link["inst"] == IL_INST_ID || $link["inst"] == 0)) {
                         $got_mobs = true;
                         $mob_links[$key] = $link;
                     }
                 }
                 // this is not cool because of performance reasons
                 // unfortunately the int link table does not
                 // store the target frame (we want to append all linked
                 // images but not inline images (i.e. mobs with no target
                 // frame))
                 if ($got_mobs) {
                     $page_object->buildDom();
                     $links = $page_object->getInternalLinks();
                     foreach ($links as $link) {
                         if ($link["Type"] == "MediaObject" && $link["TargetFrame"] != "" && $link["TargetFrame"] != "None") {
                             $media_links[] = $link;
                         }
                     }
                 }
             }
         }
     }
     $annex_cnt = 0;
     $annexes = array();
     // glossary
     if (count($glossary_links) > 0 && !$this->lm->isActivePreventGlossaryAppendix()) {
         include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
         include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
         // sort terms
         $terms = array();
         foreach ($glossary_links as $key => $link) {
             $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]);
             $terms[$term . ":" . $key] = array("key" => $key, "link" => $link, "term" => $term);
         }
         $terms = ilUtil::sortArray($terms, "term", "asc");
         //ksort($terms);
         foreach ($terms as $t) {
             $link = $t["link"];
             $key = $t["key"];
             $defs = ilGlossaryDefinition::getDefinitionList($link["id"]);
             $def_cnt = 1;
             // output all definitions of term
             foreach ($defs as $def) {
                 // definition + number, if more than 1 definition
                 if (count($defs) > 1) {
                     $this->tpl->setCurrentBlock("def_title");
                     $this->tpl->setVariable("TXT_DEFINITION", $this->lng->txt("cont_definition") . " " . $def_cnt++);
                     $this->tpl->parseCurrentBlock();
                 }
                 include_once "./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php";
                 $page_gui = new ilGlossaryDefPageGUI($def["id"]);
                 $page_gui->setTemplateOutput(false);
                 $page_gui->setOutputMode("print");
                 $this->tpl->setCurrentBlock("definition");
                 $page_gui->setFileDownloadLink("#");
                 $page_gui->setFullscreenLink("#");
                 $page_gui->setSourceCodeDownloadScript("#");
                 $output = $page_gui->showPage();
                 $this->tpl->setVariable("VAL_DEFINITION", $output);
                 $this->tpl->parseCurrentBlock();
             }
             // output term
             $this->tpl->setCurrentBlock("term");
             $this->tpl->setVariable("VAL_TERM", $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]));
             $this->tpl->parseCurrentBlock();
         }
         // output glossary header
         $annex_cnt++;
         $this->tpl->setCurrentBlock("glossary");
         $annex_title = $this->lng->txt("cont_annex") . " " . chr(64 + $annex_cnt) . ": " . $this->lng->txt("glo");
         $this->tpl->setVariable("TXT_GLOSSARY", $annex_title);
         $this->tpl->parseCurrentBlock();
         $annexes[] = $annex_title;
     }
     // referenced images
     if (count($media_links) > 0) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/MediaObjects/classes/class.ilMediaItem.php";
         foreach ($media_links as $media) {
             if (substr($media["Target"], 0, 4) == "il__") {
                 $arr = explode("_", $media["Target"]);
                 $id = $arr[count($arr) - 1];
                 $med_obj = new ilObjMediaObject($id);
                 $med_item = $med_obj->getMediaItem("Standard");
                 if (is_object($med_item)) {
                     if (is_int(strpos($med_item->getFormat(), "image"))) {
                         $this->tpl->setCurrentBlock("ref_image");
                         // image source
                         if ($med_item->getLocationType() == "LocalFile") {
                             $this->tpl->setVariable("IMG_SOURCE", ilUtil::getWebspaceDir("output") . "/mobs/mm_" . $id . "/" . $med_item->getLocation());
                         } else {
                             $this->tpl->setVariable("IMG_SOURCE", $med_item->getLocation());
                         }
                         if ($med_item->getCaption() != "") {
                             $this->tpl->setVariable("IMG_TITLE", $med_item->getCaption());
                         } else {
                             $this->tpl->setVariable("IMG_TITLE", $med_obj->getTitle());
                         }
                         $this->tpl->parseCurrentBlock();
                     }
                 }
             }
         }
         // output glossary header
         $annex_cnt++;
         $this->tpl->setCurrentBlock("ref_images");
         $annex_title = $this->lng->txt("cont_annex") . " " . chr(64 + $annex_cnt) . ": " . $this->lng->txt("cont_ref_images");
         $this->tpl->setVariable("TXT_REF_IMAGES", $annex_title);
         $this->tpl->parseCurrentBlock();
         $annexes[] = $annex_title;
     }
     // output learning module title and toc
     if ($output_header) {
         $this->tpl->setCurrentBlock("print_header");
         $this->tpl->setVariable("LM_TITLE", $this->lm->getTitle());
         if ($this->lm->getDescription() != "none") {
             include_once "Services/MetaData/classes/class.ilMD.php";
             $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
             $md_gen = $md->getGeneral();
             foreach ($md_gen->getDescriptionIds() as $id) {
                 $md_des = $md_gen->getDescription($id);
                 $description = $md_des->getDescription();
             }
             $this->tpl->setVariable("LM_DESCRIPTION", $description);
         }
         $this->tpl->parseCurrentBlock();
         // output toc
         $nodes2 = $nodes;
         foreach ($nodes2 as $node2) {
             if ($node2["type"] == "st" && ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $node2["obj_id"])) {
                 for ($j = 1; $j < $node2["depth"]; $j++) {
                     $this->tpl->setCurrentBlock("indent");
                     $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.png"));
                     $this->tpl->parseCurrentBlock();
                 }
                 $this->tpl->setCurrentBlock("toc_entry");
                 $this->tpl->setVariable("TXT_TOC_TITLE", ilStructureObject::_getPresentationTitle($node2["obj_id"], $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), 0, $this->lang));
                 $this->tpl->parseCurrentBlock();
             }
         }
         // annexes
         foreach ($annexes as $annex) {
             $this->tpl->setCurrentBlock("indent");
             $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.png"));
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("toc_entry");
             $this->tpl->setVariable("TXT_TOC_TITLE", $annex);
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock("toc");
         $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("print_start_block");
         $this->tpl->parseCurrentBlock();
     }
     // output author information
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
     if (is_object($lifecycle = $md->getLifecycle())) {
         $sep = $author = "";
         foreach ($ids = $lifecycle->getContributeIds() as $con_id) {
             $md_con = $lifecycle->getContribute($con_id);
             if ($md_con->getRole() == "Author") {
                 foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
                     $md_ent = $md_con->getEntity($ent_id);
                     $author = $author . $sep . $md_ent->getEntity();
                     $sep = ", ";
                 }
             }
         }
         if ($author != "") {
             $this->lng->loadLanguageModule("meta");
             $this->tpl->setCurrentBlock("author");
             $this->tpl->setVariable("TXT_AUTHOR", $this->lng->txt("meta_author"));
             $this->tpl->setVariable("LM_AUTHOR", $author);
             $this->tpl->parseCurrentBlock();
         }
     }
     // output copyright information
     if (is_object($md_rights = $md->getRights())) {
         $copyright = $md_rights->getDescription();
         include_once 'Services/MetaData/classes/class.ilMDUtils.php';
         $copyright = ilMDUtils::_parseCopyright($copyright);
         if ($copyright != "") {
             $this->lng->loadLanguageModule("meta");
             $this->tpl->setCurrentBlock("copyright");
             $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
             $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
             $this->tpl->parseCurrentBlock();
         }
     }
     $this->tpl->show(false);
 }
 /**
  * presentation title doesn't have to be page title, it may be
  * chapter title + page title or chapter title only, depending on settings
  *
  * @param	string	$a_mode		IL_CHAPTER_TITLE | IL_PAGE_TITLE | IL_NO_HEADER
  */
 function _getPresentationTitle($a_pg_id, $a_mode = IL_CHAPTER_TITLE, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_force_content = false, $a_lm_id = 0, $a_lang = "-")
 {
     global $ilDB, $ilUser;
     if ($a_lm_id == 0) {
         $a_lm_id = ilLMObject::_lookupContObjID($a_pg_id);
     }
     // @todo: optimize
     include_once "./Services/COPage/classes/class.ilPageMultiLang.php";
     $ml = new ilPageMultiLang("lm", $a_lm_id);
     // select
     $query = "SELECT * FROM lm_data WHERE obj_id = " . $ilDB->quote($a_pg_id, "integer");
     $pg_set = $ilDB->query($query);
     $pg_rec = $ilDB->fetchAssoc($pg_set);
     if ($a_lang != "-" && $ml->getActivated() && in_array($a_lang, $ml->getLanguages())) {
         include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
         $lmobjtrans = new ilLMObjTranslation($a_pg_id, $a_lang);
         if ($lmobjtrans->getTitle() != "") {
             $pg_rec["title"] = $lmobjtrans->getTitle();
         }
     }
     if ($a_mode == IL_NO_HEADER && !$a_force_content) {
         return "";
     }
     $tree = new ilTree($pg_rec["lm_id"]);
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     if ($a_mode == IL_PAGE_TITLE) {
         $nr = "";
         return $nr . $pg_rec["title"];
     }
     if ($tree->isInTree($pg_rec["obj_id"])) {
         $pred_node = $tree->fetchPredecessorNode($pg_rec["obj_id"], "st");
         $childs = $tree->getChildsByType($pred_node["obj_id"], "pg");
         $cnt_str = "";
         if (count($childs) > 1) {
             $cnt = 0;
             foreach ($childs as $child) {
                 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
                 $active = ilLMPage::_lookupActive($child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]), $a_time_scheduled_activation);
                 if (!$active) {
                     $act_data = ilLMPage::_lookupActivationData((int) $child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]));
                     if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                         $active = true;
                     }
                 }
                 if ($child["type"] != "pg" || $active) {
                     $cnt++;
                 }
                 if ($child["obj_id"] == $pg_rec["obj_id"]) {
                     $cur_cnt = $cnt;
                 }
             }
             if ($cnt > 1) {
                 $cnt_str = " (" . $cur_cnt . "/" . $cnt . ")";
             }
         }
         require_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
         //$struct_obj =& new ilStructureObject($pred_node["obj_id"]);
         //return $struct_obj->getTitle();
         return ilStructureObject::_getPresentationTitle($pred_node["obj_id"], $a_include_numbers) . $cnt_str;
         //return $pred_node["title"].$cnt_str;
     } else {
         return $pg_rec["title"];
     }
 }
 /**
  * get link targets
  */
 function getLinkXML($a_int_links)
 {
     if ($a_layoutframes == "") {
         $a_layoutframes = array();
     }
     $link_info = "<IntLinkInfos>";
     foreach ($a_int_links as $int_link) {
         //echo "<br>+".$int_link["Type"]."+".$int_link["TargetFrame"]."+".$int_link["Target"]."+";
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             if ($targetframe == "New") {
                 $ltarget = "_blank";
             } else {
                 $ltarget = "";
             }
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     $cont_obj =& $this->content_object;
                     if ($type == "PageObject") {
                         $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                     } else {
                         $href = "./goto.php?target=st_" . $target_id;
                     }
                     //$ltarget = "ilContObj".$lm_id;
                     break;
                 case "GlossaryItem":
                     if (ilGlossaryTerm::_lookGlossaryID($target_id) == $this->glossary->getId()) {
                         if ($this->offlineMode()) {
                             $href = "term_" . $target_id . ".html";
                         } else {
                             $this->ctrl->setParameter($this, "term_id", $target_id);
                             $href = $this->ctrl->getLinkTarget($this, "listDefinitions");
                             $href = str_replace("&", "&amp;", $href);
                         }
                     } else {
                         $href = "./goto.php?target=git_" . $target_id;
                     }
                     break;
                 case "MediaObject":
                     if ($this->offlineMode()) {
                         $href = "media_" . $target_id . ".html";
                     } else {
                         $this->ctrl->setParameter($this, "obj_type", $type);
                         $this->ctrl->setParameter($this, "mob_id", $target_id);
                         $href = $this->ctrl->getLinkTarget($this, "media");
                         $href = str_replace("&", "&amp;", $href);
                     }
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
                     $ltarget = $t_frame;
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" {$anc_par}/>";
             $this->ctrl->clearParameters($this);
         }
     }
     $link_info .= "</IntLinkInfos>";
     return $link_info;
 }
 /**
  * get node content
  *
  * @param mixed $a_node
  * @return string note name
  */
 public function getNodeContent($a_node)
 {
     $lang = $_GET["transl"] != "" ? $_GET["transl"] : "-";
     return ilLMObject::_getPresentationTitle($a_node, IL_PAGE_TITLE, $this->lm->isActiveNumbering(), false, false, $this->lm->getId(), $lang);
 }
 /**
  * check whether goto script will succeed
  */
 function _checkGoto($a_target)
 {
     global $ilAccess;
     $t_arr = explode("_", $a_target);
     if ($t_arr[0] != "lm" && $t_arr[0] != "dbk" && $t_arr[0] != "st" && $t_arr[0] != "pg" || (int) $t_arr[1] <= 0) {
         return false;
     }
     if ($t_arr[0] == "lm" || $t_arr[0] == "dbk") {
         if ($ilAccess->checkAccess("read", "", $t_arr[1]) || $ilAccess->checkAccess("visible", "", $t_arr[1])) {
             return true;
         }
     } else {
         if ($t_arr[2] > 0) {
             $ref_ids = array($t_arr[2]);
         } else {
             // determine learning object
             include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
             $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
             $ref_ids = ilObject::_getAllReferences($lm_id);
         }
         // check read permissions
         foreach ($ref_ids as $ref_id) {
             // Permission check
             if ($ilAccess->checkAccess("read", "", $ref_id)) {
                 return true;
             }
         }
     }
     return false;
 }
 /**
  * get presentation title
  *
  */
 function _getPresentationTitle($a_st_id, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_lm_id = 0, $a_lang = "-")
 {
     global $ilDB;
     if ($a_lm_id == 0) {
         $a_lm_id = ilLMObject::_lookupContObjID($a_st_id);
     }
     // @todo: optimize
     include_once "./Services/COPage/classes/class.ilPageMultiLang.php";
     $ml = new ilPageMultiLang("lm", $a_lm_id);
     // get chapter data
     $query = "SELECT * FROM lm_data WHERE obj_id = " . $ilDB->quote($a_st_id, "integer");
     $st_set = $ilDB->query($query);
     $st_rec = $ilDB->fetchAssoc($st_set);
     if ($a_lang != "-" && $ml->getActivated() && in_array($a_lang, $ml->getLanguages())) {
         include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
         $lmobjtrans = new ilLMObjTranslation($a_st_id, $a_lang);
         if ($lmobjtrans->getTitle() != "") {
             $st_rec["title"] = $lmobjtrans->getTitle();
         }
     }
     $tree = new ilTree($st_rec["lm_id"]);
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     if ($a_include_numbers) {
         if ($tree->isInTree($st_rec["obj_id"])) {
             // get chapter tree node
             $query = "SELECT * FROM lm_tree WHERE child = " . $ilDB->quote($a_st_id, "integer") . " AND lm_id = " . $ilDB->quote($st_rec["lm_id"], "integer");
             $tree_set = $ilDB->query($query);
             $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
             $depth = $tree_node["depth"];
             $nr = $tree->getChildSequenceNumber($tree_node, "st") . " ";
             for ($i = $depth - 1; $i > 1; $i--) {
                 // get next parent tree node
                 $query = "SELECT * FROM lm_tree WHERE child = " . $ilDB->quote($tree_node["parent"], "integer") . " AND lm_id = " . $ilDB->quote($st_rec["lm_id"], "integer");
                 $tree_set = $ilDB->query($query);
                 $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
                 $seq = $tree->getChildSequenceNumber($tree_node, "st");
                 $nr = $seq . "." . $nr;
             }
         }
     }
     return $nr . $st_rec["title"];
 }
 /**
  * Save export IDs
  */
 function saveExportIds()
 {
     global $ilCtrl, $lng;
     // check all export ids
     $ok = true;
     if (is_array($_POST["exportid"])) {
         foreach ($_POST["exportid"] as $pg_id => $exp_id) {
             if ($exp_id != "" && !preg_match("/^([a-zA-Z]+)[0-9a-zA-Z_]*\$/", trim($exp_id))) {
                 $ok = false;
             }
         }
     }
     if (!$ok) {
         ilUtil::sendFailure($lng->txt("cont_exp_ids_not_resp_format1") . ": a-z, A-Z, 0-9, '_'. " . $lng->txt("cont_exp_ids_not_resp_format3") . " " . $lng->txt("cont_exp_ids_not_resp_format2"));
         $this->showExportIDsOverview(true);
         return;
     }
     if (is_array($_POST["exportid"])) {
         foreach ($_POST["exportid"] as $pg_id => $exp_id) {
             ilLMPageObject::saveExportId($this->object->getId(), $pg_id, ilUtil::stripSlashes($exp_id), ilLMObject::_lookupType($pg_id));
         }
     }
     ilUtil::sendSuccess($lng->txt("cont_saved_export_ids"), true);
     $ilCtrl->redirect($this, "showExportIdsOverview");
 }
Example #26
0
 /**
  * Check if internal link refers to a valid target
  *
  * @param	string		$a_type			target type ("PageObject" | "StructureObject" |
  *										"GlossaryItem" | "MediaObject")
  * @param	string		$a_target		target id, e.g. "il__pg_244")
  *
  * @return	boolean		true/false
  */
 function _exists($a_type, $a_target)
 {
     global $tree;
     switch ($a_type) {
         case "PageObject":
         case "StructureObject":
             return ilLMObject::_exists($a_target);
             break;
         case "GlossaryItem":
             return ilGlossaryTerm::_exists($a_target);
             break;
         case "MediaObject":
             return ilObjMediaObject::_exists($a_target);
             break;
         case "WikiPage":
             include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
             return ilWikiPage::_exists("wiki", (int) $a_target);
             break;
         case "RepositoryItem":
             if (is_int(strpos($a_target, "_"))) {
                 $ref_id = ilInternalLink::_extractObjIdOfTarget($a_target);
                 return $tree->isInTree($ref_id);
             }
             break;
     }
     return false;
 }
 /**
  * fill row
  *
  * @access protected
  * @param array row data
  * @return
  */
 protected function fillRow($a_set)
 {
     $this->tpl->setVariable('VAL_ID', $a_set['id']);
     $this->tpl->setVariable('VAL_POSITION', $a_set['position']);
     $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
     if (strlen($a_set['description'])) {
         $this->tpl->setVariable('VAL_DESC', $a_set['description']);
     }
     // materials
     foreach ($a_set['materials'] as $ref_id => $data) {
         if ($data['items']) {
             $this->tpl->touchBlock('ul_begin');
             foreach ($data['items'] as $pg_st) {
                 $this->tpl->setCurrentBlock('st_pg');
                 $this->tpl->setVariable('MAT_IMG', ilUtil::getImagePath('icon_' . $pg_st['type'] . '_s.png'));
                 $this->tpl->setVariable('MAT_ALT', $this->lng->txt('obj_' . $pg_st['type']));
                 include_once 'Modules/LearningModule/classes/class.ilLMObject.php';
                 $title = ilLMObject::_lookupTitle($pg_st['obj_id']);
                 $this->tpl->setVariable('MAT_TITLE', $title);
                 $this->tpl->parseCurrentBlock();
             }
             $this->tpl->touchBlock('ul_end');
         } else {
             $this->tpl->touchBlock('new_line');
         }
         $this->tpl->setCurrentBlock('mat_row');
         $this->tpl->setVariable('LM_IMG', ilUtil::getImagePath('icon_' . $data['type'] . '_s.png'));
         $this->tpl->setVariable('LM_ALT', $this->lng->txt('obj_' . $data['type']));
         $this->tpl->setVariable('LM_TITLE', ilObject::_lookupTitle($data['obj_id']));
         $this->tpl->parseCurrentBlock();
     }
     // self assessment
     foreach ($a_set['self'] as $test) {
         foreach ($test['questions'] as $question) {
             $this->tpl->setCurrentBlock('self_qst_row');
             $this->tpl->setVariable('SELF_QST_TITLE', $question['title']);
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('self_test_row');
         $this->tpl->setVariable('SELF_TST_IMG', ilUtil::getImagePath('icon_tst_s.png'));
         $this->tpl->setVariable('SELF_TST_ALT', $this->lng->txt('obj_tst'));
         $this->tpl->setVariable('SELF_TST_TITLE', ilObject::_lookupTitle($test['obj_id']));
         $this->tpl->parseCurrentBlock();
     }
     // final test questions
     foreach ($a_set['final'] as $test) {
         foreach ($test['questions'] as $question) {
             $this->tpl->setCurrentBlock('final_qst_row');
             $this->tpl->setVariable('FINAL_QST_TITLE', $question['title']);
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('final_test_row');
         $this->tpl->setVariable('FINAL_TST_IMG', ilUtil::getImagePath('icon_tst_s.png'));
         $this->tpl->setVariable('FINAL_TST_ALT', $this->lng->txt('obj_tst'));
         $this->tpl->setVariable('FINAL_TST_TITLE', ilObject::_lookupTitle($test['obj_id']));
         $this->tpl->parseCurrentBlock();
     }
     // Edit Link
     $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'objective_id', $a_set['id']);
     $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'edit'));
     $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
 }
Example #28
0
 function _checkGoto($a_target)
 {
     global $objDefinition, $ilPluginAdmin, $ilUser;
     if (is_object($ilPluginAdmin)) {
         // get user interface plugins
         $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
         // search
         foreach ($pl_names as $pl) {
             $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
             $gui_class = $ui_plugin->getUIClassInstance();
             $resp = $gui_class->checkGotoHook($a_target);
             if ($resp["target"] !== false) {
                 $a_target = $resp["target"];
                 break;
             }
         }
     }
     if ($a_target == "") {
         return false;
     }
     $t_arr = explode("_", $a_target);
     $type = $t_arr[0];
     if ($type == "git") {
         $type = "glo";
     }
     if ($type == "pg" | $type == "st") {
         $type = "lm";
     }
     $class = $objDefinition->getClassName($type);
     if ($class == "") {
         return false;
     }
     $location = $objDefinition->getLocation($type);
     $full_class = "ilObj" . $class . "Access";
     include_once $location . "/class." . $full_class . ".php";
     $ret = call_user_func(array($full_class, "_checkGoto"), $a_target);
     // if no access and repository object => check for parent course/group
     if (!$ret && !stristr($a_target, "_wsp") && $ilUser->getId() != ANONYMOUS_USER_ID && !$objDefinition->isAdministrationObject($type) && $objDefinition->isRBACObject($type) && $t_arr[1]) {
         global $tree, $rbacsystem, $ilAccess;
         // original type "pg" => pg_<page_id>[_<ref_id>]
         if ($t_arr[0] == "pg") {
             if (isset($t_arr[2])) {
                 $ref_id = $t_arr[2];
             } else {
                 $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
                 $ref_id = ilObject::_getAllReferences($lm_id);
                 if ($ref_id) {
                     $ref_id = array_shift($ref_id);
                 }
             }
         } else {
             $ref_id = $t_arr[1];
         }
         include_once "Services/Membership/classes/class.ilParticipants.php";
         $block_obj = array();
         // walk path to find parent container
         $path = $tree->getPathId($ref_id);
         array_pop($path);
         foreach ($path as $path_ref_id) {
             $redirect_infopage = false;
             $add_member_role = false;
             $ptype = ilObject::_lookupType($path_ref_id, true);
             $pobj_id = ilObject::_lookupObjId($path_ref_id);
             // core checks: timings/object-specific
             if (!$ilAccess->doActivationCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype) || !$ilAccess->doStatusCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype)) {
                 // object in path is inaccessible - aborting
                 return false;
             } else {
                 if ($ptype == "crs") {
                     // check if already participant
                     include_once "Modules/Course/classes/class.ilCourseParticipant.php";
                     $participants = new ilCourseParticipant($pobj_id, $ilUser->getId());
                     if (!$participants->isAssigned()) {
                         // subscription currently possible?
                         include_once "Modules/Course/classes/class.ilObjCourse.php";
                         if (ilObjCourse::_isActivated($pobj_id) && ilObjCourse::_registrationEnabled($pobj_id)) {
                             $block_obj[] = $path_ref_id;
                             $add_member_role = true;
                         } else {
                             $redirect_infopage = true;
                         }
                     }
                 } else {
                     if ($ptype == "grp") {
                         // check if already participant
                         include_once "Modules/Group/classes/class.ilGroupParticipants.php";
                         if (!ilGroupParticipants::_isParticipant($path_ref_id, $ilUser->getId())) {
                             // subscription currently possible?
                             include_once "Modules/Group/classes/class.ilObjGroup.php";
                             $group_obj = new ilObjGroup($path_ref_id);
                             if ($group_obj->isRegistrationEnabled()) {
                                 $block_obj[] = $path_ref_id;
                                 $add_member_role = true;
                             } else {
                                 $redirect_infopage = true;
                             }
                         }
                     }
                 }
             }
             // add members roles for all "blocking" objects
             if ($add_member_role) {
                 // cannot join? goto will never work, so redirect to current object
                 $rbacsystem->resetPACache($ilUser->getId(), $path_ref_id);
                 if (!$rbacsystem->checkAccess("join", $path_ref_id)) {
                     $redirect_infopage = true;
                 } else {
                     $rbacsystem->addTemporaryRole($ilUser->getId(), ilParticipants::getDefaultMemberRole($path_ref_id));
                 }
             }
             // redirect to infopage of 1st blocking object in path
             if ($redirect_infopage) {
                 if ($rbacsystem->checkAccess("visible", $path_ref_id)) {
                     ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI" . "&ref_id=" . $path_ref_id . "&cmd=infoScreen");
                 } else {
                     return false;
                 }
             }
         }
         // check if access will be possible with all (possible) member roles added
         $rbacsystem->resetPACache($ilUser->getId(), $ref_id);
         if ($rbacsystem->checkAccess("read", $ref_id) && sizeof($block_obj)) {
             // this won't work with lm-pages (see above)
             // include_once "Services/Link/classes/class.ilLink.php";
             // $_SESSION["pending_goto"] = ilLink::_getStaticLink($ref_id, $type);
             // keep original target
             $_SESSION["pending_goto"] = "goto.php?target=" . $a_target;
             // redirect to 1st non-member object in path
             ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI" . "&ref_id=" . array_shift($block_obj));
         }
     }
     return $ret;
 }
Example #29
0
 /**
  * Get duplicate export IDs (count export ID usages)
  */
 public static function getDuplicateExportIDs($a_lm_id, $a_type = "pg")
 {
     include_once "./Services/MetaData/classes/class.ilMDIdentifier.php";
     $entries = ilMDIdentifier::_getEntriesForRbacObj($a_lm_id, $a_type);
     $res = array();
     foreach ($entries as $e) {
         if ($e["catalog"] == "ILIAS_NID") {
             if (ilLMObject::_exists($e["obj_id"])) {
                 $res[trim($e["entry"])]++;
             }
         }
     }
     return $res;
 }
Example #30
0
 /**
  * presentation title doesn't have to be page title, it may be
  * chapter title + page title or chapter title only, depending on settings
  *
  * @param	string	$a_mode		IL_CHAPTER_TITLE | IL_PAGE_TITLE | IL_NO_HEADER
  */
 static function _getPresentationTitle($a_pg_id, $a_mode = IL_CHAPTER_TITLE, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_force_content = false, $a_lm_id = 0, $a_lang = "-")
 {
     if ($a_mode == IL_NO_HEADER && !$a_force_content) {
         return "";
     }
     if ($a_lm_id == 0) {
         $a_lm_id = ilLMObject::_lookupContObjID($a_pg_id);
     }
     if ($a_lm_id == 0) {
         return "";
     }
     // this is optimized when ilLMObject::preloadDataByLM is invoked (e.g. done in ilLMExplorerGUI)
     $title = ilLMObject::_lookupTitle($a_pg_id);
     // this is also optimized since ilObjectTranslation re-uses instances for one lm
     include_once "./Services/Object/classes/class.ilObjectTranslation.php";
     $ot = ilObjectTranslation::getInstance($a_lm_id);
     $languages = $ot->getLanguages();
     if ($a_lang != "-" && $ot->getContentActivated() && isset($languages[$a_lang])) {
         include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
         $lmobjtrans = new ilLMObjTranslation($a_pg_id, $a_lang);
         if ($lmobjtrans->getTitle() != "") {
             $title = $lmobjtrans->getTitle();
         }
     }
     if ($a_mode == IL_PAGE_TITLE) {
         return $title;
     }
     include_once "./Modules/LearningModule/classes/class.ilLMTree.php";
     $tree = ilLMTree::getInstance($a_lm_id);
     if ($tree->isInTree($a_pg_id)) {
         $pred_node = $tree->fetchPredecessorNode($a_pg_id, "st");
         $childs = $tree->getChildsByType($pred_node["obj_id"], "pg");
         $cnt_str = "";
         if (count($childs) > 1) {
             $cnt = 0;
             foreach ($childs as $child) {
                 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
                 $active = ilLMPage::_lookupActive($child["obj_id"], ilObject::_lookupType($a_lm_id), $a_time_scheduled_activation);
                 if (!$active) {
                     $act_data = ilLMPage::_lookupActivationData((int) $child["obj_id"], ilObject::_lookupType($a_lm_id));
                     if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                         $active = true;
                     }
                 }
                 if ($child["type"] != "pg" || $active) {
                     $cnt++;
                 }
                 if ($child["obj_id"] == $a_pg_id) {
                     $cur_cnt = $cnt;
                 }
             }
             if ($cnt > 1) {
                 $cnt_str = " (" . $cur_cnt . "/" . $cnt . ")";
             }
         }
         require_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
         //$struct_obj =& new ilStructureObject($pred_node["obj_id"]);
         //return $struct_obj->getTitle();
         return ilStructureObject::_getPresentationTitle($pred_node["obj_id"], $a_include_numbers, false, 0, $a_lang) . $cnt_str;
         //return $pred_node["title"].$cnt_str;
     } else {
         return $title;
     }
 }