/**
  * 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();
             }
         }
     }
 }
 /**
  * Export HTML pages of SCO
  */
 function exportHTMLPageObjects($a_inst, $a_target_dir, &$expLog, $mode, $a_asset_type = "sco", $a_one_file = "", $a_sco_tpl = null)
 {
     global $tpl, $ilCtrl, $ilBench, $ilLog, $lng;
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php";
     include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModuleGUI.php";
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $output = "";
     $tree = new ilTree($this->slm_id);
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     // @todo
     // Why is that much HTML code in an application class?
     // Please extract all this HTML to a tpl.<t_name>.html file and use
     // placeholders and the template engine to insert data.
     //
     // There copy/paste code residenting in ilSCORM2004ScoGUI. This
     // should be merged.
     //
     // alex, 4 Apr 09
     //
     //		if ($a_one_file == "")
     //		{
     $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004");
     //		}
     //		else
     //		{
     //			$sco_tpl = $a_sco_tpl;
     //		}
     if ($mode != 'pdf' && $a_one_file == "") {
         include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php";
         $pg_exp = new ilCOPageHTMLExport($a_target_dir);
         $pg_exp->getPreparedMainTemplate($sco_tpl);
         // init and question lang vars
         $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->slm_id);
         $sco_tpl->setCurrentBlock("init");
         include_once "./Services/COPage/classes/class.ilPCQuestion.php";
         $sco_tpl->setVariable("TXT_INIT_CODE", ilPCQuestion::getJSTextInitCode($lk));
         $sco_tpl->parseCurrentBlock();
         // (additional) style sheets needed
         $styles = array("./css/yahoo/container.css", "./css/question_handling.css");
         foreach ($styles as $style) {
             $sco_tpl->setCurrentBlock("css_file");
             $sco_tpl->setVariable("CSS_FILE", $style);
             $sco_tpl->parseCurrentBlock();
         }
         // (additional) scripts needed
         $scripts = array("./js/scorm.js", "./js/pager.js", "./js/pure.js", "./js/questions_" . $this->getId() . ".js");
         foreach ($scripts as $script) {
             $sco_tpl->setCurrentBlock("js_file");
             $sco_tpl->setVariable("JS_FILE", $script);
             $sco_tpl->parseCurrentBlock();
         }
         if ($a_asset_type != "entry_asset" && $a_asset_type != "final_asset") {
             self::renderNavigation($sco_tpl, "./images/spacer.png", $lk);
         }
         $sco_tpl->touchBlock("finish");
     }
     // render head
     $sco_tpl->setCurrentBlock("head");
     $sco_tpl->setVariable("SCO_TITLE", $this->getTitle());
     $sco_tpl->parseCurrentBlock();
     $sco_tpl->touchBlock("tail");
     // meta page (meta info at SCO beginning)
     self::renderMetaPage($sco_tpl, $this, $a_asset_type, $mode);
     if ($a_one_file != "") {
         fputs($a_one_file, "<a name='sco" . $this->getId() . "'></a>");
         fputs($a_one_file, $sco_tpl->get("meta_page"));
     }
     //notify Question Exporter of new SCO
     require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
     ilQuestionExporter::indicateNewSco();
     // init export (this initialises glossary template)
     ilSCORM2004PageGUI::initExport();
     $terms = array();
     $terms = $this->getGlossaryTermIds();
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ScoGUI.php";
     $pages = $tree->getSubTree($tree->getNodeData($this->getId()), true, 'page');
     $sco_q_ids = array();
     foreach ($pages as $page) {
         //echo(print_r($page));
         $page_obj = new ilSCORM2004PageGUI($this->getType(), $page["obj_id"], 0, $this->slm_object->getId());
         $page_obj->setPresentationTitle($page["title"]);
         $page_obj->setOutputMode(IL_PAGE_OFFLINE);
         $page_obj->setStyleId($this->slm_object->getStyleSheetId());
         if (count($terms) > 1) {
             $page_obj->setGlossaryOverviewInfo(ilSCORM2004ScoGUI::getGlossaryOverviewId(), $this);
         }
         $page_output = $page_obj->showPage("export");
         // collect media objects
         $mob_ids = $page_obj->getSCORM2004Page()->collectMediaObjects(false);
         foreach ($mob_ids as $mob_id) {
             $this->mob_ids[$mob_id] = $mob_id;
             $media_obj = new ilObjMediaObject($mob_id);
             if ($media_obj->hasFullscreenItem()) {
                 $media_obj->exportMediaFullscreen($a_target_dir, $page_obj->getPageObject());
             }
         }
         // collect glossary items
         $int_links = $page_obj->getPageObject()->getInternalLinks(true);
         include_once "./Services/Link/classes/class.ilInternalLink.php";
         include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
         if (is_array($int_links)) {
             foreach ($int_links as $k => $e) {
                 // glossary link
                 if ($e["Type"] == "GlossaryItem") {
                     $karr = explode(":", $k);
                     $tid = ilInternalLink::_extractObjIdOfTarget($karr[0]);
                     $dids = ilGlossaryDefinition::getDefinitionList($tid);
                     foreach ($dids as $did) {
                         include_once "./Modules/Glossary/classes/class.ilGlossaryDefPage.php";
                         $def_pg = new ilGlossaryDefPage($did["id"]);
                         $def_pg->buildDom();
                         $mob_ids = $def_pg->collectMediaObjects(false);
                         foreach ($mob_ids as $mob_id) {
                             $this->mob_ids[$mob_id] = $mob_id;
                             //echo "<br>-$mob_id-";
                             $media_obj = new ilObjMediaObject($mob_id);
                             if ($media_obj->hasFullscreenItem()) {
                                 $media_obj->exportMediaFullscreen($a_target_dir, $def_pg);
                             }
                         }
                         include_once "./Services/COPage/classes/class.ilPCFileList.php";
                         $file_ids = ilPCFileList::collectFileItems($def_pg, $def_pg->getDomDoc());
                         foreach ($file_ids as $file_id) {
                             $this->file_ids[$file_id] = $file_id;
                         }
                     }
                 }
             }
         }
         //exit;
         // collect all file items
         include_once "./Services/COPage/classes/class.ilPCFileList.php";
         $file_ids = ilPCFileList::collectFileItems($page_obj->getSCORM2004Page(), $page_obj->getSCORM2004Page()->getDomDoc());
         foreach ($file_ids as $file_id) {
             $this->file_ids[$file_id] = $file_id;
         }
         if ($mode == 'pdf') {
             include_once "./Services/COPage/classes/class.ilPCQuestion.php";
             $q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]);
             foreach ($q_ids as $q_id) {
                 include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
                 $q_gui =& assQuestionGUI::_getQuestionGUI("", $q_id);
                 $q_gui->outAdditionalOutput();
                 $html = $q_gui->getPreview(TRUE);
                 $page_output = preg_replace("/{{{{{Question;il__qst_" . $q_id . "}}}}}/i", $html, $page_output);
             }
             $sco_tpl->touchBlock("pdf_pg_break");
         }
         $sco_tpl->setCurrentBlock("page");
         $sco_tpl->setVariable("PAGE", $page_output);
         $sco_tpl->parseCurrentBlock();
         // get all question ids of the sco
         if ($a_one_file != "") {
             include_once "./Services/COPage/classes/class.ilPCQuestion.php";
             $q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]);
             foreach ($q_ids as $i) {
                 if (!in_array($i, $sco_q_ids)) {
                     $sco_q_ids[] = $i;
                 }
             }
         }
     }
     // glossary
     if ($mode != 'pdf') {
         $sco_tpl->setVariable("GLOSSARY_HTML", ilSCORM2004PageGUI::getGlossaryHTML($this));
     }
     if ($a_one_file == "") {
         $output = $sco_tpl->get();
     } else {
         $output = $sco_tpl->get("page");
     }
     if ($mode == 'pdf') {
         $output = preg_replace("/<div class=\"ilc_page_title_PageTitle\">(.*?)<\\/div>/i", "<h2>\$1</h2>", $output);
     }
     //$output = preg_replace("/\.\/mobs\/mm_(\d+)\/([^\"]+)/i","./objects/il_".IL_INST_ID."_mob_$1/$2",$output);
     $output = preg_replace("/mobs\\/mm_(\\d+)\\/([^\"]+)/i", "./objects/il_" . IL_INST_ID . "_mob_\$1/\$2", $output);
     $output = preg_replace("/\\.\\/files\\/file_(\\d+)\\/([^\"]+)/i", "./objects/il_" . IL_INST_ID . "_file_\$1/\$2", $output);
     $output = preg_replace("/\\.\\/Services\\/MediaObjects\\/flash_mp3_player/i", "./players", $output);
     //		$output = preg_replace("/\.\/".str_replace("/", "\/", ilPlayerUtil::getFlashVideoPlayerDirectory())."/i","./players",$output);
     $output = preg_replace("/file=..\\/..\\/..\\/.\\//i", "file=../", $output);
     if ($mode != 'pdf') {
         $output = preg_replace_callback("/href=\"&mob_id=(\\d+)&pg_id=(\\d+)\"/", array(get_class($this), 'fixFullscreeenLink'), $output);
         // this one is for fullscreen in glossary entries
         $output = preg_replace_callback("/href=\"fullscreen_(\\d+)\\.html\"/", array(get_class($this), 'fixFullscreeenLink'), $output);
         $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output);
         //			$output = preg_replace("/&#123;/","",$output);
         //			$output = preg_replace("/&#125;/","",$output);
         $q_handling = file_get_contents('./Modules/Scorm2004/scripts/questions/question_handling.js');
         fputs(fopen($a_target_dir . '/js/questions_' . $this->getId() . '.js', 'w+'), ilQuestionExporter::questionsJS() . $q_handling);
         copy("./Modules/Scorm2004/templates/default/question_handling.css", $a_target_dir . '/css/question_handling.css');
         // hack to get the question js into the file and to display the correct answers
         if ($a_one_file != "") {
             $output = '<script type="text/javascript">' . ilQuestionExporter::questionsJS() . '</script>' . $output;
             if (count($sco_q_ids) > 0) {
                 $output .= '<script type="text/javascript">';
                 foreach ($sco_q_ids as $i) {
                     if ($i > 0) {
                         $output .= "ilias.questions.showCorrectAnswers(" . $i . "); \n";
                     }
                 }
                 $output .= '</script>';
             }
         }
         foreach (ilQuestionExporter::getMobs() as $mob_id) {
             $this->mob_ids[$mob_id] = $mob_id;
         }
     }
     $this->q_media = ilQuestionExporter::getFiles();
     //questions export end
     if ($a_one_file != "") {
         fputs($a_one_file, $output);
     } else {
         fputs(fopen($a_target_dir . '/index.html', 'w+'), $output);
     }
     $this->exportFileItems($a_target_dir, $expLog);
 }
 function download_paragraph()
 {
     include_once "./Modules/Glossary/classes/class.ilGlossaryDefPage.php";
     $pg_obj = new ilGlossaryDefPage($_GET["pg_id"]);
     $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
 }
 /**
  * Fill table row
  */
 protected function fillRow($term)
 {
     global $lng, $ilCtrl;
     $defs = ilGlossaryDefinition::getDefinitionList($term["id"]);
     $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
     if ($this->glossary->getPresentationMode() == "full_def") {
         $this->tpl->setCurrentBlock("fd_td");
         $this->tpl->setVariable("FULL_DEF", $this->parent_obj->listDefinitions($_GET["ref_id"], $term["id"], true));
         $this->tpl->parseCurrentBlock();
     } else {
         for ($j = 0; $j < count($defs); $j++) {
             $def = $defs[$j];
             if (count($defs) > 1) {
                 $this->tpl->setCurrentBlock("definition");
                 $this->tpl->setVariable("DEF_TEXT", $lng->txt("cont_definition") . " " . ($j + 1));
                 $this->tpl->parseCurrentBlock();
             }
             // check dirty short texts
             $this->tpl->setCurrentBlock("definition");
             if ($def["short_text_dirty"]) {
                 $def = new ilGlossaryDefinition($def["id"]);
                 $def->updateShortText();
                 $short_str = $def->getShortText();
             } else {
                 $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);
             }
             if (!$this->offline) {
                 $short_str = ilUtil::insertLatexImages($short_str);
             } else {
                 $short_str = ilUtil::buildLatexImages($short_str, $this->parent_obj->getOfflineDirectory());
             }
             $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->touchBlock("def_td");
         // display additional column 'glossary' for meta glossaries
         if ($this->glossary->isVirtual()) {
             $this->tpl->setCurrentBlock("glossary_row");
             $glo_title = ilObject::_lookupTitle($term["glo_id"]);
             $this->tpl->setVariable("GLO_TITLE", $glo_title);
             $this->tpl->parseCurrentBlock();
         }
     }
     $ilCtrl->clearParameters($this->parent_obj);
     // advanced metadata
     foreach ($this->adv_cols_order as $c) {
         if ($c["id"] == 0) {
             $this->tpl->setCurrentBlock("link_start");
             if (!$this->offline) {
                 if (!empty($filter)) {
                     $ilCtrl->setParameter($this->parent_obj, "term", $filter);
                     $ilCtrl->setParameter($this->parent_obj, "oldoffset", $_GET["oldoffset"]);
                 }
                 $ilCtrl->setParameter($this->parent_obj, "term_id", $term["id"]);
                 $ilCtrl->setParameter($this->parent_obj, "offset", $_GET["offset"]);
                 $this->tpl->setVariable("LINK_VIEW_TERM", $ilCtrl->getLinkTarget($this->parent_obj, "listDefinitions"));
                 $ilCtrl->clearParameters($this->parent_obj);
             } else {
                 $this->tpl->setVariable("LINK_VIEW_TERM", "term_" . $term["id"] . ".html");
             }
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("link_end");
             $this->tpl->setVariable("ANCHOR_TERM", "term_" . $term["id"]);
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("td");
             $this->tpl->setVariable("TEXT", $term["term"]);
             $this->tpl->parseCurrentBlock();
         } else {
             $id = $c["id"];
             $f = $this->adv_fields[$c["id"]];
             $this->tpl->setCurrentBlock("td");
             switch ($f["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] : " ";
                     break;
             }
             $this->tpl->setVariable("TEXT", $val);
             $this->tpl->parseCurrentBlock();
         }
     }
 }
 /**
  * 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":
                     $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;
             }
             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;
         }
         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"));
     }
 }
 /**
  * get internal links
  */
 function getInternalLinks()
 {
     require_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
     require_once "./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php";
     $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId());
     $term_links = array();
     for ($j = 0; $j < count($defs); $j++) {
         $def = $defs[$j];
         $page = new ilGlossaryDefPage($def["id"]);
         $page->buildDom();
         $page_links = $page->getInternalLinks();
         foreach ($page_links as $key => $page_link) {
             $term_links[$key] = $page_link;
         }
     }
     return $term_links;
 }
 /**
  * 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();
         }
     }
 }
 /**
  * parse pages that contain files, mobs and/or internal links
  */
 function processPagesToParse()
 {
     /*
     		$pg_mapping = array();
     		foreach($this->pg_mapping as $key => $value)
     		{
     			$pg_mapping[$key] = "il__pg_".$value;
     		}*/
     //echo "<br><b>processIntLinks</b>"; flush();
     // outgoin internal links
     foreach ($this->pages_to_parse as $page_id) {
         $page_arr = explode(":", $page_id);
         //echo "<br>resolve:".$this->content_object->getType().":".$page_id; flush();
         switch ($page_arr[0]) {
             case "lm":
                 switch ($this->content_object->getType()) {
                     case "lm":
                         include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
                         $page_obj = new ilLMPage($page_arr[1]);
                         break;
                     default:
                         die("Unknown content type " . $this->content_object->getType());
                 }
                 break;
             case "gdf":
                 include_once "./Modules/Glossary/classes/class.ilGlossaryDefPage.php";
                 $page_obj = new ilGlossaryDefPage($page_arr[1]);
                 break;
         }
         $page_obj->buildDom();
         $page_obj->resolveIntLinks();
         $page_obj->resolveIIMMediaAliases($this->mob_mapping);
         if (in_array($this->coType, array("lm", "dbk"))) {
             $page_obj->resolveQuestionReferences($this->qst_mapping);
         }
         $page_obj->update(false);
         if ($page_arr[0] == "gdf") {
             $def = new ilGlossaryDefinition($page_arr[1]);
             $def->updateShortText();
         }
         unset($page_obj);
     }
     //echo "<br><b>map area internal links</b>"; flush();
     // outgoins map area (mob) internal links
     foreach ($this->mobs_with_int_links as $mob_id) {
         ilMediaItem::_resolveMapAreaLinks($mob_id);
     }
     //echo "<br><b>incoming interna links</b>"; flush();
     // incoming internal links
     $done = array();
     foreach ($this->link_targets as $link_target) {
         //echo "doin link target:".$link_target.":<br>";
         $link_arr = explode("_", $link_target);
         $target_inst = $link_arr[1];
         $target_type = $link_arr[2];
         $target_id = $link_arr[3];
         //echo "<br>-".$target_type."-".$target_id."-".$target_inst."-";
         $sources = ilInternalLink::_getSourcesOfTarget($target_type, $target_id, $target_inst);
         foreach ($sources as $key => $source) {
             //echo "got source:".$key.":<br>";
             if (in_array($key, $done)) {
                 continue;
             }
             $type_arr = explode(":", $source["type"]);
             // content object pages
             if ($type_arr[1] == "pg") {
                 if (ilPageObject::_exists($type_arr[0], $source["id"])) {
                     include_once "./Services/COPage/classes/class.ilPageObjectFactory.php";
                     $page_object = ilPageObjectFactory::getInstance($type_arr[0], $source["id"]);
                     $page_object->buildDom();
                     $page_object->resolveIntLinks();
                     $page_object->update();
                     unset($page_object);
                 }
             }
             // eventually correct links in questions to learning modules
             if ($type_arr[0] == "qst") {
                 require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 assQuestion::_resolveIntLinks($source["id"]);
             }
             // eventually correct links in survey questions to learning modules
             if ($type_arr[0] == "sqst") {
                 require_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                 SurveyQuestion::_resolveIntLinks($source["id"]);
             }
             $done[$key] = $key;
         }
     }
 }