/** * Show link help list */ function showLinkHelp() { global $ilUser, $ilCtrl; // filter link types if (!$this->filter_white_list) { foreach ($this->filter_link_types as $link_type) { unset($this->ltypes[$link_type]); } } else { $ltypes = array(); foreach ($this->ltypes as $k => $l) { if (in_array($k, $this->filter_link_types)) { $ltypes[$k] = $l; } } $this->ltypes = $ltypes; } // determine link type and target $this->determineLinkType(); $ltype = $this->link_target != "" ? $this->link_type . "_" . $this->link_target : $this->link_type; $def_type = ilObject::_lookupType($this->default_obj, true); // determine content object id switch ($this->link_type) { case "PageObject": case "StructureObject": if (empty($_SESSION["il_link_cont_obj"]) && ($def_type != "mep" && $def_type != "glo")) { $_SESSION["il_link_cont_obj"] = $this->default_obj; } break; case "GlossaryItem": if (empty($_SESSION["il_link_glossary"]) && $def_type == "glo") { $_SESSION["il_link_glossary"] = $this->default_obj; } break; case "Media": if (empty($_SESSION["il_link_mep"]) && $def_type == "mep") { $_SESSION["il_link_mep"] = $this->default_obj; } break; } /* $target_str = ($link_target == "") ? "" : " target=\"".$link_target."\" ";*/ $target_str = $this->link_target == "" ? "" : " target=\"" . $this->link_target . "\""; //echo "-".$this->link_type."-"; if ($this->link_type == "GlossaryItem" && (empty($_SESSION["il_link_glossary"]) || !in_array(ilObject::_lookupType($_SESSION["il_link_glossary"], true), array("glo")))) { $this->changeTargetObject("glo"); } if (($this->link_type == "PageObject" || $this->link_type == "StructureObject") && (empty($_SESSION["il_link_cont_obj"]) || !in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true), array("lm", "dbk")))) { $this->changeTargetObject("cont_obj"); } if ($ilCtrl->isAsynch()) { $tpl = new ilTemplate("tpl.link_help_asynch.html", true, true, "Modules/LearningModule"); } else { $tpl =& new ilTemplate("tpl.link_help.html", true, true, "Modules/LearningModule"); $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation()); } switch ($this->link_type) { case "GlossaryItem": $this->ctrl->setParameter($this, "target_type", "glo"); break; case "PageObject": case "StructureObject": $this->ctrl->setParameter($this, "target_type", "cont_obj"); break; case "Media": $this->ctrl->setParameter($this, "target_type", "mep"); break; default: break; } //echo "<br><br>:".$this->ctrl->getFormAction($this).":"; //echo "<br>link_type:".$this->link_type; //echo "<br>cont_obj:".$_SESSION["il_link_cont_obj"]; //echo "<br>link_mep".$_SESSION["il_link_mep"]; //echo $this->ctrl->getFormAction($this, "", "", true); $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "changeLinkType", "", true)); $tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this)); $tpl->setVariable("TXT_HELP_HEADER", $this->lng->txt("cont_link_select")); $tpl->setVariable("TXT_TYPE", $this->lng->txt("cont_link_type")); //echo "<br><br>".$ltype; $select_ltype = ilUtil::formSelect($ltype, "ltype", $this->ltypes, false, true, "0", "", array("id" => "ilIntLinkTypeSelector")); $tpl->setVariable("SELECT_TYPE", $select_ltype); $tpl->setVariable("CMD_CHANGETYPE", "changeLinkType"); $tpl->setVariable("BTN_CHANGETYPE", $this->lng->txt("cont_change_type")); /* if ($this->isEnabledJavaScript()) { $tpl->setVariable("BTN_CLOSE_JS", $this->lng->txt("close")); } else {*/ $tpl->setVariable("CMD_CLOSE", "closeLinkHelp"); $tpl->setVariable("BTN_CLOSE", $this->lng->txt("close")); // } $chapterRowBlock = "chapter_row"; $anchor_row_block = "anchor_link"; if ($this->isEnabledJavaScript()) { $chapterRowBlock .= "_js"; $anchor_row_block .= "_js"; } $obj_id = ilObject::_lookupObjId($_SESSION["il_link_cont_obj"]); $type = ilObject::_lookupType($obj_id); // switch link type switch ($this->link_type) { // page link case "PageObject": require_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php"; include_once "./Modules/LearningModule/classes/class.ilLMPage.php"; $cont_obj = new ilObjLearningModule($_SESSION["il_link_cont_obj"], true); // get all chapters $ctree = $cont_obj->getLMTree(); $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId())); $tpl->setCurrentBlock("chapter_list"); $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj")); $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle()); $tpl->setCurrentBlock("change_cont_obj"); $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject"); $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change")); $tpl->parseCurrentBlock(); foreach ($nodes as $node) { if ($node["type"] == "st") { $tpl->setCurrentBlock("chapter_row"); $tpl->setVariable("TXT_CHAPTER", $node["title"]); $tpl->setVariable("ROWCLASS", "tblrow1"); //$tpl->setVariable("LINK_CHAPTER", // "[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]"); $tpl->parseCurrentBlock(); $tpl->setCurrentBlock("row"); $tpl->parseCurrentBlock(); } if ($node["type"] == "pg") { include_once "./Services/COPage/classes/class.ilPCParagraph.php"; $this->renderLink($tpl, $node["title"], $node["obj_id"], "PageObject", "pg", "page", ilPCParagraph::_readAnchors($type, $node["obj_id"], "")); } } // get all free pages $pages = ilLMPageObject::getPageList($cont_obj->getId()); $free_pages = array(); foreach ($pages as $page) { if (!$ctree->isInTree($page["obj_id"])) { $free_pages[] = $page; } } if (count($free_pages) > 0) { $tpl->setCurrentBlock(str_replace("_js", "", $chapterRowBlock)); $tpl->setVariable("TXT_CHAPTER", $this->lng->txt("cont_free_pages")); $tpl->setVariable("ROWCLASS", "tblrow1"); $tpl->parseCurrentBlock(); foreach ($free_pages as $node) { include_once "./Services/COPage/classes/class.ilPCParagraph.php"; $this->renderLink($tpl, $node["title"], $node["obj_id"], "PageObject", "pg", "page", ilPCParagraph::_readAnchors($type, $node["obj_id"], "")); } } $tpl->setCurrentBlock("chapter_list"); $tpl->parseCurrentBlock(); break; // chapter link // chapter link case "StructureObject": // check whether current object matchs to type if (!in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true), array("lm", "dbk"))) { $this->changeTargetObject("lm"); } if ($type == "lm") { require_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php"; $cont_obj = new ilObjLearningModule($_SESSION["il_link_cont_obj"], true); } else { if ($type == "dbk") { require_once "./Modules/LearningModule/classes/class.ilObjDlBook.php"; $cont_obj = new ilObjDlBook($_SESSION["il_link_cont_obj"], true); } } // get all chapters $ctree =& $cont_obj->getLMTree(); $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId())); $tpl->setCurrentBlock("chapter_list"); $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_content_obj")); $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle()); $tpl->setCurrentBlock("change_cont_obj"); $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject"); $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change")); $tpl->parseCurrentBlock(); foreach ($nodes as $node) { if ($node["type"] == "st") { $this->renderLink($tpl, $node["title"], $node["obj_id"], "StructureObject", "st", "chap"); } } $tpl->setCurrentBlock("chapter_list"); $tpl->parseCurrentBlock(); break; // glossary item link // glossary item link case "GlossaryItem": require_once "./Modules/Glossary/classes/class.ilObjGlossary.php"; $glossary =& new ilObjGlossary($_SESSION["il_link_glossary"], true); // get all glossary items $terms = $glossary->getTermList(); $tpl->setCurrentBlock("chapter_list"); $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary")); $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle()); $tpl->setCurrentBlock("change_cont_obj"); $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject"); $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change")); $tpl->parseCurrentBlock(); foreach ($terms as $term) { $this->renderLink($tpl, $term["term"], $term["id"], "GlossaryItem", "git", "term"); } $tpl->setCurrentBlock("chapter_list"); $tpl->parseCurrentBlock(); break; // media object // media object case "Media": include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php"; //$tpl->setVariable("TARGET2", " target=\"content\" "); // content object id = 0 --> get clipboard objects if ($_SESSION["il_link_mep"] == 0) { $tpl->setCurrentBlock("change_cont_obj"); $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject"); $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change")); $tpl->parseCurrentBlock(); $mobjs = $this->ilias->account->getClipboardObjects("mob"); // sort by name $objs = array(); foreach ($mobjs as $obj) { $objs[$obj["title"] . ":" . $obj["id"]] = $obj; } ksort($objs); $tpl->setCurrentBlock("chapter_list"); $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source")); $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard")); $tpl->setVariable("COLSPAN", "2"); foreach ($objs as $obj) { $this->renderLink($tpl, $obj["title"], $obj["id"], "MediaObject", "mob", "media"); } $tpl->setCurrentBlock("chapter_list"); $tpl->parseCurrentBlock(); } else { require_once "./Modules/MediaPool/classes/class.ilObjMediaPool.php"; $med_pool =& new ilObjMediaPool($_SESSION["il_link_mep"], true); // get current folders $fobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "fold"); $f2objs = array(); foreach ($fobjs as $obj) { $f2objs[$obj["title"] . ":" . $obj["child"]] = $obj; } ksort($f2objs); // get current media objects $mobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "mob"); $m2objs = array(); foreach ($mobjs as $obj) { $m2objs[$obj["title"] . ":" . $obj["child"]] = $obj; } ksort($m2objs); // merge everything together $objs = array_merge($f2objs, $m2objs); $tpl->setCurrentBlock("chapter_list"); $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep")); $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle()); $tpl->setCurrentBlock("change_cont_obj"); $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject"); $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change")); $tpl->setVariable("COLSPAN", "2"); $tpl->parseCurrentBlock(); if ($parent_id = $med_pool->getParentId($_SESSION["il_link_mep_obj"])) { $css_row = "tblrow1"; $tpl->setCurrentBlock("icon"); $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.png")); $tpl->parseCurrentBlock(); $tpl->setCurrentBlock("link_row"); $tpl->setVariable("ROWCLASS", $css_row); $tpl->setVariable("TXT_CHAPTER", ".."); $this->ctrl->setParameter($this, "mep_fold", $parent_id); if ($ilCtrl->isAsynch()) { $tpl->setVariable("LINK", "#"); $tpl->setVariable("LR_ONCLICK", " onclick=\"return il.IntLink.setMepPoolFolder('" . $parent_id . "');\" "); } else { $tpl->setVariable("LINK", $this->ctrl->getLinkTarget($this, "setMedPoolFolder")); } $tpl->parseCurrentBlock(); $tpl->setCurrentBlock("row"); $tpl->parseCurrentBlock(); } foreach ($objs as $obj) { if ($obj["type"] == "fold") { $css_row = $css_row == "tblrow2" ? "tblrow1" : "tblrow2"; $tpl->setCurrentBlock("icon"); $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.png")); $tpl->parseCurrentBlock(); $tpl->setCurrentBlock("link_row"); $tpl->setVariable("ROWCLASS", $css_row); $tpl->setVariable("TXT_CHAPTER", $obj["title"]); $this->ctrl->setParameter($this, "mep_fold", $obj["child"]); if ($ilCtrl->isAsynch()) { $tpl->setVariable("LINK", "#"); $tpl->setVariable("LR_ONCLICK", " onclick=\"return il.IntLink.setMepPoolFolder('" . $obj["child"] . "');\" "); } else { $tpl->setVariable("LINK", $this->ctrl->getLinkTarget($this, "setMedPoolFolder")); } $tpl->parseCurrentBlock(); } else { $fid = ilMediaPoolItem::lookupForeignId($obj["child"]); if (ilObject::_lookupType($fid) == "mob") { $this->renderLink($tpl, $obj["title"], $fid, "MediaObject", "mob", "media"); } } $tpl->setCurrentBlock("row"); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock("chapter_list"); $tpl->parseCurrentBlock(); } break; // repository item // repository item case "RepositoryItem": $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem()); break; // file download link // file download link case "File": if (!is_object($this->uploaded_file)) { $tpl->setVariable("LINK_HELP_CONTENT", $this->getFileLinkHTML()); } else { echo $this->getFileLinkHTML(); exit; } break; } if ($ilCtrl->isAsynch()) { echo $tpl->get(); exit; } exit; }
/** * Get page contents hashes */ function getPageContentsHashes() { $this->builddom(); $this->addHierIds(); $mydom = $this->dom; // get existing ids $path = "//PageContent"; $xpc = xpath_new_context($mydom); $res =& xpath_eval($xpc, $path); $hashes = array(); require_once "./Services/COPage/classes/class.ilPCParagraph.php"; for ($i = 0; $i < count($res->nodeset); $i++) { $hier_id = $res->nodeset[$i]->get_attribute("HierId"); $pc_id = $res->nodeset[$i]->get_attribute("PCID"); $dump = $mydom->dump_node($res->nodeset[$i]); if (($hpos = strpos($dump, ' HierId="' . $hier_id . '"')) > 0) { $dump = substr($dump, 0, $hpos) . substr($dump, $hpos + strlen(' HierId="' . $hier_id . '"')); } $childs = $res->nodeset[$i]->child_nodes(); $content = ""; if ($childs[0] && $childs[0]->node_name() == "Paragraph") { $content = $mydom->dump_node($childs[0]); $content = substr($content, strpos($content, ">") + 1, strrpos($content, "<") - (strpos($content, ">") + 1)); //var_dump($content); $content = ilPCParagraph::xml2output($content); //var_dump($content); } //$hashes[$hier_id] = // array("PCID" => $pc_id, "hash" => md5($dump)); $hashes[$pc_id] = array("hier_id" => $hier_id, "hash" => md5($dump), "content" => $content); } return $hashes; }
/** * Save input coming from ajax * * @param * @return */ function saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at = "") { global $ilUser; $t = self::handleAjaxContent($a_content); if ($text === false) { return false; } $pc_id = explode(":", $a_pc_id); $insert_at = explode(":", $a_insert_at); $t_id = explode(":", $t["id"]); // insert new paragraph if ($a_insert_at != "") { $par = new ilPCParagraph($this->dom); $par->create($a_pg_obj, $insert_at[0], $insert_at[1]); } else { $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]); } if ($a_insert_at != "") { $pc_id = $a_pg_obj->generatePCId(); $par->writePCId($pc_id); $this->inserted_pc_id = $pc_id; } else { $this->inserted_pc_id = $pc_id[1]; } $par->setLanguage($ilUser->getLanguage()); $par->setCharacteristic($t["class"]); $t2 = $par->input2xml($t["text"], true, false); $t2 = ilPCParagraph::handleAjaxContentPost($t2); $updated = $par->setText($t2, true); if ($updated !== true) { echo $updated; exit; return false; } $updated = $a_pg_obj->update(); return $updated; }
/** * 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(); } } } }
function importCell($lng, &$cellNode, &$aRow) { /*echo "add Cell"; var_dump($cellNode);*/ $aCell = $this->addCell($aRow); $par = new ilPCParagraph($this->getPage()); $par->createAtNode($aCell); $par->setText($par->input2xml($this->extractText($cellNode))); $par->setCharacteristic("TableContent"); $par->setLanguage($lng); $this->importCellAttributes($cellNode, $aCell); }
/** * 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"]); } }
/** * Convert * and # to lists * * @param string $a_text text * @return string text */ static function convertLists($a_text) { include_once "./Services/COPage/classes/class.ilPCParagraph.php"; $a_text = nl2br($a_text); $a_text = str_replace(array("\n", "\r"), "", $a_text); $a_text = str_replace("<br>", "<br />", $a_text); $a_text = ilPCParagraph::input2xmlReplaceLists($a_text); $a_text = str_replace(array("<SimpleBulletList>", "</SimpleBulletList>", "<SimpleListItem>", "</SimpleListItem>", "<SimpleNumberedList>", "</SimpleNumberedList>"), array("<ul class='ilc_list_u_BulletedList'>", "</ul>", "<li class='ilc_list_item_StandardListItem'>", "</li>", "<ol class='ilc_list_o_NumberedList'>", "</ol>"), $a_text); return $a_text; }
/** * 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(); } } }
/** * 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"])); }
/** * Edit data of table */ function editData() { global $lng, $ilCtrl; if (!ilPageEditorGUI::_doJSEditing()) { return $this->editDataCl(); } //var_dump($_GET); //var_dump($_POST); $this->setTabs(); $this->displayValidationError(); include_once "./Services/COPage/classes/class.ilPCParagraph.php"; $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tabledata2.html", "Services/COPage"); $dtpl = $this->tpl; //$dtpl = new ilTemplate("tpl.tabledata.html", true, true, "Services/COPage"); $dtpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "tableAction")); // $dtpl->setVariable("BB_MENU", $this->getBBMenu("cell_0_0")); // $this->tpl->addJavascript("./Services/COPage/phpBB/3_0_5/editor.js"); // $this->tpl->addJavascript("./Services/COPage/js/page_editing.js"); $this->tpl->setVariable("WYSIWYG_ACTION", $ilCtrl->getFormAction($this, "updateJS")); // get all rows $xpc = xpath_new_context($this->dom); $path = "//PageContent[@HierId='" . $this->getHierId() . "']" . "/Table/TableRow"; $res =& xpath_eval($xpc, $path); for ($i = 0; $i < count($res->nodeset); $i++) { $xpc2 = xpath_new_context($this->dom); $path2 = "//PageContent[@HierId='" . $this->getHierId() . "']" . "/Table/TableRow[{$i}+1]/TableData"; $res2 =& xpath_eval($xpc2, $path2); // if this is the first row -> col icons if ($i == 0) { for ($j = 0; $j < count($res2->nodeset); $j++) { if ($j == 0) { $dtpl->touchBlock("empty_td"); } if ($j == 0) { if (count($res2->nodeset) == 1) { $move_type = "none"; } else { $move_type = "forward"; } } else { if ($j == count($res2->nodeset) - 1) { $move_type = "backward"; } else { $move_type = "both"; } } $dtpl->setCurrentBlock("col_icon"); $dtpl->setVariable("COL_ICON_ALT", $lng->txt("content_column")); $dtpl->setVariable("COL_ICON", ilUtil::getImagePath("col.png")); $dtpl->setVariable("COL_ONCLICK", "COL_" . $move_type); $dtpl->setVariable("NR", $j); $dtpl->parseCurrentBlock(); } $dtpl->setCurrentBlock("row"); $dtpl->parseCurrentBlock(); } for ($j = 0; $j < count($res2->nodeset); $j++) { // first col: row icons if ($j == 0) { if ($i == 0) { if (count($res->nodeset) == 1) { $move_type = "none"; } else { $move_type = "forward"; } } else { if ($i == count($res->nodeset) - 1) { $move_type = "backward"; } else { $move_type = "both"; } } $dtpl->setCurrentBlock("row_icon"); $dtpl->setVariable("ROW_ICON_ALT", $lng->txt("content_row")); $dtpl->setVariable("ROW_ICON", ilUtil::getImagePath("row.png")); $dtpl->setVariable("ROW_ONCLICK", "ROW_" . $move_type); $dtpl->setVariable("NR", $i); $dtpl->parseCurrentBlock(); } // cell if ($res2->nodeset[$j]->get_attribute("Hidden") != "Y") { $dtpl->setCurrentBlock("cell"); if (is_array($_POST["cmd"]) && key($_POST["cmd"]) == "update") { $s_text = ilUtil::stripSlashes("cell_" . $i . "_" . $j, false); } else { $s_text = ilPCParagraph::xml2output($this->content_obj->getCellText($i, $j), true, false); include_once "./Services/COPage/classes/class.ilPCParagraphGUI.php"; $s_text = ilPCParagraphGUI::xml2outputJS($s_text, "TableContent", $this->content_obj->readPCId() . "_" . $i . "_" . $j); } $dtpl->setVariable("PAR_TA_NAME", "cell[" . $i . "][" . $j . "]"); $dtpl->setVariable("PAR_TA_ID", "cell_" . $i . "_" . $j); $dtpl->setVariable("PAR_TA_CONTENT", $s_text); $cs = $res2->nodeset[$j]->get_attribute("ColSpan"); $rs = $res2->nodeset[$j]->get_attribute("RowSpan"); $dtpl->setVariable("WIDTH", "140"); $dtpl->setVariable("HEIGHT", "80"); if ($cs > 1) { $dtpl->setVariable("COLSPAN", 'colspan="' . $cs . '"'); $dtpl->setVariable("WIDTH", 140 + ($cs - 1) * 146); } if ($rs > 1) { $dtpl->setVariable("ROWSPAN", 'rowspan="' . $rs . '"'); $dtpl->setVariable("HEIGHT", 80 + ($rs - 1) * 86); } $dtpl->parseCurrentBlock(); } } $dtpl->setCurrentBlock("row"); $dtpl->parseCurrentBlock(); } // init menues $types = array("row", "col"); $moves = array("none", "backward", "both", "forward"); $commands = array("row" => array("newRowAfter" => "cont_ed_new_row_after", "newRowBefore" => "cont_ed_new_row_before", "moveRowUp" => "cont_ed_row_up", "moveRowDown" => "cont_ed_row_down", "deleteRow" => "cont_ed_delete_row"), "col" => array("newColAfter" => "cont_ed_new_col_after", "newColBefore" => "cont_ed_new_col_before", "moveColLeft" => "cont_ed_col_left", "moveColRight" => "cont_ed_col_right", "deleteCol" => "cont_ed_delete_col")); foreach ($types as $type) { foreach ($moves as $move) { foreach ($commands[$type] as $command => $lang_var) { if ($move == "none" && substr($command, 0, 4) == "move") { continue; } if ($move == "backward" && in_array($command, array("movedown", "moveright")) || $move == "forward" && in_array($command, array("moveup", "moveleft"))) { continue; } $this->tpl->setCurrentBlock("menu_item"); $this->tpl->setVariable("MENU_ITEM_TITLE", $lng->txt($lang_var)); $this->tpl->setVariable("CMD", $command); $this->tpl->setVariable("TYPE", $type); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("menu"); $this->tpl->setVariable("TYPE", $type); $this->tpl->setVariable("MOVE", $move); $this->tpl->parseCurrentBlock(); } } $this->tpl->setVariable("FORMACTION2", $ilCtrl->getFormAction($this, "tableAction")); $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_table")); // js editing preparation include_once "./Services/YUI/classes/class.ilYuiUtil.php"; ilYuiUtil::initDragDrop(); ilYuiUtil::initConnection(); ilYuiUtil::initPanel(false); $GLOBALS["tpl"]->addJavascript("Services/RTE/tiny_mce_3_3_9_2/il_tiny_mce_src.js"); $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js"); $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js"); $GLOBALS["tpl"]->addOnloadCode("var preloader = new Image();\n\t\t\tpreloader.src = './templates/default/images/loader.gif';\n\t\t\tilCOPage.setContentCss('" . ilObjStyleSheet::getContentStylePath((int) $this->getStyleId()) . ", " . ilUtil::getStyleSheetLocation() . ", ./Services/COPage/css/tiny_extra.css');\n\t\t\tilCOPage.editTD('cell_0_0');\n\t\t\t\t"); $this->tpl->setVariable("IL_TINY_MENU", ilPageObjectGUI::getTinyMenu($this->pg_obj->getParentType(), false, $this->pg_obj->getParentType() == "wpg", false, $this->getStyleId(), false, true)); }
/** * 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(); } } }
/** * 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->setVariable("FULL_DEF", $this->parent_obj->listDefinitions($_GET["ref_id"], $term["id"], true)); } 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 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); } 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(); } $this->tpl->setCurrentBlock("view_term"); $this->tpl->setVariable("TEXT_TERM", $term["term"]); if (!$this->offline) { if (!empty($filter)) { $ilCtrl->setParameter($this, "term", $filter); $ilCtrl->setParameter($this, "oldoffset", $_GET["oldoffset"]); } $ilCtrl->setParameter($this, "term_id", $term["id"]); $ilCtrl->setParameter($this, "offset", $_GET["offset"]); $this->tpl->setVariable("LINK_VIEW_TERM", $ilCtrl->getLinkTarget($this->parent_obj, "listDefinitions")); $ilCtrl->clearParameters($this); } else { $this->tpl->setVariable("LINK_VIEW_TERM", "term_" . $term["id"] . ".html"); } $this->tpl->setVariable("ANCHOR_TERM", "term_" . $term["id"]); $this->tpl->parseCurrentBlock(); } $ilCtrl->clearParameters($this->parent_obj); }