/**
  * 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";
     $pg_ids = array();
     foreach ($a_ids as $id) {
         $pages = ilWikiPage::getAllPages($id);
         foreach ($pages as $p) {
             if (ilWikiPage::_exists("wpg", $p["id"])) {
                 $pg_ids[] = "wpg:" . $p["id"];
             }
         }
     }
     $deps = array(array("component" => "Services/COPage", "entity" => "pg", "ids" => $pg_ids), array("component" => "Services/Rating", "entity" => "rating_category", "ids" => $a_ids));
     $advmd_ids = array();
     foreach ($a_ids as $id) {
         $rec_ids = $this->getActiveAdvMDRecords($id);
         if (sizeof($rec_ids)) {
             foreach ($rec_ids as $rec_id) {
                 $advmd_ids[] = $id . ":" . $rec_id;
             }
         }
     }
     if (sizeof($advmd_ids)) {
         $deps[] = array("component" => "Services/AdvancedMetaData", "entity" => "advmd", "ids" => $advmd_ids);
     }
     return $deps;
 }
 /**
  * List templates
  */
 function listTemplates()
 {
     // list pages
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $pages = ilWikiPage::getAllPages($this->wiki->getId());
     $options = array("" => $this->lng->txt("please_select"));
     foreach ($pages as $p) {
         //if (!in_array($p["id"], $ipages_ids))
         //{
         $options[$p["id"]] = ilUtil::shortenText($p["title"], 60, true);
         //}
     }
     $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
     $this->toolbar->setOpenFormTag(true);
     $this->toolbar->setCloseFormTag(false);
     if (count($options) > 0) {
         include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
         $si = new ilSelectInputGUI($this->lng->txt("wiki_pages"), "templ_page_id");
         $si->setOptions($options);
         $this->toolbar->addInputItem($si);
         $this->toolbar->addFormButton($this->lng->txt("wiki_add_template"), "add");
         $this->toolbar->addSeparator();
     }
     // empty page as template?
     include_once "./Services/Form/classes/class.ilCheckboxInputGUI.php";
     $cb = new ilCheckboxInputGUI($this->lng->txt("wiki_empty_page_template"), "empty_page_templ");
     $cb->setChecked($this->wiki->getEmptyPageTemplate());
     $this->toolbar->addInputItem($cb, true);
     $this->toolbar->addFormButton($this->lng->txt("save"), "saveTemplateSettings");
     include_once "./Modules/Wiki/classes/class.ilWikiPageTemplatesTableGUI.php";
     $tab = new ilWikiPageTemplatesTableGUI($this, "listTemplates", $this->wiki->getId());
     $tab->setOpenFormTag(false);
     $tab->setCloseFormTag(true);
     $this->tpl->setContent($tab->getHTML());
 }
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $title = ilWikiPage::lookupTitle($a_set);
     $this->tpl->setVariable("TXT_PAGE_TITLE", $title);
     $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle($title));
     $this->tpl->setVariable("HREF_PAGE", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "preview"));
 }
 /**
  * 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";
     foreach ($wpg_map as $wpg_id) {
         $wiki_id = ilWikiPage::lookupWikiId($wpg_id);
         ilWikiPage::_writeParentId("wpg", $wpg_id, $wiki_id);
     }
 }
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $title = ilWikiPage::lookupTitle($a_set["id"]);
     $this->tpl->setVariable("TXT_PAGE_TITLE", $title);
     $this->tpl->setVariable("DATE", ilDatePresentation::formatDate(new ilDateTime($a_set["date"], IL_CAL_DATETIME)));
     $ilCtrl->setParameterByClass("ilwikipagegui", "page", rawurlencode($title));
     $ilCtrl->setParameterByClass("ilwikipagegui", "old_nr", $a_set["nr"]);
     $this->tpl->setVariable("HREF_PAGE", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "preview"));
     // user name
     include_once "./Services/User/classes/class.ilUserUtil.php";
     $this->tpl->setVariable("TXT_USER", ilUserUtil::getNamePresentation($a_set["user"], true, true, $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())));
 }
 /**
  * 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";
     $pg_ids = array();
     foreach ($a_ids as $id) {
         $pages = ilWikiPage::getAllPages($id);
         foreach ($pages as $p) {
             if (ilWikiPage::_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));
 }
 /**
  * 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 (ilWikiPage::_exists("wpg", $page["id"])) {
             $this->exportPageHTML($page["id"]);
             $this->co_page_html_export->collectPageElements("wpg:pg", $page["id"]);
         }
     }
     $this->co_page_html_export->exportPageElements();
 }
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng;
     if ($a_set["page_id"] > 0) {
         $this->tpl->setCurrentBlock("cb");
         $this->tpl->setVariable("PAGE_ID", $a_set["page_id"]);
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ord");
         $this->tpl->setVariable("PAGE_ID_ORD", $a_set["page_id"]);
         $this->tpl->setVariable("VAL_ORD", $a_set["ord"]);
         $this->tpl->parseCurrentBlock();
         $this->tpl->setVariable("PAGE_TITLE", ilWikiPage::lookupTitle($a_set["page_id"]));
         $this->tpl->setVariable("SEL_INDENT", ilUtil::formSelect($a_set["indent"], "indent[" . $a_set["page_id"] . "]", array(0 => "0", 1 => "1", 2 => "2"), false, true));
     } else {
         $this->tpl->setVariable("PAGE_TITLE", $lng->txt("wiki_start_page"));
     }
 }
 /**
  * execute command
  */
 function &executeCommand()
 {
     global $lng, $ilAccess, $tpl, $ilNavigationHistory;
     $cmd = $this->ctrl->getCmd();
     $next_class = $this->ctrl->getNextClass($this);
     if ($next_class == "") {
         $this->ctrl->setCmdClass("ilobjwikigui");
         $next_class = $this->ctrl->getNextClass($this);
     }
     // add entry to navigation history
     if ($ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
         $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
         $title = ilObject::_lookupTitle($obj_id);
         if ($_GET["page"] != "") {
             $page = $_GET["page"];
         } else {
             include_once "./Modules/Wiki/classes/class.ilObjWiki.php";
             $page = ilObjWiki::_lookupStartPage($obj_id);
         }
         include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
         if (ilWikiPage::exists($obj_id, $page)) {
             include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
             $add = "_" . rawurlencode($page);
             $page_id = ilWikiPage::getPageIdForTitle($obj_id, $page);
             $ptitle = ilWikiPage::lookupTitle($page_id);
             $title .= ": " . $ptitle;
             $append = $_GET["page"] != "" ? "_" . ilWikiUtil::makeUrlTitle($page) : "";
             include_once './Services/Link/classes/class.ilLink.php';
             $goto = ilLink::_getStaticLink($_GET["ref_id"], "wiki", true, $append);
             //var_dump($goto);
             $ilNavigationHistory->addItem($_GET["ref_id"], "./goto.php?target=wiki_" . $_GET["ref_id"] . $add, "wiki", $title, $page_id, $goto);
         }
     }
     switch ($next_class) {
         case 'ilobjwikigui':
             require_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php";
             $mc_gui =& new ilObjWikiGUI("", (int) $_GET["ref_id"], true, false);
             $this->ctrl->forwardCommand($mc_gui);
             break;
     }
     $tpl->show();
 }
 /**
  * get html 
  * @return
  */
 public function getHTML()
 {
     global $lng, $ilUser;
     $lng->loadLanguageModule('content');
     foreach ($this->getSubItemIds(true) as $sub_item) {
         if (is_object($this->getHighlighter()) and strlen($this->getHighlighter()->getContent($this->getObjId(), $sub_item))) {
             $this->tpl->setCurrentBlock('sea_fragment');
             $this->tpl->setVariable('TXT_FRAGMENT', $this->getHighlighter()->getContent($this->getObjId(), $sub_item));
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setCurrentBlock('subitem');
         // TODO: subitem type must returned from lucene
         if (($title = ilWikiPage::lookupTitle($sub_item)) !== false) {
             // Page
             $this->tpl->setVariable('SUBITEM_TYPE', $lng->txt('obj_pg'));
             $this->tpl->setVariable('SEPERATOR', ':');
             include_once './Services/Search/classes/class.ilUserSearchCache.php';
             $link = '&srcstring=1';
             $link = ilObjWikiGUI::getGotoLink($this->getRefId(), $title) . $link;
             $this->tpl->setVariable('LINK', $link);
             $this->tpl->setVariable('TARGET', $this->getItemListGUI()->getCommandFrame(''));
             $this->tpl->setVariable('TITLE', $title);
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setVariable('SUBITEM_TYPE', $lng->txt('obj_file'));
             $this->tpl->setVariable('SEPERATOR', ':');
             // File
             $this->getItemListGUI()->setChildId('il__file_' . $sub_item);
             $link = $this->getItemListGUI()->getCommandLink('downloadFile');
             $this->tpl->setVariable('LINK', $link);
             $this->tpl->setVariable('TITLE', ilObject::_lookupTitle($sub_item));
             $this->tpl->parseCurrentBlock();
         }
         if (count($this->getSubItemIds(true)) > 1) {
             $this->parseRelevance($sub_item);
         }
         $this->tpl->parseCurrentBlock();
     }
     $this->showDetailsLink();
     return $this->tpl->get();
 }
 /**
  * show news
  */
 function showNews()
 {
     global $lng, $ilCtrl, $ilUser;
     // workaround for dynamic mode (if cache is disabled, showNews has no data)
     if (empty(self::$st_data)) {
         $this->setData($this->getNewsData());
     }
     $news_set = new ilSetting("news");
     $enable_internal_rss = $news_set->get("enable_rss_for_internal");
     include_once "./Services/News/classes/class.ilNewsItem.php";
     $news = new ilNewsItem($_GET["news_id"]);
     $tpl = new ilTemplate("tpl.show_news.html", true, true, "Services/News");
     // get current item in data set
     $previous = $next = "";
     reset($this->data);
     $c = current($this->data);
     $curr_cnt = 1;
     while ($c["id"] > 0 && $c["id"] != $_GET["news_id"]) {
         $previous = $c;
         $c = next($this->data);
         $curr_cnt++;
     }
     // collect news items to show
     $news_list = array();
     if (is_array($c["aggregation"])) {
         //$agg_obj_id = ilObject::_lookupObjId($c["agg_ref_id"]);
         //$agg_obj_type = ilObject::_lookupType($agg_obj_id);
         //$agg_obj_title = ilObject::_lookupObjId($agg_obj_id);
         $news_list[] = array("ref_id" => $c["agg_ref_id"], "agg_ref_id" => $c["agg_ref_id"], "aggregation" => $c["aggregation"], "user_id" => "", "content_type" => "text", "mob_id" => 0, "visibility" => "", "content" => "", "content_long" => "", "update_date" => $news->getUpdateDate(), "creation_date" => "", "content_is_lang_var" => false, "loc_context" => $_GET["news_context"], "context_obj_type" => $news->getContextObjType(), "title" => "");
         foreach ($c["aggregation"] as $c_item) {
             ilNewsItem::_setRead($ilUser->getId(), $c_item["id"]);
             $c_item["loc_context"] = $c_item["ref_id"];
             $c_item["loc_stop"] = $_GET["news_context"];
             $news_list[] = $c_item;
         }
     } else {
         $news_list[] = array("ref_id" => $_GET["news_context"], "user_id" => $news->getUserId(), "content_type" => $news->getContentType(), "mob_id" => $news->getMobId(), "visibility" => $news->getVisibility(), "priority" => $news->getPriority(), "content" => $news->getContent(), "content_long" => $news->getContentLong(), "update_date" => $news->getUpdateDate(), "creation_date" => $news->getCreationDate(), "context_sub_obj_type" => $news->getContextSubObjType(), "context_obj_type" => $news->getContextObjType(), "context_sub_obj_id" => $news->getContextSubObjId(), "content_is_lang_var" => $news->getContentIsLangVar(), "content_text_is_lang_var" => $news->getContentTextIsLangVar(), "loc_context" => $_GET["news_context"], "title" => $news->getTitle());
         ilNewsItem::_setRead($ilUser->getId(), $_GET["news_id"]);
     }
     foreach ($news_list as $item) {
         // user
         if ($item["user_id"] > 0 && ilObject::_exists($item["user_id"])) {
             // get login
             if (ilObjUser::_exists($item["user_id"])) {
                 $user = new ilObjUser($item["user_id"]);
                 $displayname = $user->getLogin();
             } else {
                 // this should actually not happen, since news entries
                 // should be deleted when the user is going to be removed
                 $displayname = "<" . strtolower($lng->txt("deleted")) . ">";
             }
             $tpl->setCurrentBlock("user_info");
             $tpl->setVariable("VAL_AUTHOR", $displayname);
             $tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
             $tpl->parseCurrentBlock();
         }
         // media player
         if ($item["content_type"] == NEWS_AUDIO && $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"])) {
             include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
             include_once "./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php";
             $mob = new ilObjMediaObject($item["mob_id"]);
             $med = $mob->getMediaItem("Standard");
             $mpl = new ilMediaPlayerGUI();
             if (strcasecmp("Reference", $med->getLocationType()) == 0) {
                 $mpl->setFile($med->getLocation());
             } else {
                 $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
             }
             $mpl->setDisplayHeight($med->getHeight());
             $tpl->setCurrentBlock("player");
             $tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
             $tpl->parseCurrentBlock();
         }
         // access
         if ($enable_internal_rss && $item["visibility"] != "") {
             $obj_id = ilObject::_lookupObjId($item["ref_id"]);
             $tpl->setCurrentBlock("access");
             $tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
             if ($item["visibility"] == NEWS_PUBLIC || $item["priority"] == 0 && ilBlockSetting::_lookup("news", "public_notifications", 0, $obj_id)) {
                 $tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
             } else {
                 $tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
             }
             $tpl->parseCurrentBlock();
         }
         // content
         if (trim($item["content"]) != "") {
             $tpl->setCurrentBlock("content");
             $tpl->setVariable("VAL_CONTENT", nl2br($this->makeClickable(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]))));
             //$tpl->setVariable("VAL_CONTENT", nl2br($item["content"]));
             $tpl->parseCurrentBlock();
         }
         if (trim($item["content_long"]) != "") {
             $tpl->setCurrentBlock("long");
             $tpl->setVariable("VAL_LONG_CONTENT", $this->makeClickable($item["content_long"]));
             $tpl->parseCurrentBlock();
         }
         if ($item["update_date"] != $item["creation_date"]) {
             $tpl->setCurrentBlock("ni_update");
             $tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
             $tpl->setVariable("VAL_LAST_UPDATE", ilDatePresentation::formatDate(new ilDateTime($item["update_date"], IL_CAL_DATETIME)));
             $tpl->parseCurrentBlock();
         }
         // creation date
         if ($item["creation_date"] != "") {
             $tpl->setCurrentBlock("ni_update");
             $tpl->setVariable("VAL_CREATION_DATE", ilDatePresentation::formatDate(new ilDateTime($item["creation_date"], IL_CAL_DATETIME)));
             $tpl->setVariable("TXT_CREATED", $lng->txt("created"));
             $tpl->parseCurrentBlock();
         }
         // context / title
         if ($_GET["news_context"] > 0) {
             //$obj_id = ilObject::_lookupObjId($_GET["news_context"]);
             $obj_id = ilObject::_lookupObjId($item["ref_id"]);
             $obj_type = ilObject::_lookupType($obj_id);
             $obj_title = ilObject::_lookupTitle($obj_id);
             // file hack, not nice
             if ($obj_type == "file") {
                 $tpl->setCurrentBlock("download");
                 $tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
                 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $item["ref_id"]);
                 $tpl->setVariable("HREF_DOWNLOAD", $ilCtrl->getLinkTargetByClass("ilrepositorygui", "sendfile"));
                 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
                 $tpl->parseCurrentBlock();
             }
             // forum hack, not nice
             $add = "";
             if ($obj_type == "frm" && $item["context_sub_obj_type"] == "pos" && $item["context_sub_obj_id"] > 0) {
                 include_once "./Modules/Forum/classes/class.ilObjForumAccess.php";
                 $pos = $item["context_sub_obj_id"];
                 $thread = ilObjForumAccess::_getThreadForPosting($pos);
                 if ($thread > 0) {
                     $add = "_" . $thread . "_" . $pos;
                 }
             }
             // wiki hack, not nice
             if ($obj_type == "wiki" && $item["context_sub_obj_type"] == "wpg" && $item["context_sub_obj_id"] > 0) {
                 include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                 $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
                 if ($wptitle != "") {
                     $add = "_" . ilWikiUtil::makeUrlTitle($wptitle);
                 }
             }
             $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" . $obj_type . "_" . $item["ref_id"] . $add;
             // lm page hack, not nice
             if (in_array($obj_type, array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg" && $item["context_sub_obj_id"] > 0) {
                 $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" . "pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"];
             }
             $context_opened = false;
             if ($item["loc_context"] != null && $item["loc_context"] != $item["loc_stop"]) {
                 $tpl->setCurrentBlock("context");
                 $context_opened = true;
                 $cont_loc = new ilLocatorGUI();
                 $cont_loc->addContextItems($item["loc_context"], true, $item["loc_stop"]);
                 $tpl->setVariable("CONTEXT_LOCATOR", $cont_loc->getHTML());
             }
             //var_dump($item);
             if ($item["no_context_title"] !== true) {
                 if (!$context_opened) {
                     $tpl->setCurrentBlock("context");
                 }
                 $tpl->setVariable("HREF_CONTEXT_TITLE", $url_target);
                 $tpl->setVariable("CONTEXT_TITLE", $obj_title);
                 $tpl->setVariable("IMG_CONTEXT_TITLE", ilObject::_getIcon($obj_id, "big", $obj_type));
             }
             if ($context_opened) {
                 $tpl->parseCurrentBlock();
             }
             $tpl->setVariable("HREF_TITLE", $url_target);
         }
         // title
         $tpl->setVariable("VAL_TITLE", ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]));
         $row_css = $row_css != "tblrow1" ? "tblrow1" : "tblrow2";
         $tpl->setCurrentBlock("item");
         $tpl->setVariable("ITEM_ROW_CSS", $row_css);
         $tpl->parseCurrentBlock();
     }
     include_once "./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php";
     $content_block = new ilPDContentBlockGUI();
     $content_block->setContent($tpl->get());
     if ($this->getProperty("title") != "") {
         $content_block->setTitle($this->getProperty("title"));
     } else {
         $content_block->setTitle($lng->txt("news_internal_news"));
     }
     //$content_block->setColSpan(2);
     $content_block->setImage(ilUtil::getImagePath("icon_news.png"));
     $this->addCloseCommand($content_block);
     // previous
     if ($previous != "") {
         if ($previous["ref_id"] > 0) {
             $ilCtrl->setParameter($this, "news_context", $previous["ref_id"]);
         }
         $ilCtrl->setParameter($this, "news_id", $previous["id"]);
         $content_block->addFooterLink($lng->txt("previous"), $ilCtrl->getLinkTarget($this, "showNews"), "", "", true);
         $ilCtrl->setParameter($this, "news_context", "");
     }
     // next
     if ($c = next($this->data)) {
         if ($c["ref_id"] > 0) {
             $ilCtrl->setParameter($this, "news_context", $c["ref_id"]);
         }
         $ilCtrl->setParameter($this, "news_id", $c["id"]);
         $content_block->addFooterLink($lng->txt("next"), $ilCtrl->getLinkTarget($this, "showNews"), "", "", true);
     }
     $ilCtrl->setParameter($this, "news_context", "");
     $ilCtrl->setParameter($this, "news_id", "");
     $content_block->setCurrentItemNumber($curr_cnt);
     $content_block->setEnableNumInfo(true);
     $content_block->setData($this->getData());
     return $content_block->getHTML();
 }
 /**
  * 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;
 }
Example #13
0
 /**
  * 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;
 }
Example #14
0
 /**
  * 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("&", "&amp;", $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 (&nbsp;) 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;
 }
 /**
  * get xml for links
  */
 function getLinkXML($a_int_links, $a_layoutframes)
 {
     global $ilCtrl;
     // Determine whether the view of a learning resource should
     // be shown in the frameset of ilias, or in a separate window.
     $showViewInFrameset = true;
     if ($a_layoutframes == "") {
         $a_layoutframes = array();
     }
     $link_info = "<IntLinkInfos>";
     foreach ($a_int_links as $int_link) {
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     if ($lm_id == $this->lm->getId() || $targetframe != "None" && $targetframe != "New") {
                         $ltarget = $a_layoutframes[$targetframe]["Frame"];
                         //$nframe = ($ltarget == "")
                         //	? $_GET["frame"]
                         //	: $ltarget;
                         $nframe = $ltarget == "" ? "" : $ltarget;
                         if ($ltarget == "") {
                             if ($showViewInFrameset) {
                                 $ltarget = "_parent";
                             } else {
                                 $ltarget = "_top";
                             }
                         }
                         // scorm always in 1window view and link target
                         // is always same frame
                         if ($this->getExportFormat() == "scorm" && $this->offlineMode()) {
                             $ltarget = "";
                         }
                         $href = $this->getLink($_GET["ref_id"], "layout", $target_id, $nframe, $type, "append", $anc);
                     } else {
                         if (!$this->offlineMode()) {
                             if ($type == "PageObject") {
                                 $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                             } else {
                                 $href = "./goto.php?target=st_" . $target_id;
                             }
                         } else {
                             if ($type == "PageObject") {
                                 $href = ILIAS_HTTP_PATH . "/goto.php?target=pg_" . $target_id . $anc_add . "&amp;client_id=" . CLIENT_ID;
                             } else {
                                 $href = ILIAS_HTTP_PATH . "/goto.php?target=st_" . $target_id . "&amp;client_id=" . CLIENT_ID;
                             }
                         }
                         if ($targetframe != "New") {
                             $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
                         } else {
                             $ltarget = "_blank";
                         }
                     }
                     break;
                 case "GlossaryItem":
                     if ($targetframe == "None") {
                         $targetframe = "Glossary";
                     }
                     $ltarget = $a_layoutframes[$targetframe]["Frame"];
                     $nframe = $ltarget == "" ? $_GET["frame"] : $ltarget;
                     $href = $this->getLink($_GET["ref_id"], $a_cmd = "glossary", $target_id, $nframe, $type);
                     break;
                 case "MediaObject":
                     $ltarget = $a_layoutframes[$targetframe]["Frame"];
                     $nframe = $ltarget == "" ? $_GET["frame"] : $ltarget;
                     $href = $this->getLink($_GET["ref_id"], $a_cmd = "media", $target_id, $nframe, $type);
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     if (!$this->offlineMode()) {
                         $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     } else {
                         $href = ILIAS_HTTP_PATH . "/goto.php?target=" . $obj_type . "_" . $target_id . "&amp;client_id=" . CLIENT_ID;
                     }
                     $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
                     break;
                 case "WikiPage":
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $href = ilWikiPage::getGotoForWikiPageTarget($target_id);
                     break;
                 case "File":
                     if (!$this->offlineMode()) {
                         $ilCtrl->setParameter($this, "file_id", "il__file_" . $target_id);
                         $href = $ilCtrl->getLinkTarget($this, "downloadFile");
                         $ilCtrl->setParameter($this, "file_id", "");
                     }
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" {$anc_par}/>";
             // set equal link info for glossary links of target "None" and "Glossary"
             /*
             				if ($targetframe=="None" && $type=="GlossaryItem")
             				{
             					$link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
             						"TargetFrame=\"Glossary\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
             				}*/
         }
     }
     $link_info .= "</IntLinkInfos>";
     return $link_info;
 }
