/**
  * list definitions of a term
  */
 function listDefinitions($a_ref_id = 0, $a_term_id = 0, $a_get_html = false)
 {
     global $ilUser, $ilAccess, $ilias, $lng, $ilCtrl;
     if ($a_ref_id == 0) {
         $ref_id = (int) $_GET["ref_id"];
     } else {
         $ref_id = $a_ref_id;
     }
     if ($a_term_id == 0) {
         $term_id = $this->term_id;
     } else {
         $term_id = $a_term_id;
     }
     if (!$ilAccess->checkAccess("read", "", $ref_id)) {
         $ilias->raiseError($lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
     }
     // tabs
     if ($this->glossary->getPresentationMode() != "full_def") {
         $this->showDefinitionTabs("content");
     }
     $term = new ilGlossaryTerm($term_id);
     if (!$a_get_html) {
         $tpl = $this->tpl;
         require_once "./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php";
         $tpl->getStandardTemplate();
         //			$this->setTabs();
         if ($this->offlineMode()) {
             $style_name = $ilUser->prefs["style"] . ".css";
             $tpl->setVariable("LOCATION_STYLESHEET", "./" . $style_name);
         } else {
             $this->setLocator();
         }
         // content style
         $tpl->setCurrentBlock("ContentStyle");
         if (!$this->offlineMode()) {
             $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
         } else {
             $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
         }
         $tpl->parseCurrentBlock();
         // syntax style
         $tpl->setCurrentBlock("SyntaxStyle");
         if (!$this->offlineMode()) {
             $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
         } else {
             $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", "syntaxhighlight.css");
         }
         $tpl->parseCurrentBlock();
         $tpl->setTitleIcon(ilUtil::getImagePath("icon_term_b.png"));
         $tpl->setTitle($this->lng->txt("cont_term") . ": " . $term->getTerm());
         // load template for table
         $tpl->addBlockfile("ADM_CONTENT", "def_list", "tpl.glossary_definition_list.html", "Modules/Glossary");
     } else {
         // content style
         $this->tpl->setCurrentBlock("ContentStyle");
         if (!$this->offlineMode()) {
             $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
         } else {
             $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content.css");
         }
         $this->tpl->parseCurrentBlock();
         // syntax style
         $this->tpl->setCurrentBlock("SyntaxStyle");
         if (!$this->offlineMode()) {
             $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
         } else {
             $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", "syntaxhighlight.css");
         }
         $this->tpl->parseCurrentBlock();
         $tpl = new ilTemplate("tpl.glossary_definition_list.html", true, true, "Modules/Glossary");
     }
     $defs = ilGlossaryDefinition::getDefinitionList($term_id);
     $tpl->setVariable("TXT_TERM", $term->getTerm());
     $this->mobs = array();
     for ($j = 0; $j < count($defs); $j++) {
         $def = $defs[$j];
         $page_gui = new ilGlossaryDefPageGUI($def["id"]);
         $page_gui->setStyleId($this->glossary->getStyleSheetId());
         $page = $page_gui->getPageObject();
         // internal links
         $page->buildDom();
         $int_links = $page->getInternalLinks();
         $link_xml = $this->getLinkXML($int_links);
         $page_gui->setLinkXML($link_xml);
         if ($this->offlineMode()) {
             $page_gui->setOutputMode("offline");
             $page_gui->setOfflineDirectory($this->getOfflineDirectory());
         }
         $page_gui->setSourcecodeDownloadScript($this->getLink($ref_id));
         $page_gui->setFullscreenLink($this->getLink($ref_id, "fullscreen", $term_id, $def["id"]));
         $page_gui->setTemplateOutput(false);
         $page_gui->setRawPageContent(true);
         $page_gui->setFileDownloadLink($this->getLink($ref_id, "downloadFile"));
         if (!$this->offlineMode()) {
             $output = $page_gui->preview();
         } else {
             $output = $page_gui->presentation($page_gui->getOutputMode());
         }
         if (count($defs) > 1) {
             $tpl->setCurrentBlock("definition_header");
             $tpl->setVariable("TXT_DEFINITION", $this->lng->txt("cont_definition") . " " . ($j + 1));
             $tpl->parseCurrentBlock();
         }
         $tpl->setCurrentBlock("definition");
         $tpl->setVariable("PAGE_CONTENT", $output);
         $tpl->parseCurrentBlock();
     }
     // display possible backlinks
     $sources = ilInternalLink::_getSourcesOfTarget('git', $_GET['term_id'], 0);
     if ($sources) {
         $backlist_shown = false;
         foreach ($sources as $src) {
             $type = explode(':', $src['type']);
             if ($type[0] == 'lm') {
                 if ($type[1] == 'pg') {
                     $title = ilLMPageObject::_getPresentationTitle($src['id']);
                     $lm_id = ilLMObject::_lookupContObjID($src['id']);
                     $lm_title = ilObject::_lookupTitle($lm_id);
                     $tpl->setCurrentBlock('backlink_item');
                     $ref_ids = ilObject::_getAllReferences($lm_id);
                     $access = false;
                     foreach ($ref_ids as $rid) {
                         if ($ilAccess->checkAccess("read", "", $rid)) {
                             $access = true;
                         }
                     }
                     if ($access) {
                         $tpl->setCurrentBlock("backlink_item");
                         $tpl->setVariable("BACKLINK_LINK", ILIAS_HTTP_PATH . "/goto.php?target=" . $type[1] . "_" . $src['id']);
                         $tpl->setVariable("BACKLINK_ITEM", $lm_title . ": " . $title);
                         $tpl->parseCurrentBlock();
                         $backlist_shown = true;
                     }
                 }
             }
         }
         if ($backlist_shown) {
             $tpl->setCurrentBlock("backlink_list");
             $tpl->setVariable("BACKLINK_TITLE", $this->lng->txt('glo_term_used_in'));
             $tpl->parseCurrentBlock();
         }
     }
     if (!$a_get_html) {
         $tpl->setCurrentBlock("perma_link");
         $tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH . "/goto.php?target=" . "git" . "_" . $term_id . "_" . $ref_id . "&client_id=" . CLIENT_ID);
         $tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
         $tpl->setVariable("PERMA_TARGET", "_top");
         $tpl->parseCurrentBlock();
     }
     // highlighting?
     if ($_GET["srcstring"] != "" && !$this->offlineMode()) {
         include_once './Services/Search/classes/class.ilUserSearchCache.php';
         $cache = ilUserSearchCache::_getInstance($ilUser->getId());
         $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
         $search_string = $cache->getQuery();
         include_once "./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php";
         include_once "./Services/Search/classes/class.ilQueryParser.php";
         $p = new ilQueryParser($search_string);
         $p->parse();
         $words = $p->getQuotedWords();
         if (is_array($words)) {
             foreach ($words as $w) {
                 ilTextHighlighterGUI::highlight("ilGloContent", $w, $tpl);
             }
         }
         $this->fill_on_load_code = true;
     }
     if ($this->offlineMode() || $a_get_html) {
         return $tpl->get();
     }
 }
 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() == "ilglossarydefpagegui") {
         $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_glo.svg"));
     }
     switch ($next_class) {
         case "ilglossarydefpagegui":
             // output number of usages
             if ($ilCtrl->getCmd() == "edit" && $ilCtrl->getCmdClass() == "ilglossarydefpagegui") {
                 $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() == "ilglossarydefpagegui" || $this->ctrl->getCmdClass() == "ileditclipboardgui") {
                 $gloss_loc->display();
             }
             $this->setTabs();
             $this->ctrl->setReturnByClass("ilGlossaryDefPageGUI", "edit");
             $this->ctrl->setReturn($this, "listDefinitions");
             $page_gui = new ilGlossaryDefPageGUI($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&amp;ref_id=" . $_GET["ref_id"]);
             $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=fullscreen&amp;ref_id=" . $_GET["ref_id"]);
             $page_gui->setTemplateTargetVar("ADM_CONTENT");
             $page_gui->setOutputMode("edit");
             $page_gui->setStyleId($this->glossary->getStyleSheetId());
             $page_gui->setLocator($gloss_loc);
             $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&amp;cmd=downloadFile&amp;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;
     }
 }