5 include_once(
"Services/Block/classes/class.ilBlockGUI.php");
34 $lng->loadLanguageModule(
"news");
35 include_once(
"./Services/News/classes/class.ilNewsItem.php");
41 $this->dynamic =
false;
42 include_once(
"./Services/News/classes/class.ilNewsCache.php");
44 $cres = $this->acache->getEntry($ilUser->getId().
":".
$_GET[
"ref_id"]);
45 $this->cache_hit =
false;
47 if ($this->acache->getLastAccessStatus() ==
"hit")
49 self::$st_data = unserialize($cres);
50 $this->cache_hit =
true;
54 $this->dynamic =
true;
59 if (!empty(self::$st_data))
66 self::$st_data =
$data;
74 $this->
setTitle($lng->txt(
"news_internal_news"));
75 $this->
setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
77 $this->allow_moving =
false;
88 include_once(
"./Services/News/classes/class.ilNewsCache.php");
98 $news_item->setContextObjId($ilCtrl->getContextObjId());
99 $news_item->setContextObjType($ilCtrl->getContextObjType());
103 $prevent_aggregation =
true;
106 $news_data = $news_item->getNewsForRefId(
$_GET[
"ref_id"],
false,
false, 0,
107 $prevent_aggregation,
true);
109 $this->acache->storeEntry($ilUser->getId().
":".
$_GET[
"ref_id"],
110 serialize($news_data));
144 if ($ilCtrl->getCmdClass() ==
"ilnewsitemgui")
149 switch($ilCtrl->getCmd())
174 $next_class = $ilCtrl->getNextClass();
175 $cmd = $ilCtrl->getCmd(
"getHTML");
179 case "ilnewsitemgui":
180 include_once(
"./Services/News/classes/class.ilNewsItemGUI.php");
183 $html = $ilCtrl->forwardCommand($news_item_gui);
187 return $this->
$cmd();
198 $this->enable_edit = $a_enable_edit;
208 return $this->enable_edit;
238 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
256 if ($enable_internal_rss)
259 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&".
260 "ref_id=".
$_GET[
"ref_id"],
261 $lng->txt(
"news_feed_url"),
"_blank",
287 $ilCtrl->getLinkTargetByClass(
"ilnewsitemgui",
"editNews"),
290 $ilCtrl->setParameter($this,
"add_mode",
"block");
292 $ilCtrl->getLinkTargetByClass(
"ilnewsitemgui",
"createNewsItem"),
294 $ilCtrl->setParameter($this,
"add_mode",
"");
300 $ilCtrl->getLinkTarget($this,
"editSettings"),
301 $lng->txt(
"settings"));
322 if ($ilUser->getPref(
"il_feed_js") ==
"n")
337 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
342 $got_notices = $got_messages =
false;
343 foreach($this->data as
$row)
345 if ($row[
"priority"] == 0) $got_notices =
true;
346 if ($row[
"priority"] == 1) $got_messages =
true;
348 $this->show_view_selection =
false;
350 if ($got_notices && $got_messages)
352 $this->show_view_selection =
true;
354 else if ($got_notices)
385 $this->tpl->setCurrentBlock(
"long");
387 $this->tpl->setVariable(
"VAL_CREATION_DATE",
389 $this->tpl->parseCurrentBlock();
393 if ($news[
"priority"] == 0)
404 if ($news[
"ref_id"] > 0)
406 if ($news[
"agg_ref_id"] > 0)
410 $context_ref = $news[
"agg_ref_id"];
414 $obj_id = $news[
"context_obj_id"];
415 $type = $news[
"context_obj_type"];
416 $context_ref = $news[
"ref_id"];
419 $lang_type = in_array(
$type, array(
"sahs",
"lm",
"dbk",
"htlm"))
423 $this->tpl->setCurrentBlock(
"news_context");
424 $this->tpl->setVariable(
"TYPE", $lng->txt($lang_type));
425 $this->tpl->setVariable(
"IMG_TYPE",
427 $this->tpl->setVariable(
"TITLE",
429 if ($news[
"user_read"] > 0)
431 $this->tpl->setVariable(
"TITLE_CLASS",
'class="light"');
434 $this->tpl->parseCurrentBlock();
435 $ilCtrl->setParameter($this,
"news_context", $context_ref);
439 $ilCtrl->setParameter($this,
"news_context",
"");
443 $this->tpl->setVariable(
"VAL_TITLE",
445 ($news[
"context_obj_type"], $news[
"title"], $news[
"content_is_lang_var"],
446 $news[
"agg_ref_id"], $news[
"aggregation"])));
449 if ($news[
"user_read"] > 0)
451 $this->tpl->setVariable(
"A_CLASS",
'class="light"');
454 $ilCtrl->setParameter($this,
"news_id", $news[
"id"]);
455 $this->tpl->setVariable(
"HREF_SHOW",
456 $ilCtrl->getLinkTarget($this,
"showNews"));
457 $ilCtrl->clearParameters($this);
467 return '<div class="small">'.((int) count($this->
getData())).
" ".$lng->txt(
"news_news_items").
"</div>";
478 if (empty(self::$st_data))
484 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
486 include_once(
"./Services/News/classes/class.ilNewsItem.php");
489 $tpl =
new ilTemplate(
"tpl.show_news.html",
true,
true,
"Services/News");
492 $previous = $next =
"";
494 $c = current($this->data);
497 while($c[
"id"] > 0 &&
498 $c[
"id"] !=
$_GET[
"news_id"])
501 $c = next($this->data);
506 $news_list = array();
507 if (is_array($c[
"aggregation"]))
512 $news_list[] = array(
"ref_id" => $c[
"agg_ref_id"],
513 "agg_ref_id" => $c[
"agg_ref_id"],
514 "aggregation" => $c[
"aggregation"],
516 "content_type" =>
"text",
520 "content_long" =>
"",
521 "update_date" => $news->getUpdateDate(),
522 "creation_date" =>
"",
523 "content_is_lang_var" =>
false,
524 "loc_context" =>
$_GET[
"news_context"],
525 "context_obj_type" => $news->getContextObjType(),
528 foreach($c[
"aggregation"] as $c_item)
531 $c_item[
"loc_context"] = $c_item[
"ref_id"];
532 $c_item[
"loc_stop"] =
$_GET[
"news_context"];
533 $news_list[] = $c_item;
538 $news_list[] = array(
"ref_id" =>
$_GET[
"news_context"],
539 "user_id" => $news->getUserId(),
540 "content_type" => $news->getContentType(),
541 "mob_id" => $news->getMobId(),
542 "visibility" => $news->getVisibility(),
543 "priority" => $news->getPriority(),
544 "content" => $news->getContent(),
545 "content_long" => $news->getContentLong(),
546 "update_date" => $news->getUpdateDate(),
547 "creation_date" => $news->getCreationDate(),
548 "context_sub_obj_type" => $news->getContextSubObjType(),
549 "context_sub_obj_id" => $news->getContextSubObjId(),
550 "content_is_lang_var" => $news->getContentIsLangVar(),
551 "loc_context" =>
$_GET[
"news_context"],
552 "title" => $news->getTitle());
556 foreach ($news_list as $item)
570 $displayname =
"<". strtolower($lng->txt(
"deleted")) .
">";
573 $tpl->setCurrentBlock(
"user_info");
575 $tpl->setVariable(
"TXT_AUTHOR", $lng->txt(
"author"));
576 $tpl->parseCurrentBlock();
583 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
584 include_once(
"./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
586 $med = $mob->getMediaItem(
"Standard");
588 if (strcasecmp(
"Reference", $med->getLocationType()) == 0)
589 $mpl->setFile($med->getLocation());
592 $mpl->setDisplayHeight($med->getHeight());
593 $tpl->setCurrentBlock(
"player");
594 $tpl->setVariable(
"PLAYER",
595 $mpl->getMp3PlayerHtml());
596 $tpl->parseCurrentBlock();
600 if ($enable_internal_rss && $item[
"visibility"] !=
"")
603 $tpl->setCurrentBlock(
"access");
604 $tpl->setVariable(
"TXT_ACCESS", $lng->txt(
"news_news_item_visibility"));
606 ($item[
"priority"] == 0 &&
610 $tpl->setVariable(
"VAL_ACCESS", $lng->txt(
"news_visibility_public"));
614 $tpl->setVariable(
"VAL_ACCESS", $lng->txt(
"news_visibility_users"));
616 $tpl->parseCurrentBlock();
620 if (trim($item[
"content"]) !=
"")
622 $tpl->setCurrentBlock(
"content");
623 $tpl->setVariable(
"VAL_CONTENT",
626 $tpl->parseCurrentBlock();
628 if (trim($item[
"content_long"]) !=
"")
630 $tpl->setCurrentBlock(
"long");
632 $tpl->parseCurrentBlock();
634 if ($item[
"update_date"] != $item[
"creation_date"])
636 $tpl->setCurrentBlock(
"ni_update");
637 $tpl->setVariable(
"TXT_LAST_UPDATE", $lng->txt(
"last_update"));
638 $tpl->setVariable(
"VAL_LAST_UPDATE",
640 $tpl->parseCurrentBlock();
644 if ($item[
"creation_date"] !=
"")
646 $tpl->setCurrentBlock(
"ni_update");
647 $tpl->setVariable(
"VAL_CREATION_DATE",
649 $tpl->setVariable(
"TXT_CREATED", $lng->txt(
"created"));
650 $tpl->parseCurrentBlock();
655 if (
$_GET[
"news_context"] > 0)
663 if ($obj_type ==
"file")
665 $tpl->setCurrentBlock(
"download");
666 $tpl->setVariable(
"TXT_DOWNLOAD", $lng->txt(
"download"));
667 $tpl->setVariable(
"HREF_DOWNLOAD",
668 "./repository.php?ref_id=".$item[
"ref_id"].
"&cmd=sendfile");
669 $tpl->parseCurrentBlock();
673 $url_target =
"./goto.php?client_id=".rawurlencode(CLIENT_ID).
"&target=".
674 $obj_type.
"_".$item[
"ref_id"].$add;
677 if (in_array($obj_type, array(
"dbk",
"lm")) && $item[
"context_sub_obj_type"] ==
"pg"
678 && $item[
"context_sub_obj_id"] > 0)
680 $url_target =
"./goto.php?client_id=".rawurlencode(CLIENT_ID).
"&target=".
681 "pg_".$item[
"context_sub_obj_id"].
"_".$item[
"ref_id"];
685 $context_opened =
false;
686 if ($item[
"loc_context"] != null && $item[
"loc_context"] != $item[
"loc_stop"])
689 $tpl->setCurrentBlock(
"context");
690 $context_opened =
true;
692 $cont_loc->addContextItems($item[
"loc_context"],
true, $item[
"loc_stop"]);
693 $tpl->setVariable(
"CONTEXT_LOCATOR", $cont_loc->getHTML());
697 if ($item[
"no_context_title"] !==
true)
699 if (!$context_opened)
701 $tpl->setCurrentBlock(
"context");
703 $tpl->setVariable(
"HREF_CONTEXT_TITLE", $url_target);
704 $tpl->setVariable(
"CONTEXT_TITLE", $obj_title);
709 $tpl->parseCurrentBlock();
712 $tpl->setVariable(
"HREF_TITLE", $url_target);
718 $tpl->setVariable(
"VAL_TITLE",
720 $item[
"title"], $item[
"content_is_lang_var"], $item[
"agg_ref_id"],
721 $item[
"aggregation"]));
728 $row_css = ($row_css !=
"tblrow1")
732 $tpl->setCurrentBlock(
"item");
733 $tpl->setVariable(
"ITEM_ROW_CSS", $row_css);
734 $tpl->parseCurrentBlock();
737 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
739 $content_block->setContent(
$tpl->get());
742 $content_block->setTitle($this->
getProperty(
"title"));
746 $content_block->setTitle($lng->txt(
"news_internal_news"));
755 if ($previous[
"ref_id"] > 0)
757 $ilCtrl->setParameter($this,
"news_context", $previous[
"ref_id"]);
759 $ilCtrl->setParameter($this,
"news_id", $previous[
"id"]);
760 $content_block->addFooterLink($lng->txt(
"previous"),
761 $ilCtrl->getLinkTarget($this,
"showNews"),
"",
"",
true);
762 $ilCtrl->setParameter($this,
"news_context",
"");
766 if ($c = next($this->data))
768 if ($c[
"ref_id"] > 0)
770 $ilCtrl->setParameter($this,
"news_context", $c[
"ref_id"]);
772 $ilCtrl->setParameter($this,
"news_id", $c[
"id"]);
773 $content_block->addFooterLink($lng->txt(
"next"),
774 $ilCtrl->getLinkTarget($this,
"showNews"),
"",
"",
true);
776 $ilCtrl->setParameter($this,
"news_context",
"");
777 $ilCtrl->setParameter($this,
"news_id",
"");
778 $content_block->setCurrentItemNumber($curr_cnt);
779 $content_block->setEnableNumInfo(
true);
780 $content_block->setData($this->
getData());
782 return $content_block->getHTML();
792 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
794 $ilCtrl->returnToParent($this);
804 include_once(
"./Services/News/classes/class.ilNewsSubscription.php");
806 $ilCtrl->returnToParent($this);
818 if ($this->show_view_selection)
834 $this->
addFooterLink(
"[".$lng->txt(
"news_first_letter_of_word_notification").
"] ".
835 $lng->txt(
"news_notifications").
": ",
"",
"",
"",
false,
true);
836 if ($this->view ==
"hide_notifications")
839 $ilCtrl->getLinkTarget($this,
840 "showNotifications"),
841 $ilCtrl->getLinkTarget($this,
842 "showNotifications",
"",
true),
851 $ilCtrl->getLinkTarget($this,
852 "hideNotifications"),
853 $ilCtrl->getLinkTarget($this,
854 "hideNotifications",
"",
true),
866 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
875 if ($ilCtrl->isAsynch())
882 $ilCtrl->returnToParent($this);
890 include_once(
"Services/Block/classes/class.ilBlockSetting.php");
899 if ($ilCtrl->isAsynch())
906 $ilCtrl->returnToParent($this);
916 return $this->settings_form->getHTML();
926 $ilTabs->clearTargets();
929 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
942 if ($hide_news_date !=
"")
944 $hide_news_date = explode(
" ", $hide_news_date);
947 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
949 $this->settings_form->setTitle($lng->txt(
"news_settings"));
957 $ch->
setInfo($lng->txt(
"news_hide_news_block_info"));
958 $ch->setChecked($hide_block);
959 $this->settings_form->addItem($ch);
962 "hide_news_per_date");
963 $hnpd->
setInfo($lng->txt(
"news_hide_news_per_date_info"));
964 $hnpd->setChecked($hide_news_per_date);
968 if ($hide_news_date !=
"")
972 #$dt_prop->setDate($hide_news_date[0]);
973 #$dt_prop->setTime($hide_news_date[1]);
974 $dt_prop->setShowTime(
true);
976 $hnpd->addSubItem($dt_prop);
978 $this->settings_form->addItem($hnpd);
983 if ($this->
getProperty(
"default_visibility_option") &&
984 $enable_internal_rss)
988 if ($default_visibility ==
"")
990 $default_visibility =
995 $radio_group =
new ilRadioGroupInputGUI($lng->txt(
"news_default_visibility"),
"default_visibility");
996 $radio_option =
new ilRadioOption($lng->txt(
"news_visibility_users"),
"users");
997 $radio_group->addOption($radio_option);
998 $radio_option =
new ilRadioOption($lng->txt(
"news_visibility_public"),
"public");
999 $radio_group->addOption($radio_option);
1000 $radio_group->
setInfo($lng->txt(
"news_news_item_visibility_info"));
1001 $radio_group->setRequired(
false);
1002 $radio_group->setValue($default_visibility);
1003 $this->settings_form->addItem($radio_group);
1007 if ($this->
getProperty(
"public_notifications_option") &&
1008 $enable_internal_rss)
1011 "notifications_public");
1012 $ch->
setInfo($lng->txt(
"news_notifications_public_info"));
1013 $ch->setChecked($public);
1014 $this->settings_form->addItem($ch);
1018 if ($enable_internal_rss)
1021 "notifications_public_feed");
1022 $ch->
setInfo($lng->txt(
"news_public_feed_info"));
1023 $ch->setChecked($public_feed);
1024 $this->settings_form->addItem($ch);
1035 $this->settings_form->addCommandButton(
"saveSettings", $lng->txt(
"save"));
1036 $this->settings_form->addCommandButton(
"cancelSettings", $lng->txt(
"cancel"));
1037 $this->settings_form->setFormAction($ilCtrl->getFormaction($this));
1047 $ilCtrl->returnToParent($this);
1059 if ($this->settings_form->checkInput())
1062 $enable_internal_rss = $news_set->get(
"enable_rss_for_internal");
1064 if ($enable_internal_rss)
1067 0, $this->block_id);
1069 0, $this->block_id);
1071 0, $this->block_id);
1077 0, $this->block_id);
1079 0, $this->block_id);
1082 $hd = $this->settings_form->getInput(
"hide_news_date");
1090 $ilCtrl->returnToParent($this);
1094 $this->settings_form->setValuesByPost();
1095 return $this->settings_form->getHtml();
1106 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1110 $tpl =
new ilTemplate(
"tpl.show_feed_url.html",
true,
true,
"Services/News");
1111 $tpl->setVariable(
"TXT_TITLE",
1112 sprintf($lng->txt(
"news_feed_url_for"),
$title));
1113 $tpl->setVariable(
"TXT_INFO", $lng->txt(
"news_get_feed_info"));
1114 $tpl->setVariable(
"TXT_FEED_URL", $lng->txt(
"news_feed_url"));
1115 $tpl->setVariable(
"VAL_FEED_URL",
1116 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&user_id=".$ilUser->getId().
1117 "&obj_id=".$this->block_id.
1118 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
1119 $tpl->setVariable(
"VAL_FEED_URL_TXT",
1120 ILIAS_HTTP_PATH.
"/feed.php?client_id=".rawurlencode(CLIENT_ID).
"&<br />user_id=".$ilUser->getId().
1121 "&obj_id=".$this->block_id.
1122 "&hash=".ilObjUser::_lookupFeedHash($ilUser->getId(),
true));
1124 include_once(
"./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
1126 $content_block->setContent(
$tpl->get());
1127 $content_block->setTitle($lng->txt(
"news_internal_news"));
1129 $content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
1130 $lng->txt(
"close"),
true);
1132 return $content_block->getHTML();
1139 $a_content_block->addHeaderCommand($ilCtrl->getParentReturn($this),
1140 $lng->txt(
"close"),
true);
1147 if ($ilCtrl->getCmd() ==
"hideNotifications" ||
1148 $ilCtrl->getCmd() ==
"showNotifications")
1153 if ($ilCtrl->getCmdClass() !=
"ilcolumngui" && $ilCtrl->getCmd() !=
"enableJS")
1158 $sess_feed_js =
$_SESSION[
"il_feed_js"];
1161 if ($sess_feed_js !=
"n" &&
1162 ($ilUser->getPref(
"il_feed_js") !=
"n" || $sess_feed_js ==
"y"))
1179 $ilCtrl->setParameterByClass(
"ilcolumngui",
"block_id",
1182 $rel_tpl =
new ilTemplate(
"tpl.dynamic_reload.html",
true,
true,
"Services/News");
1183 $rel_tpl->setVariable(
"TXT_LOADING", $lng->txt(
"news_loading_news"));
1185 $rel_tpl->setVariable(
"TARGET",
1186 $ilCtrl->getLinkTargetByClass(
"ilcolumngui",
"updateBlock",
"",
true));
1189 $rel_tpl->setVariable(
"TXT_NEWS_CLICK_HERE", $lng->txt(
"news_no_js_click_here"));
1190 $rel_tpl->setVariable(
"TARGET_NO_JS",
1191 $ilCtrl->getLinkTargetByClass(strtolower(get_class($this)),
"disableJS"));
1193 return $rel_tpl->get();
1200 $ilCtrl->setParameterByClass(
"ilcolumngui",
"block_id",
1203 $rel_tpl =
new ilTemplate(
"tpl.js_enabler.html",
true,
true,
"Services/News");
1205 $rel_tpl->setVariable(
"TARGET",
1206 $ilCtrl->getLinkTargetByClass(strtolower(get_class($this)),
"enableJS",
true,
"",
false));
1208 return $rel_tpl->get();
1217 $ilUser->writePref(
"il_feed_js",
"n");
1218 $ilCtrl->returnToParent($this);
1227 $ilUser->writePref(
"il_feed_js",
"y");