public function exportQuestion($a_ref_id, $a_image_path = null, $a_output_mode = "presentation") { if ($a_ref_id != "") { $inst_id = ilInternalLink::_extractInstOfTarget($a_ref_id); if (!($inst_id > 0)) { $q_id = ilInternalLink::_extractObjIdOfTarget($a_ref_id); } } $this->q_gui = assQuestionGUI::_getQuestionGUI("", $q_id); if (!is_object($this->q_gui->object)) { return "Error: Question not found."; } $type = $this->q_gui->object->getQuestionType(); if (method_exists($this, $type)) { $this->q_gui->object->setExportImagePath($a_image_path); $this->q_gui->object->feedbackOBJ->setPageObjectOutputMode($a_output_mode); $this->json = $this->q_gui->object->toJSON(); $this->json_decoded = json_decode($this->json); self::$exported[$this->json_decoded->id] = $this->json; self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs; return $this->{$type}(); } else { return "Error: Question Type not implemented/Question editing not finished"; } }
/** * Set node (and media object node) */ function setNode($a_node) { parent::setNode($a_node); // this is the PageContent node $this->iim_node = $a_node->first_child(); $this->med_alias_node = $this->iim_node->first_child(); if (is_object($this->med_alias_node) && $this->med_alias_node->myDOMNode != null) { $id = $this->med_alias_node->get_attribute("OriginId"); $mob_id = ilInternalLink::_extractObjIdOfTarget($id); if (ilObject::_lookupType($mob_id) == "mob") { $this->setMediaObject(new ilObjMediaObject($mob_id)); } } include_once "./Services/COPage/classes/class.ilMediaAliasItem.php"; $this->std_alias_item = new ilMediaAliasItem($this->dom, $this->readHierId(), "Standard", $this->readPCId(), "InteractiveImage"); }
/** * Get all media objects linked in map areas of this media object */ function getLinkedMediaObjects($a_ignore = "") { $linked = array(); if (!is_array($a_ignore)) { $a_ignore = array(); } // get linked media objects (map areas) $med_items = $this->getMediaItems(); foreach ($med_items as $med_item) { $int_links = ilMapArea::_getIntLinks($med_item->getId()); foreach ($int_links as $k => $int_link) { if ($int_link["Type"] == "MediaObject") { include_once "./Services/COPage/classes/class.ilInternalLink.php"; $l_id = ilInternalLink::_extractObjIdOfTarget($int_link["Target"]); if (ilObject::_exists($l_id)) { if (!in_array($l_id, $linked) && !in_array($l_id, $a_ignore)) { $linked[] = $l_id; } } } } } //var_dump($linked); return $linked; }
/** * Get glossary term ids in sco * * @param * @return */ function getGlossaryTermIds() { include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $childs = $this->tree->getChilds($this->getId()); $ids = array(); foreach ($childs as $c) { $links = ilInternalLink::_getTargetsOfSource("sahs" . ":pg", $c["child"]); foreach ($links as $l) { if ($l["type"] == "git" && (int) $l["inst"] == 0 && !isset($ids[$l["id"]])) { $ids[$l["id"]] = ilGlossaryTerm::_lookGlossaryTerm($l["id"]); } } } asort($ids); return $ids; }
/** * Check if internal link refers to a valid target * * @param string $a_type target type ("PageObject" | "StructureObject" | * "GlossaryItem" | "MediaObject") * @param string $a_target target id, e.g. "il__pg_244") * * @return boolean true/false */ function _exists($a_type, $a_target) { global $tree; switch ($a_type) { case "PageObject": case "StructureObject": return ilLMObject::_exists($a_target); break; case "GlossaryItem": return ilGlossaryTerm::_exists($a_target); break; case "MediaObject": return ilObjMediaObject::_exists($a_target); break; case "WikiPage": include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; return ilWikiPage::_exists("wiki", (int) $a_target); break; case "RepositoryItem": if (is_int(strpos($a_target, "_"))) { $ref_id = ilInternalLink::_extractObjIdOfTarget($a_target); return $tree->isInTree($ref_id); } break; } return false; }
/** * delete wiki page and al related data * * @access public */ function delete() { global $ilDB; // delete internal links information to this page include_once "./Services/COPage/classes/class.ilInternalLink.php"; ilInternalLink::_deleteAllLinksToTarget("user", $this->getId()); // delete record of table usr_ext_profile_page $query = "DELETE FROM usr_ext_profile_page" . " WHERE id = " . $ilDB->quote($this->getId(), "integer"); $ilDB->manipulate($query); // delete co page parent::delete(); return true; }
/** * export all pages of learning module to html file */ function exportHTMLPages(&$a_lm_gui, $a_target_dir) { global $tpl, $ilBench, $ilLocator; $pages = ilLMPageObject::getPageList($this->getId()); $lm_tree =& $this->getLMTree(); $first_page = $lm_tree->fetchSuccessorNode($lm_tree->getRootId(), "pg"); $this->first_page_id = $first_page["child"]; // iterate all learning module pages $mobs = array(); $int_links = array(); $this->offline_files = array(); include_once "./Services/COPage/classes/class.ilPageContentUsage.php"; include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; // get html export id mapping $lm_set = new ilSetting("lm"); $exp_id_map = array(); if ($lm_set->get("html_export_ids")) { foreach ($pages as $page) { $exp_id = ilLMPageObject::getExportId($this->getId(), $page["obj_id"]); if (trim($exp_id) != "") { $exp_id_map[$page["obj_id"]] = trim($exp_id); } } } //exit; reset($pages); foreach ($pages as $page) { if (ilLMPage::_exists($this->getType(), $page["obj_id"])) { $ilLocator->clearItems(); $ilBench->start("ExportHTML", "exportHTMLPage"); $ilBench->start("ExportHTML", "exportPageHTML"); $this->exportPageHTML($a_lm_gui, $a_target_dir, $page["obj_id"], "", $exp_id_map); $ilBench->stop("ExportHTML", "exportPageHTML"); // get all snippets of page $pcs = ilPageContentUsage::getUsagesOfPage($page["obj_id"], $this->getType() . ":pg"); foreach ($pcs as $pc) { if ($pc["type"] == "incl") { $incl_mobs = ilObjMediaObject::_getMobsOfObject("mep:pg", $pc["id"]); foreach ($incl_mobs as $incl_mob) { $mobs[$incl_mob] = $incl_mob; } } } // get all media objects of page $pg_mobs = ilObjMediaObject::_getMobsOfObject($this->getType() . ":pg", $page["obj_id"]); foreach ($pg_mobs as $pg_mob) { $mobs[$pg_mob] = $pg_mob; } // get all internal links of page $pg_links = ilInternalLink::_getTargetsOfSource($this->getType() . ":pg", $page["obj_id"]); $int_links = array_merge($int_links, $pg_links); // get all files of page include_once "./Modules/File/classes/class.ilObjFile.php"; $pg_files = ilObjFile::_getFilesOfObject($this->getType() . ":pg", $page["obj_id"]); $this->offline_files = array_merge($this->offline_files, $pg_files); $ilBench->stop("ExportHTML", "exportHTMLPage"); } } $this->offline_mobs = $mobs; $this->offline_int_links = $int_links; }
/** * resolve internal links of an item id */ function _resolveIntLinks($a_item_id) { global $ilDB; //echo "maparea::resolve<br>"; $q = "SELECT * FROM map_area WHERE item_id = " . $ilDB->quote($a_item_id, "integer"); $area_set = $ilDB->query($q); while ($area_rec = $ilDB->fetchAssoc($area_set)) { $target = $area_rec["target"]; $type = $area_rec["type"]; $item_id = $area_rec["item_id"]; $nr = $area_rec["nr"]; if ($area_rec["link_type"] == IL_INT_LINK && !is_int(strpos($target, "__"))) { $new_target = ilInternalLink::_getIdForImportId($type, $target); if ($new_target !== false) { $query = "UPDATE map_area SET " . "target = " . $ilDB->quote($new_target, "text") . " " . "WHERE item_id = " . $ilDB->quote($item_id, "integer") . " AND nr = " . $ilDB->quote($nr, "integer"); $ilDB->manipulate($query); } } } }
/** * Set tabs */ function setTabs() { global $ilTabs, $ilCtrl, $lng; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; if ($this->content_obj != "") { $q_ref = $this->content_obj->getQuestionReference(); } if ($q_ref != "") { $inst_id = ilInternalLink::_extractInstOfTarget($q_ref); if (!($inst_id > 0)) { $q_id = ilInternalLink::_extractObjIdOfTarget($q_ref); } } $ilTabs->addTarget("question", $ilCtrl->getLinkTarget($this, "edit"), array("editQuestion", "save", "cancel", "addSuggestedSolution", "cancelExplorer", "linkChilds", "removeSuggestedSolution", "addPair", "addTerm", "delete", "deleteTerms", "editMode", "upload", "saveEdit", "uploadingImage", "uploadingImagemap", "addArea", "deletearea", "saveShape", "back", "saveEdit", "changeGapType", "createGaps", "addItem", "addYesNo", "addTrueFalse", "toggleGraphicalAnswers", "setMediaMode"), ""); if ($q_id > 0) { if (assQuestion::_getQuestionType($q_id) != "assTextQuestion") { $ilTabs->addTarget("feedback", $ilCtrl->getLinkTarget($this, "feedback"), array("feedback", "saveFeedback"), ""); } } }
/** * display content of page */ function showPage() { global $tree, $ilUser, $lng, $ilCtrl, $ilSetting, $ilTabs; // jquery and jquery ui are always provided for components include_once "./Services/jQuery/classes/class.iljQueryUtil.php"; iljQueryUtil::initjQuery(); iljQueryUtil::initjQueryUI(); // $this->initSelfAssessmentRendering(); include_once "./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php"; ilObjMediaObjectGUI::includePresentationJS($GLOBALS["tpl"]); $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilCOPagePres.js"); // needed for overlays in iim include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php"; ilOverlayGUI::initJavascript(); include_once "./Services/MediaObjects/classes/class.ilPlayerUtil.php"; ilPlayerUtil::initMediaElementJs($GLOBALS["tpl"]); // init template //if($this->outputToTemplate()) //{ if ($this->getOutputMode() == "edit") { //echo ":".$this->getTemplateTargetVar().":"; $tpl = new ilTemplate("tpl.page_edit_wysiwyg.html", true, true, "Services/COPage"); //$this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_edit_wysiwyg.html", "Services/COPage"); // to do: status dependent class $tpl->setVariable("CLASS_PAGE_TD", "ilc_Page"); // user comment if ($this->isEnabledChangeComments()) { $tpl->setCurrentBlock("change_comment"); $tpl->setVariable("TXT_ADD_COMMENT", $this->lng->txt("cont_add_change_comment")); $tpl->parseCurrentBlock(); } $tpl->setVariable("WYSIWYG_ACTION", $ilCtrl->getFormActionByClass("ilpageeditorgui", "", "", true)); // determine media, html and javascript mode $sel_media_mode = $ilUser->getPref("ilPageEditor_MediaMode") == "disable" ? "disable" : "enable"; $sel_html_mode = $ilUser->getPref("ilPageEditor_HTMLMode") == "disable" ? "disable" : "enable"; $sel_js_mode = "disable"; //if($ilSetting->get("enable_js_edit", 1)) //{ $sel_js_mode = ilPageEditorGUI::_doJSEditing() ? "enable" : "disable"; //} // show prepending html $tpl->setVariable("PREPENDING_HTML", $this->getPrependingHtml()); $tpl->setVariable("TXT_CONFIRM_DELETE", $lng->txt("cont_confirm_delete")); // presentation view if ($this->getViewPageLink() != "") { $ilTabs->addNonTabbedLink("pres_view", $this->lng->txt("cont_presentation_view"), $this->getViewPageLink(), $this->getViewPageTarget()); } // show actions drop down $this->addActionsMenu($tpl, $sel_media_mode, $sel_html_mode, $sel_js_mode); // get js files for JS enabled editing if ($sel_js_mode == "enable") { $this->insertHelp($tpl); include_once "./Services/YUI/classes/class.ilYuiUtil.php"; ilYuiUtil::initDragDrop(); ilYuiUtil::initConnection(); ilYuiUtil::initPanel(false); $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js"); $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js"); include_once './Services/Style/classes/class.ilObjStyleSheet.php'; $GLOBALS["tpl"]->addOnloadCode("var preloader = new Image();\n\t\t\t\t\t\tpreloader.src = './templates/default/images/loader.svg';\n\t\t\t\t\t\tilCOPage.setContentCss('" . ilObjStyleSheet::getContentStylePath((int) $this->getStyleId()) . ", " . ilUtil::getStyleSheetLocation() . ", ./Services/COPage/css/tiny_extra.css" . "')"); //$GLOBALS["tpl"]->addJavascript("Services/RTE/tiny_mce_3_3_9_2/il_tiny_mce_src.js"); $GLOBALS["tpl"]->addJavascript("Services/COPage/tiny/4_1_5/tinymce.js"); $tpl->touchBlock("init_dragging"); $cfg = $this->getPageConfig(); $tpl->setVariable("IL_TINY_MENU", self::getTinyMenu($this->getPageObject()->getParentType(), $cfg->getEnableInternalLinks(), $cfg->getEnableWikiLinks(), $cfg->getEnableKeywords(), $this->getStyleId(), true, true, $cfg->getEnableAnchors())); // add int link parts include_once "./Services/Link/classes/class.ilInternalLinkGUI.php"; $tpl->setCurrentBlock("int_link_prep"); $tpl->setVariable("INT_LINK_PREP", ilInternalLinkGUI::getInitHTML($ilCtrl->getLinkTargetByClass(array("ilpageeditorgui", "ilinternallinkgui"), "", false, true, false))); $tpl->parseCurrentBlock(); include_once "./Services/YUI/classes/class.ilYuiUtil.php"; ilYuiUtil::initConnection(); $GLOBALS["tpl"]->addJavaScript("./Services/UIComponent/Explorer/js/ilExplorer.js"); } // multiple actions $cnt_pcs = $this->getPageObject()->countPageContents(); if ($cnt_pcs > 1 || $this->getPageObject()->getParentType() != "qpl" && $cnt_pcs > 0) { $tpl->setCurrentBlock("multi_actions"); if ($sel_js_mode == "enable") { $tpl->setVariable("ONCLICK_DE_ACTIVATE_SELECTED", 'onclick="return ilEditMultiAction(\'activateSelected\');"'); $tpl->setVariable("ONCLICK_DELETE_SELECTED", 'onclick="return ilEditMultiAction(\'deleteSelected\');"'); $tpl->setVariable("ONCLICK_ASSIGN_CHARACTERISTIC", 'onclick="return ilEditMultiAction(\'assignCharacteristicForm\');"'); $tpl->setVariable("ONCLICK_COPY_SELECTED", 'onclick="return ilEditMultiAction(\'copySelected\');"'); $tpl->setVariable("ONCLICK_CUT_SELECTED", 'onclick="return ilEditMultiAction(\'cutSelected\');"'); $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all")); $tpl->setVariable("ONCLICK_SELECT_ALL", 'onclick="return ilEditMultiAction(\'selectAll\');"'); } $tpl->setVariable("TXT_DE_ACTIVATE_SELECTED", $this->lng->txt("cont_ed_enable")); $tpl->setVariable("TXT_ASSIGN_CHARACTERISTIC", $this->lng->txt("cont_assign_characteristic")); $tpl->setVariable("TXT_DELETE_SELECTED", $this->lng->txt("cont_delete_selected")); $tpl->setVariable("TXT_COPY_SELECTED", $this->lng->txt("copy")); $tpl->setVariable("TXT_CUT_SELECTED", $this->lng->txt("cut")); $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg")); $tpl->parseCurrentBlock(); } } else { // presentation or preview here $tpl = new ilTemplate("tpl.page.html", true, true, "Services/COPage"); if ($this->getEnabledPageFocus()) { $tpl->touchBlock("page_focus"); } include_once "./Services/User/classes/class.ilUserUtil.php"; // presentation if ($this->isPageContainerToBeRendered()) { $tpl->touchBlock("page_container_1"); $tpl->touchBlock("page_container_2"); $tpl->touchBlock("page_container_3"); } // history $c_old_nr = $this->getPageObject()->old_nr; if ($c_old_nr > 0 || $this->getCompareMode() || $_GET["history_mode"] == 1) { $hist_info = $this->getPageObject()->getHistoryInfo($c_old_nr); if (!$this->getCompareMode()) { $ilCtrl->setParameter($this, "history_mode", "1"); // previous revision if (is_array($hist_info["previous"])) { $tpl->setCurrentBlock("previous_rev"); $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev")); $ilCtrl->setParameter($this, "old_nr", $hist_info["previous"]["nr"]); $tpl->setVariable("HREF_PREV", $ilCtrl->getLinkTarget($this, "preview")); $tpl->parseCurrentBlock(); } else { $tpl->setCurrentBlock("previous_rev_disabled"); $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev")); $tpl->parseCurrentBlock(); } // next revision if ($c_old_nr > 0) { $tpl->setCurrentBlock("next_rev"); $tpl->setVariable("TXT_NEXT_REV", $lng->txt("cont_next_rev")); $ilCtrl->setParameter($this, "old_nr", $hist_info["next"]["nr"]); $tpl->setVariable("HREF_NEXT", $ilCtrl->getLinkTarget($this, "preview")); $tpl->parseCurrentBlock(); // latest revision $tpl->setCurrentBlock("latest_rev"); $tpl->setVariable("TXT_LATEST_REV", $lng->txt("cont_latest_rev")); $ilCtrl->setParameter($this, "old_nr", ""); $tpl->setVariable("HREF_LATEST", $ilCtrl->getLinkTarget($this, "preview")); $tpl->parseCurrentBlock(); } $ilCtrl->setParameter($this, "history_mode", ""); // rollback if ($c_old_nr > 0 && $ilUser->getId() != ANONYMOUS_USER_ID) { $tpl->setCurrentBlock("rollback"); $ilCtrl->setParameter($this, "old_nr", $c_old_nr); $tpl->setVariable("HREF_ROLLBACK", $ilCtrl->getLinkTarget($this, "rollbackConfirmation")); $ilCtrl->setParameter($this, "old_nr", ""); $tpl->setVariable("TXT_ROLLBACK", $lng->txt("cont_rollback")); $tpl->parseCurrentBlock(); } } $tpl->setCurrentBlock("hist_nav"); $tpl->setVariable("TXT_REVISION", $lng->txt("cont_revision")); $tpl->setVariable("VAL_REVISION_DATE", ilDatePresentation::formatDate(new ilDateTime($hist_info["current"]["hdate"], IL_CAL_DATETIME))); $tpl->setVariable("VAL_REV_USER", ilUserUtil::getNamePresentation($hist_info["current"]["user_id"])); $tpl->parseCurrentBlock(); } } if ($this->getOutputMode() != IL_PAGE_PRESENTATION && $this->getOutputMode() != IL_PAGE_OFFLINE && $this->getOutputMode() != IL_PAGE_PREVIEW && $this->getOutputMode() != IL_PAGE_PRINT) { $tpl->setVariable("FORMACTION", $this->ctrl->getFormActionByClass("ilpageeditorgui")); } // output media object edit list (of media links) if ($this->getOutputMode() == "edit") { $links = ilInternalLink::_getTargetsOfSource($this->obj->getParentType() . ":pg", $this->obj->getId(), $this->obj->getLanguage()); $mob_links = array(); foreach ($links as $link) { if ($link["type"] == "mob") { if (ilObject::_exists($link["id"]) && ilObject::_lookupType($link["id"]) == "mob") { $mob_links[$link["id"]] = ilObject::_lookupTitle($link["id"]) . " [" . $link["id"] . "]"; } } } // linked media objects if (count($mob_links) > 0) { $tpl->setCurrentBlock("med_link"); $tpl->setVariable("TXT_LINKED_MOBS", $this->lng->txt("cont_linked_mobs")); $tpl->setVariable("SEL_MED_LINKS", ilUtil::formSelect(0, "mob_id", $mob_links, false, true)); $tpl->setVariable("TXT_EDIT_MEDIA", $this->lng->txt("cont_edit_mob")); $tpl->setVariable("TXT_COPY_TO_CLIPBOARD", $this->lng->txt("cont_copy_to_clipboard")); //$this->tpl->setVariable("TXT_COPY_TO_POOL", $this->lng->txt("cont_copy_to_mediapool")); $tpl->parseCurrentBlock(); } // content snippets used include_once "./Services/COPage/classes/class.ilPCContentInclude.php"; $snippets = ilPCContentInclude::collectContentIncludes($this->getPageObject(), $this->getPageObject()->getDomDoc()); if (count($snippets) > 0) { foreach ($snippets as $s) { include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php"; $sn_arr[$s["id"]] = ilMediaPoolPage::lookupTitle($s["id"]); } $tpl->setCurrentBlock("med_link"); $tpl->setVariable("TXT_CONTENT_SNIPPETS_USED", $this->lng->txt("cont_snippets_used")); $tpl->setVariable("SEL_SNIPPETS", ilUtil::formSelect(0, "ci_id", $sn_arr, false, true)); $tpl->setVariable("TXT_SHOW_INFO", $this->lng->txt("cont_show_info")); $tpl->parseCurrentBlock(); } // scheduled activation? if (!$this->getPageObject()->getActive() && $this->getPageObject()->getActivationStart() != "" && $this->getPageConfig()->getEnableScheduledActivation()) { $tpl->setCurrentBlock("activation_txt"); $tpl->setVariable("TXT_SCHEDULED_ACTIVATION", $lng->txt("cont_scheduled_activation")); $tpl->setVariable("SA_FROM", ilDatePresentation::formatDate(new ilDateTime($this->getPageObject()->getActivationStart(), IL_CAL_DATETIME))); $tpl->setVariable("SA_TO", ilDatePresentation::formatDate(new ilDateTime($this->getPageObject()->getActivationEnd(), IL_CAL_DATETIME))); $tpl->parseCurrentBlock(); } } if ($_GET["reloadTree"] == "y") { $tpl->setCurrentBlock("reload_tree"); if ($this->obj->getParentType() == "dbk") { $tpl->setVariable("LINK_TREE", $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer", "", false, false)); } else { $tpl->setVariable("LINK_TREE", $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer", "", false, false)); } $tpl->parseCurrentBlock(); } // } // get content $builded = $this->obj->buildDom(); // manage hierarchical ids if ($this->getOutputMode() == "edit") { // add pc ids, if necessary if (!$this->obj->checkPCIds()) { $this->obj->insertPCIds(); $this->obj->update(true, true); } $this->obj->addFileSizes(); $this->obj->addHierIDs(); $hids = $this->obj->getHierIds(); $row1_ids = $this->obj->getFirstRowIds(); $col1_ids = $this->obj->getFirstColumnIds(); $litem_ids = $this->obj->getListItemIds(); $fitem_ids = $this->obj->getFileItemIds(); // standard menues $hids = $this->obj->getHierIds(); foreach ($hids as $hid) { $tpl->setCurrentBlock("add_dhtml"); $tpl->setVariable("CONTEXTMENU", "contextmenu_" . $hid); $tpl->parseCurrentBlock(); } // column menues for tables foreach ($col1_ids as $hid) { $tpl->setCurrentBlock("add_dhtml"); $tpl->setVariable("CONTEXTMENU", "contextmenu_r" . $hid); $tpl->parseCurrentBlock(); } // row menues for tables foreach ($row1_ids as $hid) { $tpl->setCurrentBlock("add_dhtml"); $tpl->setVariable("CONTEXTMENU", "contextmenu_c" . $hid); $tpl->parseCurrentBlock(); } // list item menues foreach ($litem_ids as $hid) { $tpl->setCurrentBlock("add_dhtml"); $tpl->setVariable("CONTEXTMENU", "contextmenu_i" . $hid); $tpl->parseCurrentBlock(); } // file item menues foreach ($fitem_ids as $hid) { $tpl->setCurrentBlock("add_dhtml"); $tpl->setVariable("CONTEXTMENU", "contextmenu_i" . $hid); $tpl->parseCurrentBlock(); } } else { $this->obj->addFileSizes(); } //echo "<br>-".htmlentities($this->obj->getXMLContent())."-<br><br>"; //echo "<br>-".htmlentities($this->getLinkXML())."-"; // set default link xml, if nothing was set yet if (!$this->link_xml_set) { $this->setDefaultLinkXml(); } //$content = $this->obj->getXMLFromDom(false, true, true, // $this->getLinkXML().$this->getQuestionXML().$this->getComponentPluginsXML()); $link_xml = $this->getLinkXML(); // disable/enable auto margins if ($this->getStyleId() > 0) { if (ilObject::_lookupType($this->getStyleId()) == "sty") { include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $style = new ilObjStyleSheet($this->getStyleId()); $template_xml = $style->getTemplateXML(); $disable_auto_margins = "n"; if ($style->lookupStyleSetting("disable_auto_margins")) { $disable_auto_margins = "y"; } } } if ($this->getAbstractOnly()) { $content = "<dummy><PageObject><PageContent><Paragraph>" . $this->obj->getFirstParagraphText() . $link_xml . "</Paragraph></PageContent></PageObject></dummy>"; } else { $content = $this->obj->getXMLFromDom(false, true, true, $link_xml . $this->getQuestionXML() . $template_xml . $this->getComponentPluginsXML()); } // check validation errors if ($builded !== true) { $this->displayValidationError($builded); } else { $this->displayValidationError($_SESSION["il_pg_error"]); } unset($_SESSION["il_pg_error"]); if (isset($_SESSION["citation_error"])) { ilUtil::sendFailure($this->lng->txt("cont_citation_selection_not_valid")); ilSession::clear("citation_error"); } // get title $pg_title = $this->getPresentationTitle(); $col_path = ilUtil::getImagePath("col.svg"); $row_path = ilUtil::getImagePath("row.svg"); $item_path = ilUtil::getImagePath("item.svg"); if ($this->getOutputMode() != "offline") { $enlarge_path = ilUtil::getImagePath("enlarge.svg"); $wb_path = ilUtil::getWebspaceDir("output") . "/"; } else { $enlarge_path = "images/enlarge.svg"; $wb_path = ""; } $pg_title_class = $this->getOutputMode() == "print" ? "ilc_PrintPageTitle" : ""; // page splitting only for learning modules and // digital books $enable_split_new = $this->obj->getParentType() == "lm" || $this->obj->getParentType() == "dbk" ? "y" : "n"; // page splitting to next page only for learning modules and // digital books if next page exists in tree if (($this->obj->getParentType() == "lm" || $this->obj->getParentType() == "dbk") && ilObjContentObject::hasSuccessorPage($this->obj->getParentId(), $this->obj->getId())) { $enable_split_next = "y"; } else { $enable_split_next = "n"; } $img_path = ilUtil::getImagePath("", false, $this->getOutputMode(), $this->getOutputMode() == "offline"); if ($this->getPageConfig()->getEnablePCType("Tabs")) { //include_once("./Services/YUI/classes/class.ilYuiUtil.php"); //ilYuiUtil::initTabView(); include_once "./Services/Accordion/classes/class.ilAccordionGUI.php"; ilAccordionGUI::addJavaScript(); ilAccordionGUI::addCss(); } $file_download_link = $this->determineFileDownloadLink(); $fullscreen_link = $this->determineFullscreenLink(); $this->sourcecode_download_script = $this->determineSourcecodeDownloadScript(); // default values for various parameters (should be used by // all instances in the future) $media_mode = $this->getOutputMode() == "edit" ? $ilUser->getPref("ilPageEditor_MediaMode") : "enable"; include_once "./Modules/LearningModule/classes/class.ilEditClipboard.php"; $paste = ilEditClipboard::getAction() == "copy" && $this->getOutputMode() == "edit"; include_once "./Services/MediaObjects/classes/class.ilPlayerUtil.php"; $flv_video_player = $this->getOutputMode() != "offline" ? ilPlayerUtil::getFlashVideoPlayerFilename(true) : ilPlayerUtil::getFlashVideoPlayerFilename(true); $cfg = $this->getPageConfig(); // added UTF-8 encoding otherwise umlaute are converted too include_once "./Services/Maps/classes/class.ilMapUtil.php"; $params = array('mode' => $this->getOutputMode(), 'pg_title' => htmlentities($pg_title, ENT_QUOTES, "UTF-8"), 'enable_placeholder' => $cfg->getEnablePCType("PlaceHolder") ? "y" : "n", 'pg_id' => $this->obj->getId(), 'pg_title_class' => $pg_title_class, 'webspace_path' => $wb_path, 'enlarge_path' => $enlarge_path, 'img_col' => $col_path, 'img_row' => $row_path, 'img_item' => $item_path, 'enable_split_new' => $enable_split_new, 'enable_split_next' => $enable_split_next, 'link_params' => $this->link_params, 'file_download_link' => $file_download_link, 'fullscreen_link' => $fullscreen_link, 'img_path' => $img_path, 'parent_id' => $this->obj->getParentId(), 'download_script' => $this->sourcecode_download_script, 'encoded_download_script' => urlencode($this->sourcecode_download_script), 'bib_id' => $this->getBibId(), 'citation' => (int) $this->isEnabledCitation(), 'pagebreak' => $this->lng->txt('dgl_pagebreak'), 'page' => $this->lng->txt('page'), 'citate_page' => $this->lng->txt('citate_page'), 'citate_from' => $this->lng->txt('citate_from'), 'citate_to' => $this->lng->txt('citate_to'), 'citate' => $this->lng->txt('citate'), 'enable_rep_objects' => $cfg->getEnablePCType("Resources") ? "y" : "n", 'enable_login_page' => $cfg->getEnablePCType("LoginPageElement") ? "y" : "n", 'enable_map' => $cfg->getEnablePCType("Map") && ilMapUtil::isActivated() ? "y" : "n", 'enable_tabs' => $cfg->getEnablePCType("Tabs") ? "y" : "n", 'enable_sa_qst' => $cfg->getEnableSelfAssessment() ? "y" : "n", 'enable_file_list' => $cfg->getEnablePCType("FileList") ? "y" : "n", 'enable_content_includes' => $cfg->getEnablePCType("ContentInclude") ? "y" : "n", 'enable_content_templates' => count($this->getPageObject()->getContentTemplates()) > 0 ? "y" : "n", 'paste' => $paste ? "y" : "n", 'media_mode' => $media_mode, 'javascript' => $sel_js_mode, 'paragraph_plugins' => $paragraph_plugin_string, 'disable_auto_margins' => $disable_auto_margins, 'page_toc' => $cfg->getEnablePageToc() ? "y" : "n", 'enable_profile' => $cfg->getEnablePCType("Profile") ? "y" : "n", 'enable_verification' => $cfg->getEnablePCType("Verification") ? "y" : "n", 'enable_blog' => $cfg->getEnablePCType("Blog") ? "y" : "n", 'enable_skills' => $cfg->getEnablePCType("Skills") ? "y" : "n", 'enable_qover' => $cfg->getEnablePCType("QuestionOverview") ? "y" : "n", 'enable_consultation_hours' => $cfg->getEnablePCType("ConsultationHours") ? "y" : "n", 'enable_my_courses' => $cfg->getEnablePCType("MyCourses") ? "y" : "n", 'enable_amd_page_list' => $cfg->getEnablePCType("AMDPageList") ? "y" : "n", 'flv_video_player' => $flv_video_player); if ($this->link_frame != "") { // todo other link types $params["pg_frame"] = $this->link_frame; } //$content = str_replace(" ", "", $content); // this ensures that cache is emptied with every update $params["version"] = ILIAS_VERSION; // ensure no cache hit, if included files/media objects have been changed $params["incl_elements_date"] = $this->obj->getLastUpdateOfIncludedElements(); // run xslt $md5 = md5(serialize($params) . $link_xml . $template_xml); //$a = microtime(); // check cache (same parameters, non-edit mode and rendered time // > last change if (($this->getOutputMode() == "preview" || $this->getOutputMode() == "presentation") && !$this->getCompareMode() && !$this->getAbstractOnly() && $md5 == $this->obj->getRenderMd5() && $this->obj->getLastChange() < $this->obj->getRenderedTime() && $this->obj->getRenderedTime() != "" && $this->obj->old_nr == 0) { // cache hit $output = $this->obj->getRenderedContent(); } else { $xsl = file_get_contents("./Services/COPage/xsl/page.xsl"); $args = array('/_xml' => $content, '/_xsl' => $xsl); $xh = xslt_create(); // echo "<b>XSLT</b>:".htmlentities($xsl).":<br>"; // echo "mode:".$this->getOutputMode().":<br>"; $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params); if (($this->getOutputMode() == "presentation" || $this->getOutputMode() == "preview") && !$this->getAbstractOnly() && $this->obj->old_nr == 0) { //echo "writerenderedcontent"; $this->obj->writeRenderedContent($output, $md5); } //echo xslt_error($xh); xslt_free($xh); } //$b = microtime(); //echo "$a - $b"; //echo "<pre>".htmlentities($output)."</pre>"; // unmask user html if (($this->getOutputMode() != "edit" || $ilUser->getPref("ilPageEditor_HTMLMode") != "disable") && !$this->getPageConfig()->getPreventHTMLUnmasking()) { $output = str_replace("<", "<", $output); $output = str_replace(">", ">", $output); } $output = str_replace("&", "&", $output); $output = ilUtil::insertLatexImages($output); // insert page snippets $output = $this->insertContentIncludes($output); // insert resource blocks $output = $this->insertResources($output); // insert page toc if ($this->getPageConfig()->getEnablePageToc()) { $output = $this->insertPageToc($output); } // insert advanced output trigger $output = $this->insertAdvTrigger($output); // workaround for preventing template engine // from hiding paragraph text that is enclosed // in curly brackets (e.g. "{a}", see ilLMEditorGUI::executeCommand()) $output = $this->replaceCurlyBrackets($output); // remove all newlines (important for code / pre output) $output = str_replace("\n", "", $output); //echo htmlentities($output); $output = $this->postOutputProcessing($output); //echo htmlentities($output); if ($this->getOutputMode() == "edit" && !$this->getPageObject()->getActive($this->getPageConfig()->getEnableScheduledActivation())) { $output = '<div class="il_editarea_disabled">' . $output . '</div>'; } // for all page components... include_once "./Services/COPage/classes/class.ilCOPagePCDef.php"; $defs = ilCOPagePCDef::getPCDefinitions(); foreach ($defs as $def) { ilCOPagePCDef::requirePCClassByName($def["name"]); $pc_class = $def["pc_class"]; $pc_obj = new $pc_class($this->getPageObject()); // post xsl page content modification by pc elements $output = $pc_obj->modifyPageContentPostXsl($output, $this->getOutputMode()); // javascript files $js_files = $pc_obj->getJavascriptFiles($this->getOutputMode()); foreach ($js_files as $js) { $GLOBALS["tpl"]->addJavascript($js); } // css files $css_files = $pc_obj->getCssFiles($this->getOutputMode()); foreach ($css_files as $css) { $GLOBALS["tpl"]->addCss($css); } // onload code $onload_code = $pc_obj->getOnloadCode($this->getOutputMode()); foreach ($onload_code as $code) { $GLOBALS["tpl"]->addOnloadCode($code); } } // $output = $this->selfAssessmentRendering($output); // output if ($ilCtrl->isAsynch() && !$this->getRawPageContent() && $this->getOutputMode() == "edit") { // e.g. ###3:110dad8bad6df8620071a0a693a2d328### if ($_GET["updated_pc_id_str"] != "") { echo $_GET["updated_pc_id_str"]; } $tpl->setVariable($this->getTemplateOutputVar(), $output); $tpl->setCurrentBlock("edit_page"); $tpl->parseCurrentBlock(); echo $tpl->get("edit_page"); exit; } if ($this->outputToTemplate()) { $tpl->setVariable($this->getTemplateOutputVar(), $output); $this->tpl->setVariable($this->getTemplateTargetVar(), $tpl->get()); return $output; } else { if ($this->getRawPageContent()) { return $output; } else { $tpl->setVariable($this->getTemplateOutputVar(), $output); return $tpl->get(); } } }
/** * Get initial opened content * * @param */ function getInitialOpenedContent() { $this->buildDom(); $xpc = xpath_new_context($this->dom); $path = "//PageObject/InitOpenedContent"; $res = xpath_eval($xpc, $path); $il_node = null; if (count($res->nodeset) > 0) { $init_node = $res->nodeset[0]; $childs = $init_node->child_nodes(); for ($i = 0; $i < count($childs); $i++) { if ($childs[$i]->node_name() == "IntLink") { $il_node = $childs[$i]; } } } if (!is_null($il_node)) { $id = $il_node->get_attribute("Target"); $link_type = $il_node->get_attribute("Type"); $target = $il_node->get_attribute("TargetFrame"); switch ($link_type) { case "MediaObject": $type = "media"; break; case "PageObject": $type = "page"; break; case "GlossaryItem": $type = "term"; break; } include_once "./Services/Link/classes/class.ilInternalLink.php"; $id = ilInternalLink::_extractObjIdOfTarget($id); return array("id" => $id, "type" => $type, "target" => $target); } return array(); }
/** * Check if internal link refers to a valid target * * @param string $a_type target type ("PageObject" | "StructureObject" | * "GlossaryItem" | "MediaObject") * @param string $a_target target id, e.g. "il__pg_244") * * @return boolean true/false */ function _exists($a_type, $a_target) { global $tree; switch ($a_type) { case "PageObject": case "StructureObject": return ilLMObject::_exists($a_target); break; case "GlossaryItem": return ilGlossaryTerm::_exists($a_target); break; case "MediaObject": return ilObjMediaObject::_exists($a_target); break; case "RepositoryItem": if (is_int(strpos($a_target, "_"))) { $ref_id = ilInternalLink::_extractObjIdOfTarget($a_target); return $tree->isInTree($ref_id); } break; } return false; }
/** * After page has been updated (or created) * * @param object page object * @param DOMDocument $a_domdoc dom document * @param string xml * @param bool true on creation, otherwise false */ static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation) { global $ilDB; include_once "./Services/Link/classes/class.ilInternalLink.php"; $ilDB->manipulateF("DELETE FROM page_question WHERE page_parent_type = %s " . " AND page_id = %s AND page_lang = %s", array("text", "integer", "text"), array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage())); $xpath = new DOMXPath($a_domdoc); $nodes = $xpath->query('//Question'); $q_ids = array(); foreach ($nodes as $node) { $q_ref = $node->getAttribute("QRef"); $inst_id = ilInternalLink::_extractInstOfTarget($q_ref); if (!($inst_id > 0)) { $q_id = ilInternalLink::_extractObjIdOfTarget($q_ref); if ($q_id > 0) { $q_ids[$q_id] = $q_id; } } } foreach ($q_ids as $qid) { $ilDB->manipulateF("INSERT INTO page_question (page_parent_type, page_id, page_lang, question_id)" . " VALUES (%s,%s,%s,%s)", array("text", "integer", "text", "integer"), array($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $qid)); } }
function _resolveIntLinks($question_id) { global $ilDB; $resolvedlinks = 0; $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s", array('integer'), array($question_id)); if ($result->numRows()) { while ($row = $ilDB->fetchAssoc($result)) { $internal_link = $row["internal_link"]; include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; $resolved_link = SurveyQuestion::_resolveInternalLink($internal_link); if (strcmp($internal_link, $resolved_link) != 0) { // internal link was resolved successfully $affectedRows = $ilDB->manipulateF("UPDATE svy_material SET internal_link = %s, tstamp = %s WHERE material_id = %s", array('text', 'integer', 'integer'), array($resolved_link, time(), $row["material_id"])); $resolvedlinks++; } } } if ($resolvedlinks) { // there are resolved links -> reenter theses links to the database // delete all internal links from the database include_once "./Services/Link/classes/class.ilInternalLink.php"; ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id); $result = $ilDB->queryF("SELECT * FROM svy_material WHERE question_fi = %s", array('integer'), array($question_id)); if ($result->numRows()) { while ($row = $ilDB->fetchAssoc($result)) { if (preg_match("/il_(\\d*?)_(\\w+)_(\\d+)/", $row["internal_link"], $matches)) { ilInternalLink::_saveLink("sqst", $question_id, $matches[2], $matches[3], $matches[1]); } } } } }
/** * Get number of usages * * @param int term id * @return int number of usages */ static function getUsages($a_term_id) { include_once "./Services/COPage/classes/class.ilInternalLink.php"; return ilInternalLink::_getSourcesOfTarget("git", $a_term_id, 0); }
/** * 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": $page_obj =& new ilPageObject($this->content_object->getType(), $page_arr[1]); break; case "gdf": $page_obj =& new ilPageObject("gdf", $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]; $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") { $page_object = new ilPageObject($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; } } }
/** * 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(); } }
/** * Set tabs */ function setTabs() { if ($this->getSelfAssessmentMode()) { return; } global $ilTabs, $ilCtrl, $lng; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; if ($this->content_obj != "") { $q_ref = $this->content_obj->getQuestionReference(); } if ($q_ref != "") { $inst_id = ilInternalLink::_extractInstOfTarget($q_ref); if (!($inst_id > 0)) { $q_id = ilInternalLink::_extractObjIdOfTarget($q_ref); } } $ilTabs->addTarget("question", $ilCtrl->getLinkTarget($this, "edit"), array("editQuestion", "save", "cancel", "addSuggestedSolution", "cancelExplorer", "linkChilds", "removeSuggestedSolution", "addPair", "addTerm", "delete", "deleteTerms", "editMode", "upload", "saveEdit", "uploadingImage", "uploadingImagemap", "addArea", "deletearea", "saveShape", "back", "saveEdit", "changeGapType", "createGaps", "addItem", "addYesNo", "addTrueFalse", "toggleGraphicalAnswers", "setMediaMode"), ""); if ($q_id > 0) { if (assQuestion::_getQuestionType($q_id) != "assTextQuestion") { require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php'; require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php'; $tabCommands = assQuestionGUI::getCommandsFromClassConstants('ilAssQuestionFeedbackEditingGUI'); $tabLink = ilUtil::appendUrlParameterString($ilCtrl->getLinkTargetByClass('ilAssQuestionFeedbackEditingGUI', ilAssQuestionFeedbackEditingGUI::CMD_SHOW), "q_id=" . (int) $q_id); $ilTabs->addTarget('feedback', $tabLink, $tabCommands, $ilCtrl->getCmdClass(), ''); } } }
/** * delete portfolio page and all related data */ function delete() { global $ilDB; $id = $this->getId(); if ($id) { // delete internal links information to this page include_once "./Services/Link/classes/class.ilInternalLink.php"; ilInternalLink::_deleteAllLinksToTarget("user", $this->getId()); // delete record of table usr_portfolio_page $query = "DELETE FROM usr_portfolio_page" . " WHERE id = " . $ilDB->quote($this->getId(), "integer"); $ilDB->manipulate($query); // delete co page parent::delete(); } }
/** * Check access rights for glossary terms * This checks also learning modules linking the term * * @param int object id (glossary) * @param int page id (definition) * @return boolean access given (true/false) */ private function checkAccessGlossaryTerm($obj_id, $page_id) { // give access if glossary is readable if ($this->checkAccessObject($obj_id)) { return true; } include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $term_id = ilGlossaryDefinition::_lookupTermId($page_id); include_once './Services/COPage/classes/class.ilInternalLink.php'; $sources = ilInternalLink::_getSourcesOfTarget('git', $term_id, 0); if ($sources) { foreach ($sources as $src) { switch ($src['type']) { // Give access if term is linked by a learning module with read access. // The term including media is shown by the learning module presentation! case 'lm:pg': include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $src_obj_id = ilLMObject::_lookupContObjID($src['id']); if ($this->checkAccessObject($src_obj_id, 'lm')) { return true; } break; // Don't yet give access if the term is linked by another glossary // The link will lead to the origin glossary which is already checked /* case 'gdf:pg': $src_term_id = ilGlossaryDefinition::_lookupTermId($src['id']); $src_obj_id = ilGlossaryTerm::_lookGlossaryID($src_term_id); if ($this->checkAccessObject($src_obj_id, 'glo')) { return true; } break; */ } } } }
/** * Checks wether a node exists * * @param int $id id * * @return boolean true, if lm content object exists */ function _exists($a_id) { global $ilDB; include_once "./Services/COPage/classes/class.ilInternalLink.php"; if (is_int(strpos($a_id, "_"))) { $a_id = ilInternalLink::_extractObjIdOfTarget($a_id); } $q = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = " . $ilDB->quote($a_id, "integer"); $obj_set = $ilDB->query($q); if ($obj_rec = $ilDB->fetchAssoc($obj_set)) { return true; } else { return false; } }
/** * show print view */ function showPrintView() { global $ilUser, $lng, $ilCtrl; include_once "./Modules/LearningModule/classes/class.ilLMPage.php"; if (!$this->lm->isActivePrintView()) { return; } $this->renderPageTitle(); $c_obj_id = $this->getCurrentPageId(); // set values according to selection if ($_POST["sel_type"] == "page") { if (!is_array($_POST["obj_id"]) || !in_array($c_obj_id, $_POST["obj_id"])) { $_POST["obj_id"][] = $c_obj_id; } } if ($_POST["sel_type"] == "chapter" && $c_obj_id > 0) { $path = $this->lm_tree->getPathFull($c_obj_id); $chap_id = $path[1]["child"]; if ($chap_id > 0) { $_POST["obj_id"][] = $chap_id; } } //var_dump($_GET); //var_dump($_POST); // set style sheets if (!$this->offlineMode()) { $this->tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle()); } else { $style_name = $ilUser->getPref("style") . ".css"; $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name); } // content style $this->tpl->setCurrentBlock("ContentStyle"); if (!$this->offlineMode()) { $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())); } else { $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css"); } $this->tpl->parseCurrentBlock(); // syntax style $this->tpl->setCurrentBlock("SyntaxStyle"); $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath()); $this->tpl->parseCurrentBlock(); //$this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation()); $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_print_view.html", true); // set title header $this->tpl->setVariable("HEADER", $this->lm->getTitle()); $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId())); include_once "./Modules/LearningModule/classes/class.ilLMPageGUI.php"; include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php"; include_once "./Modules/LearningModule/classes/class.ilStructureObject.php"; $act_level = 99999; $activated = false; $glossary_links = array(); $output_header = false; $media_links = array(); // get header and footer if ($this->lm->getFooterPage() > 0 && !$this->lm->getHideHeaderFooterPrint()) { if (ilLMObject::_exists($this->lm->getFooterPage())) { $page_object_gui = $this->getLMPageGUI($this->lm->getFooterPage()); include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId($this->lm->getStyleSheetId(), "lm")); // determine target frames for internal links $page_object_gui->setLinkFrame($_GET["frame"]); $page_object_gui->setOutputMode("print"); $page_object_gui->setPresentationTitle(""); $page_object_gui->setFileDownloadLink("#"); $page_object_gui->setFullscreenLink("#"); $page_object_gui->setSourceCodeDownloadScript("#"); $footer_page_content = $page_object_gui->showPage(); } } if ($this->lm->getHeaderPage() > 0 && !$this->lm->getHideHeaderFooterPrint()) { if (ilLMObject::_exists($this->lm->getHeaderPage())) { $page_object_gui = $this->getLMPageGUI($this->lm->getHeaderPage()); include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId($this->lm->getStyleSheetId(), "lm")); // determine target frames for internal links $page_object_gui->setLinkFrame($_GET["frame"]); $page_object_gui->setOutputMode("print"); $page_object_gui->setPresentationTitle(""); $page_object_gui->setFileDownloadLink("#"); $page_object_gui->setFullscreenLink("#"); $page_object_gui->setSourceCodeDownloadScript("#"); $header_page_content = $page_object_gui->showPage(); } } // add free selected pages if (is_array($_POST["obj_id"])) { foreach ($_POST["obj_id"] as $k) { if ($k > 0 && !$this->lm_tree->isInTree($k)) { if (ilLMObject::_lookupType($k) == "pg") { $nodes[] = array("obj_id" => $k, "type" => "pg", "free" => true); } } } } else { ilUtil::sendFailure($lng->txt("cont_print_no_page_selected"), true); $ilCtrl->redirect($this, "showPrintViewSelection"); } foreach ($nodes as $node_key => $node) { // check page activation $active = ilLMPage::_lookupActive($node["obj_id"], $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation")); if ($node["type"] == "pg" && !$active) { continue; } // print all subchapters/subpages if higher chapter // has been selected if ($node["depth"] <= $act_level) { if (is_array($_POST["obj_id"]) && in_array($node["obj_id"], $_POST["obj_id"])) { $act_level = $node["depth"]; $activated = true; } else { $act_level = 99999; $activated = false; } } if ($activated && ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $node["obj_id"])) { // output learning module header if ($node["type"] == "du") { $output_header = true; } // output chapter title if ($node["type"] == "st") { if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && $this->lm_gui->object->getPublicAccessMode() == "selected") { if (!ilLMObject::_isPagePublic($node["obj_id"])) { continue; } } $chap = new ilStructureObject($this->lm, $node["obj_id"]); $this->tpl->setCurrentBlock("print_chapter"); $chapter_title = $chap->_getPresentationTitle($node["obj_id"], $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), 0, $this->lang); $this->tpl->setVariable("CHAP_TITLE", $chapter_title); if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE) { if ($nodes[$node_key + 1]["type"] == "pg") { $this->tpl->setVariable("CHAP_HEADER", $header_page_content); $did_chap_page_header = true; } } $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("print_block"); $this->tpl->parseCurrentBlock(); } // output page if ($node["type"] == "pg") { if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && $this->lm_gui->object->getPublicAccessMode() == "selected") { if (!ilLMObject::_isPagePublic($node["obj_id"])) { continue; } } $this->tpl->setCurrentBlock("print_item"); // get page $page_id = $node["obj_id"]; $page_object_gui = $this->getLMPageGUI($page_id); $page_object = $page_object_gui->getPageObject(); include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId($this->lm->getStyleSheetId(), "lm")); // get lm page $lm_pg_obj = new ilLMPageObject($this->lm, $page_id); $lm_pg_obj->setLMId($this->lm->getId()); // determine target frames for internal links $page_object_gui->setLinkFrame($_GET["frame"]); $page_object_gui->setOutputMode("print"); $page_object_gui->setPresentationTitle(""); if ($this->lm->getPageHeader() == IL_PAGE_TITLE || $node["free"] === true) { $page_title = ilLMPageObject::_getPresentationTitle($lm_pg_obj->getId(), $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lang); // prevent page title after chapter title // that have the same content if ($this->lm->isActiveNumbering()) { $chapter_title = trim(substr($chapter_title, strpos($chapter_title, " "))); } if ($page_title != $chapter_title) { $page_object_gui->setPresentationTitle($page_title); } } // handle header / footer $hcont = $header_page_content; $fcont = $footer_page_content; if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE) { if ($did_chap_page_header) { $hcont = ""; } if ($nodes[$node_key + 1]["type"] == "pg" && !($nodes[$node_key + 1]["depth"] <= $act_level && !in_array($nodes[$node_key + 1]["obj_id"], $_POST["obj_id"]))) { $fcont = ""; } } $page_object_gui->setFileDownloadLink("#"); $page_object_gui->setFullscreenLink("#"); $page_object_gui->setSourceCodeDownloadScript("#"); $page_content = $page_object_gui->showPage(); if ($this->lm->getPageHeader() != IL_PAGE_TITLE) { $this->tpl->setVariable("CONTENT", $hcont . $page_content . $fcont); } else { $this->tpl->setVariable("CONTENT", $hcont . $page_content . $fcont . "<br />"); } $chapter_title = ""; $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("print_block"); $this->tpl->parseCurrentBlock(); // get internal links $int_links = ilInternalLink::_getTargetsOfSource($this->lm->getType() . ":pg", $node["obj_id"]); $got_mobs = false; foreach ($int_links as $key => $link) { if ($link["type"] == "git" && ($link["inst"] == IL_INST_ID || $link["inst"] == 0)) { $glossary_links[$key] = $link; } if ($link["type"] == "mob" && ($link["inst"] == IL_INST_ID || $link["inst"] == 0)) { $got_mobs = true; $mob_links[$key] = $link; } } // this is not cool because of performance reasons // unfortunately the int link table does not // store the target frame (we want to append all linked // images but not inline images (i.e. mobs with no target // frame)) if ($got_mobs) { $page_object->buildDom(); $links = $page_object->getInternalLinks(); foreach ($links as $link) { if ($link["Type"] == "MediaObject" && $link["TargetFrame"] != "" && $link["TargetFrame"] != "None") { $media_links[] = $link; } } } } } } $annex_cnt = 0; $annexes = array(); // glossary if (count($glossary_links) > 0 && !$this->lm->isActivePreventGlossaryAppendix()) { include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; // sort terms $terms = array(); foreach ($glossary_links as $key => $link) { $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]); $terms[$term . ":" . $key] = array("key" => $key, "link" => $link, "term" => $term); } $terms = ilUtil::sortArray($terms, "term", "asc"); //ksort($terms); foreach ($terms as $t) { $link = $t["link"]; $key = $t["key"]; $defs = ilGlossaryDefinition::getDefinitionList($link["id"]); $def_cnt = 1; // output all definitions of term foreach ($defs as $def) { // definition + number, if more than 1 definition if (count($defs) > 1) { $this->tpl->setCurrentBlock("def_title"); $this->tpl->setVariable("TXT_DEFINITION", $this->lng->txt("cont_definition") . " " . $def_cnt++); $this->tpl->parseCurrentBlock(); } include_once "./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php"; $page_gui = new ilGlossaryDefPageGUI($def["id"]); $page_gui->setTemplateOutput(false); $page_gui->setOutputMode("print"); $this->tpl->setCurrentBlock("definition"); $page_gui->setFileDownloadLink("#"); $page_gui->setFullscreenLink("#"); $page_gui->setSourceCodeDownloadScript("#"); $output = $page_gui->showPage(); $this->tpl->setVariable("VAL_DEFINITION", $output); $this->tpl->parseCurrentBlock(); } // output term $this->tpl->setCurrentBlock("term"); $this->tpl->setVariable("VAL_TERM", $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"])); $this->tpl->parseCurrentBlock(); } // output glossary header $annex_cnt++; $this->tpl->setCurrentBlock("glossary"); $annex_title = $this->lng->txt("cont_annex") . " " . chr(64 + $annex_cnt) . ": " . $this->lng->txt("glo"); $this->tpl->setVariable("TXT_GLOSSARY", $annex_title); $this->tpl->parseCurrentBlock(); $annexes[] = $annex_title; } // referenced images if (count($media_links) > 0) { include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; include_once "./Services/MediaObjects/classes/class.ilMediaItem.php"; foreach ($media_links as $media) { if (substr($media["Target"], 0, 4) == "il__") { $arr = explode("_", $media["Target"]); $id = $arr[count($arr) - 1]; $med_obj = new ilObjMediaObject($id); $med_item = $med_obj->getMediaItem("Standard"); if (is_object($med_item)) { if (is_int(strpos($med_item->getFormat(), "image"))) { $this->tpl->setCurrentBlock("ref_image"); // image source if ($med_item->getLocationType() == "LocalFile") { $this->tpl->setVariable("IMG_SOURCE", ilUtil::getWebspaceDir("output") . "/mobs/mm_" . $id . "/" . $med_item->getLocation()); } else { $this->tpl->setVariable("IMG_SOURCE", $med_item->getLocation()); } if ($med_item->getCaption() != "") { $this->tpl->setVariable("IMG_TITLE", $med_item->getCaption()); } else { $this->tpl->setVariable("IMG_TITLE", $med_obj->getTitle()); } $this->tpl->parseCurrentBlock(); } } } } // output glossary header $annex_cnt++; $this->tpl->setCurrentBlock("ref_images"); $annex_title = $this->lng->txt("cont_annex") . " " . chr(64 + $annex_cnt) . ": " . $this->lng->txt("cont_ref_images"); $this->tpl->setVariable("TXT_REF_IMAGES", $annex_title); $this->tpl->parseCurrentBlock(); $annexes[] = $annex_title; } // output learning module title and toc if ($output_header) { $this->tpl->setCurrentBlock("print_header"); $this->tpl->setVariable("LM_TITLE", $this->lm->getTitle()); if ($this->lm->getDescription() != "none") { include_once "Services/MetaData/classes/class.ilMD.php"; $md = new ilMD($this->lm->getId(), 0, $this->lm->getType()); $md_gen = $md->getGeneral(); foreach ($md_gen->getDescriptionIds() as $id) { $md_des = $md_gen->getDescription($id); $description = $md_des->getDescription(); } $this->tpl->setVariable("LM_DESCRIPTION", $description); } $this->tpl->parseCurrentBlock(); // output toc $nodes2 = $nodes; foreach ($nodes2 as $node2) { if ($node2["type"] == "st" && ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $node2["obj_id"])) { for ($j = 1; $j < $node2["depth"]; $j++) { $this->tpl->setCurrentBlock("indent"); $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.png")); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("toc_entry"); $this->tpl->setVariable("TXT_TOC_TITLE", ilStructureObject::_getPresentationTitle($node2["obj_id"], $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), 0, $this->lang)); $this->tpl->parseCurrentBlock(); } } // annexes foreach ($annexes as $annex) { $this->tpl->setCurrentBlock("indent"); $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.png")); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("toc_entry"); $this->tpl->setVariable("TXT_TOC_TITLE", $annex); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("toc"); $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc")); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("print_start_block"); $this->tpl->parseCurrentBlock(); } // output author information include_once 'Services/MetaData/classes/class.ilMD.php'; $md = new ilMD($this->lm->getId(), 0, $this->lm->getType()); if (is_object($lifecycle = $md->getLifecycle())) { $sep = $author = ""; foreach ($ids = $lifecycle->getContributeIds() as $con_id) { $md_con = $lifecycle->getContribute($con_id); if ($md_con->getRole() == "Author") { foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) { $md_ent = $md_con->getEntity($ent_id); $author = $author . $sep . $md_ent->getEntity(); $sep = ", "; } } } if ($author != "") { $this->lng->loadLanguageModule("meta"); $this->tpl->setCurrentBlock("author"); $this->tpl->setVariable("TXT_AUTHOR", $this->lng->txt("meta_author")); $this->tpl->setVariable("LM_AUTHOR", $author); $this->tpl->parseCurrentBlock(); } } // output copyright information if (is_object($md_rights = $md->getRights())) { $copyright = $md_rights->getDescription(); include_once 'Services/MetaData/classes/class.ilMDUtils.php'; $copyright = ilMDUtils::_parseCopyright($copyright); if ($copyright != "") { $this->lng->loadLanguageModule("meta"); $this->tpl->setCurrentBlock("copyright"); $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright")); $this->tpl->setVariable("LM_COPYRIGHT", $copyright); $this->tpl->parseCurrentBlock(); } } $this->tpl->show(false); }
/** * Update internal links, after multiple pages have been copied */ static function updateInternalLinks($a_copied_nodes, $a_parent_type = "lm") { $all_fixes = array(); foreach ($a_copied_nodes as $original_id => $copied_id) { $copied_type = ilLMObject::_lookupType($copied_id); $copy_lm = ilLMObject::_lookupContObjID($copied_id); if ($copied_type == "pg") { // // 1. Outgoing links from the copied page. // //$targets = ilInternalLink::_getTargetsOfSource($a_parent_type.":pg", $copied_id); include_once "./Modules/LearningModule/classes/class.ilLMPage.php"; $tpg = new ilLMPage($copied_id); $tpg->buildDom(); $il = $tpg->getInternalLinks(); $targets = array(); foreach ($il as $l) { $targets[] = array("type" => ilInternalLink::_extractTypeOfTarget($l["Target"]), "id" => (int) ilInternalLink::_extractObjIdOfTarget($l["Target"]), "inst" => (int) ilInternalLink::_extractInstOfTarget($l["Target"])); } $fix = array(); foreach ($targets as $target) { if (($target["inst"] == 0 || ($target["inst"] = IL_INST_ID)) && ($target["type"] == "pg" || $target["type"] == "st")) { // first check, whether target is also within the copied set if ($a_copied_nodes[$target["id"]] > 0) { $fix[$target["id"]] = $a_copied_nodes[$target["id"]]; } else { // now check, if a copy if the target is already in the same lm // only if target is not already in the same lm! $trg_lm = ilLMObject::_lookupContObjID($target["id"]); if ($trg_lm != $copy_lm) { $lm_data = ilLMObject::_getAllObjectsForImportId("il__" . $target["type"] . "_" . $target["id"]); $found = false; foreach ($lm_data as $item) { if (!$found && $item["lm_id"] == $copy_lm) { $fix[$target["id"]] = $item["obj_id"]; $found = true; } } } } } } // outgoing links to be fixed if (count($fix) > 0) { //echo "<br>--".$copied_id; //var_dump($fix); $t = ilObject::_lookupType($copy_lm); if (is_array($all_fixes[$t . ":" . $copied_id])) { $all_fixes[$t . ":" . $copied_id] += $fix; } else { $all_fixes[$t . ":" . $copied_id] = $fix; } } } if ($copied_type == "pg" || $copied_type == "st") { // // 2. Incoming links to the original pages // // A->B A2 (A+B currently copied) // A->C B2 // B->A // C->A C2->A (C already copied) $original_lm = ilLMObject::_lookupContObjID($original_id); $original_type = ilObject::_lookupType($original_lm); if ($original_lm != $copy_lm) { // This gets sources that link to A+B (so we have C here) // (this also does already the trick when instance map areas are given in C) // int_link, where target_type, target_id, target_inst -> ok $sources = ilInternalLink::_getSourcesOfTarget($copied_type, $original_id, 0); // mobs linking to $original_id // map_area, where link_type, target -> ok $mobs = ilMapArea::_getMobsForTarget("int", "il__" . $copied_type . "_" . $original_id); // pages using these mobs include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; foreach ($mobs as $mob) { // mob_usage, where id -> ok // mep_item, where foreign_id, type -> ok // mep_tree, where child -> already existed // il_news_item, where mob_id -> ok // map_area, where link_type, target -> aready existed // media_item, where id -> already existed // personal_clipboard, where item_id, type -> ok $usages = ilObjMediaObject::lookupUsages($mob); foreach ($usages as $usage) { if ($usage["type"] == "lm:pg" | $usage["type"] == "lm:st") { $sources[] = $usage; } } } $fix = array(); foreach ($sources as $source) { $stype = explode(":", $source["type"]); $source_type = $stype[1]; if ($source_type == "pg" || $source_type == "st") { // first of all: source must be in original lm $src_lm = ilLMObject::_lookupContObjID($source["id"]); if ($src_lm == $original_lm) { // check, if a copy if the source is already in the same lm // now we look for the latest copy of C in LM2 $lm_data = ilLMObject::_getAllObjectsForImportId("il__" . $source_type . "_" . $source["id"], $copy_lm); $found = false; foreach ($lm_data as $item) { if (!$found) { $fix[$item["obj_id"]][$original_id] = $copied_id; $found = true; } } } } } // outgoing links to be fixed if (count($fix) > 0) { foreach ($fix as $page_id => $fix_array) { $t = ilObject::_lookupType($copy_lm); if (is_array($all_fixes[$t . ":" . $page_id])) { $all_fixes[$t . ":" . $page_id] += $fix_array; } else { $all_fixes[$t . ":" . $page_id] = $fix_array; } } } } } } foreach ($all_fixes as $pg => $fixes) { $pg = explode(":", $pg); include_once "./Services/COPage/classes/class.ilPageObjectFactory.php"; $page = ilPageObjectFactory::getInstance($pg[0], $pg[1]); if ($page->moveIntLinks($fixes)) { $page->update(true, true); } } }
/** * Rename page */ function rename($a_new_name) { global $ilDB; // replace unallowed characters $a_new_name = str_replace(array("<", ">"), '', $a_new_name); // replace multiple whitespace characters by one single space $a_new_name = trim(preg_replace('!\\s+!', ' ', $a_new_name)); $page_title = ilWikiUtil::makeDbTitle($a_new_name); $pg_id = ilWikiPage::_getPageIdForWikiTitle($this->getWikiId(), $page_title); $xml_new_name = str_replace("&", "&", $a_new_name); if ($pg_id == 0 || $pg_id == $this->getId()) { include_once "./Services/COPage/classes/class.ilInternalLink.php"; $sources = ilInternalLink::_getSourcesOfTarget("wpg", $this->getId(), 0); foreach ($sources as $s) { if ($s["type"] == "wpg:pg") { $wpage = new ilWikiPage($s["id"]); $col = ilWikiUtil::processInternalLinks($wpage->getXmlContent(), 0, IL_WIKI_MODE_EXT_COLLECT); $new_content = $wpage->getXmlContent(); foreach ($col as $c) { // this complicated procedure is needed due to the fact // that depending on the collation e = é is true // in the (mysql) database // see bug http://www.ilias.de/mantis/view.php?id=11227 $t1 = ilWikiUtil::makeDbTitle($c["nt"]->mTextform); $t2 = ilWikiUtil::makeDbTitle($this->getTitle()); // this one replaces C2A0 ( ) by a usual space // otherwise the comparision will fail, since you // get these characters from tiny if more than one // space is repeated in a string. This may not be // 100% but we do not store $t1 anywhere and only // modify it for the comparison $t1 = preg_replace('/\\xC2\\xA0/', ' ', $t1); $t2 = preg_replace('/\\xC2\\xA0/', ' ', $t2); $set = $ilDB->query($q = "SELECT " . $ilDB->quote($t1, "text") . " = " . $ilDB->quote($t2, "text") . " isequal"); $rec = $ilDB->fetchAssoc($set); if ($rec["isequal"]) { $new_content = str_replace("[[" . $c["nt"]->mTextform . "]]", "[[" . $xml_new_name . "]]", $new_content); if ($c["text"] != "") { $new_content = str_replace("[[" . $c["text"] . "]]", "[[" . $xml_new_name . "]]", $new_content); } $add = $c["text"] != "" ? "|" . $c["text"] : ""; $new_content = str_replace("[[" . $c["nt"]->mTextform . $add . "]]", "[[" . $xml_new_name . $add . "]]", $new_content); } } $wpage->setXmlContent($new_content); //echo htmlentities($new_content); $wpage->update(); } } include_once "./Modules/Wiki/classes/class.ilObjWiki.php"; if (ilObjWiki::_lookupStartPage($this->getWikiId()) == $this->getTitle()) { ilObjWiki::writeStartPage($this->getWikiId(), $a_new_name); } $this->setTitle($a_new_name); $this->update(); } return $a_new_name; }