function isVisible($a_id, $a_type)
 {
     include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
     $active = ilLMPage::_lookupActive($a_id, $this->lm_obj->getType(), $this->lm_set->get("time_scheduled_page_activation"));
     if (!$active && $a_type == "pg") {
         $act_data = ilLMPage::_lookupActivationData((int) $a_id, $this->lm_obj->getType());
         if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
 /**
  * inserts sequential learning module navigation
  * at template variable LMNAVIGATION_CONTENT
  */
 function ilLMNavigation()
 {
     global $ilUser;
     include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
     include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
     $page_id = $this->getCurrentPageId();
     if (empty($page_id)) {
         return;
     }
     // process navigation for free page
     if (!$this->lm_tree->isInTree($page_id)) {
         if ($this->offlineMode() || $_GET["back_pg"] == "") {
             return;
         }
         $limpos = strpos($_GET["back_pg"], ":");
         if ($limpos > 0) {
             $back_pg = substr($_GET["back_pg"], 0, $limpos);
         } else {
             $back_pg = $_GET["back_pg"];
         }
         if (!$this->lm->cleanFrames()) {
             $back_href = $this->getLink($this->lm->getRefId(), "layout", $back_pg, $_GET["frame"], "", "reduce");
             $back_target = "";
         } else {
             $back_href = $this->getLink($this->lm->getRefId(), "layout", $back_pg, "", "", "reduce");
             $back_target = 'target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
         }
         $back_img = ilUtil::getImagePath("nav_arr2_L.png", false, "output", $this->offlineMode());
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
         $this->tpl->setVariable("IMG_PREV", $back_img);
         $this->tpl->setVariable("HREF_PREV", $back_href);
         $this->tpl->setVariable("FRAME_PREV", $back_target);
         $this->tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
         $this->tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
         $this->tpl->setVariable("PREV_ACC_KEY", ilAccessKeyGUI::getAttribute(ilAccessKey::PREVIOUS));
         $this->tpl->setVariable("SPACER_PREV", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
         $this->tpl->setVariable("IMG_PREV2", $back_img);
         $this->tpl->setVariable("HREF_PREV2", $back_href);
         $this->tpl->setVariable("FRAME_PREV2", $back_target);
         $this->tpl->setVariable("TXT_PREV2", $this->lng->txt("back"));
         $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("back"));
         $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
         return;
     }
     // determine successor page_id
     $found = false;
     // empty chapter
     if ($this->chapter_has_no_active_page && ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
         $c_id = $_GET["obj_id"];
     } else {
         if ($this->deactivated_page) {
             $c_id = $_GET["obj_id"];
         } else {
             $c_id = $page_id;
         }
     }
     while (!$found) {
         $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
         $c_id = $succ_node["obj_id"];
         $active = ilLMPage::_lookupActive($c_id, $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
         if ($succ_node["obj_id"] > 0 && ($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == "selected" && !ilLMObject::_isPagePublic($succ_node["obj_id"]))) {
             $found = false;
         } else {
             if ($succ_node["obj_id"] > 0 && !$active) {
                 // look, whether activation data should be shown
                 $act_data = ilLMPage::_lookupActivationData((int) $succ_node["obj_id"], $this->lm->getType());
                 if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                     $found = true;
                 } else {
                     $found = false;
                 }
             } else {
                 $found = true;
             }
         }
     }
     $succ_str = $succ_node !== false ? " -> " . $succ_node["obj_id"] . "_" . $succ_node["type"] : "";
     // determine predecessor page id
     $found = false;
     if ($this->deactivated_page) {
         $c_id = $_GET["obj_id"];
     } else {
         $c_id = $page_id;
     }
     while (!$found) {
         $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
         $c_id = $pre_node["obj_id"];
         $active = ilLMPage::_lookupActive($c_id, $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
         if ($pre_node["obj_id"] > 0 && ($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == "selected" && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
             $found = false;
         } else {
             if ($pre_node["obj_id"] > 0 && !$active) {
                 // look, whether activation data should be shown
                 $act_data = ilLMPage::_lookupActivationData((int) $pre_node["obj_id"], $this->lm->getType());
                 if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                     $found = true;
                 } else {
                     $found = false;
                 }
             } else {
                 $found = true;
             }
         }
     }
     $pre_str = $pre_node !== false ? $pre_node["obj_id"] . "_" . $pre_node["type"] . " -> " : "";
     // determine target frame
     $framestr = !empty($_GET["frame"]) ? "frame=" . $_GET["frame"] . "&" : "";
     // Determine whether the view of a learning resource should
     // be shown in the frameset of ilias, or in a separate window.
     $showViewInFrameset = true;
     if ($pre_node != "") {
         // get presentation title
         $prev_title = ilLMPageObject::_getPresentationTitle($pre_node["obj_id"], $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lang);
         $prev_title = ilUtil::shortenText($prev_title, 50, true);
         $prev_img = ilUtil::getImagePath("nav_arr_L.png", false, "output", $this->offlineMode());
         if (!$this->lm->cleanFrames()) {
             $prev_href = $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"], $_GET["frame"]);
             $prev_target = "";
         } else {
             if ($showViewInFrameset && !$this->offlineMode()) {
                 $prev_href = $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
                 $prev_target = 'target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
             } else {
                 $prev_href = $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
                 $prev_target = 'target="_top" ';
             }
         }
         if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
             $output = $this->lng->txt("msg_page_not_public");
         }
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
         $this->tpl->setVariable("IMG_PREV", $prev_img);
         $this->tpl->setVariable("HREF_PREV", $prev_href);
         $this->tpl->setVariable("FRAME_PREV", $prev_target);
         $this->tpl->setVariable("TXT_PREV", $prev_title);
         $this->tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
         $this->tpl->setVariable("SPACER_PREV", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->setVariable("PREV_ACC_KEY", ilAccessKeyGUI::getAttribute(ilAccessKey::PREVIOUS));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
         $this->tpl->setVariable("IMG_PREV2", $prev_img);
         $this->tpl->setVariable("HREF_PREV2", $prev_href);
         $this->tpl->setVariable("FRAME_PREV2", $prev_target);
         $this->tpl->setVariable("TXT_PREV2", $prev_title);
         $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("previous"));
         $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
     }
     if ($succ_node != "") {
         // get presentation title
         $succ_title = ilLMPageObject::_getPresentationTitle($succ_node["obj_id"], $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lang);
         $succ_title = ilUtil::shortenText($succ_title, 50, true);
         $succ_img = ilUtil::getImagePath("nav_arr_R.png", false, "output", $this->offlineMode());
         if (!$this->lm->cleanFrames()) {
             $succ_href = $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]);
             $succ_target = "";
         } else {
             if ($showViewInFrameset && !$this->offlineMode()) {
                 $succ_href = $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
                 $succ_target = ' target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
             } else {
                 $succ_href = $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
                 $succ_target = ' target="_top" ';
             }
         }
         if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
             $output = $this->lng->txt("msg_page_not_public");
         }
         $this->tpl->setCurrentBlock("ilLMNavigation_Next");
         $this->tpl->setVariable("IMG_SUCC", $succ_img);
         $this->tpl->setVariable("HREF_SUCC", $succ_href);
         $this->tpl->setVariable("FRAME_SUCC", $succ_target);
         $this->tpl->setVariable("TXT_SUCC", $succ_title);
         $this->tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
         $this->tpl->setVariable("SPACER_SUCC", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->setVariable("NEXT_ACC_KEY", ilAccessKeyGUI::getAttribute(ilAccessKey::NEXT));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ilLMNavigation_Next2");
         $this->tpl->setVariable("IMG_SUCC2", $succ_img);
         $this->tpl->setVariable("HREF_SUCC2", $succ_href);
         $this->tpl->setVariable("FRAME_SUCC2", $succ_target);
         $this->tpl->setVariable("TXT_SUCC2", $succ_title);
         $this->tpl->setVariable("ALT_SUCC2", $this->lng->txt("next"));
         $this->tpl->setVariable("SPACER_SUCC2", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
         // check if successor page is not restricted
         if (!$this->offlineMode()) {
             if ($this->lm->getRestrictForwardNavigation()) {
                 if ($this->getTracker()->hasPredIncorrectAnswers($succ_node["obj_id"])) {
                     $this->tpl->addOnLoadCode("\$('.ilc_page_rnav_RightNavigation').addClass('ilNoDisplay');");
                 }
             }
         }
     }
 }
示例#3
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;
     }
 }
 /**
  * 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"];
     }
 }