Example #16
0
 /**
  * Handle wiki page rating
  * 
  * @param ilWikiPage $a_page_obj
  * @param int $a_user_id
  */
 public static function handlePageRating(ilWikiPage $a_page_obj, $a_user_id)
 {
     // do page first!
     $rating = self::getAverageRating($a_page_obj->getWikiId(), $a_page_obj->getId());
     // wiki_stat_page: num_ratings, avg_rating
     self::writeStatPage($a_page_obj->getWikiId(), $a_page_obj->getId(), array("num_ratings" => array("integer", $rating["cnt"]), "avg_rating" => array("integer", $rating["avg"] * 100)));
     $rating = self::getAverageRating($a_page_obj->getWikiId());
     // wiki_stat: avg_rating
     $is_update = self::writeStat($a_page_obj->getWikiId(), array("avg_rating" => array("integer", $rating["avg"] * 100)));
     if (!$is_update) {
         // wiki: num_pages (count)
         self::writeStat($a_page_obj->getWikiId(), array("num_pages" => array("integer", self::countPages($a_page_obj->getWikiId()))));
     }
 }
Example #17
0
 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]);
         }
     }
 }
 /**
  * Fill data section
  */
 function fillDataSection()
 {
     global $ilCtrl, $lng, $ilAccess;
     $tpl = new ilTemplate("tpl.wiki_side_block_content.html", true, true, "Modules/Wiki");
     $wp = $this->getPageObject();
     // info
     $actions[] = array("txt" => $lng->txt("info_short"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "infoScreen"));
     // recent changes
     $actions[] = array("txt" => $lng->txt("wiki_recent_changes"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "recentChanges"));
     foreach ($actions as $a) {
         $tpl->setCurrentBlock("action");
         $tpl->setVariable("HREF", $a["href"]);
         $tpl->setVariable("TXT", $a["txt"]);
         $tpl->parseCurrentBlock();
         $tpl->touchBlock("item");
     }
     $actions = array();
     // all pages
     $actions[] = array("txt" => $lng->txt("wiki_all_pages"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "allPages"));
     // new pages
     $actions[] = array("txt" => $lng->txt("wiki_new_pages"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "newPages"));
     // popular pages
     $actions[] = array("txt" => $lng->txt("wiki_popular_pages"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "popularPages"));
     // orphaned pages
     $actions[] = array("txt" => $lng->txt("wiki_orphaned_pages"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "orphanedPages"));
     // page lists
     include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
     $list = new ilAdvancedSelectionListGUI();
     $list->setListTitle($lng->txt("wiki_page_lists"));
     $list->setStyle(ilAdvancedSelectionListGUI::STYLE_LINK);
     $list->setId("wiki_pglists");
     foreach ($actions as $a) {
         $list->addItem($a["txt"], "", $a["href"]);
     }
     $tpl->setCurrentBlock("plain");
     $tpl->setVariable("PLAIN", $list->getHTML());
     $tpl->parseCurrentBlock();
     $tpl->touchBlock("item");
     // page actions
     $list = new ilAdvancedSelectionListGUI();
     $list->setStyle(ilAdvancedSelectionListGUI::STYLE_LINK);
     $list->setListTitle($lng->txt("wiki_page_actions"));
     $list->setId("wiki_pgactions");
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         // rating
         if (ilObjWiki::_lookupRating($this->getPageObject()->getWikiId())) {
             if (!$this->getPageObject()->getRating()) {
                 $list->addItem($lng->txt("wiki_activate_page_rating"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "activateWikiPageRating"));
             } else {
                 $list->addItem($lng->txt("wiki_deactivate_page_rating"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deactivateWikiPageRating"));
             }
         }
         // unhide advmd?
         include_once "./Modules/Wiki/classes/class.ilWikiAdvMetaDataBlockGUI.php";
         if (ilWikiAdvMetaDataBlockGUI::isActive($this->getPageObject()->getWikiId()) && ilWikiPage::lookupAdvancedMetadataHidden($this->getPageObject()->getId())) {
             $list->addItem($lng->txt("wiki_unhide_meta_adv_records"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unhideAdvancedMetaData"));
         }
     }
     if ($ilAccess->checkAccess("edit_content", "", $_GET["ref_id"]) && !$this->getPageObject()->getBlocked() || $ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         // rename
         $list->addItem($lng->txt("wiki_rename_page"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage"));
     }
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         // block/unblock
         if ($this->getPageObject()->getBlocked()) {
             $list->addItem($lng->txt("wiki_unblock_page"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage"));
         } else {
             $list->addItem($lng->txt("wiki_block_page"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage"));
         }
         // delete page
         $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId());
         if ($st_page != $this->getPageObject()->getTitle()) {
             $list->addItem($lng->txt("wiki_delete_page"), "", $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen"));
         }
         include_once "Modules/Wiki/classes/class.ilWikiPageTemplate.php";
         $wpt = new ilWikiPageTemplate($this->getPageObject()->getParentId());
         if (!$wpt->isPageTemplate($this->getPageObject()->getId())) {
             $list->addItem($lng->txt("wiki_add_template"), "", $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "addPageTemplateFromPageAction"));
         } else {
             $list->addItem($lng->txt("wiki_remove_template_status"), "", $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "removePageTemplateFromPageAction"));
         }
     }
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) || $ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
         $tpl->setCurrentBlock("plain");
         $tpl->setVariable("PLAIN", $list->getHTML());
         $tpl->parseCurrentBlock();
         $tpl->touchBlock("item");
     }
     // permissions
     //		if ($ilAccess->checkAccess('edit_permission', "", $_GET["ref_id"]))
     //		{
     //			$actions[] = array(
     //				"txt" => $lng->txt("perm_settings"),
     //				"href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm")
     //				);
     //		}
     $actions = array();
     // settings
     if ($ilAccess->checkAccess('write', "", $_GET["ref_id"])) {
         //			$actions[] = array(
         //				"txt" => $lng->txt("settings"),
         //				"href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
         //				);
         $actions[] = array("txt" => $lng->txt("wiki_contributors"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors"));
     }
     // manage
     if ($ilAccess->checkAccess('write', "", $_GET["ref_id"])) {
         $actions[] = array("txt" => $lng->txt("settings"), "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings"));
     } else {
         if ($ilAccess->checkAccess('statistics_read', "", $_GET["ref_id"])) {
             $actions[] = array("txt" => $lng->txt("statistics"), "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilwikistatgui"), "initial"));
         }
     }
     foreach ($actions as $a) {
         $tpl->setCurrentBlock("action");
         $tpl->setVariable("HREF", $a["href"]);
         $tpl->setVariable("TXT", $a["txt"]);
         $tpl->parseCurrentBlock();
         $tpl->touchBlock("item");
     }
     $this->setDataSection($tpl->get());
 }
Example #19
0
 /**
  * Used for rating export
  * 
  * @param int $a_id
  * @param string $a_type
  * @return string
  */
 function getSubObjectTitle($a_id, $a_type)
 {
     include_once "Modules/Wiki/classes/class.ilWikiPage.php";
     return ilWikiPage::lookupTitle($a_id);
 }
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl, $ilAccess;
     $usage = $a_set;
     //var_dump($usage);
     if (is_int(strpos($usage["type"], ":"))) {
         $us_arr = explode(":", $usage["type"]);
         $usage["type"] = $us_arr[1];
         $cont_type = $us_arr[0];
     }
     //var_dump($usage);
     include_once './Services/Link/classes/class.ilLink.php';
     switch ($usage["type"]) {
         case "pg":
             include_once "./Services/COPage/classes/class.ilPageObjectFactory.php";
             $page_obj = ilPageObjectFactory::getInstance($cont_type, $usage["id"]);
             $item = array();
             //$this->tpl->setVariable("TXT_OBJECT", $usage["type"].":".$usage["id"]);
             switch ($cont_type) {
                 case "lm":
                     require_once "./Modules/LearningModule/classes/class.ilObjContentObject.php";
                     require_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
                     require_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                     $lm_obj = new ilObjLearningModule($page_obj->getParentId(), false);
                     $item["obj_type_txt"] = $this->lng->txt("obj_" . $cont_type);
                     $item["obj_title"] = $lm_obj->getTitle();
                     $item["sub_txt"] = $this->lng->txt("pg");
                     $item["sub_title"] = ilLMObject::_lookupTitle($page_obj->getId());
                     $ref_id = $this->getFirstWritableRefId($lm_obj->getId());
                     if ($ref_id > 0) {
                         $item["obj_link"] = ilLink::_getStaticLink($page_obj->getId() . "_" . $ref_id, "pg");
                     }
                     break;
                 case "wpg":
                     require_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $item["obj_type_txt"] = $this->lng->txt("obj_wiki");
                     $item["obj_title"] = ilObject::_lookupTitle($page_obj->getParentId());
                     $item["sub_txt"] = $this->lng->txt("pg");
                     $item["sub_title"] = ilWikiPage::lookupTitle($page_obj->getId());
                     $ref_id = $this->getFirstWritableRefId($page_obj->getParentId());
                     if ($ref_id > 0) {
                         $item["obj_link"] = ilLink::_getStaticLink($ref_id, "wiki");
                     }
                     break;
                 case "gdf":
                     require_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                     require_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
                     $term_id = ilGlossaryDefinition::_lookupTermId($page_obj->getId());
                     $glo_id = ilGlossaryTerm::_lookGlossaryId($term_id);
                     $item["obj_type_txt"] = $this->lng->txt("obj_glo");
                     $item["obj_title"] = ilObject::_lookupTitle($glo_id);
                     $item["sub_txt"] = $this->lng->txt("cont_term");
                     $item["sub_title"] = ilGlossaryTerm::_lookGlossaryTerm($term_id);
                     $ref_id = $this->getFirstWritableRefId($page_obj->getParentId());
                     if ($ref_id > 0) {
                         $item["obj_link"] = ilLink::_getStaticLink($ref_id, "glo");
                     }
                     break;
                 case "cont":
                     $item["obj_type_txt"] = $this->lng->txt("obj_" . $cont_type);
                     $item["obj_title"] = ilObject::_lookupTitle($page_obj->getId());
                     $ref_id = $this->getFirstWritableRefId($page_obj->getId());
                     if ($ref_id > 0) {
                         $item["obj_link"] = ilLink::_getStaticLink($ref_id, $cont_type);
                     }
                     break;
             }
             break;
         case "mep":
             $item["obj_type_txt"] = $this->lng->txt("obj_mep");
             $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
             $ref_id = $this->getFirstWritableRefId($usage["id"]);
             if ($ref_id > 0) {
                 $item["obj_link"] = ilLink::_getStaticLink($ref_id, "mep");
             }
             break;
         case "map":
             $item["obj_type_txt"] = $this->lng->txt("obj_mob");
             $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
             $item["sub_txt"] = $this->lng->txt("cont_link_area");
             break;
     }
     // show versions
     if (is_array($usage["hist_nr"]) && (count($usage["hist_nr"]) > 1 || $usage["hist_nr"][0] > 0)) {
         asort($usage["hist_nr"]);
         $ver = $sep = "";
         if ($usage["hist_nr"][0] == 0) {
             array_shift($usage["hist_nr"]);
             $usage["hist_nr"][] = 0;
         }
         if (count($usage["hist_nr"]) > 5) {
             $ver .= "..., ";
             $cnt = count($usage["hist_nr"]) - 5;
             for ($i = 0; $i < $cnt; $i++) {
                 unset($usage["hist_nr"][$i]);
             }
         }
         foreach ($usage["hist_nr"] as $nr) {
             if ($nr > 0) {
                 $ver .= $sep . $nr;
             } else {
                 $ver .= $sep . $this->lng->txt("cont_current_version");
             }
             $sep = ", ";
         }
         $this->tpl->setCurrentBlock("versions");
         $this->tpl->setVariable("TXT_VERSIONS", $this->lng->txt("cont_versions"));
         $this->tpl->setVariable("VAL_VERSIONS", $ver);
         $this->tpl->parseCurrentBlock();
     }
     if ($item["obj_type_txt"] != "") {
         $this->tpl->setCurrentBlock("type");
         $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("type"));
         $this->tpl->setVariable("VAL_TYPE", $item["obj_type_txt"]);
         $this->tpl->parseCurrentBlock();
     }
     if ($usage["type"] != "clip") {
         if ($item["obj_link"]) {
             $this->tpl->setCurrentBlock("linked_item");
             $this->tpl->setVariable("TXT_OBJECT", $item["obj_title"]);
             $this->tpl->setVariable("HREF_LINK", $item["obj_link"]);
             $this->tpl->parseCurrentBlock();
         } else {
             $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $item["obj_title"]);
         }
         if ($item["sub_txt"] != "") {
             $this->tpl->setVariable("SEP", ", ");
             $this->tpl->setVariable("SUB_TXT", $item["sub_txt"]);
             if ($item["sub_title"] != "") {
                 $this->tpl->setVariable("SEP2", ": ");
                 $this->tpl->setVariable("SUB_TITLE", $item["sub_title"]);
             }
         }
     } else {
         $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $this->lng->txt("cont_users_have_mob_in_clip1") . " " . $usage["cnt"] . " " . $this->lng->txt("cont_users_have_mob_in_clip2"));
     }
 }
 /**
  * Show link help list
  */
 function showLinkHelp()
 {
     global $ilUser, $ilCtrl;
     // filter link types
     if (!$this->filter_white_list) {
         foreach ($this->filter_link_types as $link_type) {
             unset($this->ltypes[$link_type]);
         }
     } else {
         $ltypes = array();
         foreach ($this->ltypes as $k => $l) {
             if (in_array($k, $this->filter_link_types)) {
                 $ltypes[$k] = $l;
             }
         }
         $this->ltypes = $ltypes;
     }
     // determine link type and target
     $this->determineLinkType();
     $ltype = $this->link_target != "" ? $this->link_type . "_" . $this->link_target : $this->link_type;
     $def_type = ilObject::_lookupType($this->default_obj, true);
     // determine content object id
     switch ($this->link_type) {
         case "PageObject":
         case "StructureObject":
             if (empty($_SESSION["il_link_cont_obj"]) && ($def_type != "mep" && $def_type != "glo")) {
                 $_SESSION["il_link_cont_obj"] = $this->default_obj;
             }
             break;
         case "GlossaryItem":
             if (empty($_SESSION["il_link_glossary"]) && $def_type == "glo") {
                 $_SESSION["il_link_glossary"] = $this->default_obj;
             }
             break;
         case "Media":
             if (empty($_SESSION["il_link_mep"]) && $def_type == "mep") {
                 $_SESSION["il_link_mep"] = $this->default_obj;
             }
             break;
         case "WikiPage":
             if (empty($_SESSION["il_link_wiki"]) && $def_type == "wiki") {
                 $_SESSION["il_link_wiki"] = $this->default_obj;
             }
             break;
     }
     /*
     		$target_str = ($link_target == "")
     			? ""
     			: " target=\"".$link_target."\" ";*/
     $target_str = $this->link_target == "" ? "" : " target=\"" . $this->link_target . "\"";
     //echo "-".$this->link_type."-";
     if ($this->link_type == "GlossaryItem" && (empty($_SESSION["il_link_glossary"]) || !in_array(ilObject::_lookupType($_SESSION["il_link_glossary"], true), array("glo")))) {
         $this->changeTargetObject("glo");
     }
     if ($this->link_type == "WikiPage" && (empty($_SESSION["il_link_wiki"]) || !in_array(ilObject::_lookupType($_SESSION["il_link_wiki"], true), array("wiki")))) {
         $this->changeTargetObject("wiki");
     }
     if (($this->link_type == "PageObject" || $this->link_type == "StructureObject") && (empty($_SESSION["il_link_cont_obj"]) || !in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true), array("lm", "dbk")))) {
         $this->changeTargetObject("cont_obj");
     }
     if ($ilCtrl->isAsynch()) {
         $tpl = new ilTemplate("tpl.link_help_asynch.html", true, true, "Services/Link");
     } else {
         $tpl =& new ilTemplate("tpl.link_help.html", true, true, "Services/Link");
         $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     }
     switch ($this->link_type) {
         case "GlossaryItem":
             $this->ctrl->setParameter($this, "target_type", "glo");
             break;
         case "PageObject":
         case "StructureObject":
             $this->ctrl->setParameter($this, "target_type", "cont_obj");
             break;
         case "Media":
             $this->ctrl->setParameter($this, "target_type", "mep");
             break;
         case "WikiPage":
             $this->ctrl->setParameter($this, "target_type", "wiki");
             break;
         default:
             break;
     }
     //echo "<br><br>:".$this->ctrl->getFormAction($this).":";
     //echo "<br>link_type:".$this->link_type;
     //echo "<br>cont_obj:".$_SESSION["il_link_cont_obj"];
     //echo "<br>link_mep".$_SESSION["il_link_mep"];
     $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "changeLinkType", "", true));
     $tpl->setVariable("FORMACTION2", $this->ctrl->getFormAction($this));
     $tpl->setVariable("TXT_HELP_HEADER", $this->lng->txt("cont_link_select"));
     $tpl->setVariable("TXT_TYPE", $this->lng->txt("cont_link_type"));
     //echo "<br><br>".$ltype;
     $select_ltype = ilUtil::formSelect($ltype, "ltype", $this->ltypes, false, true, "0", "", array("id" => "ilIntLinkTypeSelector"));
     $tpl->setVariable("SELECT_TYPE", $select_ltype);
     $tpl->setVariable("CMD_CHANGETYPE", "changeLinkType");
     $tpl->setVariable("BTN_CHANGETYPE", $this->lng->txt("cont_change_type"));
     /*		if ($this->isEnabledJavaScript())
     		{
     			$tpl->setVariable("BTN_CLOSE_JS", $this->lng->txt("close"));
     		}
     		else 
     		{*/
     $tpl->setVariable("CMD_CLOSE", "closeLinkHelp");
     $tpl->setVariable("BTN_CLOSE", $this->lng->txt("close"));
     //		}
     $chapterRowBlock = "chapter_row";
     $anchor_row_block = "anchor_link";
     if ($this->isEnabledJavaScript()) {
         $chapterRowBlock .= "_js";
         $anchor_row_block .= "_js";
     }
     $obj_id = ilObject::_lookupObjId($_SESSION["il_link_cont_obj"]);
     $type = ilObject::_lookupType($obj_id);
     // switch link type
     switch ($this->link_type) {
         // page link
         case "PageObject":
             require_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
             include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
             $cont_obj = new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
             // get all chapters
             $ctree = $cont_obj->getLMTree();
             $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
             $tpl->setCurrentBlock("chapter_list");
             $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_lm"));
             $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
             $tpl->setVariable("THEAD", $this->lng->txt("pages"));
             $tpl->setCurrentBlock("change_cont_obj");
             $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
             $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
             $tpl->parseCurrentBlock();
             foreach ($nodes as $node) {
                 if ($node["type"] == "st") {
                     $tpl->setCurrentBlock("chapter_row");
                     $tpl->setVariable("TXT_CHAPTER", $node["title"]);
                     $tpl->setVariable("ROWCLASS", "tblrow1");
                     //$tpl->setVariable("LINK_CHAPTER",
                     //	"[iln chap=\"".$node["obj_id"]."\"".$target_str."] [/iln]");
                     $tpl->parseCurrentBlock();
                     $tpl->setCurrentBlock("row");
                     $tpl->parseCurrentBlock();
                 }
                 if ($node["type"] == "pg") {
                     include_once "./Services/COPage/classes/class.ilPCParagraph.php";
                     $this->renderLink($tpl, $node["title"], $node["obj_id"], "PageObject", "pg", "page", ilPCParagraph::_readAnchors($type, $node["obj_id"], ""));
                 }
             }
             // get all free pages
             $pages = ilLMPageObject::getPageList($cont_obj->getId());
             $free_pages = array();
             foreach ($pages as $page) {
                 if (!$ctree->isInTree($page["obj_id"])) {
                     $free_pages[] = $page;
                 }
             }
             if (count($free_pages) > 0) {
                 $tpl->setCurrentBlock(str_replace("_js", "", $chapterRowBlock));
                 $tpl->setVariable("TXT_CHAPTER", $this->lng->txt("cont_free_pages"));
                 $tpl->setVariable("ROWCLASS", "tblrow1");
                 $tpl->parseCurrentBlock();
                 foreach ($free_pages as $node) {
                     include_once "./Services/COPage/classes/class.ilPCParagraph.php";
                     $this->renderLink($tpl, $node["title"], $node["obj_id"], "PageObject", "pg", "page", ilPCParagraph::_readAnchors($type, $node["obj_id"], ""));
                 }
             }
             $tpl->setCurrentBlock("chapter_list");
             $tpl->parseCurrentBlock();
             break;
             // chapter link
         // chapter link
         case "StructureObject":
             // check whether current object matchs to type
             if (!in_array(ilObject::_lookupType($_SESSION["il_link_cont_obj"], true), array("lm", "dbk"))) {
                 $this->changeTargetObject("lm");
             }
             if ($type == "lm") {
                 require_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
                 $cont_obj = new ilObjLearningModule($_SESSION["il_link_cont_obj"], true);
             } else {
                 if ($type == "dbk") {
                     require_once "./Modules/LearningModule/classes/class.ilObjDlBook.php";
                     $cont_obj = new ilObjDlBook($_SESSION["il_link_cont_obj"], true);
                 }
             }
             // get all chapters
             $ctree =& $cont_obj->getLMTree();
             $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
             $tpl->setCurrentBlock("chapter_list");
             $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_lm"));
             $tpl->setVariable("TXT_CONT_TITLE", $cont_obj->getTitle());
             $tpl->setVariable("THEAD", $this->lng->txt("link_chapters"));
             $tpl->setCurrentBlock("change_cont_obj");
             $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
             $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
             $tpl->parseCurrentBlock();
             foreach ($nodes as $node) {
                 if ($node["type"] == "st") {
                     $this->renderLink($tpl, $node["title"], $node["obj_id"], "StructureObject", "st", "chap");
                 }
             }
             $tpl->setCurrentBlock("chapter_list");
             $tpl->parseCurrentBlock();
             break;
             // glossary item link
         // glossary item link
         case "GlossaryItem":
             require_once "./Modules/Glossary/classes/class.ilObjGlossary.php";
             $glossary =& new ilObjGlossary($_SESSION["il_link_glossary"], true);
             // get all glossary items
             $terms = $glossary->getTermList();
             $tpl->setCurrentBlock("chapter_list");
             $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("glossary"));
             $tpl->setVariable("TXT_CONT_TITLE", $glossary->getTitle());
             $tpl->setVariable("THEAD", $this->lng->txt("link_terms"));
             $tpl->setCurrentBlock("change_cont_obj");
             $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
             $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
             $tpl->parseCurrentBlock();
             foreach ($terms as $term) {
                 $this->renderLink($tpl, $term["term"], $term["id"], "GlossaryItem", "git", "term");
             }
             $tpl->setCurrentBlock("chapter_list");
             $tpl->parseCurrentBlock();
             break;
             // media object
         // media object
         case "Media":
             include_once "./Modules/MediaPool/classes/class.ilMediaPoolItem.php";
             //$tpl->setVariable("TARGET2", " target=\"content\" ");
             // content object id = 0 --> get clipboard objects
             if ($_SESSION["il_link_mep"] == 0) {
                 $tpl->setCurrentBlock("change_cont_obj");
                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
                 $tpl->parseCurrentBlock();
                 $mobjs = $ilUser->getClipboardObjects("mob");
                 // sort by name
                 $objs = array();
                 foreach ($mobjs as $obj) {
                     $objs[$obj["title"] . ":" . $obj["id"]] = $obj;
                 }
                 ksort($objs);
                 $tpl->setCurrentBlock("chapter_list");
                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("cont_media_source"));
                 $tpl->setVariable("TXT_CONT_TITLE", $this->lng->txt("cont_personal_clipboard"));
                 $tpl->setVariable("THEAD", $this->lng->txt("link_mobs"));
                 $tpl->setVariable("COLSPAN", "2");
                 foreach ($objs as $obj) {
                     $this->renderLink($tpl, $obj["title"], $obj["id"], "MediaObject", "mob", "media");
                 }
                 $tpl->setCurrentBlock("chapter_list");
                 $tpl->parseCurrentBlock();
             } else {
                 require_once "./Modules/MediaPool/classes/class.ilObjMediaPool.php";
                 $med_pool =& new ilObjMediaPool($_SESSION["il_link_mep"], true);
                 // get current folders
                 $fobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "fold");
                 $f2objs = array();
                 foreach ($fobjs as $obj) {
                     $f2objs[$obj["title"] . ":" . $obj["child"]] = $obj;
                 }
                 ksort($f2objs);
                 // get current media objects
                 $mobjs = $med_pool->getChilds($_SESSION["il_link_mep_obj"], "mob");
                 $m2objs = array();
                 foreach ($mobjs as $obj) {
                     $m2objs[$obj["title"] . ":" . $obj["child"]] = $obj;
                 }
                 ksort($m2objs);
                 // merge everything together
                 $objs = array_merge($f2objs, $m2objs);
                 $tpl->setCurrentBlock("chapter_list");
                 $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("mep"));
                 $tpl->setVariable("TXT_CONT_TITLE", $med_pool->getTitle());
                 $tpl->setVariable("THEAD", $this->lng->txt("link_mobs"));
                 $tpl->setCurrentBlock("change_cont_obj");
                 $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
                 $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
                 $tpl->setVariable("COLSPAN", "2");
                 $tpl->parseCurrentBlock();
                 if ($parent_id = $med_pool->getParentId($_SESSION["il_link_mep_obj"])) {
                     $css_row = "tblrow1";
                     $tpl->setCurrentBlock("icon");
                     $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.svg"));
                     $tpl->parseCurrentBlock();
                     $tpl->setCurrentBlock("link_row");
                     $tpl->setVariable("ROWCLASS", $css_row);
                     $tpl->setVariable("TXT_CHAPTER", "..");
                     $this->ctrl->setParameter($this, "mep_fold", $parent_id);
                     if ($ilCtrl->isAsynch()) {
                         $tpl->setVariable("LINK", "#");
                         $tpl->setVariable("LR_ONCLICK", " onclick=\"return il.IntLink.setMepPoolFolder('" . $parent_id . "');\" ");
                     } else {
                         $tpl->setVariable("LINK", $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
                     }
                     $tpl->parseCurrentBlock();
                     $tpl->setCurrentBlock("row");
                     $tpl->parseCurrentBlock();
                 }
                 foreach ($objs as $obj) {
                     if ($obj["type"] == "fold") {
                         $css_row = $css_row == "tblrow2" ? "tblrow1" : "tblrow2";
                         $tpl->setCurrentBlock("icon");
                         $tpl->setVariable("ICON_SRC", ilUtil::getImagePath("icon_fold.svg"));
                         $tpl->parseCurrentBlock();
                         $tpl->setCurrentBlock("link_row");
                         $tpl->setVariable("ROWCLASS", $css_row);
                         $tpl->setVariable("TXT_CHAPTER", $obj["title"]);
                         $this->ctrl->setParameter($this, "mep_fold", $obj["child"]);
                         if ($ilCtrl->isAsynch()) {
                             $tpl->setVariable("LINK", "#");
                             $tpl->setVariable("LR_ONCLICK", " onclick=\"return il.IntLink.setMepPoolFolder('" . $obj["child"] . "');\" ");
                         } else {
                             $tpl->setVariable("LINK", $this->ctrl->getLinkTarget($this, "setMedPoolFolder"));
                         }
                         $tpl->parseCurrentBlock();
                     } else {
                         $fid = ilMediaPoolItem::lookupForeignId($obj["child"]);
                         if (ilObject::_lookupType($fid) == "mob") {
                             $this->renderLink($tpl, $obj["title"], $fid, "MediaObject", "mob", "media");
                         }
                     }
                     $tpl->setCurrentBlock("row");
                     $tpl->parseCurrentBlock();
                 }
                 $tpl->setCurrentBlock("chapter_list");
                 $tpl->parseCurrentBlock();
             }
             break;
             // glossary item link
         // glossary item link
         case "WikiPage":
             $wiki_id = ilObject::_lookupObjId($_SESSION["il_link_wiki"]);
             require_once "./Modules/Wiki/classes/class.ilWikiPage.php";
             $wpages = ilWikiPage::getAllPages($wiki_id);
             // get all glossary items
             $tpl->setCurrentBlock("chapter_list");
             $tpl->setVariable("TXT_CONTENT_OBJECT", $this->lng->txt("obj_wiki"));
             $tpl->setVariable("TXT_CONT_TITLE", ilObject::_lookupTitle($wiki_id));
             $tpl->setVariable("THEAD", $this->lng->txt("link_wpages"));
             $tpl->setCurrentBlock("change_cont_obj");
             $tpl->setVariable("CMD_CHANGE_CONT_OBJ", "changeTargetObject");
             $tpl->setVariable("BTN_CHANGE_CONT_OBJ", $this->lng->txt("change"));
             $tpl->parseCurrentBlock();
             foreach ($wpages as $wpage) {
                 $this->renderLink($tpl, $wpage["title"], $wpage["id"], "WikiPage", "wpage", "wpage");
             }
             $tpl->setCurrentBlock("chapter_list");
             $tpl->parseCurrentBlock();
             break;
             // repository item
         // repository item
         case "RepositoryItem":
             $tpl->setVariable("LINK_HELP_CONTENT", $this->selectRepositoryItem());
             break;
             // file download link
         // file download link
         case "File":
             if (!is_object($this->uploaded_file)) {
                 $tpl->setVariable("LINK_HELP_CONTENT", $this->getFileLinkHTML());
             } else {
                 echo $this->getFileLinkHTML();
                 exit;
             }
             break;
     }
     if ($ilCtrl->isAsynch()) {
         echo $tpl->get();
         exit;
     }
     exit;
 }
