/** * Get media pool page gui for id and title */ static function getGUIForTitle($a_media_pool_id, $a_title, $a_old_nr = 0) { global $ilDB; include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php"; $id = ilMediaPoolPage::getPageIdForTitle($a_media_pool_id, $a_title); $page_gui = new ilMediaPoolPageGUI($id, $a_old_nr); return $page_gui; }
/** * Show snippet info */ function showSnippetInfo() { global $tpl, $lng, $ilAccess, $ilCtrl; $stpl = new ilTemplate("tpl.snippet_info.html", true, true, "Services/COPage"); include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php"; $mep_pools = ilMediaPoolItem::getPoolForItemId($_POST["ci_id"]); foreach ($mep_pools as $mep_id) { $ref_ids = ilObject::_getAllReferences($mep_id); $edit_link = false; foreach ($ref_ids as $rid) { if (!$edit_link && $ilAccess->checkAccess("write", "", $rid)) { $stpl->setCurrentBlock("edit_link"); $stpl->setVariable("TXT_EDIT", $lng->txt("edit")); $stpl->setVariable("HREF_EDIT", "./goto.php?target=mep_" . $rid); $stpl->parseCurrentBlock(); } } $stpl->setCurrentBlock("pool"); $stpl->setVariable("TXT_MEDIA_POOL", $lng->txt("obj_mep")); $stpl->setVariable("VAL_MEDIA_POOL", ilObject::_lookupTitle($mep_id)); $stpl->parseCurrentBlock(); } include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php"; $stpl->setVariable("TXT_TITLE", $lng->txt("title")); $stpl->setVariable("VAL_TITLE", ilMediaPoolPage::lookupTitle($_POST["ci_id"])); $stpl->setVariable("TXT_BACK", $lng->txt("back")); $stpl->setVariable("HREF_BACK", $ilCtrl->getLinkTarget($this->page_gui, "edit")); $tpl->setContent($stpl->get()); }
/** * Insert content includes */ function insertContentIncludes($a_html) { global $ilCtrl, $lng; $c_pos = 0; $start = strpos($a_html, "{{{{{ContentInclude;"); if (is_int($start)) { $end = strpos($a_html, "}}}}}", $start); } $i = 1; while ($end > 0) { $param = substr($a_html, $start + 20, $end - $start - 20); $param = explode(";", $param); if ($param[0] == "mep" && is_numeric($param[1]) && $param[2] <= 0) { include_once "./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php"; if (ilMediaPoolPage::_exists($param[1])) { $page_gui = new ilMediaPoolPageGUI($param[1], 0, true, "-"); if ($this->getOutputMode() != "offline") { $page_gui->setFileDownloadLink($this->determineFileDownloadLink()); $page_gui->setFullscreenLink($this->determineFullscreenLink()); $page_gui->setSourceCodeDownloadScript($this->determineSourcecodeDownloadScript()); } else { $page_gui->setOutputMode(IL_PAGE_OFFLINE); } $html = $page_gui->getRawContent(); } else { if ($this->getOutputMode() == "edit") { $html = "// " . $lng->txt("cont_missing_snippet") . " //"; } } $h2 = substr($a_html, 0, $start) . $html . substr($a_html, $end + 5); $a_html = $h2; $i++; } $start = strpos($a_html, "{{{{{ContentInclude;", $start + 5); $end = 0; if (is_int($start)) { $end = strpos($a_html, "}}}}}", $start); } } return $a_html; }
/** * Copy tree content * * @param * @return */ function copyTreeContent($a_new_obj, $a_target_parent, $a_source_parent) { include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php"; include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php"; include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; // get all chapters of root lm $nodes = $this->getTree()->getChilds($a_source_parent); foreach ($nodes as $node) { $item = new ilMediaPoolItem(); $item->setType($node["type"]); switch ($node["type"]) { case "mob": $mob_id = ilMediaPoolItem::lookupForeignId($node["child"]); $mob = new ilObjMediaObject($mob_id); $new_mob = $mob->duplicate(); $item->setForeignId($new_mob->getId()); $item->setTitle($new_mob->getTitle()); $item->create(); break; case "pg": $item->setTitle($node["title"]); $item->create(); $page = new ilMediaPoolPage($node["child"]); $new_page = new ilMediaPoolPage(); $new_page->setId($item->getId()); $new_page->create(); // todo: make mobs being copied $new_page->setXMLContent($page->copyXMLContent(true)); $new_page->buildDom(); $new_page->update(); break; case "fold": $item->setTitle($node["title"]); $item->create(); break; } // insert item into tree $a_new_obj->insertInTree($item->getId(), $a_target_parent); // handle childs $this->copyTreeContent($a_new_obj, $item->getId(), $node["child"]); } }
/** * get all clipboard objects of user and specified type */ function getClipboardObjects($a_type = "", $a_top_nodes_only = false) { global $ilDB; $par = ""; if ($a_top_nodes_only) { $par = " AND parent = " . $ilDB->quote(0, "integer") . " "; } $type_str = $a_type != "" ? " AND type = " . $ilDB->quote($a_type, "text") . " " : ""; $q = "SELECT * FROM personal_clipboard WHERE " . "user_id = " . $ilDB->quote($this->getId(), "integer") . " " . $type_str . $par . " ORDER BY order_nr"; $objs = $ilDB->query($q); $objects = array(); while ($obj = $ilDB->fetchAssoc($objs)) { if ($obj["type"] == "mob") { $obj["title"] = ilObject::_lookupTitle($obj["item_id"]); } if ($obj["type"] == "incl") { include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php"; $obj["title"] = ilMediaPoolPage::lookupTitle($obj["item_id"]); } $objects[] = array("id" => $obj["item_id"], "type" => $obj["type"], "title" => $obj["title"], "insert_time" => $obj["insert_time"]); } return $objects; }
/** * Save media pool page */ public function saveMediaPoolPage() { global $tpl, $lng, $ilCtrl; $this->initMediaPoolPageForm("create"); if ($this->form->checkInput()) { // create media pool item include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php"; $item = new ilMediaPoolItem(); $item->setTitle($_POST["title"]); $item->setType("pg"); $item->create(); if ($item->getId() > 0) { // put in tree $tree = $this->object->getTree(); $parent = $_GET["mepitem_id"] > 0 ? $_GET["mepitem_id"] : $tree->getRootId(); $this->object->insertInTree($item->getId(), $parent); // create page include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php"; $page = new ilMediaPoolPage(); $page->setId($item->getId()); $page->create(); ilUtil::sendSuccess($lng->txt("mep_page_created"), true); } $ilCtrl->redirect($this, "listMedia"); } $this->form->setValuesByPost(); $tpl->setContent($this->form->getHtml()); }
/** * Check access to media object * * @param * @return */ function checkAccessMob($obj_id) { $usages = ilObjMediaObject::lookupUsages($obj_id); foreach ($usages as $usage) { $oid = ilObjMediaObject::getParentObjectIdForUsage($usage, true); // for content snippets we must get their usages and check them if ($usage["type"] == "mep:pg") { include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php"; $usages2 = ilMediaPoolPage::lookupUsages($usage["id"]); foreach ($usages2 as $usage2) { $oid2 = ilObjMediaObject::getParentObjectIdForUsage($usage2, true); if ($this->checkAccessMobUsage($usage2, $oid2)) { return true; } } } else { if ($this->checkAccessMobUsage($usage, $oid)) { return true; } } } return false; }
/** * Save media pool page */ public function saveMediaPoolPage() { global $tpl, $lng, $ilCtrl; $this->checkPermission("write"); $this->initMediaPoolPageForm("create"); if ($this->form->checkInput()) { // create media pool item include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php"; $item = new ilMediaPoolItem(); $item->setTitle($_POST["title"]); $item->setType("pg"); $item->create(); if ($item->getId() > 0) { // put in tree $tree = $this->object->getTree(); $parent = $_GET["mepitem_id"] > 0 ? $_GET["mepitem_id"] : $tree->getRootId(); $this->object->insertInTree($item->getId(), $parent); // create page include_once "./Modules/MediaPool/classes/class.ilMediaPoolPage.php"; $page = new ilMediaPoolPage(); $page->setId($item->getId()); $page->create(); $ilCtrl->setParameterByClass("ilmediapoolpagegui", "mepitem_id", $item->getId()); $ilCtrl->redirectByClass("ilmediapoolpagegui", "edit"); } $ilCtrl->redirect($this, "listMedia"); } $this->form->setValuesByPost(); $tpl->setContent($this->form->getHtml()); }