/** * get the HTML pages of a card from the glossary * Each page is an assoc array with title and html code * The first page is assumed to be the question * * @return array ( array ("title" => string, "html" => string), ...) */ function getGlossaryTermPages() { require_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; require_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; require_once "./Services/COPage/classes/class.ilPageObjectGUI.php"; $term = new ilGlossaryTerm($this->card->getTermId()); $defs = ilGlossaryDefinition::getDefinitionList($term->getId()); // get the term page $term_page = array("title" => $this->plugin->txt("glossary_term"), "html" => $term->getTerm()); // get the definition pages $i = 1; $def_pages = array(); $def_title = count($defs) > 1 ? $this->plugin->txt("glossary_definition_x") : $this->plugin->txt("glossary_definition"); foreach ($defs as $definition) { $page_gui = new ilPageObjectGUI("gdf", $definition["id"]); $page_gui->setTemplateOutput(false); $page_gui->setOutputMode(IL_PAGE_PRESENTATION); $page_gui->setEnabledTabs(false); $def_pages[] = array("title" => sprintf($def_title, $i++), "html" => $page_gui->getHTML()); } // return the pages according to the glossary mode switch ($this->object->getGlossaryMode()) { case ilObjFlashcards::GLOSSARY_MODE_TERM_DEFINITIONS: return array_merge(array($term_page), $def_pages); case ilObjFlashcards::GLOSSARY_MODE_DEFINITION_TERM: return array_merge($def_pages, array($term_page)); case ilObjFlashcards::GLOSSARY_MODE_DEFINITIONS: $def_pages[0]["title"] = $this->plugin->txt("question"); $answer_title = count($def_pages) > 2 ? $this->plugin->txt("answer_x") : $this->plugin->txt("answer"); for ($i = 1; $i < count($def_pages); $i++) { $def_pages[$i]["title"] = sprintf($answer_title, $i); } return $def_pages; } }
/** * get html * @return */ public function getHTML() { global $lng, $ilUser; $lng->loadLanguageModule('content'); 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('SUBITEM_TYPE', $lng->txt('cont_term')); $this->tpl->setVariable('SEPERATOR', ':'); #$this->getItemListGUI()->setChildId($sub_item); include_once './Services/Search/classes/class.ilUserSearchCache.php'; $src_string = ilUserSearchCache::_getInstance($ilUser->getId())->getUrlEncodedQuery(); $this->tpl->setVariable('LINK', ilLink::_getLink($this->getRefId(), 'git', array('target' => 'git_' . $sub_item . '_' . $this->getRefId(), 'srcstring' => 1))); $this->tpl->setVariable('TARGET', $this->getItemListGUI()->getCommandFrame('')); $this->tpl->setVariable('TITLE', ilGlossaryTerm::_lookGlossaryTerm($sub_item)); // begin-patch mime_filter if (count($this->getSubItemIds(true)) > 1) { $this->parseRelevance($sub_item); } // end-patch mime_filter $this->tpl->parseCurrentBlock(); } $this->showDetailsLink(); return $this->tpl->get(); }
/** * Fill table row */ protected function fillRow($term) { global $lng, $ilCtrl; $defs = ilGlossaryDefinition::getDefinitionList($term["id"]); $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]); for ($j = 0; $j < count($defs); $j++) { $def = $defs[$j]; if ($this->glossary->getId() == $term["glo_id"]) { // up if ($j > 0) { $this->tpl->setCurrentBlock("move_up"); $this->tpl->setVariable("TXT_UP", $lng->txt("up")); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]); $this->tpl->setVariable("LINK_UP", $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionUp")); $this->tpl->parseCurrentBlock(); } // down if ($j + 1 < count($defs)) { $this->tpl->setCurrentBlock("move_down"); $this->tpl->setVariable("TXT_DOWN", $lng->txt("down")); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]); $this->tpl->setVariable("LINK_DOWN", $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionDown")); $this->tpl->parseCurrentBlock(); } // delete $this->tpl->setCurrentBlock("delete"); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]); $this->tpl->setVariable("LINK_DELETE", $ilCtrl->getLinkTarget($this->parent_obj, "confirmDefinitionDeletion")); $this->tpl->setVariable("TXT_DELETE", $lng->txt("delete")); $this->tpl->parseCurrentBlock(); // edit $this->tpl->setCurrentBlock("edit"); $ilCtrl->setParameterByClass("ilpageobjectgui", "term_id", $term["id"]); $ilCtrl->setParameterByClass("ilpageobjectgui", "def", $def["id"]); $this->tpl->setVariable("LINK_EDIT", $ilCtrl->getLinkTargetByClass(array("ilglossarytermgui", "iltermdefinitioneditorgui", "ilpageobjectgui"), "edit")); $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit")); $this->tpl->parseCurrentBlock(); } // text $this->tpl->setCurrentBlock("definition"); $short_str = $def["short_text"]; // replace tex // if a tex end tag is missing a tex end tag $ltexs = strrpos($short_str, "[tex]"); $ltexe = strrpos($short_str, "[/tex]"); if ($ltexs > $ltexe) { $page =& new ilPageObject("gdf", $def["id"]); $page->buildDom(); $short_str = $page->getFirstParagraphText(); $short_str = strip_tags($short_str, "<br>"); $ltexe = strpos($short_str, "[/tex]", $ltexs); $short_str = ilUtil::shortenText($short_str, $ltexe + 6, true); } $short_str = ilUtil::insertLatexImages($short_str); $short_str = ilPCParagraph::xml2output($short_str); $this->tpl->setVariable("DEF_SHORT", $short_str); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("definition_row"); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("check_col"); $this->tpl->setVariable("CHECKBOX_ID", $term["id"]); $this->tpl->parseCurrentBlock(); // edit term link $this->tpl->setCurrentBlock("edit_term"); $this->tpl->setVariable("TEXT_TERM", $term["term"]); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); if ($this->glossary->getId() == $term["glo_id"]) { $this->tpl->setVariable("LINK_EDIT_TERM", $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "editTerm")); $this->tpl->setVariable("TXT_EDIT_TERM", $lng->txt("edit")); } $this->tpl->parseCurrentBlock(); // usage $nr_usage = ilGlossaryTerm::getNumberOfUsages($term["id"]); if ($nr_usage > 0 && $this->glossary->getId() == $term["glo_id"]) { $this->tpl->setCurrentBlock("link_usage"); $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]); $this->tpl->setVariable("LUSAGE", ilGlossaryTerm::getNumberOfUsages($term["id"])); $this->tpl->setVariable("LINK_USAGE", $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages")); $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", ""); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("usage"); $this->tpl->setVariable("USAGE", ilGlossaryTerm::getNumberOfUsages($term["id"])); $this->tpl->parseCurrentBlock(); } // glossary title if (in_array($this->glossary->getVirtualMode(), array("level", "subtree"))) { $this->tpl->setCurrentBlock("glossary"); $this->tpl->setVariable("GLO_TITLE", ilObject::_lookupTitle($term["glo_id"])); $this->tpl->parseCurrentBlock(); } // output term and language $this->tpl->setVariable("TEXT_LANGUAGE", $lng->txt("meta_l_" . $term["language"])); }
/** * Fill table row */ protected function fillRow($term) { global $lng, $ilCtrl; $defs = ilGlossaryDefinition::getDefinitionList($term["id"]); $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]); for ($j = 0; $j < count($defs); $j++) { $def = $defs[$j]; if ($this->glossary->getId() == $term["glo_id"]) { // up if ($j > 0) { $this->tpl->setCurrentBlock("move_up"); $this->tpl->setVariable("TXT_UP", $lng->txt("up")); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]); $this->tpl->setVariable("LINK_UP", $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionUp")); $this->tpl->parseCurrentBlock(); } // down if ($j + 1 < count($defs)) { $this->tpl->setCurrentBlock("move_down"); $this->tpl->setVariable("TXT_DOWN", $lng->txt("down")); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]); $this->tpl->setVariable("LINK_DOWN", $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionDown")); $this->tpl->parseCurrentBlock(); } // delete $this->tpl->setCurrentBlock("delete"); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]); $this->tpl->setVariable("LINK_DELETE", $ilCtrl->getLinkTarget($this->parent_obj, "confirmDefinitionDeletion")); $this->tpl->setVariable("TXT_DELETE", $lng->txt("delete")); $this->tpl->parseCurrentBlock(); // edit $this->tpl->setCurrentBlock("edit"); $ilCtrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term["id"]); $ilCtrl->setParameterByClass("ilglossarydefpagegui", "def", $def["id"]); $this->tpl->setVariable("LINK_EDIT", $ilCtrl->getLinkTargetByClass(array("ilglossarytermgui", "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit")); $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit")); $this->tpl->parseCurrentBlock(); } // text $this->tpl->setCurrentBlock("definition"); $short_str = $def["short_text"]; // replace tex // if a tex end tag is missing a tex end tag $ltexs = strrpos($short_str, "[tex]"); $ltexe = strrpos($short_str, "[/tex]"); if ($ltexs > $ltexe) { $page = new ilGlossaryDefPage($def["id"]); $page->buildDom(); $short_str = $page->getFirstParagraphText(); $short_str = strip_tags($short_str, "<br>"); $ltexe = strpos($short_str, "[/tex]", $ltexs); $short_str = ilUtil::shortenText($short_str, $ltexe + 6, true); } $short_str = ilUtil::insertLatexImages($short_str); $short_str = ilPCParagraph::xml2output($short_str); $this->tpl->setVariable("DEF_SHORT", $short_str); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("definition_row"); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("check_col"); $this->tpl->setVariable("CHECKBOX_ID", $term["id"]); $this->tpl->parseCurrentBlock(); // edit term link $this->tpl->setCurrentBlock("edit_term"); $this->tpl->setVariable("TEXT_TERM", $term["term"]); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); if ($this->glossary->getId() == $term["glo_id"]) { $this->tpl->setVariable("LINK_EDIT_TERM", $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "editTerm")); $this->tpl->setVariable("TXT_EDIT_TERM", $lng->txt("edit")); } $this->tpl->parseCurrentBlock(); // usage if (in_array("usage", $this->getSelectedColumns())) { $nr_usage = ilGlossaryTerm::getNumberOfUsages($term["id"]); if ($nr_usage > 0 && $this->glossary->getId() == $term["glo_id"]) { $this->tpl->setCurrentBlock("link_usage"); $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]); $this->tpl->setVariable("LUSAGE", ilGlossaryTerm::getNumberOfUsages($term["id"])); $this->tpl->setVariable("LINK_USAGE", $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages")); $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", ""); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("usage"); $this->tpl->setVariable("USAGE", ilGlossaryTerm::getNumberOfUsages($term["id"])); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("td_usage"); $this->tpl->parseCurrentBlock(); } // glossary title if (in_array($this->glossary->getVirtualMode(), array("level", "subtree"))) { $this->tpl->setCurrentBlock("glossary"); $this->tpl->setVariable("GLO_TITLE", ilObject::_lookupTitle($term["glo_id"])); $this->tpl->parseCurrentBlock(); } // output language if (in_array("language", $this->getSelectedColumns())) { $this->tpl->setCurrentBlock("td_lang"); $this->tpl->setVariable("TEXT_LANGUAGE", $lng->txt("meta_l_" . $term["language"])); $this->tpl->parseCurrentBlock(); } // adv metadata foreach ($this->getSelectedColumns() as $c) { if (substr($c, 0, 3) == "md_") { $id = (int) substr($c, 3); $this->tpl->setCurrentBlock("td_md"); switch ($this->adv_fields[$id]["type"]) { case ilAdvancedMDFieldDefinition::TYPE_DATETIME: $val = $term["md_" . $id] > 0 ? ilDatePresentation::formatDate(new ilDateTime($term["md_" . $id], IL_CAL_UNIX)) : " "; break; case ilAdvancedMDFieldDefinition::TYPE_DATE: $val = $term["md_" . $id] > 0 ? ilDatePresentation::formatDate(new ilDate($term["md_" . $id], IL_CAL_UNIX)) : " "; break; default: $val = $term["md_" . $id] != "" ? $term["md_" . $id] : " "; breal; } $this->tpl->setVariable("MD_VAL", $val); $this->tpl->parseCurrentBlock(); } } }
/** * 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 "RepositoryItem": if (is_int(strpos($a_target, "_"))) { $ref_id = ilInternalLink::_extractObjIdOfTarget($a_target); return $tree->isInTree($ref_id); } break; } return false; }
/** * Print view selection * * @param * @return */ function printViewSelection() { global $ilUser, $lng, $ilToolbar, $ilCtrl, $tpl, $ilTabs; $ilCtrl->saveParameter($this, "term_id"); if ((int) $this->term_id == 0) { $this->setTabs(); $ilTabs->activateTab("print_view"); } else { $tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.png")); $term = new ilGlossaryTerm((int) $this->term_id); $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm()); $this->showDefinitionTabs("print_view"); } $this->initPrintViewSelectionForm(); $tpl->setContent($this->form->getHTML()); }
/** * Fill table row */ protected function fillRow($term) { global $lng, $ilCtrl; include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php"; $defs = ilGlossaryDefinition::getDefinitionList($term["id"]); $ilCtrl->setParameterByClass("ilobjglossarygui", "term_id", $term["id"]); $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]); $ilCtrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term["id"]); // actions drop down if ($this->glossary->getId() == $term["glo_id"]) { $list = new ilAdvancedSelectionListGUI(); $list->addItem($lng->txt("cont_edit_term"), "", $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "editTerm")); if (count($defs) > 1) { $list->addItem($lng->txt("cont_edit_definitions"), "", $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listDefinitions")); } else { if (count($defs) == 1) { $ilCtrl->setParameterByClass("ilglossarydefpagegui", "def", $defs[0]["id"]); $list->addItem($lng->txt("cont_edit_definition"), "", $ilCtrl->getLinkTargetByClass(array("ilglossarytermgui", "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit")); } } $list->addItem($lng->txt("cont_add_definition"), "", $ilCtrl->getLinkTargetByClass("ilobjglossarygui", "addDefinition")); $ilCtrl->setParameterByClass("ilglossarydefpagegui", "def", ""); $list->setId("act_term_" . $term["id"]); $list->setListTitle($lng->txt("actions")); $this->tpl->setVariable("ACTIONS", $list->getHTML()); } for ($j = 0; $j < count($defs); $j++) { $def = $defs[$j]; /*if ($this->glossary->getId() == $term["glo_id"]) { // up if ($j > 0) { $this->tpl->setCurrentBlock("move_up"); $this->tpl->setVariable("TXT_UP", $lng->txt("up")); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]); $this->tpl->setVariable("LINK_UP", $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionUp")); $this->tpl->parseCurrentBlock(); } // down if ($j+1 < count($defs)) { $this->tpl->setCurrentBlock("move_down"); $this->tpl->setVariable("TXT_DOWN", $lng->txt("down")); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]); $this->tpl->setVariable("LINK_DOWN", $ilCtrl->getLinkTarget($this->parent_obj, "moveDefinitionDown")); $this->tpl->parseCurrentBlock(); } // delete $this->tpl->setCurrentBlock("delete"); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); $ilCtrl->setParameter($this->parent_obj, "def", $def["id"]); $this->tpl->setVariable("LINK_DELETE", $ilCtrl->getLinkTarget($this->parent_obj, "confirmDefinitionDeletion")); $this->tpl->setVariable("TXT_DELETE", $lng->txt("delete")); $this->tpl->parseCurrentBlock(); // edit $this->tpl->setCurrentBlock("edit"); $ilCtrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term["id"]); $ilCtrl->setParameterByClass("ilglossarydefpagegui", "def", $def["id"]); $this->tpl->setVariable("LINK_EDIT", $ilCtrl->getLinkTargetByClass(array("ilglossarytermgui", "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit")); $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit")); $this->tpl->parseCurrentBlock(); }*/ // text $this->tpl->setCurrentBlock("definition"); $short_str = $def["short_text"]; // replace tex // if a tex end tag is missing a tex end tag $ltexs = strrpos($short_str, "[tex]"); $ltexe = strrpos($short_str, "[/tex]"); if ($ltexs > $ltexe) { $page = new ilGlossaryDefPage($def["id"]); $page->buildDom(); $short_str = $page->getFirstParagraphText(); $short_str = strip_tags($short_str, "<br>"); $ltexe = strpos($short_str, "[/tex]", $ltexs); $short_str = ilUtil::shortenText($short_str, $ltexe + 6, true); } $short_str = ilUtil::insertLatexImages($short_str); $short_str = ilPCParagraph::xml2output($short_str); $this->tpl->setVariable("DEF_SHORT", $short_str); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("definition_row"); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("check_col"); $this->tpl->setVariable("CHECKBOX_ID", $term["id"]); $this->tpl->parseCurrentBlock(); $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]); // usage if (in_array("usage", $this->getSelectedColumns())) { $nr_usage = ilGlossaryTerm::getNumberOfUsages($term["id"]); if ($nr_usage > 0 && $this->glossary->getId() == $term["glo_id"]) { $this->tpl->setCurrentBlock("link_usage"); $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", $term["id"]); $this->tpl->setVariable("LUSAGE", ilGlossaryTerm::getNumberOfUsages($term["id"])); $this->tpl->setVariable("LINK_USAGE", $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages")); $ilCtrl->setParameterByClass("ilglossarytermgui", "term_id", ""); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("usage"); $this->tpl->setVariable("USAGE", ilGlossaryTerm::getNumberOfUsages($term["id"])); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("td_usage"); $this->tpl->parseCurrentBlock(); } // glossary title if (in_array($this->glossary->getVirtualMode(), array("level", "subtree"))) { $this->tpl->setCurrentBlock("glossary"); $this->tpl->setVariable("GLO_TITLE", ilObject::_lookupTitle($term["glo_id"])); $this->tpl->parseCurrentBlock(); } // output language if (in_array("language", $this->getSelectedColumns())) { $this->tpl->setCurrentBlock("td_lang"); $this->tpl->setVariable("TEXT_LANGUAGE", $lng->txt("meta_l_" . $term["language"])); $this->tpl->parseCurrentBlock(); } foreach ($this->adv_cols_order as $c) { if ($c["id"] == 0) { $this->tpl->setCurrentBlock("td"); $this->tpl->setVariable("TD_VAL", $term["term"]); $this->tpl->parseCurrentBlock(); } else { if (in_array("md_" . $c["id"], $this->selected_cols)) { $id = (int) $c["id"]; $val = " "; if (isset($term["md_" . $id . "_presentation"])) { $pb = $term["md_" . $id . "_presentation"]->getHTML(); if ($pb) { $val = $pb; } } $this->tpl->setCurrentBlock("td"); $this->tpl->setVariable("TD_VAL", $val); $this->tpl->parseCurrentBlock(); } } } }
/** * redirect script * * @param string $a_target */ function _goto($a_target, $a_ref_id = "") { global $rbacsystem, $ilErr, $lng, $ilAccess; $glo_id = ilGlossaryTerm::_lookGlossaryID($a_target); //::_lookupContObjID($a_target); // get all references if ($a_ref_id > 0) { $ref_ids = array($a_ref_id); } else { $ref_ids = ilObject::_getAllReferences($glo_id); } // check read permissions foreach ($ref_ids as $ref_id) { // Permission check if ($ilAccess->checkAccess("read", "", $ref_id)) { $_GET["baseClass"] = "ilGlossaryPresentationGUI"; $_GET["term_id"] = $a_target; $_GET["ref_id"] = $ref_id; $_GET["cmd"] = "listDefinitions"; include_once "ilias.php"; exit; } } if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) { ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"), ilObject::_lookupTitle($glo_id)), true); ilObjectGUI::_gotoRepositoryRoot(); } $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL); }
public static function getTranslatedValue($a_value) { global $lng; $value = explode("|", $a_value); switch ($value[0]) { case "media": $type = $lng->txt("obj_mob"); $name = ilObject::_lookupTitle($value[1]); break; case "page": include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php"; $type = $lng->txt("obj_pg"); $name = ilLMPageObject::_lookupTitle($value[1]); break; case "term": include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $type = $lng->txt("term"); $name = ilGlossaryTerm::_lookGlossaryTerm($value[1]); break; default: $type = $lng->txt("obj_" . $value[0]); $name = ilObject::_lookupTitle(ilObject::_lookupObjId($value[1])); break; } return array("type" => $type, "name" => $name); }
/** * 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); }
/** * Get glossary term ids in sco * * @param * @return */ function getGlossaryTermIds() { include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $childs = $this->tree->getChilds($this->getId()); $ids = array(); foreach ($childs as $c) { $links = ilInternalLink::_getTargetsOfSource("sahs" . ":pg", $c["child"]); foreach ($links as $l) { if ($l["type"] == "git" && (int) $l["inst"] == 0 && !isset($ids[$l["id"]])) { $ids[$l["id"]] = ilGlossaryTerm::_lookGlossaryTerm($l["id"]); } } } asort($ids); return $ids; }
/** * Update the cards from the glossary * delete all cards * * @param integer $a_obj_id * @param integer $a_glossary_ref_id */ public function updateCardsFromGlossary() { // get all term_ids from the glossaries involved $all_terms = array(); if ($this->getGlossaryRefId()) { $glossary = ilObjectFactory::getInstanceByRefId($this->getGlossaryRefId()); $glo_ids = $glossary->getAllGlossaryIds(); if (!is_array($glo_ids)) { $glo_ids = array($glo_ids); } foreach ($glo_ids as $glo_id) { $terms = ilGlossaryTerm::getTermsOfGlossary($glo_id); $all_terms = array_merge($all_terms, $terms); } } // delete all cards without terms $found_terms = array(); foreach ($this->cards as $card_id => $card) { if (!in_array($card->getTermId(), $all_terms)) { $card->delete(); unset($this->cards[$card_id]); } else { $found_terms[] = $card->getTermId(); } } // add new cards for new terms $missing_terms = array_diff($all_terms, $found_terms); $this->plugin->includeClass('class.ilFlashcard.php'); foreach ($missing_terms as $term_id) { $card = new ilFlashCard(); $card->setObjId($this->getId()); $card->setTermId($term_id); $card->save(); $this->cards[$card->getCardId()] = $card; } // cleanup the trainings $this->plugin->includeClass('class.ilFlashcardUsage.php'); ilFlashcardUsage::_cleanup($this); }
/** * Perform automatic modifications (may be overwritten by sub classes) */ function performAutomaticModifications() { if ($this->getGlossaryId() > 0) { // we fix glossary links here $this->buildDom(); $xpc = xpath_new_context($this->dom); $path = "//IntLink[@Type='GlossaryItem']"; $res =& xpath_eval($xpc, $path); for ($i = 0; $i < count($res->nodeset); $i++) { $target = $res->nodeset[$i]->get_attribute("Target"); //echo "<br>".$target; $tarr = explode("_", $target); $term_id = $tarr[count($tarr) - 1]; if (is_int(strpos($target, "__")) && $term_id > 0) { include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; //echo "<br>-".ilGlossaryTerm::_lookGlossaryID($term_id)."-".$this->getGlossaryId()."-"; if (ilGlossaryTerm::_lookGlossaryID($term_id) != $this->getGlossaryId()) { // copy the glossary term from glossary a to b $new_id = ilGlossaryTerm::_copyTerm($term_id, $this->getGlossaryId()); $res->nodeset[$i]->set_attribute("Target", "il__git_" . $new_id); } } } } //exit; }
/** * Clone glossary * * @param int target ref_id * @param int copy id */ public function cloneObject($a_target_id, $a_copy_id = 0) { global $ilDB, $ilUser, $ilias; $new_obj = parent::cloneObject($a_target_id, $a_copy_id); $this->cloneMetaData($new_obj); $new_obj->setTitle($this->getTitle()); $new_obj->setDescription($this->getDescription()); $new_obj->setVirtualMode($this->getVirtualMode()); $new_obj->setPresentationMode($this->getPresentationMode()); $new_obj->setSnippetLength($this->getSnippetLength()); $new_obj->update(); // set/copy stylesheet include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $style_id = $this->getStyleSheetId(); if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) { $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id); $new_id = $style_obj->ilClone(); $new_obj->setStyleSheetId($new_id); $new_obj->update(); } // copy taxonomy if (($tax_id = $this->getTaxonomyId()) > 0) { // clone it include_once "./Services/Taxonomy/classes/class.ilObjTaxonomy.php"; $tax = new ilObjTaxonomy($tax_id); $new_tax = $tax->cloneObject(0, 0, true); $map = $tax->getNodeMapping(); // assign new taxonomy to new glossary ilObjTaxonomy::saveUsage($new_tax->getId(), $new_obj->getId()); } // assign new tax/new glossary // handle mapping // prepare tax node assignments objects include_once "./Services/Taxonomy/classes/class.ilTaxNodeAssignment.php"; if ($tax_id > 0) { $tax_ass = new ilTaxNodeAssignment("glo", "term", $tax_id); $new_tax_ass = new ilTaxNodeAssignment("glo", "term", $new_tax->getId()); } // copy terms foreach (ilGlossaryTerm::getTermList($this->getId()) as $term) { $new_term_id = ilGlossaryTerm::_copyTerm($term["id"], $new_obj->getId()); // copy tax node assignments if ($tax_id > 0) { $assignmts = $tax_ass->getAssignmentsOfItem($term["id"]); foreach ($assignmts as $a) { if ($map[$a["node_id"]] > 0) { $new_tax_ass->addAssignment($map[$a["node_id"]], $new_term_id); } } } } return $new_obj; }
/** * check whether goto script will succeed */ function _checkGoto($a_target) { global $ilAccess; $t_arr = explode("_", $a_target); if ($t_arr[0] != "glo" && $t_arr[0] != "git" || (int) $t_arr[1] <= 0) { return false; } if ($t_arr[0] == "glo") { if ($ilAccess->checkAccess("read", "", $t_arr[1]) || $ilAccess->checkAccess("visible", "", $t_arr[1])) { return true; } } if ($t_arr[0] == "git") { if ($t_arr[2] > 0) { $ref_ids = array($t_arr[2]); } else { // determine learning object require_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $glo_id = ilGlossaryTerm::_lookGlossaryID($t_arr[1]); $ref_ids = ilObject::_getAllReferences($glo_id); } // check read permissions foreach ($ref_ids as $ref_id) { // Permission check if ($ilAccess->checkAccess("read", "", $ref_id)) { return true; } } } return false; }
public function __appendChildLinks($html, $item, &$item_list_gui) { if (!count($item['child'])) { return $html; } $tpl = new ilTemplate('tpl.detail_links.html', true, true, 'Services/Search'); switch ($item['type']) { case 'lm': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once 'Modules/LearningModule/classes/class.ilLMObject.php'; foreach ($item['child'] as $child) { $tpl->setCurrentBlock("link_row"); switch (ilLMObject::_lookupType($child)) { case 'pg': $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('obj_pg')); break; case 'st': $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('obj_st')); break; } $item_list_gui->setChildId($child); $tpl->setVariable("SEPERATOR", ' -> '); $tpl->setVariable("LINK", $item_list_gui->getCommandLink('page')); $tpl->setVariable("TARGET", $item_list_gui->getCommandFrame('page')); $tpl->setVariable("TITLE", ilLMObject::_lookupTitle($child)); $tpl->parseCurrentBlock(); } break; case 'frm': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once './Modules/Forum/classes/class.ilObjForum.php'; foreach ($item['child'] as $child) { $thread_post = explode('_', $child); $tpl->setCurrentBlock("link_row"); $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('thread')); $item_list_gui->setChildId($thread_post); $tpl->setVariable("SEPERATOR", ': '); $tpl->setVariable("LINK", $item_list_gui->getCommandLink('posting')); $tpl->setVariable("TARGET", $item_list_gui->getCommandFrame('')); $tpl->setVariable("TITLE", ilObjForum::_lookupThreadSubject($thread_post[0])); $tpl->parseCurrentBlock(); } break; case 'glo': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once './Modules/Glossary/classes/class.ilGlossaryTerm.php'; $this->lng->loadLanguageModule('content'); foreach ($item['child'] as $child) { $tpl->setCurrentBlock("link_row"); $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('cont_term')); $tpl->setVariable("SEPERATOR", ': '); $tpl->setVariable("LINK", ilLink::_getLink($item['ref_id'], 'git', array('target' => 'git_' . $child . '_' . $item['ref_id']))); $tpl->setVariable("TITLE", ilGlossaryTerm::_lookGlossaryTerm($child)); $tpl->parseCurrentBlock(); } break; case 'wiki': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once './Modules/Wiki/classes/class.ilWikiPage.php'; include_once './Modules/Wiki/classes/class.ilWikiUtil.php'; $this->lng->loadLanguageModule('wiki'); foreach ($item['child'] as $child) { $page_title = ilWikiPage::lookupTitle($child); $tpl->setCurrentBlock("link_row"); $tpl->setVariable("CHAPTER_PAGE", $this->lng->txt('wiki_page')); $tpl->setVariable("SEPERATOR", ': '); $tpl->setVariable("LINK", ilLink::_getLink($item['ref_id'], 'wiki', array(), "_" . ilWikiUtil::makeUrlTitle($page_title))); $tpl->setVariable("TITLE", $page_title); $tpl->parseCurrentBlock(); } break; case 'mcst': $tpl->setVariable("HITS", $this->lng->txt('search_hits')); include_once "./Services/News/classes/class.ilNewsItem.php"; foreach ($item['child'] as $child) { $tpl->setCurrentBlock("link_row"); //$tpl->setVariable("CHAPTER_PAGE",$this->lng->txt('item')); $item_list_gui->setChildId($child); //$tpl->setVariable("SEPERATOR",': '); $tpl->setVariable("LINK", $item_list_gui->getCommandLink('listItems')); $tpl->setVariable("TARGET", $item_list_gui->getCommandFrame('')); $tpl->setVariable("TITLE", ilNewsItem::_lookupTitle($child)); $tpl->parseCurrentBlock(); } break; default: } return $html . $tpl->get(); }
/** * Auto link glossaries * * @param * @return */ function autoLinkGlossaries($a_glos) { if (is_array($a_glos) && count($a_glos) > 0) { include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; // check which terms occur in the text (we may // get some false positives due to the strip_tags, but // we do not want to find strong or list or other stuff // within the tags $text = strip_tags($this->getText()); $found_terms = array(); foreach ($a_glos as $glo) { if (ilObject::_lookupType($glo) == "glo") { $terms = ilGlossaryTerm::getTermList($glo); foreach ($terms as $t) { if (is_int(stripos($text, $t["term"]))) { $found_terms[$t["id"]] = $t; } } } } // did we find anything? -> modify content if (count($found_terms) > 0) { self::linkTermsInDom($this->dom, $found_terms, $this->par_node); } } }
/** * Standard Version of Fill Row. Most likely to * be overwritten by derived class. */ protected function fillRow($a_set) { global $lng, $ilCtrl; $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]); $ilCtrl->setParameterByClass("illmpageobjectgui", "obj_id", $a_set["obj_id"]); $this->tpl->setVariable("HREF_PAGE", $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "edit")); include_once "./Modules/LearningModule/classes/class.ilLMPage.php"; $page_object = new ilLMPage($a_set["obj_id"]); $page_object->buildDom(); $int_links = $page_object->getInternalLinks(); foreach ($int_links as $link) { $target = $link["Target"]; if (substr($target, 0, 4) == "il__") { $target_arr = explode("_", $target); $target_id = $target_arr[count($target_arr) - 1]; $type = $link["Type"]; switch ($type) { case "PageObject": $this->tpl->setCurrentBlock("link"); $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg")); if (ilLMObject::_exists($target_id)) { $lm_id = ilLMObject::_lookupContObjID($target_id); $add_str = $lm_id != $this->lm_id ? " (" . ilObject::_lookupTitle($lm_id) . ")" : ""; $this->tpl->setVariable("TXT_LINK_TITLE", ilLMObject::_lookupTitle($target_id) . $add_str); } else { $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"); } $this->tpl->parseCurrentBlock(); break; case "StructureObject": $this->tpl->setCurrentBlock("link"); $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st")); if (ilLMObject::_exists($target_id)) { $lm_id = ilLMObject::_lookupContObjID($target_id); $add_str = $lm_id != $this->lm_id ? " (" . ilObject::_lookupTitle($lm_id) . ")" : ""; $this->tpl->setVariable("TXT_LINK_TITLE", ilLMObject::_lookupTitle($target_id) . $add_str); } else { $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"); } $this->tpl->parseCurrentBlock(); break; case "GlossaryItem": $this->tpl->setCurrentBlock("link"); $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term")); include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; if (ilGlossaryTerm::_exists($target_id)) { $this->tpl->setVariable("TXT_LINK_TITLE", ilGlossaryTerm::_lookGlossaryTerm($target_id)); } else { $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"); } $this->tpl->parseCurrentBlock(); break; case "MediaObject": $this->tpl->setCurrentBlock("link"); $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob")); if (ilObject::_exists($target_id)) { $this->tpl->setVariable("TXT_LINK_TITLE", ilObject::_lookupTitle($target_id)); } else { $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"); } $this->tpl->parseCurrentBlock(); break; case "RepositoryItem": $this->tpl->setCurrentBlock("link"); $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item")); $obj_type = ilObject::_lookupType($target_id, true); $obj_id = ilObject::_lookupObjId($target_id); if (ilObject::_exists($obj_id)) { $this->tpl->setVariable("TXT_LINK_TITLE", ilObject::_lookupTitle($obj_id) . " (" . $lng->txt("obj_" . $obj_type) . ")"); } else { $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"); } $this->tpl->parseCurrentBlock(); break; } } else { $type = $link["Type"]; switch ($type) { case "PageObject": $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg")); break; case "StructureObject": $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st")); break; case "GlossaryItem": $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term")); break; case "MediaObject": $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob")); break; case "RepositoryItem": $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item")); break; } $this->tpl->setCurrentBlock("link"); $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target . "]" . "</b>"); $this->tpl->parseCurrentBlock(); } } }
/** * Auto link glossary terms * * @param * @return */ function autoLinkGlossaryTerms($a_glo_id) { // get terms include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $terms = ilGlossaryTerm::getTermList($a_glo_id); // each get page: get content include_once "./Modules/LearningModule/classes/class.ilLMPage.php"; $pages = ilLMPage::getAllPages($this->getType(), $this->getId()); // determine terms that occur in the page $found_pages = array(); foreach ($pages as $p) { $pg = new ilLMPage($p["id"]); $c = $pg->getXMLContent(); foreach ($terms as $t) { if (is_int(stripos($c, $t["term"]))) { $found_pages[$p["id"]]["terms"][] = $t; if (!is_object($found_pages[$p["id"]]["page"])) { $found_pages[$p["id"]]["page"] = $pg; } } } reset($terms); } // ilPCParagraph autoLinkGlossariesPage with page and terms include_once "./Services/COPage/classes/class.ilPCParagraph.php"; foreach ($found_pages as $id => $fp) { ilPCParagraph::autoLinkGlossariesPage($fp["page"], $fp["terms"]); } }
function getTemplate() { $this->tpl->getStandardTemplate(); $title = $this->object->getTitle(); if ($this->term_id > 0) { $this->tpl->setTitle($this->lng->txt("term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($this->term_id)); } else { parent::setTitleAndDescription(); $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg")); $this->tpl->setTitle($this->lng->txt("glo") . ": " . $title); } }
function &executeCommand() { global $tpl, $ilCtrl, $lng; $next_class = $this->ctrl->getNextClass($this); $cmd = $this->ctrl->getCmd(); // content style $this->tpl->setCurrentBlock("ContentStyle"); $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId())); $this->tpl->parseCurrentBlock(); // syntax style $this->tpl->setCurrentBlock("SyntaxStyle"); $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath()); $this->tpl->parseCurrentBlock(); require_once "./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php"; $gloss_loc =& new ilGlossaryLocatorGUI(); $gloss_loc->setTerm($this->term); $gloss_loc->setGlossary($this->glossary); $gloss_loc->setDefinition($this->definition); $this->tpl->getStandardTemplate(); $this->tpl->setTitle($this->term->getTerm() . " - " . $this->lng->txt("cont_definition") . " " . $this->definition->getNr()); if ($this->ctrl->getNextClass() == "ilpageobjectgui") { $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_def_b.png")); } switch ($next_class) { case "ilpageobjectgui": // output number of usages if ($ilCtrl->getCmd() == "edit" && $ilCtrl->getCmdClass() == "ilpageobjectgui") { $nr = ilGlossaryTerm::getNumberOfUsages($_GET["term_id"]); if ($nr > 0) { $link = "[<a href='" . $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") . "'>" . $lng->txt("glo_list_usages") . "</a>]"; ilUtil::sendInfo(sprintf($lng->txt("glo_term_is_used_n_times"), $nr) . " " . $link); } } // not so nice, to do: revise locator handling if ($this->ctrl->getNextClass() == "ilpageobjectgui" || $this->ctrl->getCmdClass() == "ileditclipboardgui") { $gloss_loc->display(); } $this->setTabs(); $this->ctrl->setReturnByClass("ilPageObjectGUI", "edit"); $this->ctrl->setReturn($this, "listDefinitions"); $page_gui =& new ilPageObjectGUI("gdf", $this->definition->getId()); $page = $page_gui->getPageObject(); $this->definition->assignPageObject($page); $page->addUpdateListener($this, "saveShortText"); $page_gui->setEditPreview(true); // metadata // ... set title to term, if no title is given include_once "./Services/MetaData/classes/class.ilMD.php"; $md = new ilMD($this->glossary->getId(), $this->definition->getId(), "gdf"); $md_gen = $md->getGeneral(); if ($md_gen->getTitle() == "") { $md_gen->setTitle($this->term->getTerm()); $md_gen->update(); } $page_gui->activateMetaDataEditor($this->glossary->getId(), $this->definition->getId(), "gdf"); // $this->obj, "MDUpdateListener"); $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&ref_id=" . $_GET["ref_id"]); $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&cmd=fullscreen&ref_id=" . $_GET["ref_id"]); $page_gui->setTemplateTargetVar("ADM_CONTENT"); $page_gui->setOutputMode("edit"); $page_gui->setEnableKeywords(true); $page_gui->setStyleId($this->glossary->getStyleSheetId()); $page_gui->setLocator($gloss_loc); $page_gui->setEnabledInternalLinks(true); $page_gui->setIntLinkHelpDefault("GlossaryItem", $_GET["ref_id"]); $page_gui->setIntLinkReturn($this->ctrl->getLinkTargetByClass("ilobjglossarygui", "quickList", "", false, false)); $page_gui->setPageBackTitle($this->lng->txt("cont_definition")); $page_gui->setLinkParams("ref_id=" . $_GET["ref_id"]); $page_gui->setHeader($this->term->getTerm()); $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&cmd=downloadFile&ref_id=" . $_GET["ref_id"]); $page_gui->setPresentationTitle($this->term->getTerm()); $ret =& $this->ctrl->forwardCommand($page_gui); $tpl->setContent($ret); break; default: $this->setTabs(); $gloss_loc->display(); $ret =& $this->{$cmd}(); break; } }
public static function getAdvMDSubItemTitle($a_obj_id, $a_sub_type, $a_sub_id) { global $lng; if ($a_sub_type == "term") { $lng->loadLanguageModule("glo"); include_once "Modules/Glossary/classes/class.ilGlossaryTerm.php"; return $lng->txt("glo_term") . ' "' . ilGlossaryTerm::_lookGlossaryTerm($a_sub_id) . '"'; } }
/** * 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; }
/** * Copy a term to a glossary * * @param * @return */ function _copyTerm($a_term_id, $a_glossary_id) { $old_term = new ilGlossaryTerm($a_term_id); // copy the term $new_term = new ilGlossaryTerm(); $new_term->setTerm($old_term->getTerm()); $new_term->setLanguage($old_term->getLanguage()); $new_term->setGlossaryId($a_glossary_id); $new_term->create(); // copy the definitions include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; $def_list = ilGlossaryDefinition::getDefinitionList($a_term_id); foreach ($def_list as $def) { $old_def = new ilGlossaryDefinition($def["id"]); $new_def = new ilGlossaryDefinition(); $new_def->setShortText($old_def->getShortText()); $new_def->setNr($old_def->getNr()); $new_def->setTermId($new_term->getId()); $new_def->create(); // copy meta data include_once "Services/MetaData/classes/class.ilMD.php"; $md = new ilMD($old_term->getGlossaryId(), $old_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType()); $new_md = $md->cloneMD($a_glossary_id, $new_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType()); // page content $new_def->getPageObject()->setXMLContent($old_def->getPageObject()->copyXmlContent(true)); $new_def->getPageObject()->buildDom(); $new_def->getPageObject()->update(); } return $new_term->getId(); }
/** * 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; }
/** * Sets a material link for the question * * @param string $material_id An internal link pointing to the material * @param boolean $is_import A boolean indication that the internal link was imported from another ILIAS installation * @access public */ function setMaterial($material_id = "", $is_import = false, $material_title = "") { if (strcmp($material_id, "") != 0) { $import_id = ""; if ($is_import) { $import_id = $material_id; $material_id = $this->_resolveInternalLink($import_id); } if (strcmp($material_title, "") == 0) { if (preg_match("/il__(\\w+)_(\\d+)/", $material_id, $matches)) { $type = $matches[1]; $target_id = $matches[2]; $material_title = $this->lng->txt("obj_{$type}") . ": "; switch ($type) { case "lm": include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php"; $cont_obj_gui =& new ilObjContentObjectGUI("", $target_id, true); $cont_obj = $cont_obj_gui->object; $material_title .= $cont_obj->getTitle(); break; case "pg": include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php"; include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $lm_id = ilLMObject::_lookupContObjID($target_id); include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php"; $cont_obj_gui =& new ilObjContentObjectGUI("", $lm_id, FALSE); $cont_obj = $cont_obj_gui->object; $pg_obj =& new ilLMPageObject($cont_obj, $target_id); $material_title .= $pg_obj->getTitle(); break; case "st": include_once "./Modules/LearningModule/classes/class.ilStructureObject.php"; include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $lm_id = ilLMObject::_lookupContObjID($target_id); include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php"; $cont_obj_gui =& new ilObjContentObjectGUI("", $lm_id, FALSE); $cont_obj = $cont_obj_gui->object; $st_obj =& new ilStructureObject($cont_obj, $target_id); $material_title .= $st_obj->getTitle(); break; case "git": include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id); break; case "mob": break; } } } $this->material = array("internal_link" => $material_id, "import_id" => $import_id, "title" => $material_title); } $this->saveMaterial(); }
/** * Set short texts dirty * * @param * @return */ static function setShortTextsDirty($a_glo_id) { global $ilDB; include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $term_ids = ilGlossaryTerm::getTermsOfGlossary($a_glo_id); foreach ($term_ids as $term_id) { $ilDB->manipulate("UPDATE glossary_definition SET " . " short_text_dirty = " . $ilDB->quote(1, "integer") . " WHERE term_id = " . $ilDB->quote($term_id, "integer")); } }
/** * Get's the repository object ID of a parent object, if possible */ 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) { case "html": // "old" category pages if ($cont_type == "cat") { $obj_id = $id; } // Test InfoScreen Text if ($cont_type == "tst" || $cont_type == "svy") { $obj_id = $id; //var_dump($qinfo); } // Question Pool *Question* Text (Test) if ($cont_type == "qpl") { 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 } } // Question Pool *Question* Text (Survey) if ($cont_type == "spl") { 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); } } // Forum if ($cont_type == "frm") { $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); } if ($cont_type == 'frm~') { $obj_id = $a_usage['id']; } if ($cont_type == "dcl") { $obj_id = $id; } break; case "pg": // Question Pool Question Pages if ($cont_type == "qpl") { 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 } } // learning modules if ($cont_type == "lm" || $cont_type == "dbk") { include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $obj_id = ilLMObject::_lookupContObjID($id); } // glossary definition if ($cont_type == "gdf") { 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); } // wiki page if ($cont_type == 'wpg') { include_once 'Modules/Wiki/classes/class.ilWikiPage.php'; $obj_id = ilWikiPage::lookupObjIdByPage($id); } // sahs page if ($cont_type == 'sahs') { // can this implementation be used for other content types, too? include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'sahs'); } // repository pages if (in_array($cont_type, array("crs", "grp", "cat", "fold", "root"))) { $obj_id = $id; } if ($cont_type == 'prtf') { include_once "Services/Portfolio/classes/class.ilPortfolioPage.php"; $obj_id = ilPortfolioPage::findPortfolioForPage($id); } if ($cont_type == 'blp') { include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'blp'); } 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; }
/** * 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")); } }
/** * 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; if (is_int(strpos($usage["type"], ":"))) { $us_arr = explode(":", $usage["type"]); $usage["type"] = $us_arr[1]; $cont_type = $us_arr[0]; } include_once './Services/Link/classes/class.ilLink.php'; switch ($usage["type"]) { case "pg": $item = array(); //$this->tpl->setVariable("TXT_OBJECT", $usage["type"].":".$usage["id"]); switch ($cont_type) { case "sahs": require_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php"; $page_obj = new ilSCORM2004Page($usage["id"]); require_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php"; require_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php"; $lm_obj = new ilObjSAHSLearningModule($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"] = ilSCORM2004PageNode::_lookupTitle($page_obj->getId()); $ref_id = $this->getFirstWritableRefId($lm_obj->getId()); if ($ref_id > 0) { $item["obj_link"] = ilLink::_getStaticLink($ref_id, "sahs"); } break; case "lm": require_once "./Modules/LearningModule/classes/class.ilLMPage.php"; $page_obj = new ilLMPage($usage["id"]); 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($ref_id, "lm"); } break; case "wpg": require_once "./Modules/Wiki/classes/class.ilWikiPage.php"; $page_obj = new ilWikiPage($usage["id"]); $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.ilGlossaryDefPage.php"; $page_obj = new ilGlossaryDefPage($usage["id"]); 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 "fold": case "root": case "crs": case "grp": case "cat": case "cont": $item["obj_type_txt"] = $this->lng->txt("obj_" . $cont_type); $item["obj_title"] = ilObject::_lookupTitle($usage["id"]); $ref_id = $this->getFirstWritableRefId($usage["id"]); if ($ref_id > 0) { $item["obj_link"] = ilLink::_getStaticLink($ref_id, $cont_type); } break; default: $item["obj_title"] = "Page " . $cont_type . ", " . $usage["id"]; 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; case "sqst": $item["obj_type_txt"] = $this->lng->txt("cont_sqst"); include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; $obj_id = SurveyQuestion::lookupObjFi($usage["id"]); $item["obj_title"] = ilObject::_lookupTitle($obj_id); $item["sub_txt"] = $this->lng->txt("question"); $item["sub_title"] = SurveyQuestion::_getTitle($usage["id"]); $ref_id = $this->getFirstWritableRefId($obj_id); if ($ref_id > 0) { $item["obj_link"] = ilLink::_getStaticLink($ref_id); } break; default: $item["obj_title"] = "Type " . $usage["type"] . ", " . $usage["id"]; 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; } 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")); } }