Example #22
0
 protected function export()
 {
     global $ilCtrl;
     $params = $this->viewToolbar();
     if ($params) {
         // data
         $tfr = explode("-", (string) $params["month"]);
         $day_from = date("Y-m-d", mktime(0, 0, 1, $tfr[1] - ($params["scope"] - 1), 1, $tfr[0]));
         $day_to = date("Y-m-d", mktime(0, 0, 1, $tfr[1] + 1, 0, $tfr[0]));
         unset($tfr);
         $chart_data = $this->getChartData($params["figure"], $params["scope"], $day_from, $day_to);
         // excel
         $period = ilDatePresentation::formatPeriod(new ilDate($day_from, IL_CAL_DATE), new ilDate($day_to, IL_CAL_DATE));
         $filename = ilObject::_lookupTitle($this->wiki_id);
         if ($this->page_id) {
             $filename .= " - " . ilWikiPage::lookupTitle($this->page_id);
         }
         $filename .= " - " . ilWikiStat::getFigureTitle($params["figure"]) . " - " . $period . ".xls";
         include_once "./Services/Excel/classes/class.ilExcelUtils.php";
         include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
         $adapter = new ilExcelWriterAdapter($filename, true);
         $workbook = $adapter->getWorkbook();
         $worksheet = $workbook->addWorksheet();
         // $worksheet->setLandscape();
         /*
         $worksheet->setColumn(0, 0, 20);
         $worksheet->setColumn(1, 1, 40);
         */
         $row = 0;
         foreach ($chart_data as $day => $value) {
             $row++;
             $worksheet->writeString($row, 0, $day);
             $worksheet->writeNumber($row, 1, $value);
         }
         $workbook->close();
         exit;
     }
     $ilCtrl->redirect($this, "view");
 }
 /**
  * get link targets
  */
 function getLinkXML($a_int_links)
 {
     if ($a_layoutframes == "") {
         $a_layoutframes = array();
     }
     $link_info = "<IntLinkInfos>";
     foreach ($a_int_links as $int_link) {
         //echo "<br>+".$int_link["Type"]."+".$int_link["TargetFrame"]."+".$int_link["Target"]."+";
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             if ($targetframe == "New") {
                 $ltarget = "_blank";
             } else {
                 $ltarget = "";
             }
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     $cont_obj =& $this->content_object;
                     if ($type == "PageObject") {
                         $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                     } else {
                         $href = "./goto.php?target=st_" . $target_id;
                     }
                     //$ltarget = "ilContObj".$lm_id;
                     break;
                 case "GlossaryItem":
                     if (ilGlossaryTerm::_lookGlossaryID($target_id) == $this->glossary->getId()) {
                         if ($this->offlineMode()) {
                             $href = "term_" . $target_id . ".html";
                         } else {
                             $this->ctrl->setParameter($this, "term_id", $target_id);
                             $href = $this->ctrl->getLinkTarget($this, "listDefinitions");
                             $href = str_replace("&", "&amp;", $href);
                         }
                     } else {
                         $href = "./goto.php?target=git_" . $target_id;
                     }
                     break;
                 case "MediaObject":
                     if ($this->offlineMode()) {
                         $href = "media_" . $target_id . ".html";
                     } else {
                         $this->ctrl->setParameter($this, "obj_type", $type);
                         $this->ctrl->setParameter($this, "mob_id", $target_id);
                         $href = $this->ctrl->getLinkTarget($this, "media");
                         $href = str_replace("&", "&amp;", $href);
                     }
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
                     $ltarget = $t_frame;
                     break;
                 case "WikiPage":
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $href = ilWikiPage::getGotoForWikiPageTarget($target_id);
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" {$anc_par}/>";
             $this->ctrl->clearParameters($this);
         }
     }
     $link_info .= "</IntLinkInfos>";
     return $link_info;
 }
 /**
  * Rename page
  */
 public function renamePage()
 {
     global $tpl, $lng, $ilCtrl, $ilAccess;
     $this->initRenameForm();
     if ($this->form->checkInput()) {
         if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
             $new_name = $this->form->getInput("new_page_name");
             $page_title = ilWikiUtil::makeDbTitle($new_name);
             $pg_id = ilWikiPage::_getPageIdForWikiTitle($this->getPageObject()->getWikiId(), $page_title);
             // we might get the same page id back here, if the page
             // name only differs in diacritics
             // see bug http://www.ilias.de/mantis/view.php?id=11226
             if ($pg_id > 0 && $pg_id != $this->getPageObject()->getId()) {
                 ilUtil::sendFailure($lng->txt("wiki_page_already_exists"));
             } else {
                 $new_name = $this->getPageObject()->rename($new_name);
                 $ilCtrl->setParameterByClass("ilobjwikigui", "page", ilWikiUtil::makeUrlTitle($new_name));
                 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
                 $ilCtrl->redirect($this, "preview");
             }
         }
     }
     $this->form->setValuesByPost();
     $tpl->setContent($this->form->getHtml());
 }
 function ilUserFeedWriter($a_user_id, $a_hash, $privFeed = false)
 {
     global $ilSetting, $lng;
     parent::ilFeedWriter();
     //$lng->loadLanguageModule("news");
     if ($a_user_id == "" || $a_hash == "") {
         return;
     }
     $news_set = new ilSetting("news");
     if (!$news_set->get("enable_rss_for_internal")) {
         return;
     }
     include_once "Services/User/classes/class.ilObjUser.php";
     $hash = ilObjUser::_lookupFeedHash($a_user_id);
     include_once "./Services/News/classes/class.ilNewsItem.php";
     $rss_period = ilNewsItem::_lookupRSSPeriod();
     if ($a_hash == $hash) {
         if ($privFeed) {
             //ilNewsItem::setPrivateFeedId($a_user_id);
             $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, false, true, $rss_period);
         } else {
             $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, true, true, $rss_period);
         }
         if ($ilSetting->get('short_inst_name') != "") {
             $this->setChannelTitle($ilSetting->get('short_inst_name'));
         } else {
             $this->setChannelTitle("ILIAS");
         }
         $this->setChannelAbout(ILIAS_HTTP_PATH);
         $this->setChannelLink(ILIAS_HTTP_PATH);
         //$this->setChannelDescription("ILIAS Channel Description");
         $i = 0;
         foreach ($items as $item) {
             $obj_id = ilObject::_lookupObjId($item["ref_id"]);
             $obj_type = ilObject::_lookupType($obj_id);
             $obj_title = ilObject::_lookupTitle($obj_id);
             // not nice, to do: general solution
             if ($obj_type == "mcst") {
                 include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
                 if (!ilObjMediaCastAccess::_lookupOnline($obj_id)) {
                     continue;
                 }
             }
             $i++;
             $feed_item = new ilFeedItem();
             $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]);
             // path
             $loc = $this->getContextPath($item["ref_id"]);
             // title
             if ($news_set->get("rss_title_format") == "news_obj") {
                 $feed_item->setTitle($this->prepareStr(str_replace("<br />", " ", $title)) . " (" . $this->prepareStr($loc) . " " . $this->prepareStr($obj_title) . ")");
             } else {
                 $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) . ": " . $this->prepareStr(str_replace("<br />", " ", $title)));
             }
             // description
             $content = $this->prepareStr(nl2br(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"])));
             $feed_item->setDescription($content);
             // lm page hack, not nice
             if (in_array($item["context_obj_type"], array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg" && $item["context_sub_obj_id"] > 0) {
                 $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"]);
             } else {
                 if ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg" && $item["context_sub_obj_id"] > 0) {
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
                     $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . urlencode($wptitle));
                     // #14629
                 } else {
                     if (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos" && $item["context_sub_obj_id"] > 0) {
                         // frm hack, not nice
                         include_once "./Modules/Forum/classes/class.ilObjForumAccess.php";
                         $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
                         if ($thread_id > 0) {
                             $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]);
                         } else {
                             $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
                         }
                     } else {
                         $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
                     }
                 }
             }
             $feed_item->setAbout($feed_item->getLink() . "&amp;il_about_feed=" . $item["id"]);
             $feed_item->setDate($item["creation_date"]);
             $this->addItem($feed_item);
         }
     }
 }
 /**
  * Get's the repository object ID of a parent object, if possible
  */
 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) {
         case "html":
             // "old" category pages
             if ($cont_type == "cat") {
                 $obj_id = $id;
             }
             // Test InfoScreen Text
             if ($cont_type == "tst" || $cont_type == "svy") {
                 $obj_id = $id;
                 //var_dump($qinfo);
             }
             // Question Pool *Question* Text (Test)
             if ($cont_type == "qpl") {
                 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
                 }
             }
             // Question Pool *Question* Text (Survey)
             if ($cont_type == "spl") {
                 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);
                 }
             }
             // Forum
             if ($cont_type == "frm") {
                 $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);
             }
             if ($cont_type == 'frm~') {
                 $obj_id = $a_usage['id'];
             }
             if ($cont_type == "dcl") {
                 $obj_id = $id;
             }
             break;
         case "pg":
             // Question Pool Question Pages
             if ($cont_type == "qpl") {
                 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
                 }
             }
             // learning modules
             if ($cont_type == "lm" || $cont_type == "dbk") {
                 include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                 $obj_id = ilLMObject::_lookupContObjID($id);
             }
             // glossary definition
             if ($cont_type == "gdf") {
                 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);
             }
             // wiki page
             if ($cont_type == 'wpg') {
                 include_once 'Modules/Wiki/classes/class.ilWikiPage.php';
                 $obj_id = ilWikiPage::lookupObjIdByPage($id);
             }
             // sahs page
             if ($cont_type == 'sahs') {
                 // can this implementation be used for other content types, too?
                 include_once './Services/COPage/classes/class.ilPageObject.php';
                 $obj_id = ilPageObject::lookupParentId($id, 'sahs');
             }
             // repository pages
             if (in_array($cont_type, array("crs", "grp", "cat", "fold", "root"))) {
                 $obj_id = $id;
             }
             if ($cont_type == 'prtf') {
                 include_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
                 $obj_id = ilPortfolioPage::findPortfolioForPage($id);
             }
             if ($cont_type == 'blp') {
                 include_once './Services/COPage/classes/class.ilPageObject.php';
                 $obj_id = ilPageObject::lookupParentId($id, 'blp');
             }
             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;
 }
 /**
  * Get pages for list.
  */
 function getPages()
 {
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $pages = array();
     $this->setDefaultOrderField("title");
     switch ($this->pg_list_mode) {
         case IL_WIKI_WHAT_LINKS_HERE:
             $pages = ilWikiPage::getLinksToPage($this->wiki_id, $this->page_id);
             break;
         case IL_WIKI_ALL_PAGES:
             $pages = ilWikiPage::getAllPages($this->wiki_id);
             break;
         case IL_WIKI_NEW_PAGES:
             $this->setDefaultOrderField("created");
             $this->setDefaultOrderDirection("desc");
             $pages = ilWikiPage::getNewPages($this->wiki_id);
             break;
         case IL_WIKI_POPULAR_PAGES:
             $this->setDefaultOrderField("cnt");
             $this->setDefaultOrderDirection("desc");
             $pages = ilWikiPage::getPopularPages($this->wiki_id);
             break;
         case IL_WIKI_ORPHANED_PAGES:
             $pages = ilWikiPage::getOrphanedPages($this->wiki_id);
             break;
     }
     if ($pages) {
         // enable sorting
         include_once "./Services/User/classes/class.ilUserUtil.php";
         foreach (array_keys($pages) as $idx) {
             $pages[$idx]["user_sort"] = ilUserUtil::getNamePresentation($pages[$idx]["user"], false, false);
         }
     }
     $this->setData($pages);
 }
