5 include_once(
"Services/Block/classes/class.ilBlockGUI.php");
34 $lng->loadLanguageModule(
"news");
35 $ilHelp->addHelpSection(
"news_block");
37 include_once(
"./Services/News/classes/class.ilNewsItem.php");
43 $this->dynamic =
false;
44 include_once(
"./Services/News/classes/class.ilNewsCache.php");
46 $cres = $this->acache->getEntry($ilUser->getId().
":".
$_GET[
"ref_id"]);
47 $this->cache_hit =
false;
49 if ($this->acache->getLastAccessStatus() ==
"hit")
51 self::$st_data = unserialize($cres);
52 $this->cache_hit =
true;
56 $this->dynamic =
true;
61 if (!empty(self::$st_data))
68 self::$st_data =
$data;
76 $this->
setTitle($lng->txt(
"news_internal_news"));
77 $this->
setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
79 $this->allow_moving =
false;
90 include_once(
"./Services/News/classes/class.ilNewsCache.php");
100 $news_item->setContextObjId($ilCtrl->getContextObjId());
101 $news_item->setContextObjType($ilCtrl->getContextObjType());
105 $prevent_aggregation =
true;
106 if ($ilCtrl->getContextObjType() !=
"frm")
108 $forum_grouping =
true;
112 $forum_grouping =
false;
116 $news_data = $news_item->getNewsForRefId(
$_GET[
"ref_id"],
false,
false, 0,
117 $prevent_aggregation, $forum_grouping);
119 $this->acache->storeEntry($ilUser->getId().
":".
$_GET[
"ref_id"],
120 serialize($news_data));
154 if ($ilCtrl->getCmdClass() ==
"ilnewsitemgui")
159 switch($ilCtrl->getCmd())
184 $next_class = $ilCtrl->getNextClass();
185 $cmd = $ilCtrl->getCmd(
"getHTML");
189 case "ilnewsitemgui":
190 include_once(
"./Services/News/classes/class.ilNewsItemGUI.php");
193 $html = $ilCtrl->forwardCommand($news_item_gui);
197 return $this->
$cmd();
208 $this->enable_edit = $a_enable_edit;
218 return $this->enable_edit;
248 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
266 if ($enable_internal_rss)
269 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&".
270 "ref_id=".
$_GET[
"ref_id"],
271 $lng->txt(
"news_feed_url"),
"_blank",
297 $ilCtrl->getLinkTargetByClass(
"ilnewsitemgui",
"editNews"),
300 $ilCtrl->setParameter($this,
"add_mode",
"block");
302 $ilCtrl->getLinkTargetByClass(
"ilnewsitemgui",
"createNewsItem"),
304 $ilCtrl->setParameter($this,
"add_mode",
"");
310 $ilCtrl->getLinkTarget($this,
"editSettings"),
311 $lng->txt(
"settings"));
327 && (!$news_set->get(
"enable_rss_for_internal") ||
329 0, $this->block_id)))
335 if ($ilUser->getPref(
"il_feed_js") ==
"n")
350 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
355 $got_notices = $got_messages =
false;
356 foreach($this->data as
$row)
358 if ($row[
"priority"] == 0) $got_notices =
true;
359 if ($row[
"priority"] == 1) $got_messages =
true;
361 $this->show_view_selection =
false;
363 if ($got_notices && $got_messages)
365 $this->show_view_selection =
true;
367 else if ($got_notices)
398 $this->tpl->setCurrentBlock(
"long");
400 $this->tpl->setVariable(
"VAL_CREATION_DATE",
402 $this->tpl->parseCurrentBlock();
406 if ($news[
"priority"] == 0)
417 if ($news[
"ref_id"] > 0)
419 if ($news[
"agg_ref_id"] > 0)
423 $context_ref = $news[
"agg_ref_id"];
427 $obj_id = $news[
"context_obj_id"];
428 $type = $news[
"context_obj_type"];
429 $context_ref = $news[
"ref_id"];
432 $lang_type = in_array($type, array(
"sahs",
"lm",
"dbk",
"htlm"))
436 $this->tpl->setCurrentBlock(
"news_context");
437 $this->tpl->setVariable(
"TYPE", $lng->txt($lang_type));
438 $this->tpl->setVariable(
"IMG_TYPE",
440 $this->tpl->setVariable(
"TITLE",
442 if ($news[
"user_read"] > 0)
444 $this->tpl->setVariable(
"TITLE_CLASS",
'class="light"');
447 $this->tpl->parseCurrentBlock();
448 $ilCtrl->setParameter($this,
"news_context", $context_ref);
452 $ilCtrl->setParameter($this,
"news_context",
"");
456 $this->tpl->setVariable(
"VAL_TITLE",
458 ($news[
"context_obj_type"], $news[
"title"], $news[
"content_is_lang_var"],
459 $news[
"agg_ref_id"], $news[
"aggregation"])));
462 if ($news[
"user_read"] > 0)
464 $this->tpl->setVariable(
"A_CLASS",
'class="light"');
467 $ilCtrl->setParameter($this,
"news_id", $news[
"id"]);
468 $this->tpl->setVariable(
"HREF_SHOW",
469 $ilCtrl->getLinkTarget($this,
"showNews"));
470 $ilCtrl->clearParameters($this);
480 return '<div class="small">'.((int) count($this->
getData())).
" ".$lng->txt(
"news_news_items").
"</div>";
491 if (empty(self::$st_data))
497 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
499 include_once(
"./Services/News/classes/class.ilNewsItem.php");
502 $tpl =
new ilTemplate(
"tpl.show_news.html",
true,
true,
"Services/News");
505 $previous = $next =
"";
507 $c = current($this->data);
510 while($c[
"id"] > 0 &&
511 $c[
"id"] !=
$_GET[
"news_id"])
514 $c = next($this->data);
519 $news_list = array();
520 if (is_array($c[
"aggregation"]))
525 $news_list[] = array(
"ref_id" => $c[
"agg_ref_id"],
526 "agg_ref_id" => $c[
"agg_ref_id"],
527 "aggregation" => $c[
"aggregation"],
529 "content_type" =>
"text",
533 "content_long" =>
"",
534 "update_date" => $news->getUpdateDate(),
535 "creation_date" =>
"",
536 "content_is_lang_var" =>
false,
537 "loc_context" =>
$_GET[
"news_context"],
538 "context_obj_type" => $news->getContextObjType(),
541 foreach($c[
"aggregation"] as $c_item)
544 $c_item[
"loc_context"] = $c_item[
"ref_id"];
545 $c_item[
"loc_stop"] =
$_GET[
"news_context"];
546 $news_list[] = $c_item;
551 $news_list[] = array(
"ref_id" =>
$_GET[
"news_context"],
552 "user_id" => $news->getUserId(),
553 "content_type" => $news->getContentType(),
554 "mob_id" => $news->getMobId(),
555 "visibility" => $news->getVisibility(),
556 "priority" => $news->getPriority(),
557 "content" => $news->getContent(),
558 "content_long" => $news->getContentLong(),
559 "update_date" => $news->getUpdateDate(),
560 "creation_date" => $news->getCreationDate(),
561 "context_sub_obj_type" => $news->getContextSubObjType(),
562 "context_obj_type" => $news->getContextObjType(),
563 "context_sub_obj_id" => $news->getContextSubObjId(),
564 "content_is_lang_var" => $news->getContentIsLangVar(),
565 "content_text_is_lang_var" => $news->getContentTextIsLangVar(),
566 "loc_context" =>
$_GET[
"news_context"],
567 "title" => $news->getTitle());
571 foreach ($news_list as $item)
580 $displayname = $user->getLogin();
585 $displayname =
"<". strtolower($lng->txt(
"deleted")) .
">";
588 $tpl->setCurrentBlock(
"user_info");
589 $tpl->setVariable(
"VAL_AUTHOR", $displayname);
590 $tpl->setVariable(
"TXT_AUTHOR", $lng->txt(
"author"));
591 $tpl->parseCurrentBlock();
598 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
599 include_once(
"./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
601 $med = $mob->getMediaItem(
"Standard");
603 if (strcasecmp(
"Reference", $med->getLocationType()) == 0)
604 $mpl->setFile($med->getLocation());
607 $mpl->setDisplayHeight($med->getHeight());
608 $tpl->setCurrentBlock(
"player");
609 $tpl->setVariable(
"PLAYER",
610 $mpl->getMp3PlayerHtml());
611 $tpl->parseCurrentBlock();
615 if ($enable_internal_rss && $item[
"visibility"] !=
"")
618 $tpl->setCurrentBlock(
"access");
619 $tpl->setVariable(
"TXT_ACCESS", $lng->txt(
"news_news_item_visibility"));
621 ($item[
"priority"] == 0 &&
625 $tpl->setVariable(
"VAL_ACCESS", $lng->txt(
"news_visibility_public"));
629 $tpl->setVariable(
"VAL_ACCESS", $lng->txt(
"news_visibility_users"));
631 $tpl->parseCurrentBlock();
635 if (trim($item[
"content"]) !=
"")
637 $tpl->setCurrentBlock(
"content");
638 $tpl->setVariable(
"VAL_CONTENT",
643 $tpl->parseCurrentBlock();
645 if (trim($item[
"content_long"]) !=
"")
647 $tpl->setCurrentBlock(
"long");
648 $tpl->setVariable(
"VAL_LONG_CONTENT", $this->
makeClickable($item[
"content_long"]));
649 $tpl->parseCurrentBlock();
651 if ($item[
"update_date"] != $item[
"creation_date"])
653 $tpl->setCurrentBlock(
"ni_update");
654 $tpl->setVariable(
"TXT_LAST_UPDATE", $lng->txt(
"last_update"));
655 $tpl->setVariable(
"VAL_LAST_UPDATE",
657 $tpl->parseCurrentBlock();
661 if ($item[
"creation_date"] !=
"")
663 $tpl->setCurrentBlock(
"ni_update");
664 $tpl->setVariable(
"VAL_CREATION_DATE",
666 $tpl->setVariable(
"TXT_CREATED", $lng->txt(
"created"));
667 $tpl->parseCurrentBlock();
672 if (
$_GET[
"news_context"] > 0)
680 if ($obj_type ==
"file")
682 $tpl->setCurrentBlock(
"download");
683 $tpl->setVariable(
"TXT_DOWNLOAD", $lng->txt(
"download"));
684 $ilCtrl->setParameterByClass(
"ilrepositorygui",
"ref_id", $item[
"ref_id"]);
685 $tpl->setVariable(
"HREF_DOWNLOAD",
686 $ilCtrl->getLinkTargetByClass(
"ilrepositorygui",
"sendfile"));
687 $ilCtrl->setParameterByClass(
"ilrepositorygui",
"ref_id",
$_GET[
"ref_id"]);
688 $tpl->parseCurrentBlock();
693 if ($obj_type ==
"frm" && $item[
"context_sub_obj_type"] ==
"pos"
694 && $item[
"context_sub_obj_id"] > 0)
696 include_once(
"./Modules/Forum/classes/class.ilObjForumAccess.php");
697 $pos = $item[
"context_sub_obj_id"];
698 $thread = ilObjForumAccess::_getThreadForPosting($pos);
701 $add =
"_".$thread.
"_".$pos;
706 if ($obj_type ==
"wiki" && $item[
"context_sub_obj_type"] ==
"wpg"
707 && $item[
"context_sub_obj_id"] > 0)
709 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
713 $add =
"_".ilWikiUtil::makeUrlTitle($wptitle);
717 $url_target =
"./goto.php?client_id=".rawurlencode(CLIENT_ID).
"&target=".
718 $obj_type.
"_".$item[
"ref_id"].$add;
721 if (in_array($obj_type, array(
"dbk",
"lm")) && $item[
"context_sub_obj_type"] ==
"pg"
722 && $item[
"context_sub_obj_id"] > 0)
724 $url_target =
"./goto.php?client_id=".rawurlencode(CLIENT_ID).
"&target=".
725 "pg_".$item[
"context_sub_obj_id"].
"_".$item[
"ref_id"];
729 $context_opened =
false;
730 if ($item[
"loc_context"] != null && $item[
"loc_context"] != $item[
"loc_stop"])
733 $tpl->setCurrentBlock(
"context");
734 $context_opened =
true;
736 $cont_loc->addContextItems($item[
"loc_context"],
true, $item[
"loc_stop"]);
737 $tpl->setVariable(
"CONTEXT_LOCATOR", $cont_loc->getHTML());
741 if ($item[
"no_context_title"] !==
true)
743 if (!$context_opened)
745 $tpl->setCurrentBlock(
"context");
747 $tpl->setVariable(
"HREF_CONTEXT_TITLE", $url_target);
748 $tpl->setVariable(
"CONTEXT_TITLE", $obj_title);
753 $tpl->parseCurrentBlock();
756 $tpl->setVariable(
"HREF_TITLE", $url_target);
760 $tpl->setVariable(
"VAL_TITLE",
762 $item[
"title"], $item[
"content_is_lang_var"], $item[
"agg_ref_id"],
763 $item[
"aggregation"]));
765 $row_css = ($row_css !=
"tblrow1")
769 $tpl->setCurrentBlock(
"item");
770 $tpl->setVariable(
"ITEM_ROW_CSS", $row_css);
771 $tpl->parseCurrentBlock();
774 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
776 $content_block->setContent(
$tpl->get());
779 $content_block->setTitle($this->
getProperty(
"title"));
783 $content_block->setTitle($lng->txt(
"news_internal_news"));
792 if ($previous[
"ref_id"] > 0)
794 $ilCtrl->setParameter($this,
"news_context", $previous[
"ref_id"]);
796 $ilCtrl->setParameter($this,
"news_id", $previous[
"id"]);
797 $content_block->addFooterLink($lng->txt(
"previous"),
798 $ilCtrl->getLinkTarget($this,
"showNews"),
"",
"",
true);
799 $ilCtrl->setParameter($this,
"news_context",
"");
803 if ($c = next($this->data))
805 if ($c[
"ref_id"] > 0)
807 $ilCtrl->setParameter($this,
"news_context", $c[
"ref_id"]);
809 $ilCtrl->setParameter($this,
"news_id", $c[
"id"]);
810 $content_block->addFooterLink($lng->txt(
"next"),
811 $ilCtrl->getLinkTarget($this,
"showNews"),
"",
"",
true);
813 $ilCtrl->setParameter($this,
"news_context",
"");
814 $ilCtrl->setParameter($this,
"news_id",
"");
815 $content_block->setCurrentItemNumber($curr_cnt);
816 $content_block->setEnableNumInfo(
true);
817 $content_block->setData($this->
getData());
819 return $content_block->getHTML();
832 if (is_int(strpos($a_str,
">")) && is_int(strpos($a_str,
"<")))
848 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
850 $ilCtrl->returnToParent($this);
860 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
862 $ilCtrl->returnToParent($this);
874 if ($this->show_view_selection)
890 $this->
addFooterLink(
"[".$lng->txt(
"news_first_letter_of_word_notification").
"] ".
891 $lng->txt(
"news_notifications").
": ",
"",
"",
"",
false,
true);
892 if ($this->view ==
"hide_notifications")
895 $ilCtrl->getLinkTarget($this,
896 "showNotifications"),
897 $ilCtrl->getLinkTarget($this,
898 "showNotifications",
"",
true),
907 $ilCtrl->getLinkTarget($this,
908 "hideNotifications"),
909 $ilCtrl->getLinkTarget($this,
910 "hideNotifications",
"",
true),
922 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
931 if ($ilCtrl->isAsynch())
938 $ilCtrl->returnToParent($this);
946 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
955 if ($ilCtrl->isAsynch())
962 $ilCtrl->returnToParent($this);
972 return $this->settings_form->getHTML();
982 $ilTabs->clearTargets();
985 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
998 if ($hide_news_date !=
"")
1000 $hide_news_date = explode(
" ", $hide_news_date);
1003 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1005 $this->settings_form->setTitle($lng->txt(
"news_settings"));
1013 $ch->
setInfo($lng->txt(
"news_hide_news_block_info"));
1014 $ch->setChecked($hide_block);
1015 $this->settings_form->addItem($ch);
1018 "hide_news_per_date");
1019 $hnpd->
setInfo($lng->txt(
"news_hide_news_per_date_info"));
1020 $hnpd->setChecked($hide_news_per_date);
1024 if ($hide_news_date !=
"")
1028 #$dt_prop->setDate($hide_news_date[0]);
1029 #$dt_prop->setTime($hide_news_date[1]);
1030 $dt_prop->setShowTime(
true);
1032 $hnpd->addSubItem($dt_prop);
1034 $this->settings_form->addItem($hnpd);
1039 if ($this->
getProperty(
"default_visibility_option") &&
1040 $enable_internal_rss)
1043 0, $this->block_id);
1044 if ($default_visibility ==
"")
1046 $default_visibility =
1051 $radio_group =
new ilRadioGroupInputGUI($lng->txt(
"news_default_visibility"),
"default_visibility");
1052 $radio_option =
new ilRadioOption($lng->txt(
"news_visibility_users"),
"users");
1053 $radio_group->addOption($radio_option);
1054 $radio_option =
new ilRadioOption($lng->txt(
"news_visibility_public"),
"public");
1055 $radio_group->addOption($radio_option);
1056 $radio_group->
setInfo($lng->txt(
"news_news_item_visibility_info"));
1057 $radio_group->setRequired(
false);
1058 $radio_group->setValue($default_visibility);
1059 $this->settings_form->addItem($radio_group);
1063 if ($this->
getProperty(
"public_notifications_option") &&
1064 $enable_internal_rss)
1067 "notifications_public");
1068 $ch->
setInfo($lng->txt(
"news_notifications_public_info"));
1069 $ch->setChecked($public);
1070 $this->settings_form->addItem($ch);
1074 if ($enable_internal_rss)
1077 "notifications_public_feed");
1078 $ch->
setInfo($lng->txt(
"news_public_feed_info"));
1079 $ch->setChecked($public_feed);
1080 $this->settings_form->addItem($ch);
1091 $this->settings_form->addCommandButton(
"saveSettings", $lng->txt(
"save"));
1092 $this->settings_form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
1093 $this->settings_form->setFormAction($ilCtrl->getFormaction($this));
1103 $ilCtrl->returnToParent($this);
1115 if ($this->settings_form->checkInput())
1118 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
1120 if ($enable_internal_rss)
1123 0, $this->block_id);
1125 0, $this->block_id);
1127 0, $this->block_id);
1133 0, $this->block_id);
1135 0, $this->block_id);
1138 $hd = $this->settings_form->getInput(
"hide_news_date");
1146 include_once(
"./Services/News/classes/class.ilNewsCache.php");
1148 $cache->deleteEntry($ilUser->getId().
":".
$_GET[
"ref_id"]);
1150 $ilCtrl->returnToParent($this);
1154 $this->settings_form->setValuesByPost();
1155 return $this->settings_form->getHtml();
1166 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1170 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"Services/News");
1171 $tpl->setVariable(
"TXT_TITLE",
1172 sprintf($lng->txt(
"news_feed_url_for"),
$title));
1173 $tpl->setVariable(
"TXT_INFO", $lng->txt(
"news_get_feed_info"));
1174 $tpl->setVariable(
"TXT_FEED_URL", $lng->txt(
"news_feed_url"));
1175 $tpl->setVariable(
"VAL_FEED_URL",
1176 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
1177 "&obj_id=".$this->block_id.
1178 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
1179 $tpl->setVariable(
"VAL_FEED_URL_TXT",
1180 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
1181 "&obj_id=".$this->block_id.
1182 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
1184 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
1186 $content_block->setContent(
$tpl->get());
1187 $content_block->setTitle($lng->txt(
"news_internal_news"));
1189 $content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
1190 $lng->txt(
"close"),
true);
1192 return $content_block->getHTML();
1199 $a_content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
1200 $lng->txt(
"close"),
true);
1207 if ($ilCtrl->getCmd() ==
"hideNotifications" ||
1208 $ilCtrl->getCmd() ==
"showNotifications")
1213 if ($ilCtrl->getCmdClass() !=
"ilcolumngui" && $ilCtrl->getCmd() !=
"enableJS")
1218 $sess_feed_js =
$_SESSION[
"il_feed_js"];
1221 if ($sess_feed_js !=
"n" &&
1222 ($ilUser->getPref(
"il_feed_js") !=
"n" || $sess_feed_js ==
"y"))
1239 $ilCtrl->setParameterByClass(
"ilcolumngui",
"block_id",
1242 $rel_tpl =
new ilTemplate(
"tpl.dynamic_reload.html",
true,
true,
"Services/News");
1243 $rel_tpl->setVariable(
"TXT_LOADING", $lng->txt(
"news_loading_news"));
1245 $rel_tpl->setVariable(
"TARGET",
1246 $ilCtrl->getLinkTargetByClass(
"ilcolumngui",
"updateBlock",
"",
true));
1249 $rel_tpl->setVariable(
"TXT_NEWS_CLICK_HERE", $lng->txt(
"news_no_js_click_here"));
1250 $rel_tpl->setVariable(
"TARGET_NO_JS",
1251 $ilCtrl->getLinkTargetByClass(strtolower(get_class($this)),
"disableJS"));
1253 return $rel_tpl->get();
1260 $ilCtrl->setParameterByClass(
"ilcolumngui",
"block_id",
1263 $rel_tpl =
new ilTemplate(
"tpl.js_enabler.html",
true,
true,
"Services/News");
1265 $rel_tpl->setVariable(
"TARGET",
1266 $ilCtrl->getLinkTargetByClass(strtolower(get_class($this)),
"enableJS",
true,
"",
false));
1268 return $rel_tpl->get();
1277 $ilUser->writePref(
"il_feed_js",
"n");
1278 $ilCtrl->returnToParent($this);
1287 $ilUser->writePref(
"il_feed_js",
"y");