/** * Insert content template * * @param ilPageObject $a_pg_obj page object * @param string $a_hier_id Hierarchical ID * @param string $a_pc_id pc id * @param int $a_page_templ template page id */ function create($a_pg_obj, $a_hier_id, $a_pc_id, $a_page_templ) { $source_id = explode(":", $a_page_templ); $source_page = ilPageObjectFactory::getInstance($source_id[1], $source_id[0]); $source_page->buildDom(); $source_page->addHierIds(); $hier_ids = $source_page->getHierIds(); $copy_ids = array(); foreach ($hier_ids as $hier_id) { // move top level nodes only if (!is_int(strpos($hier_id, "_"))) { if ($hier_id != "pg" && $hier_id >= $a_hid) { $copy_ids[] = $hier_id; } } } asort($copy_ids); // get the target parent node $pos = explode("_", $a_pos); array_pop($pos); $parent_pos = implode($pos, "_"); if ($parent_pos != "") { $target_parent = $a_pg_obj->getContentNode($parent_pos); } else { $target_parent = $a_pg_obj->getNode(); } //$source_parent = $source_page->getContentNode("pg"); $curr_node = $a_pg_obj->getContentNode($a_hier_id, $a_pcid); foreach ($copy_ids as $copy_id) { $source_node = $source_page->getContentNode($copy_id); $new_node = $source_node->clone_node(true); $new_node->unlink_node($new_node); if ($succ_node = $curr_node->next_sibling()) { $succ_node->insert_before($new_node, $succ_node); } else { //echo "movin doin append_child"; $target_parent->append_child($new_node); } //$xpc = xpath_new_context($a_pg_obj->getDomDoc()); $xpath = new DOMXpath($a_pg_obj->getDomDoc()); //var_dump($new_node->myDOMNode); //echo "-".$new_node->get_attribute("PCID")."-"; exit; if ($new_node->get_attribute("PCID") != "") { $new_node->set_attribute("PCID", ""); } $els = $xpath->query(".//*[@PCID]", $new_node->myDOMNode); foreach ($els as $el) { $el->setAttribute("PCID", ""); } $curr_node = $new_node; } $a_pg_obj->update(); //$this->node = $this->createPageContentNode(); /*$a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id); $this->map_node =& $this->dom->create_element("Map"); $this->map_node =& $this->node->append_child($this->map_node); $this->map_node->set_attribute("Latitude", "0"); $this->map_node->set_attribute("Longitude", "0"); $this->map_node->set_attribute("Zoom", "3");*/ }
public function forwardToPageObject() { global $lng, $ilTabs; $ilTabs->clearTargets(); $ilTabs->setBackTarget($lng->txt('back'), $this->ctrl->getLinkTarget($this), '_top'); // page object include_once 'Services/COPage/classes/class.ilPageObject.php'; include_once 'Services/COPage/classes/class.ilPageObjectGUI.php'; $lng->loadLanguageModule('content'); include_once './Services/Style/classes/class.ilObjStyleSheet.php'; $this->tpl->setVariable('LOCATION_CONTENT_STYLESHEET', ilObjStyleSheet::getContentStylePath(0)); if (!ilPageObject::_exists('shop', self::SHOP_PAGE_EDITOR_PAGE_ID)) { // doesn't exist -> create new one $new_page_object = new ilPageObject('shop'); $new_page_object->setParentId(0); $new_page_object->setId(self::SHOP_PAGE_EDITOR_PAGE_ID); $new_page_object->createFromXML(); } $this->ctrl->setReturnByClass('ilpageobjectgui', 'edit'); $page_gui = new ilPageObjectGUI('shop', self::SHOP_PAGE_EDITOR_PAGE_ID); $page_gui->setIntLinkHelpDefault('StructureObject', self::SHOP_PAGE_EDITOR_PAGE_ID); $page_gui->setTemplateTargetVar('ADM_CONTENT'); $page_gui->setLinkXML(''); $page_gui->setFileDownloadLink($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'downloadFile')); $page_gui->setFullscreenLink($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'displayMediaFullscreen')); $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTargetByClass(array('ilpageobjectgui'), 'download_paragraph')); $page_gui->setPresentationTitle(''); $page_gui->setTemplateOutput(false); $page_gui->setHeader(''); $page_gui->setEnabledRepositoryObjects(false); $page_gui->setEnabledFileLists(true); $page_gui->setEnabledMaps(true); $page_gui->setEnabledPCTabs(true); return $this->ctrl->forwardCommand($page_gui); }
/** * Constructor * * @param object $a_parent_obj parent gui object * @param string $a_parent_cmd parent cmd * @param ilObjContentObject $a_lm learning module */ public function __construct($a_parent_obj, $a_parent_cmd, ilObjContentObject $a_lm, $a_id = "") { $this->lm = $a_lm; include_once "./Modules/LearningModule/classes/class.ilLMTree.php"; $tree = ilLMTree::getInstance($this->lm->getId()); //echo "+".$tree->isCacheUsed()."+"; // $tree = new ilTree($this->lm->getId()); // $tree->setTableNames('lm_tree','lm_data'); // $tree->setTreeTablePK("lm_id"); include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $this->cnt_lmobj = ilLMObject::preloadDataByLM($this->lm->getId()); include_once "./Services/COPage/classes/class.ilPageObject.php"; ilPageObject::preloadActivationDataByParentId($this->lm->getId()); if ($a_id == "") { $a_id = "lm_exp"; // this does not work, since it is not set yet if ($this->getOfflineMode()) { $a_id = "lm_exp_off"; } } parent::__construct($a_id, $a_parent_obj, $a_parent_cmd, $tree); $this->setSkipRootNode(false); $this->setAjax(false); $this->setPreloadChilds(true); if ((int) $_GET["obj_id"] > 0) { $this->setPathOpen((int) $_GET["obj_id"]); } }
/** * Final processing * * @param array mapping array */ function finalProcessing($a_mapping) { $blp_map = $a_mapping->getMappingsOfEntity("Services/COPage", "pg"); foreach ($blp_map as $blp_id) { $blp_id = substr($blp_id, 4); $blog_id = ilBlogPosting::lookupBlogId($blp_id); ilPageObject::_writeParentId("blp", $blp_id, $blog_id); } }
/** * Final processing * * @param array mapping array */ function finalProcessing($a_mapping) { $wpg_map = $a_mapping->getMappingsOfEntity("Modules/Wiki", "wpg"); include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; include_once "./Services/COPage/classes/class.ilPageObject.php"; foreach ($wpg_map as $wpg_id) { $wiki_id = ilWikiPage::lookupWikiId($wpg_id); ilPageObject::_writeParentId("wpg", $wpg_id, $wiki_id); } }
/** * Fill table row */ protected function fillRow($a_set) { global $lng, $ilCtrl; //var_dump($a_set); // icon... // check activation include_once "./Services/COPage/classes/class.ilPageObject.php"; $active = ilPageObject::_lookupActive($a_set["obj_id"], $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation")); // is page scheduled? $img_sc = $this->lm_set->get("time_scheduled_page_activation") && ilPageObject::_isScheduledActivation($a_set["obj_id"], $this->lm->getType()) ? "_sc" : ""; if (!$active) { $img = "icon_pg_d" . $img_sc . ".png"; $alt = $lng->txt("cont_page_deactivated"); } else { if (ilPageObject::_lookupContainsDeactivatedElements($a_set["obj_id"], $this->lm->getType())) { $img = "icon_pg_del" . $img_sc . ".png"; $alt = $lng->txt("cont_page_deactivated_elements"); } else { $img = "icon_pg" . $img_sc . ".png"; $alt = $this->lng->txt("pg"); } } $this->tpl->setVariable("ICON", ilUtil::img(ilUtil::getImagePath($img), $alt)); // title/link $ilCtrl->setParameter($this, "backcmd", ""); $ilCtrl->setParameterByClass("ilLMPageObjectGUI", "obj_id", $a_set["obj_id"]); $this->tpl->setVariable("HREF_TITLE", $ilCtrl->getLinkTargetByClass("ilLMPageObjectGUI", "edit")); $this->tpl->setVariable("TITLE", $a_set["title"]); $this->tpl->setVariable("ID", $a_set["obj_id"]); // context if ($this->lm->lm_tree->isInTree($a_set["obj_id"])) { $path_str = $this->parent_obj->getContextPath($a_set["obj_id"]); } else { $path_str = "---"; } // check whether page is header or footer $add_str = ""; if ($a_set["obj_id"] == $this->lm->getHeaderPage()) { $add_str = " <b>(" . $lng->txt("cont_header") . ")</b>"; } if ($a_set["obj_id"] == $this->lm->getFooterPage()) { $add_str = " <b>(" . $lng->txt("cont_footer") . ")</b>"; } $this->tpl->setVariable("USAGE", $path_str . $add_str); // layout if ($this->lm->getLayoutPerPage()) { if (($l = ilLMObject::lookupLayout($a_set["obj_id"])) != "") { $this->tpl->setVariable("LAYOUT", $lng->txt("cont_layout_" . $l)); } } }
/** * Final processing * * @param array mapping array */ function finalProcessing($a_mapping) { $pages = $a_mapping->getMappingsOfEntity("Services/COPage", "pg"); $media_objects = $a_mapping->getMappingsOfEntity("Services/MediaObjects", "mob"); $file_objects = $a_mapping->getMappingsOfEntity("Modules/File", "file"); if (count($media_objects) > 0 || count($file_objects) > 0) { foreach ($pages as $p) { $id = explode(":", $p); if (count($id) == 2) { include_once "./Services/COPage/classes/class.ilPageObject.php"; if (ilPageObject::_exists($id[0], $id[1])) { $new_page = new ilPageObject($id[0], $id[1]); $new_page->buildDom(); $med = $new_page->resolveMediaAliases($media_objects); $fil = $new_page->resolveFileItems($file_objects); if ($med || $fil) { $new_page->update(false, true); } } } } } }
/** * Export all pages */ function exportHTMLPages() { global $tpl, $ilBench, $ilLocator; $pages = ilWikiPage::getAllPages($this->wiki->getId()); include_once "./Services/COPage/classes/class.ilPageContentUsage.php"; include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; foreach ($pages as $page) { if (ilPageObject::_exists("wpg", $page["id"])) { $this->exportPageHTML($page["id"]); $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]); } } $this->co_page_html_export->exportPageElements(); }
/** * Get tail dependencies * * @param string entity * @param string target release * @param array ids * @return array array of array with keys "component", entity", "ids" */ function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids) { include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; include_once "./Services/COPage/classes/class.ilPageObject.php"; $pg_ids = array(); foreach ($a_ids as $id) { $pages = ilWikiPage::getAllPages($id); foreach ($pages as $p) { if (ilPageObject::_exists("wpg", $p["id"])) { $pg_ids[] = "wpg:" . $p["id"]; } } } return array(array("component" => "Services/COPage", "entity" => "pg", "ids" => $pg_ids), array("component" => "Services/Rating", "entity" => "rating_category", "ids" => $a_ids)); }
/** * Process answer */ function processAnswer() { global $ilUser, $ilDB, $lng, $ilPluginAdmin, $ilLog; parent::processAnswer(); // // Send notifications to authors that want to be informed on blocked users // $parent_id = ilPageObject::lookupParentId((int) $_GET["page_id"], "lm"); // is restriction mode set? include_once "./Modules/LearningModule/classes/class.ilObjContentObject.php"; if (ilObjContentObject::_lookupRestrictForwardNavigation($parent_id)) { // check if user is blocked $id = ilUtil::stripSlashes($_POST["id"]); include_once "./Services/COPage/classes/class.ilPageQuestionProcessor.php"; $as = ilPageQuestionProcessor::getAnswerStatus($id, $ilUser->getId()); // get question information include_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionList.php"; $qlist = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin); $qlist->setParentObjId(0); $qlist->addFieldFilter("question_id", array($id)); $qlist->load(); $qdata = $qlist->getQuestionDataArray(); // has the user been blocked? if ($as["try"] >= $qdata[$as["qst_id"]]["nr_of_tries"] && $qdata[$as["qst_id"]]["nr_of_tries"] > 0 && !$as["passed"]) { include_once "./Services/Notification/classes/class.ilNotification.php"; $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_LM_BLOCKED_USERS, $parent_id); if (count($users) > 0) { include_once "./Modules/LearningModule/classes/class.ilLMMailNotification.php"; $not = new ilLMMailNotification(); $not->setType(ilLMMailNotification::TYPE_USER_BLOCKED); $not->setQuestionId($id); $not->setRefId((int) $_GET["ref_id"]); $not->setRecipients($users); $not->send(); } } } }
static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null) { global $ilUser, $ilObjDataCache, $ilAccess; include_once "./Services/Notification/classes/class.ilNotification.php"; include_once "./Modules/Wiki/classes/class.ilObjWiki.php"; include_once "./Modules/Wiki/classes/class.ilWikiPage.php"; $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id); $wiki = new ilObjWiki($a_wiki_ref_id, true); $page = new ilWikiPage($a_page_id); // #11138 $ignore_threshold = $a_action == "comment"; // 1st update will be converted to new - see below if ($a_action == "new") { return; } if ($a_type == ilNotification::TYPE_WIKI_PAGE) { $users = ilNotification::getNotificationsForObject($a_type, $a_page_id, null, $ignore_threshold); $wiki_users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); $users = array_merge($users, $wiki_users); if (!sizeof($users)) { return; } ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI_PAGE, $a_page_id, $users); } else { $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold); if (!sizeof($users)) { return; } } ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI, $wiki_id, $users, $a_page_id); // #15192 - should always be present if ($a_page_id) { include_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php"; $link = ILIAS_HTTP_PATH . "/" . ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle()); } else { include_once "./Services/Link/classes/class.ilLink.php"; $link = ilLink::_getLink($a_wiki_ref_id); } include_once "./Services/Mail/classes/class.ilMail.php"; include_once "./Services/User/classes/class.ilObjUser.php"; include_once "./Services/Language/classes/class.ilLanguageFactory.php"; include_once "./Services/User/classes/class.ilUserUtil.php"; // see ilBlogPostingGUI::getSnippet() // see ilBlogPosting::getNotificationAbstract() include_once "Modules/Wiki/classes/class.ilWikiPageGUI.php"; $pgui = new ilWikiPageGUI($page->getId()); $pgui->setRawPageContent(true); $pgui->setAbstractOnly(true); $pgui->setFileDownloadLink("."); $pgui->setFullscreenLink("."); $pgui->setSourcecodeDownloadScript("."); $snippet = $pgui->showPage(); $snippet = ilPageObject::truncateHTML($snippet, 500, "..."); // making things more readable $snippet = str_replace('<br/>', "\n", $snippet); $snippet = str_replace('<br />', "\n", $snippet); $snippet = str_replace('</p>', "\n", $snippet); $snippet = str_replace('</div>', "\n", $snippet); $snippet = trim(strip_tags($snippet)); // "fake" new (to enable snippet - if any) $current_version = array_shift($page->getHistoryEntries()); $current_version = $current_version["nr"]; if (!$current_version) { $a_type = ilNotification::TYPE_WIKI; $a_action = "new"; } foreach (array_unique($users) as $idx => $user_id) { if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $a_wiki_ref_id)) { // use language of recipient to compose message $ulng = ilLanguageFactory::_getLanguageOfUser($user_id); $ulng->loadLanguageModule('wiki'); $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle()); $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n"; if ($a_type == ilNotification::TYPE_WIKI_PAGE) { // update/delete $message .= $ulng->txt('wiki_change_notification_page_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n"; if ($snippet) { $message .= "\n" . $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n"; } // include comment/note text if ($a_comment) { $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n"; } $message .= "\n" . $ulng->txt('wiki_change_notification_page_link') . ": " . $link; } else { // new $message .= $ulng->txt('wiki_change_notification_body_' . $a_action) . ":\n\n"; $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n"; $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n"; $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n"; if ($snippet) { $message .= $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n\n"; } $message .= $ulng->txt('wiki_change_notification_link') . ": " . $link; } $mail_obj = new ilMail(ANONYMOUS_USER_ID); $mail_obj->appendInstallationSignature(true); $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system")); } else { unset($users[$idx]); } } }
/** * Export all pages */ function exportHTMLPages() { global $tpl, $ilBench, $ilLocator; require_once "Services/Portfolio/classes/class.ilPortfolioPage.php"; $pages = ilPortfolioPage::getAllPages($this->object->getId()); $this->tabs = array(); foreach ($pages as $page) { // substitute blog id with title if ($page["type"] == ilPortfolioPage::TYPE_BLOG) { include_once "Modules/Blog/classes/class.ilObjBlog.php"; $page["title"] = ilObjBlog::_lookupTitle((int) $page["title"]); } $this->tabs[$page["id"]] = $page["title"]; } // for sub-pages, e.g. blog postings $tpl_callback = array($this, "buildExportTemplate"); include_once "./Services/COPage/classes/class.ilPageContentUsage.php"; include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $has_index = false; foreach ($pages as $page) { if (ilPageObject::_exists("prtf", $page["id"])) { $this->active_tab = "user_page_" . $page["id"]; if ($page["type"] == ilPortfolioPage::TYPE_BLOG) { $link_template = "prtf_" . $page["id"] . "_bl{TYPE}_{ID}.html"; include_once "Modules/Blog/classes/class.ilObjBlogGUI.php"; $blog = new ilObjBlogGUI((int) $page["title"], ilObject2GUI::WORKSPACE_OBJECT_ID); $blog->exportHTMLPages($this->export_dir . "/", $link_template, $tpl_callback, $this->co_page_html_export, "prtf_" . $page["id"] . ".html"); } else { $this->exportPageHTML($page["id"]); $this->co_page_html_export->collectPageElements("prtf:pg", $page["id"]); } if (!$has_index) { copy($this->export_dir . "/prtf_" . $page["id"] . ".html", $this->export_dir . "/index.html"); $has_index = true; } } } $this->co_page_html_export->exportPageElements(); }
/** * Get all postings of blog * * @param int $a_blog_id * @param int $a_limit * @param int $a_offset * @return array */ static function getAllPostings($a_blog_id, $a_limit = 1000, $a_offset = 0) { global $ilDB; $pages = parent::getAllPages("blp", $a_blog_id); if ($a_limit) { $ilDB->setLimit($a_limit, $a_offset); } $query = "SELECT * FROM il_blog_posting" . " WHERE blog_id = " . $ilDB->quote($a_blog_id, "integer") . " ORDER BY created DESC"; $set = $ilDB->query($query); $post = array(); while ($rec = $ilDB->fetchAssoc($set)) { if (isset($pages[$rec["id"]])) { $post[$rec["id"]] = $pages[$rec["id"]]; $post[$rec["id"]]["title"] = $rec["title"]; $post[$rec["id"]]["created"] = new ilDateTime($rec["created"], IL_CAL_DATETIME); $post[$rec["id"]]["author"] = $rec["author"]; $post[$rec["id"]]["approved"] = (bool) $rec["approved"]; } } return $post; }
/** * Get icon alt text * * @param array itema array * @return string icon alt text */ function getChildIconAlt($a_item) { global $lng; include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; if ($a_item["type"] == "pg") { include_once "./Services/COPage/classes/class.ilPageObject.php"; $active = ilPageObject::_lookupActive($a_item["node_id"], $this->lm_type); if (!$active) { return $lng->txt("cont_page_deactivated"); } else { include_once "./Services/COPage/classes/class.ilPageObject.php"; $contains_dis = ilPageObject::_lookupContainsDeactivatedElements($a_item["node_id"], $this->lm_type); if ($contains_dis) { return $lng->txt("cont_page_deactivated_elements"); } } } return ilUtil::getImagePath("icon_" . $a_item["type"] . ".png"); }
public function deleteView() { global $ilCtrl, $lng; if ($this->table_id && ilDataCollectionRecordViewViewdefinition::getIdByTableId($this->table_id)) { global $ilDB; $id = ilDataCollectionRecordViewViewdefinition::getIdByTableId($this->table_id); $pageObject = new ilPageObject("dclf", $id); $pageObject->delete(); $query = "DELETE FROM il_dcl_view WHERE table_id = " . $this->table_id . " AND type = " . $ilDB->quote(0, "integer") . " AND formtype = " . $ilDB->quote(0, "integer"); $ilDB->manipulate($query); } ilUtil::sendSuccess($lng->txt("dcl_empty_view_success"), true); $ilCtrl->redirectByClass("ilDataCollectionFieldListGUI", "listFields"); }
/** * Get all pages of wiki * * @access public */ static function getNewPages($a_wiki_id) { global $ilDB; $pages = parent::getNewPages("wpg", $a_wiki_id); foreach ($pages as $k => $page) { $pages[$k]["title"] = ilWikiPage::lookupTitle($page["id"]); } return $pages; }
/** * Get's the repository object ID of a parent object, if possible * * see ilWebAccessChecker */ function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false) { if (is_int(strpos($a_usage["type"], ":"))) { $us_arr = explode(":", $a_usage["type"]); $type = $us_arr[1]; $cont_type = $us_arr[0]; } else { $type = $a_usage["type"]; } $id = $a_usage["id"]; $obj_id = false; switch ($type) { // RTE / tiny mce case "html": switch ($cont_type) { case "qpl": // Question Pool *Question* Text (Test) include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $qinfo = assQuestion::_getQuestionInfo($id); if ($qinfo["original_id"] > 0) { include_once "./Modules/Test/classes/class.ilObjTest.php"; $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test } else { $obj_id = $qinfo["obj_fi"]; // usage in pool } break; case "spl": // Question Pool *Question* Text (Survey) include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; $quest = SurveyQuestion::_instanciateQuestion($id); if ($quest) { if ($quest->getOriginalId() > 0) { $obj_id = $quest->getSurveyId(); } else { $obj_id = $quest->getObjId(); // usage in pool } unset($quest); } break; case "exca": // Exercise assignment $returned_pk = $a_usage['id']; // we are just checking against exercise object include_once 'Modules/Exercise/classes/class.ilObjExercise.php'; $obj_id = ilObjExercise::lookupExerciseIdForReturnedId($returned_pk); break; case "frm": // Forum $post_pk = $a_usage['id']; include_once 'Modules/Forum/classes/class.ilForumPost.php'; include_once 'Modules/Forum/classes/class.ilForum.php'; $oPost = new ilForumPost($post_pk); $frm_pk = $oPost->getForumId(); $obj_id = ilForum::_lookupObjIdForForumId($frm_pk); break; // temporary items (per user) // temporary items (per user) case "frm~": case "exca~": $obj_id = $a_usage['id']; break; // "old" category pages // "old" category pages case "cat": // InfoScreen Text // InfoScreen Text case "tst": case "svy": // data collection // data collection case "dcl": $obj_id = $id; break; } break; // page editor // page editor case "pg": switch ($cont_type) { case "qpl": // Question Pool Question Pages include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $qinfo = assQuestion::_getQuestionInfo($id); if ($qinfo["original_id"] > 0) { include_once "./Modules/Test/classes/class.ilObjTest.php"; $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test } else { $obj_id = $qinfo["obj_fi"]; // usage in pool } break; case "lm": case "dbk": // learning modules include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $obj_id = ilLMObject::_lookupContObjID($id); break; case "gdf": // glossary definition include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $term_id = ilGlossaryDefinition::_lookupTermId($id); $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id); break; case "wpg": // wiki page include_once 'Modules/Wiki/classes/class.ilWikiPage.php'; $obj_id = ilWikiPage::lookupObjIdByPage($id); break; case "sahs": // sahs page // can this implementation be used for other content types, too? include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'sahs'); break; case "prtf": // portfolio include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php"; $obj_id = ilPortfolioPage::findPortfolioForPage($id); break; case "prtt": // portfolio template include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php"; $obj_id = ilPortfolioTemplatePage::findPortfolioForPage($id); break; case "blp": // blog include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'blp'); break; case "crs": case "grp": case "cat": case "fold": case "root": // repository pages $obj_id = $id; break; } break; // Media Pool // Media Pool case "mep": $obj_id = $id; break; // News Context Object (e.g. MediaCast) // News Context Object (e.g. MediaCast) case "news": include_once "./Services/News/classes/class.ilNewsItem.php"; $obj_id = ilNewsItem::_lookupContextObjId($id); break; } return $obj_id; }
/** * Switch to language */ function switchToLanguage() { global $ilCtrl; $l = ilUtil::stripSlashes($_GET["totransl"]); $p = $this->getPageObject(); if (!ilPageObject::_exists($p->getParentType(), $p->getId(), $l)) { $this->confirmPageTranslationCreation(); return; } $ilCtrl->setParameter($this, "transl", $_GET["totransl"]); $ilCtrl->redirect($this, "edit"); }
/** * Copy page * * @param int $a_id target page id * @param string $a_parent_type target parent type * @param int $a_parent_id target parent id */ function copy($a_id, $a_parent_type = "", $a_parent_id = 0, $a_clone_mobs = false) { if ($a_parent_type == "") { $a_parent_type = $this->getParentType(); if ($a_parent_id == 0) { $a_parent_id = $this->getParentId(); } } include_once "./Services/COPage/classes/class.ilPageObjectFactory.php"; foreach (self::lookupTranslations($this->getParentType(), $this->getId()) as $l) { $existed = false; $orig_page = ilPageObjectFactory::getInstance($this->getParentType(), $this->getId(), 0, $l); if (ilPageObject::_exists($a_parent_type, $a_id, $l)) { $new_page_object = ilPageObjectFactory::getInstance($a_parent_type, $a_id, 0, $l); $existed = true; } else { $new_page_object = ilPageObjectFactory::getInstance($a_parent_type, 0, 0, $l); $new_page_object->setParentId($a_parent_id); $new_page_object->setId($a_id); } $new_page_object->setXMLContent($orig_page->copyXMLContent($a_clone_mobs)); $new_page_object->setActive($orig_page->getActive()); $new_page_object->setActivationStart($orig_page->getActivationStart()); $new_page_object->setActivationEnd($orig_page->getActivationEnd()); if ($existed) { $new_page_object->buildDom(); $new_page_object->update(); } else { $new_page_object->create(); } } }
/** * Get question ids * * note: this method must be called afer exportXMLPageContent */ function getQuestionIds() { return ilPageObject::_getQuestionIdsForPage($this->content_object->getType(), $this->getId()); }
/** * Lookup usages of media object * * @todo: This should be all in one context -> mob id table */ function lookupUsages($a_id, $a_incl_hist = true) { global $ilDB; // get usages in pages $q = "SELECT * FROM page_pc_usage WHERE pc_id = " . $ilDB->quote($a_id, "integer") . " AND pc_type = " . $ilDB->quote("incl", "text"); if (!$a_incl_hist) { $q .= " AND usage_hist_nr = " . $ilDB->quote(0, "integer"); } $us_set = $ilDB->query($q); $ret = array(); while ($us_rec = $ilDB->fetchAssoc($us_set)) { $ut = ""; if (is_int(strpos($us_rec["usage_type"], ":"))) { $us_arr = explode(":", $us_rec["usage_type"]); $ut = $us_arr[1]; $ct = $us_arr[0]; } // check whether page exists $skip = false; if ($ut == "pg") { include_once "./Services/COPage/classes/class.ilPageObject.php"; if (!ilPageObject::_exists($ct, $us_rec["usage_id"])) { $skip = true; } } if (!$skip) { $ret[] = array("type" => $us_rec["usage_type"], "id" => $us_rec["usage_id"], "hist_nr" => $us_rec["usage_hist_nr"]); } } // get usages in media pools $q = "SELECT DISTINCT mep_id FROM mep_tree JOIN mep_item ON (child = obj_id) WHERE mep_item.obj_id = " . $ilDB->quote($a_id, "integer") . " AND mep_item.type = " . $ilDB->quote("pg", "text"); $us_set = $ilDB->query($q); while ($us_rec = $ilDB->fetchAssoc($us_set)) { $ret[] = array("type" => "mep", "id" => $us_rec["mep_id"]); } return $ret; }
/** * 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; }
/** * Update Viewdefinition * @param bool $a_validate * @param bool $a_no_history * @return boolean */ public function update($a_validate = true, $a_no_history = false) { //TODO //Page-Object updaten //Es wäre auch möglich direkt in der GUI-Klasse ilPageObject aufzurufen. Falls wir aber bei doCreate, //das Page-Object anlegen, fänd ich es sinnvoll, wenn wir auch hier das PageObject updaten würden. //Andernfalls sämtliche Page-Object-Methoden in der GUI-Klasse aufrufen. parent::update($a_validate, $a_no_history); return true; }
/** * Fix container item group references after a container has been cloned * * @param * @return */ static function fixContainerItemGroupRefsAfterCloning($a_source_container, $a_copy_id) { global $ilLog; $ilLog->write(__METHOD__ . ': Fix item group references in ' . $a_source_container->getType()); include_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php'; $cwo = ilCopyWizardOptions::_getInstance($a_copy_id); $mappings = $cwo->getMappings(); $new_container_ref_id = $mappings[$a_source_container->getRefId()]; $ilLog->write(__METHOD__ . ': 2-' . $new_container_ref_id . '-'); $new_container_obj_id = ilObject::_lookupObjId($new_container_ref_id); include_once "./Services/COPage/classes/class.ilPageObject.php"; include_once "./Services/Container/classes/class.ilContainerPage.php"; $ilLog->write(__METHOD__ . ': 3' . $new_container_obj_id . '-'); if (ilPageObject::_exists("cont", $new_container_obj_id)) { $ilLog->write(__METHOD__ . ': 4'); $new_page = new ilContainerPage($new_container_obj_id); $new_page->buildDom(); include_once "./Services/COPage/classes/class.ilPCResources.php"; ilPCResources::modifyItemGroupRefIdsByMapping($new_page, $mappings); $new_page->update(); } $ilLog->write(__METHOD__ . ': 5'); }
/** * Replaces existing question content elements with * new copies */ function newQuestionCopies(&$temp_dom) { // Get question IDs $path = "//Question"; $xpc = xpath_new_context($temp_dom); $res =& xpath_eval($xpc, $path); $q_ids = array(); include_once "./Services/COPage/classes/class.ilInternalLink.php"; for ($i = 0; $i < count($res->nodeset); $i++) { $qref = $res->nodeset[$i]->get_attribute("QRef"); $inst_id = ilInternalLink::_extractInstOfTarget($qref); $q_id = ilInternalLink::_extractObjIdOfTarget($qref); if (!($inst_id > 0)) { if ($q_id > 0) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $question = assQuestion::_instanciateQuestion($q_id); // check if page for question exists // due to a bug in early 4.2.x version this is possible if (!ilPageObject::_exists("qpl", $q_id)) { $question->createPageObject(); } // now copy this question and change reference to // new question id $duplicate_id = $question->duplicate(false); $res->nodeset[$i]->set_attribute("QRef", "il__qst_" . $duplicate_id); } } } }
/** * Get lm page object * * @param * @return */ function getLMPage($a_id) { include_once "./Modules/LearningModule/classes/class.ilLMPage.php"; if ($this->lang != "-" && ilPageObject::_exists("lm", $a_id, $this->lang)) { return new ilLMPage($a_id, 0, $this->lang); } return new ilLMPage($a_id); }
/** * 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(); } }
/** * get internal links */ function getInternalLinks() { require_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; require_once "./Services/COPage/classes/class.ilPageObjectGUI.php"; $defs = ilGlossaryDefinition::getDefinitionList($this->term->getId()); $term_links = array(); for ($j = 0; $j < count($defs); $j++) { $def = $defs[$j]; $page = new ilPageObject("gdf", $def["id"]); $page->buildDom(); $page_links = $page->getInternalLinks(); foreach ($page_links as $key => $page_link) { $term_links[$key] = $page_link; } } return $term_links; }
/** * Get effective language for given language. This checks if * - multilinguality is activated and * - the given language is part of the available translations * If not a "-" is returned (master language). * * @param string $a_lang language * @param string $a_parent_type page parent type * @return string effective language ("-" for master) */ function getEffectiveContentLang($a_lang, $a_parent_type) { $langs = $this->getLanguages(); if ($this->getContentActivated() && isset($langs[$a_lang]) && ilPageObject::_exists($a_parent_type, $this->getObjId(), $a_lang)) { return $a_lang; } return "-"; }
/** * Get first text paragraph of page * * @param int $a_id * @param bool $a_truncate * @param int $a_truncate_length * @param bool $a_include_picture * @param int $a_picture_width * @param int $a_picture_height * @param string $a_export_directory * @return string */ static function getSnippet($a_id, $a_truncate = false, $a_truncate_length = 500, $a_truncate_sign = "...", $a_include_picture = false, $a_picture_width = 144, $a_picture_height = 144, $a_export_directory = null) { $bpgui = new self(0, null, $a_id); // scan the full page for media objects if ($a_include_picture) { $img = $bpgui->getFirstMediaObjectAsTag($a_picture_width, $a_picture_height, $a_export_directory); } $bpgui->setRawPageContent(true); $bpgui->setAbstractOnly(true); // #8627: export won't work - should we set offline mode? $bpgui->setFileDownloadLink("."); $bpgui->setFullscreenLink("."); $bpgui->setSourcecodeDownloadScript("."); // render without title $page = $bpgui->showPage(); if ($a_truncate) { $page = ilPageObject::truncateHTML($page, $a_truncate_length, $a_truncate_sign); } if ($img) { $page = '<div>' . $img . $page . '</div><div style="clear:both;"></div>'; } return $page; }