Example #28
0
 /**
  * Set standard link xml
  */
 function setDefaultLinkXml()
 {
     global $ilCtrl;
     $int_links = $this->getPageObject()->getInternalLinks();
     //var_dump($int_links);
     $link_info = "<IntLinkInfos>";
     $targetframe = "None";
     foreach ($int_links as $int_link) {
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             $ltarget = "_top";
             if ($targetframe != "None") {
                 $ltarget = "_blank";
             }
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             $href = "";
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     if ($type == "PageObject") {
                         $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                     } else {
                         $href = "./goto.php?target=st_" . $target_id;
                     }
                     break;
                 case "GlossaryItem":
                     if ($targetframe == "None") {
                         $targetframe = "Glossary";
                     }
                     $href = "./goto.php?target=git_" . $target_id;
                     break;
                 case "MediaObject":
                     $ilCtrl->setParameter($this, "mob_id", $target_id);
                     //$ilCtrl->setParameter($this, "pg_id", $this->obj->getId());
                     $href = $ilCtrl->getLinkTarget($this, "displayMedia");
                     $ilCtrl->setParameter($this, "mob_id", "");
                     break;
                 case "WikiPage":
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $href = ilWikiPage::getGotoForWikiPageTarget($target_id);
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . $anc_par . " " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" />";
         }
     }
     $link_info .= "</IntLinkInfos>";
     $this->setLinkXML($link_info);
 }
 /**
  * Is block currently hidden?
  * 
  * @return boolean
  */
 protected function isHidden()
 {
     if ($this->adv_md_hidden === null) {
         $this->adv_md_hidden = ilWikiPage::lookupAdvancedMetadataHidden($this->page_id);
     }
     return $this->adv_md_hidden;
 }
 function ilObjectFeedWriter($a_ref_id, $a_userid = false, $a_purpose = false)
 {
     global $ilSetting, $lng;
     parent::ilFeedWriter();
     if ($a_ref_id <= 0) {
         return;
     }
     include_once "./Services/Block/classes/class.ilBlockSetting.php";
     $news_set = new ilSetting("news");
     if (!$news_set->get("enable_rss_for_internal")) {
         return;
     }
     $obj_id = ilObject::_lookupObjId($a_ref_id);
     $obj_type = ilObject::_lookupType($obj_id);
     $obj_title = ilObject::_lookupTitle($obj_id);
     if (!ilBlockSetting::_lookup("news", "public_feed", 0, $obj_id)) {
         return;
     }
     if ($ilSetting->get('short_inst_name') != "") {
         $this->setChannelTitle($ilSetting->get('short_inst_name') . " - " . $this->prepareStr($loc . $obj_title));
     } else {
         $this->setChannelTitle("ILIAS" . " - " . $this->prepareStr($loc . $obj_title . ($a_purpose ? " - " . $a_purpose : "")));
     }
     $this->setChannelAbout(ILIAS_HTTP_PATH);
     $this->setChannelLink(ILIAS_HTTP_PATH);
     // not nice, to do: general solution
     if ($obj_type == "mcst") {
         include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
         if (!ilObjMediaCastAccess::_lookupOnline($obj_id)) {
             $lng->loadLanguageModule("mcst");
             $feed_item = new ilFeedItem();
             $feed_item->setTitle($lng->txt("mcst_media_cast_not_online"));
             $feed_item->setDescription($lng->txt("mcst_media_cast_not_online_text"));
             $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"]);
             $this->addItem($feed_item);
             return;
         }
     }
     include_once "./Services/Locator/classes/class.ilLocatorGUI.php";
     $cont_loc = new ilLocatorGUI();
     $cont_loc->addContextItems($a_ref_id, true);
     $cont_loc->setTextOnly(true);
     $loc = $cont_loc->getTextVersion();
     if (trim($loc) != "") {
         $loc = " [" . $loc . "] ";
     }
     $rss_period = ilNewsItem::_lookupRSSPeriod();
     ilNewsItem::setPrivateFeedId($a_userid);
     $news_item = new ilNewsItem();
     $news_item->setContextObjId($obj_id);
     $news_item->setContextObjType($obj_type);
     $items = $news_item->getNewsForRefId($a_ref_id, true, false, $rss_period, true);
     if ($a_purpose) {
         include_once "./Services/MediaObjects/classes/class.ilMediaItem.php";
     }
     $i = 0;
     foreach ($items as $item) {
         $i++;
         if ($a_purpose != false && $obj_type == "mcst") {
             $mob = ilMediaItem::_getMediaItemsOfMObId($item[mob_id], $a_purpose);
             if ($mob == false) {
                 continue;
             }
         }
         $obj_title = ilObject::_lookupTitle($item["context_obj_id"]);
         $feed_item = new ilFeedItem();
         $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]);
         // path
         $cont_loc = new ilLocatorGUI();
         $cont_loc->addContextItems($item["ref_id"], true, $a_ref_id);
         $cont_loc->setTextOnly(true);
         $loc = $cont_loc->getHTML();
         if (trim($loc) != "") {
             $loc = "[" . $loc . "]";
         }
         if ($news_set->get("rss_title_format") == "news_obj") {
             $sep = trim($this->prepareStr($loc)) == "" ? "" : " ";
             $feed_item->setTitle($this->prepareStr($title) . " (" . $this->prepareStr($loc) . $sep . $this->prepareStr($obj_title) . ")");
         } else {
             $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) . ": " . $this->prepareStr($title));
         }
         $feed_item->setDescription($this->prepareStr(nl2br(ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]))));
         // lm hack, not nice
         if (in_array($item["context_obj_type"], array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg" && $item["context_sub_obj_id"] > 0) {
             $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"]);
         } else {
             if ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg" && $item["context_sub_obj_id"] > 0) {
                 include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                 $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
                 $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $wptitle);
             } else {
                 if (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos" && $item["context_sub_obj_id"] > 0) {
                     // frm hack, not nice
                     include_once "./Modules/Forum/classes/class.ilObjForumAccess.php";
                     $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
                     if ($thread_id > 0) {
                         $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]);
                     } else {
                         $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
                     }
                 } else {
                     $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
                     //echo "<br>".ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
                     //					"&amp;target=".$item["context_obj_type"]."_".$item["ref_id"];
                 }
             }
         }
         $feed_item->setAbout($feed_item->getLink() . "&amp;il_about_feed=" . $item["id"]);
         $feed_item->setDate($item["creation_date"]);
         // Enclosure
         if ($item["content_type"] == NEWS_AUDIO && $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"])) {
             $go_on = true;
             if ($obj_type == "mcst") {
                 include_once "./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
                 if (!ilObjMediaCastAccess::_lookupPublicFiles($obj_id)) {
                     $go_on = false;
                 }
             }
             if ($go_on) {
                 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
                 $url = ilObjMediaObject::_lookupItemPath($item["mob_id"], true, true, $mob["purpose"]);
                 $file = ilObjMediaObject::_lookupItemPath($item["mob_id"], false, false, $mob["purpose"]);
                 if (is_file($file)) {
                     $size = filesize($file);
                 }
                 $feed_item->setEnclosureUrl($url);
                 $feed_item->setEnclosureType(isset($mob["format"]) ? $mob["format"] : "audio/mpeg");
                 $feed_item->setEnclosureLength($size);
             }
         }
         $this->addItem($feed_item);
     }
 }