/** * 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(); }