/** * 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(); }
function showGallery() { global $tpl, $ilTabs; $tpl->addJavascript("./Modules/MediaCast/js/MediaCast.js"); $ilTabs->activateTab("content"); $this->addContentSubTabs("content"); $ctpl = new ilTemplate("tpl.mcst_content.html", true, true, "Modules/MediaCast"); include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; foreach ($this->object->getSortedItemsArray() as $item) { $mob = new ilObjMediaObject($item["mob_id"]); $med = $mob->getMediaItem("Standard"); $ctpl->setCurrentBlock("item"); $ctpl->setVariable("TITLE", $item["title"]); $ctpl->setVariable("TIME", $item["playtime"]); $ctpl->setVariable("ID", $item["id"]); if ($mob->getVideoPreviewPic() != "") { $ctpl->setVariable("PREVIEW_PIC", ilUtil::img($mob->getVideoPreviewPic(), $item["title"], 320, 240)); } else { $ctpl->setVariable("PREVIEW_PIC", ilUtil::img(ilUtil::getImagePath("mcst_preview.png"), $item["title"], 320, 240)); } // player if (is_object($med)) { include_once "./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php"; $mpl = new ilMediaPlayerGUI(); if (strcasecmp("Reference", $med->getLocationType()) == 0) { $mpl->setFile($med->getLocation()); } else { $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation()); } $mpl->setMimeType($med->getFormat()); //$mpl->setDisplayHeight($med->getHeight()); $mpl->setDisplayHeight("480"); $mpl->setDisplayWidth("640"); $mpl->setVideoPreviewPic($mob->getVideoPreviewPic()); $mpl->setTitle($item["title"]); $mpl->setDescription($item["content"]); $mpl->setForceAudioPreview(true); $med_alt = $mob->getMediaItem("VideoAlternative"); if (is_object($med_alt)) { $mpl->setAlternativeVideoFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med_alt->getLocation()); $mpl->setAlternativeVideoMimeType($med_alt->getFormat()); } $ctpl->setVariable("PLAYER", $mpl->getPreviewHtml()); } $ctpl->parseCurrentBlock(); } $feed_icon_html = $this->getFeedIconsHTML(); if ($feed_icon_html != "") { $feed_icon_html = '<p>' . $feed_icon_html . '</p>'; } $tpl->setContent($feed_icon_html . $ctpl->get()); }
/** * Standard Version of Fill Row. Most likely to * be overwritten by derived class. */ protected function fillRow($a_set) { global $lng, $ilCtrl, $ilAccess; include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $news_set = new ilSetting("news"); $enable_internal_rss = $news_set->get("enable_rss_for_internal"); // access if ($enable_internal_rss && !$this->presentation_mode) { $this->tpl->setCurrentBlock("access"); $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility")); if ($a_set["visibility"] == NEWS_PUBLIC) { $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public")); } else { $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users")); } $this->tpl->parseCurrentBlock(); } $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", ""); if (ilObject::_exists($a_set["mob_id"])) { if ($a_set["update_date"] != "") { $this->tpl->setCurrentBlock("last_update"); $this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update")); $this->tpl->setVariable("VAL_LAST_UPDATE", ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME))); $this->tpl->parseCurrentBlock(); } $mob = new ilObjMediaObject($a_set["mob_id"]); $med = $mob->getMediaItem("Standard"); $this->tpl->setVariable("VAL_TITLE", $a_set["title"]); $this->tpl->setVariable("VAL_DESCRIPTION", $a_set["content"]); $this->tpl->setVariable("TXT_CREATED", $lng->txt("created")); $this->tpl->setVariable("VAL_CREATED", ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME))); $this->tpl->setVariable("TXT_DURATION", $lng->txt("mcst_play_time")); if ($a_set["playtime"] != "00:00:00") { $this->tpl->setVariable("VAL_DURATION", $a_set["playtime"]); } else { $this->tpl->setVariable("VAL_DURATION", "-"); } if (!$this->edit_order) { if ($this->downloadable) { $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]); // to keep always the order of the purposes // iterate through purposes and display the according mediaitems foreach (ilObjMediaCast::$purposes as $purpose) { $a_mob = $mob->getMediaItem($purpose); if (!is_object($a_mob)) { continue; } $ilCtrl->setParameterByClass("ilobjmediacastgui", "purpose", $a_mob->getPurpose()); $file = ilObjMediaObject::_lookupItemPath($a_mob->getMobId(), false, false, $a_mob->getPurpose()); if (is_file($file)) { $size = filesize($file); $size = ", " . sprintf("%.1f MB", $size / 1024 / 1024); } $format = $a_mob->getFormat() != "" ? $a_mob->getFormat() : "audio/mpeg"; $this->tpl->setCurrentBlock("downloadable"); $this->tpl->setVariable("TXT_DOWNLOAD", $lng->txt("mcst_download_" . strtolower($a_mob->getPurpose()))); $this->tpl->setVariable("CMD_DOWNLOAD", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem")); $this->tpl->setVariable("TITLE_DOWNLOAD", "(" . $format . $size . ")"); $this->tpl->parseCurrentBlock(); } } include_once "./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php"; $mpl = new ilMediaPlayerGUI(); if (is_object($med)) { if (strcasecmp("Reference", $med->getLocationType()) == 0) { $mpl->setFile($med->getLocation()); } else { $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation()); } $mpl->setMimeType($med->getFormat()); //$mpl->setDisplayHeight($med->getHeight()); $mpl->setDisplayWidth("640"); $mpl->setDisplayHeight("480"); $mpl->setVideoPreviewPic($mob->getVideoPreviewPic()); $mpl->setTitle($a_set["title"]); $mpl->setDescription($a_set["content"]); $med_alt = $mob->getMediaItem("VideoAlternative"); if (is_object($med_alt)) { $mpl->setAlternativeVideoFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med_alt->getLocation()); $mpl->setAlternativeVideoMimeType($med_alt->getFormat()); } } //$this->tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml()); $this->tpl->setVariable("PLAYER", $mpl->getPreviewHtml()); // edit link $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]); if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && !$this->presentation_mode) { $this->tpl->setCurrentBlock("edit"); $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit")); $this->tpl->setVariable("CMD_EDIT", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "editCastItem")); if (!is_int(strpos($med->getFormat(), "image/"))) { $this->tpl->setVariable("TXT_DET_PLAYTIME", $lng->txt("mcst_det_playtime")); $this->tpl->setVariable("CMD_DET_PLAYTIME", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "determinePlaytime")); } $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("edit_checkbox"); $this->tpl->setVariable("VAL_ID", $a_set["id"]); $this->tpl->parseCurrentBlock(); // $this->tpl->touchBlock("contrl_col"); } } else { $this->tpl->setCurrentBlock("edit_order"); $this->tpl->setVariable("VAL_ID", $a_set["id"]); $this->tpl->setVariable("VAL_ORDER", $a_set["order"]); $this->tpl->parseCurrentBlock(); // $this->tpl->touchBlock("contrl_col"); } } }
/** * Standard Version of Fill Row. Most likely to * be overwritten by derived class. */ protected function fillRow($a_set) { global $lng, $ilCtrl; $news_set = new ilSetting("news"); $enable_internal_rss = $news_set->get("enable_rss_for_internal"); // context $obj_id = ilObject::_lookupObjId($a_set["ref_id"]); $obj_type = ilObject::_lookupType($obj_id); $obj_title = ilObject::_lookupTitle($obj_id); // user if ($a_set["user_id"] > 0) { $this->tpl->setCurrentBlock("user_info"); if ($obj_type == "frm") { include_once "./Modules/Forum/classes/class.ilForumProperties.php"; if (ilForumProperties::_isAnonymized($a_set["context_obj_id"])) { if ($a_set["context_sub_obj_type"] == "pos" && $a_set["context_sub_obj_id"] > 0) { include_once "./Modules/Forum/classes/class.ilForumPost.php"; $post = new ilForumPost($a_set["context_sub_obj_id"]); if ($post->getUserAlias() != "") { $this->tpl->setVariable("VAL_AUTHOR", ilUtil::stripSlashes($post->getUserAlias())); } else { $this->tpl->setVariable("VAL_AUTHOR", $lng->txt("forums_anonymous")); } } else { $this->tpl->setVariable("VAL_AUTHOR", $lng->txt("forums_anonymous")); } } else { if (ilObject::_exists($a_set["user_id"])) { $user_obj = new ilObjUser($a_set["user_id"]); $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin()); } } } else { if (ilObject::_exists($a_set["user_id"])) { $user_obj = new ilObjUser($a_set["user_id"]); $this->tpl->setVariable("VAL_AUTHOR", $user_obj->getLogin()); } } $this->tpl->setVariable("TXT_AUTHOR", $lng->txt("author")); $this->tpl->parseCurrentBlock(); } // media player if ($a_set["content_type"] == NEWS_AUDIO && $a_set["mob_id"] > 0 && ilObject::_exists($a_set["mob_id"])) { include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; include_once "./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php"; $mob = new ilObjMediaObject($a_set["mob_id"]); $med = $mob->getMediaItem("Standard"); $mpl = new ilMediaPlayerGUI(); $mpl->setFile(ilObjMediaObject::_getDirectory($a_set["mob_id"]) . "/" . $med->getLocation()); $this->tpl->setCurrentBlock("player"); $this->tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml()); $this->tpl->parseCurrentBlock(); } // access if ($enable_internal_rss) { $this->tpl->setCurrentBlock("access"); include_once "./Services/Block/classes/class.ilBlockSetting.php"; $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility")); if ($a_set["visibility"] == NEWS_PUBLIC || $a_set["priority"] == 0 && ilBlockSetting::_lookup("news", "public_notifications", 0, $obj_id)) { $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public")); } else { $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users")); } $this->tpl->parseCurrentBlock(); } // content if ($a_set["content"] != "") { $this->tpl->setCurrentBlock("content"); $this->tpl->setVariable("VAL_CONTENT", ilUtil::makeClickable($a_set["content"], true)); $this->tpl->parseCurrentBlock(); } if ($a_set["content_long"] != "") { $this->tpl->setCurrentBlock("long"); $this->tpl->setVariable("VAL_LONG_CONTENT", ilUtil::makeClickable($a_set["content_long"], true)); $this->tpl->parseCurrentBlock(); } if ($a_set["update_date"] != $a_set["creation_date"]) { $this->tpl->setCurrentBlock("ni_update"); $this->tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update")); $this->tpl->setVariable("VAL_LAST_UPDATE", ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME))); $this->tpl->parseCurrentBlock(); } // forum hack, not nice $add = ""; if ($obj_type == "frm" && $a_set["context_sub_obj_type"] == "pos" && $a_set["context_sub_obj_id"] > 0) { include_once "./Modules/Forum/classes/class.ilObjForumAccess.php"; $pos = $a_set["context_sub_obj_id"]; $thread = ilObjForumAccess::_getThreadForPosting($pos); if ($thread > 0) { $add = "_" . $thread . "_" . $pos; } } $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" . $obj_type . "_" . $a_set["ref_id"] . $add; $this->tpl->setCurrentBlock("context"); $cont_loc = new ilLocatorGUI(); $cont_loc->addContextItems($a_set["ref_id"], true); $this->tpl->setVariable("CONTEXT_LOCATOR", $cont_loc->getHTML()); $this->tpl->setVariable("HREF_CONTEXT_TITLE", $url_target); $this->tpl->setVariable("CONTEXT_TITLE", $obj_title); $this->tpl->setVariable("ALT_CONTEXT_TITLE", $lng->txt("icon") . " " . $lng->txt("obj_" . $obj_type)); $this->tpl->setVariable("IMG_CONTEXT_TITLE", ilUtil::getImagePath("icon_" . $obj_type . "_b.png")); $this->tpl->parseCurrentBlock(); $this->tpl->setVariable("HREF_TITLE", $url_target); // title if ($a_set["content_is_lang_var"]) { $this->tpl->setVariable("VAL_TITLE", $lng->txt($a_set["title"])); } else { $this->tpl->setVariable("VAL_TITLE", ilUtil::stripSlashes($a_set["title"])); // title } // creation date $this->tpl->setVariable("VAL_CREATION_DATE", ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME))); $this->tpl->setVariable("TXT_CREATED", $lng->txt("created")); $this->tpl->parseCurrentBlock(); }
/** * Get Html for MP3 Player */ function getMp3PlayerHtml($a_preview = false) { global $tpl, $lng; include_once "./Services/YUI/classes/class.ilYuiUtil.php"; ilYuiUtil::initConnection(); $tpl->addJavascript("./Services/MediaObjects/js/MediaObjects.js"); if (!self::$lightbox_initialized && $a_preview) { include_once "./Services/UIComponent/Lightbox/classes/class.ilLightboxGUI.php"; $lb = new ilLightboxGUI("media_lightbox"); $lb->setWidth("660px"); $lb->addLightbox(); self::$lightbox_initialized = true; } require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php'; include_once "./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php"; // youtube /* if (ilExternalMediaAnalyzer::isYouTube($this->getFile())) { $p = ilExternalMediaAnalyzer::extractYouTubeParameters($this->getFile()); $html = '<object width="320" height="240">'. '<param name="movie" value="http://www.youtube.com/v/'.$p["v"].'?fs=1">'. '</param><param name="allowFullScreen" value="true"></param>'. '<param name="allowscriptaccess" value="always">'. '</param><embed src="http://www.youtube.com/v/'.$p["v"].'?fs=1" '. 'type="application/x-shockwave-flash" allowscriptaccess="always" '. 'allowfullscreen="true" width="320" height="240"></embed></object>'; return $html; } // vimeo if (ilExternalMediaAnalyzer::isVimeo($this->getFile())) { $p = ilExternalMediaAnalyzer::extractVimeoParameters($this->getFile()); $html = '<iframe src="http://player.vimeo.com/video/'.$p["id"].'" width="320" height="240" '. 'frameborder="0"></iframe>'; return $html; } */ $mimeType = $this->mimeType == "" ? ilObjMediaObject::getMimeType(basename($this->getFile())) : $this->mimeType; include_once "./Services/MediaObjects/classes/class.ilPlayerUtil.php"; // video tag if (in_array($mimeType, array("video/mp4", "video/m4v", "video/rtmp", "video/x-flv", "video/webm", "video/youtube", "video/vimeo", "video/ogg"))) { ilPlayerUtil::initMediaElementJs(); if ($mimeType == "video/quicktime") { $mimeType = "video/mov"; } $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects"); // preview if ($a_preview) { if ($this->getDownloadLink() != "") { $mp_tpl->setCurrentBlock("download"); $mp_tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download")); $mp_tpl->setVariable("HREF_DOWNLOAD", $this->getDownloadLink()); $mp_tpl->parseCurrentBlock(); } $mp_tpl->setCurrentBlock("preview"); if ($this->getVideoPreviewPic() != "") { $mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic()); } else { $mp_tpl->setVariable("IMG_SRC", ilUtil::getImagePath("mcst_preview.svg")); } $mp_tpl->setVariable("IMG_ALT", $this->video_preview_pic_alt); $mp_tpl->setVariable("PTITLE", $this->getTitle()); $mp_tpl->parseCurrentBlock(); } // sources $mp_tpl->setCurrentBlock("source"); $mp_tpl->setVariable("FILE", $this->getFile()); $mp_tpl->setVariable("MIME", $mimeType); $mp_tpl->parseCurrentBlock(); if (in_array($this->getAlternativeVideoMimeType(), array("video/mp4", "video/webm"))) { $mp_tpl->setCurrentBlock("source"); $mp_tpl->setVariable("FILE", $this->getAlternativeVideoFile()); $mp_tpl->setVariable("MIME", $this->getAlternativeVideoMimeType()); $mp_tpl->parseCurrentBlock(); } $mp_tpl->setCurrentBlock("mejs_video"); if ($a_preview) { $mp_tpl->setVariable("CLASS", "ilNoDisplay"); } $mp_tpl->setVariable("PLAYER_NR", $this->id . "_" . $this->current_nr); $mp_tpl->setVariable("EVENT_URL", $this->event_callback_url); $height = $this->getDisplayHeight(); $width = $this->getDisplayWidth(); if (is_int(strpos($mimeType, "audio/mpeg"))) { $height = "30"; } $mp_tpl->setVariable("DISPLAY_HEIGHT", $height); $mp_tpl->setVariable("DISPLAY_WIDTH", $width); $mp_tpl->setVariable("PREVIEW_PIC", $this->getVideoPreviewPic()); $mp_tpl->setVariable("SWF_FILE", ilPlayerUtil::getFlashVideoPlayerFilename(true)); $mp_tpl->setVariable("FFILE", $this->getFile()); $mp_tpl->setVariable("TITLE", $this->getTitle()); $mp_tpl->setVariable("DESCRIPTION", $this->getDescription()); include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php"; if ($a_preview) { $mp_tpl->setVariable("CLOSE", ilGlyphGUI::get(ilGlyphGUI::CLOSE)); } $mp_tpl->parseCurrentBlock(); $r = $mp_tpl->get(); if (!$a_preview) { $tpl->addOnLoadCode("new MediaElementPlayer('#player_" . $this->id . "_" . $this->current_nr . "');"); } //echo htmlentities($r); return $r; } // audio/mpeg if (is_int(strpos($mimeType, "audio/mpeg")) || in_array($mimeType, array("application/ogg", "audio/ogg"))) { ilPlayerUtil::initMediaElementJs(); $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects"); $preview_output = false; if ($this->getVideoPreviewPic() != "" || $this->getForceAudioPreview()) { if ($this->getDownloadLink() != "") { $mp_tpl->setCurrentBlock("adownload"); $mp_tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download")); $mp_tpl->setVariable("HREF_DOWNLOAD", $this->getDownloadLink()); $mp_tpl->parseCurrentBlock(); } $mp_tpl->setCurrentBlock("apreview"); if ($this->getVideoPreviewPic() != "") { $mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic()); } else { $mp_tpl->setVariable("IMG_SRC", ilUtil::getImagePath("mcst_preview.svg")); } $mp_tpl->setVariable("PTITLE", $this->getTitle()); $mp_tpl->parseCurrentBlock(); $preview_output = true; } $mp_tpl->setCurrentBlock("audio"); if ($preview_output) { $mp_tpl->setVariable("ASTYLE", "margin-top:-30px"); } $mp_tpl->setVariable("AFILE", $this->getFile()); $mp_tpl->setVariable("APLAYER_NR", $this->id . "_" . $this->current_nr); $mp_tpl->setVariable("AEVENT_URL", $this->event_callback_url); $mp_tpl->setVariable("AHEIGHT", "30"); $mp_tpl->setVariable("AWIDTH", "320"); $mp_tpl->parseCurrentBlock(); return $mp_tpl->get(); } // images if (is_int(strpos($mimeType, "image/"))) { $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects"); if ($this->getDownloadLink() != "") { $mp_tpl->setCurrentBlock("idownload"); $mp_tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download")); $mp_tpl->setVariable("HREF_DOWNLOAD", $this->getDownloadLink()); $mp_tpl->parseCurrentBlock(); } $mp_tpl->setCurrentBlock("ipreview"); if ($this->getVideoPreviewPic() != "") { $mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic()); } else { $mp_tpl->setVariable("IMG_SRC", $this->getFile()); } $mp_tpl->setVariable("PTITLE", $this->getTitle()); $mp_tpl->parseCurrentBlock(); $mp_tpl->setCurrentBlock("image"); $mp_tpl->setVariable("IFILE", $this->getFile()); $mp_tpl->setVariable("IPLAYER_NR", $this->id . "_" . $this->current_nr); $mp_tpl->setVariable("ITITLE", $this->getTitle()); $mp_tpl->setVariable("IDESCRIPTION", $this->getDescription()); include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php"; $mp_tpl->setVariable("ICLOSE", ilGlyphGUI::get(ilGlyphGUI::CLOSE)); $height = $this->getDisplayHeight(); $width = $this->getDisplayWidth(); $mp_tpl->setVariable("IHEIGHT", $height); $mp_tpl->setVariable("IWIDTH", $width); $mp_tpl->parseCurrentBlock(); return $mp_tpl->get(); } // fallback, no preview mode $mimeType = $this->mimeType == "" ? ilObjMediaObject::getMimeType(basename($this->getFile())) : $this->mimeType; if (strpos($mimeType, "flv") === false && strpos($mimeType, "audio/mpeg") === false && strpos($mimeType, "image/png") === false && strpos($mimeType, "image/gif") === false) { $html = '<embed src="' . $this->getFile() . '" ' . 'type="' . $mimeType . '" ' . 'ShowControls="1" ' . 'autoplay="false" autostart="false" ' . 'width="320" height="240" scale="aspect" ></embed>'; return $html; } return; $tpl->addJavaScript("./Services/MediaObjects/flash_flv_player/swfobject.js"); $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects"); $mp_tpl->setCurrentBlock("default"); $mp_tpl->setVariable("FILE", urlencode($this->getFile())); $mp_tpl->setVariable("PLAYER_NR", $this->current_nr); $mp_tpl->setVariable("DISPLAY_HEIGHT", strpos($mimeType, "audio/mpeg") === false ? "240" : "20"); $mp_tpl->setVariable("DISPLAY_WIDTH", "320"); $mp_tpl->parseCurrentBlock(); return $mp_tpl->get(); }
/** * function parses stored value in database to a html output for eg. the record list gui. * * @param $value * @param ilDataCollectionRecordField $record_field * * @return mixed */ public function parseHTML($value, ilDataCollectionRecordField $record_field, $link = true) { global $ilAccess, $ilCtrl, $lng; switch ($this->id) { case self::INPUTFORMAT_DATETIME: $html = ilDatePresentation::formatDate(new ilDate($value, IL_CAL_DATETIME)); break; case self::INPUTFORMAT_FILE: if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") { $html = ""; break; } $file_obj = new ilObjFile($value, false); $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "record_id", $record_field->getRecord()->getId()); $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "field_id", $record_field->getField()->getId()); $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordlistgui", "sendFile") . '">' . $file_obj->getFileName() . '</a>'; if (ilPreview::hasPreview($file_obj->getId())) { ilPreview::createPreview($file_obj); // Create preview if not already existing $preview = new ilPreviewGUI((int) $_GET['ref_id'], ilPreviewGUI::CONTEXT_REPOSITORY, $file_obj->getId(), $ilAccess); $preview_status = ilPreview::lookupRenderStatus($file_obj->getId()); $preview_status_class = ""; $preview_text_topic = "preview_show"; if ($preview_status == ilPreview::RENDER_STATUS_NONE) { $preview_status_class = "ilPreviewStatusNone"; $preview_text_topic = "preview_none"; } $wrapper_html_id = 'record_field_' . $record_field->getId(); $script_preview_click = $preview->getJSCall($wrapper_html_id); $preview_title = $lng->txt($preview_text_topic); $preview_icon = ilUtil::getImagePath("preview.png", "Services/Preview"); $html = '<div id="' . $wrapper_html_id . '">' . $html; $html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="' . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon . '" height="16" width="16"></a></span></div>'; } break; case self::INPUTFORMAT_MOB: $mob = new ilObjMediaObject($value, false); $med = $mob->getMediaItem('Standard'); if (!$med->location) { $html = ""; break; } $arr_properties = $record_field->getField()->getProperties(); $is_linked_field = $arr_properties[ilDataCollectionField::PROPERTYID_LINK_DETAIL_PAGE_MOB]; $has_view = ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId()); if (in_array($med->getSuffix(), array('jpg', 'jpeg', 'png', 'gif'))) { // Image $dir = ilObjMediaObject::_getDirectory($mob->getId()); $width = (int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH]; $height = (int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT]; $html = ilUtil::img($dir . "/" . $med->location, '', $width, $height); if ($is_linked_field and $has_view and $link) { $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId()); $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $html . '</a>'; } } else { // Video/Audio $mpl = new ilMediaPlayerGUI($med->getId(), ''); $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation()); $mpl->setMimeType($med->getFormat()); $mpl->setDisplayWidth((int) $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH] . 'px'); $mpl->setDisplayHeight((int) $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT] . 'px'); $mpl->setVideoPreviewPic($mob->getVideoPreviewPic()); $html = $mpl->getPreviewHtml(); if ($is_linked_field and $has_view) { global $lng; $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId()); $html = $html . '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $lng->txt('details') . '</a>'; } } break; case self::INPUTFORMAT_BOOLEAN: switch ($value) { case 0: $im = ilUtil::getImagePath('icon_not_ok.svg'); break; case 1: $im = ilUtil::getImagePath('icon_ok.svg'); break; } $html = "<img src='" . $im . "'>"; break; case ilDataCollectionDatatype::INPUTFORMAT_TEXT: //Property URL $arr_properties = $record_field->getField()->getProperties(); if ($arr_properties[ilDataCollectionField::PROPERTYID_URL]) { $link = $value; if (preg_match("/^[a-z0-9!#\$%&'*+=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$/i", $value)) { $value = "mailto:" . $value; } elseif (!preg_match('~(^(news|(ht|f)tp(s?)\\://){1}\\S+)~i', $value)) { return $link; } $link = $this->shortenLink($link); $html = "<a target='_blank' href='" . $value . "'>" . $link . "</a>"; } elseif ($arr_properties[ilDataCollectionField::PROPERTYID_LINK_DETAIL_PAGE_TEXT] and $link and ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId())) { $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId()); $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $value . '</a>'; } else { $html = $value; } break; default: $html = $value; break; } return $html; }