ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilNewsForContextBlockGUI Class Reference

BlockGUI class for block NewsForContext. More...

+ Inheritance diagram for ilNewsForContextBlockGUI:
+ Collaboration diagram for ilNewsForContextBlockGUI:

Public Member Functions

 __construct ()
 
 getNewsData ()
 
 getBlockType ()
 
 executeCommand ()
 
 getHTML ()
 
 handleView ()
 Handles show/hide notification view and removes notifications if hidden. More...
 
 getInfoForData (array $news)
 
 getOverview ()
 
 showNews ()
 
 makeClickable (string $a_str)
 
 showNotifications ()
 
 hideNotifications ()
 
 editSettings ()
 Show settings screen. More...
 
 initSettingsForm ()
 Init setting form. More...
 
 cancelSettings ()
 
 saveSettings ()
 
 showFeedUrl ()
 
 getDynamicReload ()
 
 getJSEnabler ()
 
 disableJS ()
 
 enableJS ()
 
 getNoItemFoundContent ()
 
- Public Member Functions inherited from ilBlockGUI
 __construct ()
 
 getBlockType ()
 
 setData (array $a_data)
 
 getData ()
 
 setPresentation (int $type)
 
 getPresentation ()
 
 setBlockId (string $a_block_id="0")
 
 getBlockId ()
 
 setGuiObject (object $a_gui_object)
 Set GuiObject. More...
 
 getGuiObject ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setOffset (int $a_offset)
 
 getOffset ()
 
 checkOffset (int $offset)
 
 setLimit (int $a_limit)
 
 getLimit ()
 
 setEnableEdit (bool $a_enableedit)
 
 getEnableEdit ()
 
 setRepositoryMode (bool $a_repositorymode)
 
 getRepositoryMode ()
 
 setSubtitle (string $a_subtitle)
 
 getSubtitle ()
 
 setRefId (int $a_refid)
 Set Ref Id (only used if isRepositoryObject() is true). More...
 
 getRefId ()
 
 setAdminCommands (bool $a_admincommands)
 
 getAdminCommands ()
 
 setEnableNumInfo (bool $a_enablenuminfo)
 
 getEnableNumInfo ()
 
 setProperties (array $a_properties)
 This function is supposed to be used for block type specific properties, that should be inherited through ilColumnGUI->setBlockProperties. More...
 
 getProperty (string $a_property)
 
 setProperty (string $a_property, string $a_value)
 
 setRowTemplate (string $a_rowtemplatename, string $a_rowtemplatedir="")
 Set Row Template Name. More...
 
 getNavParameter ()
 
 getConfigParameter ()
 
 getMoveParameter ()
 
 getRowTemplateName ()
 
 getRowTemplateDir ()
 
 addBlockCommand (string $a_href, string $a_text, string $a_onclick="", ?RoundTrip $modal=null)
 
 getBlockCommands ()
 
 getHTML ()
 
 getAsynch ()
 Use this for final get before sending asynchronous output (ajax) per echo to output. More...
 
 getPaginationViewControl ()
 Fill previous/next row. More...
 
 getViewControlsForPanel ()
 
 sortObject ()
 
 addSortOption (string $option, string $label, bool $active)
 
 setSortTarget (string $target)
 
 addPresentation (string $label, string $target, bool $active)
 
 getNoItemFoundContent ()
 

Static Public Member Functions

static getScreenMode ()
 
static addToSettingsForm (ilFormPropertyGUI $a_input)
 Add inputs to the container news settings form to configure also the contextBlock options. More...
 
static writeSettings (array $a_values)
 
static getScreenMode ()
 

Data Fields

const OBJECTS_WITH_NEWS_SUBTAB = ["category", "course", "group", "forum"]
 object type names with settings->news settings subtab More...
 
- Data Fields inherited from ilBlockGUI
const PRES_MAIN_LEG = 0
 
const PRES_SEC_LEG = 1
 
const PRES_SEC_LIST = 2
 
const PRES_MAIN_LIST = 3
 
const PRES_MAIN_TILE = 4
 

Static Public Attributes

static string $block_type = "news"
 
static array $st_data
 

Protected Member Functions

 isRepositoryObject ()
 Returns whether block has a corresponding repository object. More...
 
 getMediaPath (int $mob_id)
 
 getListItemForData (array $data)
 Get list item for data array. More...
 
 downloadMob ()
 
- Protected Member Functions inherited from ilBlockGUI
 isRepositoryObject ()
 Returns whether block has a corresponding repository object. More...
 
 specialCharsAsEntities (string $string)
 
 initCommands ()
 
 preloadData (array $data)
 Can be overwritten in subclasses. More...
 
 getLegacyContent ()
 Get legacy content. More...
 
 getListItemForData (array $data)
 Get list item for data array. More...
 
 handleNavigation ()
 Handle navigation. More...
 
 loadData ()
 Load data for current page. More...
 
 getListItemGroups ()
 Get items. More...
 
 addRepoCommands ()
 Add repo commands. More...
 
 getActionsForPanel ()
 
 send (string $output)
 Send. More...
 

Protected Attributes

ILIAS News InternalGUIService $gui
 
NewsAccess $news_access
 
bool $cache_hit = false
 
bool $dynamic = false
 
ilNewsCache $acache
 
bool $show_view_selection
 
string $view
 
ilPropertyFormGUI $settings_form
 
ilHelpGUI $help
 
ilSetting $settings
 
ilTabsGUI $tabs
 
ilObjectDefinition $obj_definition
 
StandardGUIRequest $std_request
 
- Protected Attributes inherited from ilBlockGUI
ILIAS UI Renderer $renderer
 
Factory $factory
 
object $gui_object
 
ILIAS Container Block StandardGUIRequest $request
 
ILIAS Container Block BlockManager $block_manager
 
bool $repositorymode = false
 
ILIAS DI UIServices $ui
 
array $data = array()
 
bool $enablenuminfo = true
 
array $footer_links = array()
 
string $block_id = "0"
 
bool $allow_moving = true
 
array $move = array("left" => false, "right" => false, "up" => false, "down" => false)
 
array $block_commands = array()
 
int $max_count = 0
 
bool $close_command = false
 
bool $image = false
 
array $property = []
 
string $nav_value = ""
 
string $css_row = ""
 
string $title = ""
 
bool $admincommands = false
 
array $dropdown
 
ilTemplate $tpl
 
ilGlobalTemplateInterface $main_tpl
 
ilObjUser $user
 
ilCtrl $ctrl
 
ilAccessHandler $access
 
ilLanguage $lng
 
ilObjectDefinition $obj_def
 
int $presentation
 
int $requested_ref_id
 

Detailed Description

BlockGUI class for block NewsForContext.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de @ilCtrl_IsCalledBy ilNewsForContextBlockGUI: ilColumnGUI @ilCtrl_Calls ilNewsForContextBlockGUI: ilNewsItemGUI

Definition at line 29 of file class.ilNewsForContextBlockGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilNewsForContextBlockGUI::__construct ( )

Reimplemented from ilBlockGUI.

Reimplemented in ilPDNewsBlockGUI.

Definition at line 55 of file class.ilNewsForContextBlockGUI.php.

56 {
57 global $DIC;
58 $this->ctrl = $DIC->ctrl();
59 $this->lng = $DIC->language();
60 $this->user = $DIC->user();
61 $this->help = $DIC["ilHelp"];
62 $this->access = $DIC->access();
63 $this->settings = $DIC->settings();
64 $this->tabs = $DIC->tabs();
65 $this->obj_definition = $DIC["objDefinition"];
66 $this->std_request = $DIC->news()
67 ->internal()
68 ->gui()
69 ->standardRequest();
70
71 $this->news_access = new NewsAccess($this->std_request->getRefId());
72
73 $ilCtrl = $DIC->ctrl();
74 $lng = $DIC->language();
75 $ilUser = $DIC->user();
76 $ilHelp = $DIC["ilHelp"];
77
79
80 $lng->loadLanguageModule("news");
81 $ilHelp->addHelpSection("news_block");
82
83 $this->setBlockId((string) $ilCtrl->getContextObjId());
84 $this->setLimit(5);
85 $this->setEnableNumInfo(true);
86
87 $this->dynamic = false;
88 $this->acache = new ilNewsCache();
89 $cres = unserialize(
90 (string) $this->acache->getEntry($ilUser->getId() . ":" . $this->std_request->getRefId()),
91 ["allowed_classes" => false]
92 );
93 $this->cache_hit = false;
94
95 if ($this->acache->getLastAccessStatus() === "hit" && is_array($cres)) {
96 self::$st_data = ilNewsItem::prepareNewsDataFromCache($cres);
97 $this->cache_hit = true;
98 }
99 if (!empty(self::$st_data)) {
101 } else {
102 $data = $this->getNewsData();
103 self::$st_data = $data;
104 }
105
106 $this->setTitle($lng->txt("news_internal_news"));
107 $this->setRowTemplate("tpl.block_row_news_for_context.html", "components/ILIAS/News");
108 $this->setData($data);
109 $this->allow_moving = false;
110 $this->handleView();
111
112 $this->setPresentation(self::PRES_SEC_LIST);
113 $this->gui = $DIC->news()->internal()->gui();
114 }
setData(array $a_data)
ilLanguage $lng
setTitle(string $a_title)
setPresentation(int $type)
setBlockId(string $a_block_id="0")
setLimit(int $a_limit)
setEnableNumInfo(bool $a_enablenuminfo)
setRowTemplate(string $a_rowtemplatename, string $a_rowtemplatedir="")
Set Row Template Name.
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
handleView()
Handles show/hide notification view and removes notifications if hidden.
static prepareNewsDataFromCache(array $a_cres)
Prepare news data from cache.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References ilBlockGUI\$data, $DIC, ilBlockGUI\$lng, $st_data, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), getNewsData(), handleView(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ilLanguage\loadLanguageModule(), ilNewsItem\prepareNewsDataFromCache(), ilBlockGUI\setBlockId(), ilBlockGUI\setData(), ilBlockGUI\setEnableNumInfo(), ilBlockGUI\setLimit(), ilBlockGUI\setPresentation(), ilBlockGUI\setRowTemplate(), ILIAS\Repository\settings(), ilBlockGUI\setTitle(), ILIAS\Repository\tabs(), ilLanguage\txt(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addToSettingsForm()

static ilNewsForContextBlockGUI::addToSettingsForm ( ilFormPropertyGUI  $a_input)
static

Add inputs to the container news settings form to configure also the contextBlock options.

Definition at line 1008 of file class.ilNewsForContextBlockGUI.php.

1008 : void
1009 {
1010 global $DIC;
1011
1012 $std_request = $DIC->news()
1013 ->internal()
1014 ->gui()
1015 ->standardRequest();
1016
1017 $lng = $DIC->language();
1018 $block_id = $DIC->ctrl()->getContextObjId();
1019
1020 $news_set = new ilSetting("news");
1021 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1022
1023 $public_feed = ilBlockSetting::_lookup(
1024 self::$block_type,
1025 "public_feed",
1026 0,
1027 $block_id
1028 );
1029 $default_visibility = ilBlockSetting::_lookup(self::$block_type, "default_visibility", 0, $block_id);
1030 if ($default_visibility == "") {
1031 $default_visibility =
1033 }
1034 $radio_group = new ilRadioGroupInputGUI($lng->txt("news_default_visibility"), "default_visibility");
1035 $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "users");
1036 $radio_group->addOption($radio_option);
1037 $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "public");
1038 $radio_group->addOption($radio_option);
1039 $radio_group->setInfo($lng->txt("news_news_item_visibility_info"));
1040 $radio_group->setRequired(false);
1041 $radio_group->setValue($default_visibility);
1042 $a_input->addSubItem($radio_group);
1043
1044 // extra rss feed
1045 if ($enable_internal_rss) {
1046 $radio_rss = new ilCheckboxInputGUI(
1047 $lng->txt("news_public_feed"),
1048 "notifications_public_feed"
1049 );
1050 $radio_rss->setInfo($lng->txt("news_public_feed_info"));
1051 $radio_rss->setChecked((bool) $public_feed);
1052 $a_input->addSubItem($radio_rss);
1053 }
1054 }
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
This class represents a checkbox property in a property form.
static _getDefaultVisibilityForRefId(int $a_ref_id)
Get default visibility for reference id.
This class represents a property in a property form.
This class represents an option in a radio group.
ILIAS Setting Class.

References ilBlockGUI\$block_id, $DIC, ilBlockGUI\$lng, $std_request, ilNewsItem\_getDefaultVisibilityForRefId(), ilBlockSetting\_lookup(), ILIAS\News\StandardGUIRequest\getRefId(), and ilLanguage\txt().

Referenced by ilContainerNewsSettingsGUI\initForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelSettings()

ilNewsForContextBlockGUI::cancelSettings ( )

Definition at line 1066 of file class.ilNewsForContextBlockGUI.php.

1066 : void
1067 {
1068 $ilCtrl = $this->ctrl;
1069
1070 $ilCtrl->returnToParent($this);
1071 }
returnToParent(object $a_gui_obj, ?string $a_anchor=null)
@inheritDoc

References ilBlockGUI\$ctrl, and ilCtrl\returnToParent().

+ Here is the call graph for this function:

◆ disableJS()

ilNewsForContextBlockGUI::disableJS ( )

Definition at line 1242 of file class.ilNewsForContextBlockGUI.php.

1242 : void
1243 {
1244 $ilCtrl = $this->ctrl;
1245 $ilUser = $this->user;
1246
1247 ilSession::set("il_feed_js", "n");
1248 $ilUser->writePref("il_feed_js", "n");
1249 $ilCtrl->returnToParent($this);
1250 }
ilObjUser $user
static set(string $a_var, $a_val)
Set a value.

References ilBlockGUI\$ctrl, ilBlockGUI\$user, and ilSession\set().

+ Here is the call graph for this function:

◆ downloadMob()

ilNewsForContextBlockGUI::downloadMob ( )
protected

Definition at line 1285 of file class.ilNewsForContextBlockGUI.php.

1285 : void
1286 {
1287 $news_id = $this->std_request->getNewsId();
1288 $news = new ilNewsItem($news_id);
1289 $news->deliverMobFile("Standard", true);
1290 }
A news item can be created by different sources.

◆ editSettings()

ilNewsForContextBlockGUI::editSettings ( )

Show settings screen.

Definition at line 864 of file class.ilNewsForContextBlockGUI.php.

864 : string
865 {
866 $this->initSettingsForm();
867 return $this->settings_form->getHTML();
868 }

References initSettingsForm().

Referenced by ilPDNewsBlockGUI\changeFeedSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enableJS()

ilNewsForContextBlockGUI::enableJS ( )

Definition at line 1252 of file class.ilNewsForContextBlockGUI.php.

1252 : void
1253 {
1254 $ilUser = $this->user;
1255 ilSession::set("il_feed_js", "y");
1256 $ilUser->writePref("il_feed_js", "y");
1257 $this->send($this->getHTML());
1258 }
send(string $output)
Send.

References ilBlockGUI\$user, getHTML(), ilBlockGUI\send(), and ilSession\set().

+ Here is the call graph for this function:

◆ executeCommand()

ilNewsForContextBlockGUI::executeCommand ( )

Reimplemented in ilPDNewsBlockGUI.

Definition at line 196 of file class.ilNewsForContextBlockGUI.php.

197 {
198 if (strcasecmp($this->ctrl->getNextClass(), ilNewsItemGUI::class) === 0) {
199 $news_item_gui = new ilNewsItemGUI();
200 $news_item_gui->setEnableEdit($this->getEnableEdit());
201 return $this->ctrl->forwardCommand($news_item_gui);
202 }
203
204 $cmd = $this->ctrl->getCmd("getHTML");
205 return $this->$cmd();
206 }
User Interface for NewsItem entities.

References ILIAS\Repository\ctrl(), and ilBlockGUI\getEnableEdit().

+ Here is the call graph for this function:

◆ getBlockType()

ilNewsForContextBlockGUI::getBlockType ( )

Reimplemented from ilBlockGUI.

Reimplemented in ilPDNewsBlockGUI.

Definition at line 162 of file class.ilNewsForContextBlockGUI.php.

162 : string
163 {
164 return self::$block_type;
165 }

References $block_type.

Referenced by getDynamicReload(), getHTML(), getJSEnabler(), handleView(), hideNotifications(), initSettingsForm(), saveSettings(), and showNotifications().

+ Here is the caller graph for this function:

◆ getDynamicReload()

ilNewsForContextBlockGUI::getDynamicReload ( )

Definition at line 1192 of file class.ilNewsForContextBlockGUI.php.

1192 : string
1193 {
1194 $ilCtrl = $this->ctrl;
1195 $lng = $this->lng;
1196
1197 $ilCtrl->setParameterByClass(
1198 ilColumnGUI::class,
1199 "block_id",
1200 "block_" . $this->getBlockType() . "_" . $this->getBlockId()
1201 );
1202
1203 $rel_tpl = new ilTemplate("tpl.dynamic_reload.html", true, true, "components/ILIAS/News");
1204 $rel_tpl->setVariable("TXT_LOADING", $lng->txt("news_loading_news"));
1205 $rel_tpl->setVariable("BLOCK_ID", "block_" . $this->getBlockType() . "_" . $this->getBlockId());
1206 $rel_tpl->setVariable(
1207 "TARGET",
1208 $ilCtrl->getLinkTargetByClass(ilColumnGUI::class, "updateBlock", "", true)
1209 );
1210
1211 // no JS
1212 $rel_tpl->setVariable("TXT_NEWS_CLICK_HERE", $lng->txt("news_no_js_click_here"));
1213 $rel_tpl->setVariable(
1214 "TARGET_NO_JS",
1215 $ilCtrl->getLinkTarget($this, "disableJS")
1216 );
1217
1218 return $rel_tpl->get();
1219 }
special template class to simplify handling of ITX/PEAR

References ilBlockGUI\$ctrl, ilBlockGUI\$lng, ilBlockGUI\getBlockId(), getBlockType(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ getHTML()

ilNewsForContextBlockGUI::getHTML ( )

Reimplemented from ilBlockGUI.

Reimplemented in ilPDNewsBlockGUI.

Definition at line 208 of file class.ilNewsForContextBlockGUI.php.

208 : string
209 {
210 global $DIC;
211
212 $ilCtrl = $this->ctrl;
214 $ilUser = $this->user;
215
216 $news_set = new ilSetting("news");
217 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
218
219 $hide_block = ilBlockSetting::_lookup(
220 $this->getBlockType(),
221 "hide_news_block",
222 0,
223 (int) $this->block_id
224 );
225
226 if ($this->getProperty("title") != "") {
227 $this->setTitle($this->getProperty("title"));
228 }
229
230 $public_feed = ilBlockSetting::_lookup(
231 $this->getBlockType(),
232 "public_feed",
233 0,
234 (int) $this->block_id
235 );
236 if ($public_feed && $enable_internal_rss) {
237 // @todo: rss icon HTML: ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_RSS)
238 $this->addBlockCommand(
239 ILIAS_HTTP_PATH . "/feed.php?client_id=" . rawurlencode(CLIENT_ID) . "&" .
240 "ref_id=" . $this->std_request->getRefId(),
241 $lng->txt("news_feed_url")
242 );
243 }
244
245 // add edit commands
246 if ($this->news_access->canAdd()) {
247 $this->addBlockCommand(
248 $ilCtrl->getLinkTargetByClass(ilNewsItemGUI::class, "editNews"),
249 $lng->txt("edit")
250 );
251
252 $ilCtrl->setParameter($this, "add_mode", "block");
253 $this->addBlockCommand(
254 $ilCtrl->getLinkTargetByClass(ilNewsItemGUI::class, "createNewsItem"),
255 $lng->txt("add")
256 );
257 $ilCtrl->setParameter($this, "add_mode", "");
258 }
259
260 if ($this->getProperty("settings")) {
261 $ref_id = $this->std_request->getRefId();
262 $obj_def = $DIC["objDefinition"];
264 $obj_type = ilObject::_lookupType($ref_id, true);
265 $obj_class = strtolower($obj_def->getClassName($obj_type));
266 $parent_gui = "ilobj" . $obj_class . "gui";
267
268 $ilCtrl->setParameterByClass(ilContainerNewsSettingsGUI::class, "ref_id", $ref_id);
269
270 if (in_array($obj_class, self::OBJECTS_WITH_NEWS_SUBTAB)) {
271 $this->addBlockCommand(
272 $ilCtrl->getLinkTargetByClass([ilRepositoryGUI::class, $parent_gui, ilContainerNewsSettingsGUI::class], "show"),
273 $lng->txt("settings")
274 );
275 } else {
276 // not sure if this code is still used anywhere, see discussion at
277 // https://mantis.ilias.de/view.php?id=31801
278 // If ILIAS 8 beta phase does not throw this exception, we can remove this part.
279 //throw new ilException("News settings are deprecated.");
280 // the info screen will call this
281 $this->addBlockCommand(
282 $ilCtrl->getLinkTarget($this, "editSettings"),
283 $lng->txt("settings")
284 );
285 }
286 }
287
288 // do not display hidden repository news blocks for users
289 // who do not have write permission
290 if (!$this->getEnableEdit() && $this->getRepositoryMode() &&
292 $this->getBlockType(),
293 "hide_news_block",
294 0,
295 (int) $this->block_id
296 )) {
297 return "";
298 }
299
300 // do not display empty news blocks for users
301 // who do not have write permission
302 if (!$this->dynamic && !$this->getEnableEdit() && $this->getRepositoryMode() && count($this->getData()) === 0 &&
303 (
304 !$news_set->get("enable_rss_for_internal") ||
306 $this->getBlockType(),
307 "public_feed",
308 0,
309 (int) $this->block_id
310 )
311 )) {
312 return "";
313 }
314
315 $en = "";
316
317 return parent::getHTML() . $en;
318 }
ilObjectDefinition $obj_def
getProperty(string $a_property)
addBlockCommand(string $a_href, string $a_text, string $a_onclick="", ?RoundTrip $modal=null)
getClassName(string $obj_name)
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
const CLIENT_ID
Definition: constants.php:41
$ref_id
Definition: ltiauth.php:66

References ilBlockGUI\$ctrl, $DIC, ilBlockGUI\$lng, ilBlockGUI\$obj_def, $ref_id, ilBlockGUI\$user, ilBlockSetting\_lookup(), ilObject\_lookupObjectId(), ilObject\_lookupType(), ilBlockGUI\addBlockCommand(), CLIENT_ID, getBlockType(), ilObjectDefinition\getClassName(), ilBlockGUI\getData(), ilBlockGUI\getEnableEdit(), ilBlockGUI\getProperty(), ilBlockGUI\getRepositoryMode(), ilBlockGUI\setTitle(), and ilLanguage\txt().

Referenced by enableJS(), hideNotifications(), and showNotifications().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInfoForData()

ilNewsForContextBlockGUI::getInfoForData ( array  $news)

Definition at line 353 of file class.ilNewsForContextBlockGUI.php.

353 : array
354 {
355 $ilCtrl = $this->ctrl;
358
359 $info = [];
360
361 $info["ref_id"] = $news["ref_id"] ?? 0;
362 $info["creation_date"] =
363 ilDatePresentation::formatDate(new ilDateTime($news["creation_date"], IL_CAL_DATETIME));
364
365 // title image type
366 if (($news["ref_id"] ?? 0) > 0) {
367 if (isset($news["agg_ref_id"]) && $news["agg_ref_id"] > 0) {
368 $obj_id = ilObject::_lookupObjId($news["agg_ref_id"]);
369 $type = ilObject::_lookupType($obj_id);
370 $context_ref = $news["agg_ref_id"];
371 } else {
372 $obj_id = $news["context_obj_id"];
373 $type = $news["context_obj_type"];
374 $context_ref = $news["ref_id"];
375 }
376
377 $lang_type = in_array($type, ["sahs", "lm", "htlm"])
378 ? "lres"
379 : "obj_" . $type;
380
381 $type_txt = ($obj_definition->isPlugin($news["context_obj_type"]))
382 ? ilObjectPlugin::lookupTxtById($news["context_obj_type"], $lang_type)
383 : $lng->txt($lang_type);
384
385
386 $info["type_txt"] = $type_txt;
387 $info["type_icon"] = ilObject::_getIcon($obj_id, "tiny", $type);
388 $info["obj_title"] = ilStr::shortenWords(ilObject::_lookupTitle($obj_id));
389 $info["user_read"] = $news["user_read"];
390
391 $ilCtrl->setParameter($this, "news_context", $context_ref);
392 } else {
393 $ilCtrl->setParameter($this, "news_context", "");
394 }
395
396 // title
397 $info["news_title"] =
400 $news["context_obj_type"] ?? "",
401 $news["title"] ?? "",
402 $news["content_is_lang_var"] ?? false,
403 $news["agg_ref_id"] ?? 0,
404 $news["aggregation"] ?? []
405 )
406 );
407
408
409 $ilCtrl->setParameter($this, "news_id", $news["id"]);
410 $info["url"] =
411 $ilCtrl->getLinkTarget($this, "showNews");
412 $ilCtrl->clearParameters($this);
413
414 return $info;
415 }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static determineNewsTitle(string $a_context_obj_type, string $a_title, bool $a_content_is_lang_var, int $a_agg_ref_id=0, array $a_aggregation=[], ?ilLanguage $lng=null)
Determine title for news item entry.
isPlugin(string $obj_name)
get RBAC status by type returns true if object type is an (activated) plugin type
static lookupTxtById(string $plugin_id, string $lang_var)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static shortenWords(string $a_str, int $a_len=30, bool $a_dots=true)
Ensure that the maximum word lenght within a text is not longer than $a_len.
$info
Definition: entry_point.php:21

References ilBlockGUI\$ctrl, $info, ilBlockGUI\$lng, $obj_definition, ilObject\_getIcon(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilNewsItem\determineNewsTitle(), ilDatePresentation\formatDate(), IL_CAL_DATETIME, ilObjectDefinition\isPlugin(), ilObjectPlugin\lookupTxtById(), ilStr\shortenWords(), and ilLanguage\txt().

Referenced by getListItemForData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getJSEnabler()

ilNewsForContextBlockGUI::getJSEnabler ( )

Definition at line 1221 of file class.ilNewsForContextBlockGUI.php.

1221 : string
1222 {
1223 $ilCtrl = $this->ctrl;
1224
1225 $ilCtrl->setParameterByClass(
1226 ilColumnGUI::class,
1227 "block_id",
1228 "block_" . $this->getBlockType() . "_" . $this->getBlockId()
1229 );
1230 //echo "hh";
1231 $rel_tpl = new ilTemplate("tpl.js_enabler.html", true, true, "components/ILIAS/News");
1232 $rel_tpl->setVariable("BLOCK_ID", "block_" . $this->getBlockType() . "_" . $this->getBlockId());
1233 $rel_tpl->setVariable(
1234 "TARGET",
1235 $ilCtrl->getLinkTarget($this, "enableJS", "", true, false)
1236 );
1237
1238 return $rel_tpl->get();
1239 }
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc

References ilBlockGUI\$ctrl, ilBlockGUI\getBlockId(), getBlockType(), and ilCtrl\setParameterByClass().

Referenced by ilPDNewsBlockGUI\getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getListItemForData()

ilNewsForContextBlockGUI::getListItemForData ( array  $data)
protected

Get list item for data array.

Parameters
array$data
Returns
null|\ILIAS\UI\Component\Item\Item

Reimplemented from ilBlockGUI.

Definition at line 1260 of file class.ilNewsForContextBlockGUI.php.

1261 {
1262 if ((int) ($data["id"] ?? 0) === 0) {
1263 return null;
1264 }
1265 $info = $this->getInfoForData($data);
1266
1267 $props = [
1268 $this->lng->txt("date") => $info["creation_date"] ?? ""
1269 ];
1270
1271 $factory = $this->ui->factory();
1272 $item = $factory->item()->standard($factory->link()->standard($info["news_title"] ?? "", $info["url"] ?? ""))
1273 ->withProperties($props);
1274 if (($info["ref_id"] ?? 0) > 0) {
1275 $item = $item->withDescription($info["type_txt"] . ": " . $info["obj_title"]);
1276 }
1277 return $item;
1278 }
Factory $factory
Common interface to all items.
Definition: Item.php:32

References ilBlockGUI\$data, ilBlockGUI\$factory, $info, getInfoForData(), ILIAS\Repository\lng(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ getMediaPath()

ilNewsForContextBlockGUI::getMediaPath ( int  $mob_id)
protected

Definition at line 790 of file class.ilNewsForContextBlockGUI.php.

790 : string
791 {
792 $media_path = "";
793 if ($mob_id > 0) {
794 $mob = new ilObjMediaObject($mob_id);
795 $media_path = $mob->getStandardSrc();
796 }
797 return $media_path;
798 }

Referenced by showNews().

+ Here is the caller graph for this function:

◆ getNewsData()

ilNewsForContextBlockGUI::getNewsData ( )

Reimplemented in ilPDNewsBlockGUI.

Definition at line 116 of file class.ilNewsForContextBlockGUI.php.

116 : array
117 {
118 $ilCtrl = $this->ctrl;
119 $ilUser = $this->user;
120
121 $this->acache = new ilNewsCache();
122 /* $cres = $this->acache->getEntry($ilUser->getId().":".$_GET["ref_id"]);
123 if ($this->acache->getLastAccessStatus() == "hit" && false)
124 {
125 $news_data = unserialize($cres);
126 }
127 else
128 {*/
129 $news_item = new ilNewsItem();
130 $news_item->setContextObjId($ilCtrl->getContextObjId());
131 $news_item->setContextObjType($ilCtrl->getContextObjType());
132
133 // workaround, better: reduce constructor and introduce
134 //$prevent_aggregation = $this->getProperty("prevent_aggregation");
135 $prevent_aggregation = true;
136 if ($ilCtrl->getContextObjType() !== "frm") {
137 $forum_grouping = true;
138 } else {
139 $forum_grouping = false;
140 }
141
142
143 $news_data = $news_item->getNewsForRefId(
144 $this->std_request->getRefId(),
145 false,
146 false,
147 0,
148 $prevent_aggregation,
149 $forum_grouping
150 );
151
152 $this->acache->storeEntry(
153 $ilUser->getId() . ":" . $this->std_request->getRefId(),
154 serialize($news_data)
155 );
156
157 // }
158 //var_dump($news_data);
159 return $news_data;
160 }

References ilBlockGUI\$ctrl, and ilBlockGUI\$user.

Referenced by __construct(), hideNotifications(), showNews(), and showNotifications().

+ Here is the caller graph for this function:

◆ getNoItemFoundContent()

ilNewsForContextBlockGUI::getNoItemFoundContent ( )

Reimplemented from ilBlockGUI.

Definition at line 1280 of file class.ilNewsForContextBlockGUI.php.

1280 : string
1281 {
1282 return $this->lng->txt("news_no_news_items");
1283 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getOverview()

ilNewsForContextBlockGUI::getOverview ( )

Definition at line 417 of file class.ilNewsForContextBlockGUI.php.

417 : string
418 {
420
421 return '<div class="small">' . (count($this->getData())) . " " . $lng->txt("news_news_items") . "</div>";
422 }

References ilBlockGUI\$lng, ilBlockGUI\getData(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ getScreenMode()

static ilNewsForContextBlockGUI::getScreenMode ( )
static

Reimplemented from ilBlockGUI.

Reimplemented in ilPDNewsBlockGUI.

Definition at line 172 of file class.ilNewsForContextBlockGUI.php.

172 : string
173 {
174 global $DIC;
175
176 $ilCtrl = $DIC->ctrl();
177
178 if (strcasecmp($ilCtrl->getCmdClass(), ilNewsItemGUI::class) === 0) {
179 return IL_SCREEN_FULL;
180 }
181
182 switch ($ilCtrl->getCmd()) {
183 case "showNews":
184 case "showFeedUrl":
185 return IL_SCREEN_CENTER;
186
187 case "editSettings":
188 case "saveSettings":
189 return IL_SCREEN_FULL;
190
191 default:
192 return IL_SCREEN_SIDE;
193 }
194 }
const IL_SCREEN_SIDE
const IL_SCREEN_CENTER
const IL_SCREEN_FULL

References $DIC, IL_SCREEN_CENTER, IL_SCREEN_FULL, and IL_SCREEN_SIDE.

◆ handleView()

ilNewsForContextBlockGUI::handleView ( )

Handles show/hide notification view and removes notifications if hidden.

Definition at line 323 of file class.ilNewsForContextBlockGUI.php.

323 : void
324 {
325 $ilUser = $this->user;
326
327 $this->view = (string) ilBlockSetting::_lookup(
328 $this->getBlockType(),
329 "view",
330 $ilUser->getId(),
331 (int) $this->block_id
332 );
333
334 // check whether notices and messages exist
335 $got_notices = $got_messages = false;
336 foreach ($this->data as $row) {
337 if ((int) ($row["priority"] ?? 0) === 0) {
338 $got_notices = true;
339 }
340 if ((int) ($row["priority"] ?? 0) === 1) {
341 $got_messages = true;
342 }
343 }
344 $this->show_view_selection = false;
345
346 if ($got_notices && $got_messages) {
347 $this->show_view_selection = true;
348 } elseif ($got_notices) {
349 $this->view = "";
350 }
351 }

References ilBlockGUI\$user, ilBlockSetting\_lookup(), getBlockType(), and ILIAS\Repository\int().

Referenced by __construct(), ilPDNewsBlockGUI\__construct(), hideNotifications(), and showNotifications().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hideNotifications()

ilNewsForContextBlockGUI::hideNotifications ( )

Definition at line 836 of file class.ilNewsForContextBlockGUI.php.

836 : void
837 {
838 $ilCtrl = $this->ctrl;
839 $ilUser = $this->user;
840
842 $this->getBlockType(),
843 "view",
844 "hide_notifications",
845 $ilUser->getId(),
846 (int) $this->block_id
847 );
848
849 // reload data
850 $data = $this->getNewsData();
851 $this->setData($data);
852 $this->handleView();
853
854 if ($ilCtrl->isAsynch()) {
855 $this->send($this->getHTML());
856 }
857
858 $ilCtrl->returnToParent($this);
859 }
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.

References ilBlockGUI\$ctrl, ilBlockGUI\$data, ilBlockGUI\$user, ilBlockSetting\_write(), getBlockType(), getHTML(), getNewsData(), handleView(), ilBlockGUI\send(), and ilBlockGUI\setData().

+ Here is the call graph for this function:

◆ initSettingsForm()

ilNewsForContextBlockGUI::initSettingsForm ( )

Init setting form.

Definition at line 873 of file class.ilNewsForContextBlockGUI.php.

873 : void
874 {
876 $ilCtrl = $this->ctrl;
877 $ilTabs = $this->tabs;
878
879 $ilTabs->clearTargets();
880
881 $news_set = new ilSetting("news");
882 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
883
884 $public = ilBlockSetting::_lookup(
885 $this->getBlockType(),
886 "public_notifications",
887 0,
888 (int) $this->block_id
889 );
890 $public_feed = ilBlockSetting::_lookup(
891 $this->getBlockType(),
892 "public_feed",
893 0,
894 (int) $this->block_id
895 );
896 $hide_block = ilBlockSetting::_lookup(
897 $this->getBlockType(),
898 "hide_news_block",
899 0,
900 (int) $this->block_id
901 );
902 $hide_news_per_date = ilBlockSetting::_lookup(
903 $this->getBlockType(),
904 "hide_news_per_date",
905 0,
906 (int) $this->block_id
907 );
908 $hide_news_date = ilBlockSetting::_lookup(
909 $this->getBlockType(),
910 "hide_news_date",
911 0,
912 (int) $this->block_id
913 );
914
915 if (is_string($hide_news_date) && $hide_news_date !== '') {
916 $hide_news_date = explode(" ", $hide_news_date);
917 }
918
919 $this->settings_form = new ilPropertyFormGUI();
920 $this->settings_form->setTitle($lng->txt("news_settings"));
921
922 // hide news block for learners
923 if ($this->getProperty("hide_news_block_option")) {
924 $ch = new ilCheckboxInputGUI(
925 $lng->txt("news_hide_news_block"),
926 "hide_news_block"
927 );
928 $ch->setInfo($lng->txt("news_hide_news_block_info"));
929 $ch->setChecked((bool) $hide_block);
930 $this->settings_form->addItem($ch);
931
932 $hnpd = new ilCheckboxInputGUI(
933 $lng->txt("news_hide_news_per_date"),
934 "hide_news_per_date"
935 );
936 $hnpd->setInfo($lng->txt("news_hide_news_per_date_info"));
937 $hnpd->setChecked((bool) $hide_news_per_date);
938
939 $dt_prop = new ilDateTimeInputGUI(
940 $lng->txt("news_hide_news_date"),
941 "hide_news_date"
942 );
943 $dt_prop->setRequired(true);
944 if (is_array($hide_news_date) && count($hide_news_date) === 2) {
945 $dt_prop->setDate(new ilDateTime($hide_news_date[0] . ' ' . $hide_news_date[1], IL_CAL_DATETIME));
946 }
947 $dt_prop->setShowTime(true);
948 $hnpd->addSubItem($dt_prop);
949
950 $this->settings_form->addItem($hnpd);
951 }
952
953 // default visibility
954 if ($enable_internal_rss && $this->getProperty("default_visibility_option")) {
955 $default_visibility = ilBlockSetting::_lookup(
956 $this->getBlockType(),
957 "default_visibility",
958 0,
959 (int) $this->block_id
960 );
961 if ($default_visibility == "") {
962 $default_visibility =
963 ilNewsItem::_getDefaultVisibilityForRefId($this->std_request->getRefId());
964 }
965
966 // Default Visibility
967 $radio_group = new ilRadioGroupInputGUI($lng->txt("news_default_visibility"), "default_visibility");
968 $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "users");
969 $radio_group->addOption($radio_option);
970 $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "public");
971 $radio_group->addOption($radio_option);
972 $radio_group->setInfo($lng->txt("news_news_item_visibility_info"));
973 $radio_group->setRequired(false);
974 $radio_group->setValue($default_visibility);
975 $this->settings_form->addItem($radio_group);
976 }
977
978 // public notifications
979 if ($enable_internal_rss && $this->getProperty("public_notifications_option")) {
980 $ch = new ilCheckboxInputGUI(
981 $lng->txt("news_notifications_public"),
982 "notifications_public"
983 );
984 $ch->setInfo($lng->txt("news_notifications_public_info"));
985 $ch->setChecked((bool) $public);
986 $this->settings_form->addItem($ch);
987 }
988
989 // extra rss feed
990 if ($enable_internal_rss) {
991 $ch = new ilCheckboxInputGUI(
992 $lng->txt("news_public_feed"),
993 "notifications_public_feed"
994 );
995 $ch->setInfo($lng->txt("news_public_feed_info"));
996 $ch->setChecked((bool) $public_feed);
997 $this->settings_form->addItem($ch);
998 }
999
1000 $this->settings_form->addCommandButton("saveSettings", $lng->txt("save"));
1001 $this->settings_form->addCommandButton("cancelSettings", $lng->txt("cancel"));
1002 $this->settings_form->setFormAction($ilCtrl->getFormAction($this));
1003 }
This class represents a date/time property in a property form.
This class represents a property form user interface.
clearTargets()
clear all targets

References ilBlockGUI\$ctrl, ilBlockGUI\$lng, $tabs, ilNewsItem\_getDefaultVisibilityForRefId(), ilBlockSetting\_lookup(), ilTabsGUI\clearTargets(), getBlockType(), ilBlockGUI\getProperty(), IL_CAL_DATETIME, and ilLanguage\txt().

Referenced by editSettings(), and saveSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRepositoryObject()

ilNewsForContextBlockGUI::isRepositoryObject ( )
protected

Returns whether block has a corresponding repository object.

Reimplemented from ilBlockGUI.

Definition at line 167 of file class.ilNewsForContextBlockGUI.php.

167 : bool
168 {
169 return false;
170 }

◆ makeClickable()

ilNewsForContextBlockGUI::makeClickable ( string  $a_str)

Definition at line 800 of file class.ilNewsForContextBlockGUI.php.

800 : string
801 {
802 // this fixes bug 8744. We assume that strings that contain < and >
803 // already contain html, we do not handle these
804 if (is_int(strpos($a_str, ">")) && is_int(strpos($a_str, "<"))) {
805 return $a_str;
806 }
807
808 return ilUtil::makeClickable($a_str);
809 }
static makeClickable(string $a_text, bool $detectGotoLinks=false, ?string $ilias_http_path=null)

References ilUtil\makeClickable().

+ Here is the call graph for this function:

◆ saveSettings()

ilNewsForContextBlockGUI::saveSettings ( )

Reimplemented in ilPDNewsBlockGUI.

Definition at line 1073 of file class.ilNewsForContextBlockGUI.php.

1073 : string
1074 {
1075 $ilCtrl = $this->ctrl;
1076 $ilUser = $this->user;
1077
1078 $this->initSettingsForm();
1079 $form = $this->settings_form;
1080 if ($form->checkInput()) {
1081 $news_set = new ilSetting("news");
1082 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1083
1084 if ($enable_internal_rss) {
1086 $this->getBlockType(),
1087 "public_notifications",
1088 $form->getInput("notifications_public"),
1089 0,
1090 (int) $this->block_id
1091 );
1093 $this->getBlockType(),
1094 "public_feed",
1095 $form->getInput("notifications_public_feed"),
1096 0,
1097 (int) $this->block_id
1098 );
1100 $this->getBlockType(),
1101 "default_visibility",
1102 $form->getInput("default_visibility"),
1103 0,
1104 (int) $this->block_id
1105 );
1106 }
1107
1108 if ($this->getProperty("hide_news_block_option")) {
1110 $this->getBlockType(),
1111 "hide_news_block",
1112 $form->getInput("hide_news_block"),
1113 0,
1114 (int) $this->block_id
1115 );
1117 $this->getBlockType(),
1118 "hide_news_per_date",
1119 $form->getInput("hide_news_per_date"),
1120 0,
1121 (int) $this->block_id
1122 );
1123
1124 // hide date
1125 $hd = $this->settings_form->getItemByPostVar("hide_news_date");
1126 $hide_date = $hd->getDate();
1127 if ($hide_date instanceof ilDateTime && $form->getInput("hide_news_per_date")) {
1129 $this->getBlockType(),
1130 "hide_news_date",
1131 $hide_date->get(IL_CAL_DATETIME),
1132 0,
1133 (int) $this->block_id
1134 );
1135 } else {
1137 $this->getBlockType(),
1138 "hide_news_date",
1139 "",
1140 0,
1141 (int) $this->block_id
1142 );
1143 }
1144 }
1145
1146 $cache = new ilNewsCache();
1147 $cache->deleteEntry($ilUser->getId() . ":" . $this->std_request->getRefId());
1148
1149 $ilCtrl->returnToParent($this);
1150 } else {
1151 $this->settings_form->setValuesByPost();
1152 return $this->settings_form->getHTML();
1153 }
1154 return "";
1155 }

References ilBlockGUI\$ctrl, $settings_form, ilBlockGUI\$user, ilBlockSetting\_write(), getBlockType(), ilBlockGUI\getProperty(), IL_CAL_DATETIME, and initSettingsForm().

+ Here is the call graph for this function:

◆ showFeedUrl()

ilNewsForContextBlockGUI::showFeedUrl ( )

Reimplemented in ilPDNewsBlockGUI.

Definition at line 1157 of file class.ilNewsForContextBlockGUI.php.

1157 : string
1158 {
1159 $lng = $this->lng;
1160 $ilUser = $this->user;
1161
1162 $title = ilObject::_lookupTitle((int) $this->block_id);
1163
1164 $tpl = new ilTemplate("tpl.show_feed_url.html", true, true, "components/ILIAS/News");
1166 "TXT_TITLE",
1167 sprintf($lng->txt("news_feed_url_for"), $title)
1168 );
1169 $tpl->setVariable("TXT_INFO", $lng->txt("news_get_feed_info"));
1170 $tpl->setVariable("TXT_FEED_URL", $lng->txt("news_feed_url"));
1172 "VAL_FEED_URL",
1173 ILIAS_HTTP_PATH . "/feed.php?client_id=" . rawurlencode(CLIENT_ID) . "&user_id=" . $ilUser->getId() .
1174 "&obj_id=" . $this->block_id .
1175 "&hash=" . ilObjUser::_lookupFeedHash($ilUser->getId(), true)
1176 );
1178 "VAL_FEED_URL_TXT",
1179 ILIAS_HTTP_PATH . "/feed.php?client_id=" . rawurlencode(CLIENT_ID) . "&<br />user_id=" . $ilUser->getId() .
1180 "&obj_id=" . $this->block_id .
1181 "&hash=" . ilObjUser::_lookupFeedHash($ilUser->getId(), true)
1182 );
1183
1184 $panel = $this->ui->factory()->panel()->standard(
1185 $lng->txt("news_internal_news"),
1186 $this->ui->factory()->legacy()->content($tpl->get())
1187 );
1188
1189 return $this->ui->renderer()->render($panel);
1190 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
ilTemplate $tpl
static _lookupFeedHash(int $a_user_id, bool $a_create=false)
get(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Returns a block with all replacements done.

References ilBlockGUI\$lng, ilBlockGUI\$title, ilBlockGUI\$tpl, ilBlockGUI\$user, ilObjUser\_lookupFeedHash(), ilObject\_lookupTitle(), CLIENT_ID, ilTemplate\get(), HTML_Template_IT\setVariable(), ilLanguage\txt(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ showNews()

ilNewsForContextBlockGUI::showNews ( )

Definition at line 424 of file class.ilNewsForContextBlockGUI.php.

424 : string
425 {
427 $ilCtrl = $this->ctrl;
428 $ilUser = $this->user;
429 $ilAccess = $this->access;
430
431 // workaround for dynamic mode (if cache is disabled, showNews has no data)
432 if (empty(self::$st_data)) {
433 $this->setData($this->getNewsData());
434 }
435
436 $news_set = new ilSetting("news");
437 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
438
439
440 $tpl = new ilTemplate("tpl.show_news.html", true, true, "components/ILIAS/News");
441
442 // get current item in data set
443 $previous = "";
444 reset($this->data);
445 $c = current($this->data);
446 $curr_cnt = 1;
447
448 if ($this->std_request->getNewsId() > 0) {
449 $news = new ilNewsItem($this->std_request->getNewsId());
450 $news_context = $this->std_request->getNewsContext();
451 while ($c["id"] > 0 && (int) $c["id"] !== $this->std_request->getNewsId()) {
452 $previous = $c;
453 $c = next($this->data);
454 $curr_cnt++;
455 }
456 } else {
457 $news_page = $this->std_request->getNewsPage();
458 $news_context = 0;
459 while ($curr_cnt - 1 < $news_page) {
460 $previous = $c;
461 $c = next($this->data);
462 if ($curr_cnt - 1 === $news_page) {
463 }
464 $curr_cnt++;
465 }
466 $news = new ilNewsItem($c["id"] ?? 0);
467 if (($c["ref_id"] ?? 0) > 0) {
468 $news_context = (int) $c["ref_id"];
469 }
470 }
471
472
473 if (!is_array($c) && is_object($news) && $news->getId() > 0
474 && ilNewsItem::_lookupContextObjId($news->getId()) !== $ilCtrl->getContextObjId()) {
475 throw new ilException("News ID does not match object context.");
476 }
477
478
479 // collect news items to show
480 $news_list = [];
481 if (isset($c["aggregation"]) && is_array($c["aggregation"])) { // we have an aggregation
482 $news_list[] = [
483 "ref_id" => $c["agg_ref_id"],
484 "agg_ref_id" => $c["agg_ref_id"],
485 "aggregation" => $c["aggregation"],
486 "user_id" => "",
487 "content_type" => "text",
488 "mob_id" => 0,
489 "visibility" => "",
490 "content" => "",
491 "content_long" => "",
492 "update_date" => $news->getUpdateDate(),
493 "creation_date" => "",
494 "content_is_lang_var" => false,
495 "loc_context" => $news_context,
496 "context_obj_type" => $news->getContextObjType(),
497 "title" => ""
498 ];
499
500 foreach ($c["aggregation"] as $c_item) {
501 ilNewsItem::_setRead($ilUser->getId(), $c_item["id"]);
502 $c_item["loc_context"] = $c_item["ref_id"];
503 $c_item["loc_stop"] = $news_context;
504 $news_list[] = $c_item;
505 }
506 } else { // no aggregation, simple news item
507 $news_list[] = [
508 "id" => $news->getId(),
509 "ref_id" => $news_context,
510 "user_id" => $news->getUserId(),
511 "content_type" => $news->getContentType(),
512 "mob_id" => $news->getMobId(),
513 "visibility" => $news->getVisibility(),
514 "priority" => $news->getPriority(),
515 "content" => $news->getContent(),
516 "content_long" => $news->getContentLong(),
517 "update_date" => $news->getUpdateDate(),
518 "creation_date" => $news->getCreationDate(),
519 "context_sub_obj_type" => $news->getContextSubObjType(),
520 "context_obj_type" => $news->getContextObjType(),
521 "context_sub_obj_id" => $news->getContextSubObjId(),
522 "content_is_lang_var" => $news->getContentIsLangVar(),
523 "content_text_is_lang_var" => $news->getContentTextIsLangVar(),
524 "loc_context" => $news_context,
525 "title" => $news->getTitle()
526 ];
527 ilNewsItem::_setRead($ilUser->getId(), $this->std_request->getNewsId());
528 }
529
530 $row_css = "";
531 $cache_deleted = false;
532 foreach ($news_list as $item) {
533 $row_css = ($row_css !== "tblrow1")
534 ? "tblrow1"
535 : "tblrow2";
536
537 if ($item["ref_id"] > 0 && !$ilAccess->checkAccess("read", "", $item["ref_id"])) {
538 $tpl->setCurrentBlock("content");
539 $tpl->setVariable("VAL_CONTENT", $lng->txt("news_sorry_not_accessible_anymore"));
541 $tpl->setCurrentBlock("item");
542 $tpl->setVariable("ITEM_ROW_CSS", $row_css);
544 if (!$cache_deleted) {
545 $this->acache->deleteEntry($ilUser->getId() . ":" . $this->std_request->getRefId());
546 $cache_deleted = true;
547 }
548 continue;
549 }
550
551 // user
552 if ($item["user_id"] > 0 &&
553 \ilObjUser::userExists([$item["user_id"]])
554 ) {
555 // get login
556 if (ilObjUser::_exists($item["user_id"])) {
557 $user = new ilObjUser($item["user_id"]);
558 $displayname = $user->getLogin();
559 } else {
560 // this should actually not happen, since news entries
561 // should be deleted when the user is going to be removed
562 $displayname = "&lt;" . strtolower($lng->txt("deleted")) . "&gt;";
563 }
564
565 $tpl->setCurrentBlock("user_info");
566 $tpl->setVariable("VAL_AUTHOR", $displayname);
567 $tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
569 }
570
571 // media player
572 $ui_renderer = $this->ui->renderer();
573 $ui_factory = $this->ui->factory();
574
575 if ($item["mob_id"] > 0 && ilObject::_exists((int) $item["mob_id"])) {
576 $media_path = $this->getMediaPath((int) $item["mob_id"]);
577 $mime = ilObjMediaObject::getMimeType($media_path);
578 if (in_array($mime, ["image/jpeg", "image/svg+xml", "image/gif", "image/png"])) {
579 $title = basename($media_path);
580 $html = $ui_renderer->render($ui_factory->image()->responsive($media_path, $title));
581 } elseif (in_array($mime, ["video/mp4", "video/youtube", "video/vimeo"])) {
582 $video = $ui_factory->player()->video($media_path);
583 $html = $ui_renderer->render($video);
584 } elseif (in_array($mime, ["audio/mpeg"])) {
585 $audio = $ui_factory->player()->audio($media_path);
586 $html = $ui_renderer->render($audio);
587 } elseif (in_array($mime, ["application/pdf"])) {
588 $this->ctrl->setParameter($this, "news_id", $item["id"]);
589 $link = $ui_factory->link()->standard(
590 basename($media_path),
591 $this->ctrl->getLinkTarget($this, "downloadMob")
592 );
593 $html = $ui_renderer->render($link);
594 $this->ctrl->setParameter($this, "news_id", null);
595 } else {
596 // download?
597 $html = $mime;
598 }
599
600
601 $tpl->setCurrentBlock("player");
603 "PLAYER",
604 $html
605 );
607 }
608
609 // access
610 if ($enable_internal_rss && $item["visibility"] != "") {
611 $obj_id = ilObject::_lookupObjId($item["ref_id"]);
612 $tpl->setCurrentBlock("access");
613 $tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
614 if ($item["visibility"] === NEWS_PUBLIC ||
615 ((int) $item["priority"] === 0 &&
617 "news",
618 "public_notifications",
619 0,
620 $obj_id
621 ))) {
622 $tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
623 } else {
624 $tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
625 }
627 }
628
629 // content
630 $renderer = ilNewsRendererFactory::getRenderer($item["context_obj_type"]);
631 if (trim($item["content"]) != "") { // content
632 $it = new ilNewsItem($item["id"]);
633 $renderer->setNewsItem($it, $item["ref_id"]);
634 $tpl->setCurrentBlock("content");
635 $tpl->setVariable("VAL_CONTENT", $renderer->getDetailContent());
637 }
638 if ($item["update_date"] != $item["creation_date"]) { // update date
639 $tpl->setCurrentBlock("ni_update");
640 $tpl->setVariable("TXT_LAST_UPDATE", $lng->txt("last_update"));
642 "VAL_LAST_UPDATE",
644 );
646 }
647
648 // creation date
649 if ($item["creation_date"] != "") {
650 $tpl->setCurrentBlock("ni_update");
652 "VAL_CREATION_DATE",
653 ilDatePresentation::formatDate(new ilDateTime($item["creation_date"], IL_CAL_DATETIME))
654 );
655 $tpl->setVariable("TXT_CREATED", $lng->txt("created"));
657 }
658
659
660 // context / title
661 if ($news_context > 0) {
662 //$obj_id = ilObject::_lookupObjId($_GET["news_context"]);
663 $obj_id = ilObject::_lookupObjId($item["ref_id"]);
664 $obj_type = ilObject::_lookupType($obj_id);
665 $obj_title = ilObject::_lookupTitle($obj_id);
666
667 // file hack, not nice
668 if ($obj_type === "file") {
669 $ilCtrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $item["ref_id"]);
670 $url = $ilCtrl->getLinkTargetByClass(ilRepositoryGUI::class, "sendfile");
671 $ilCtrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $this->std_request->getRefId());
672
673 $button = $this->gui->button(
674 $this->lng->txt("download"),
675 $url
676 );
677
678 $tpl->setCurrentBlock("download");
679 $tpl->setVariable("BUTTON_DOWNLOAD", $button->render());
681 }
682
683 // forum hack, not nice
684 $add = "";
685 if ($obj_type === "frm" && ($item["context_sub_obj_type"] ?? "") === "pos"
686 && $item["context_sub_obj_id"] > 0) {
687 $pos = $item["context_sub_obj_id"];
689 if ($thread > 0) {
690 $add = "_" . $thread . "_" . $pos;
691 }
692 }
693
694 // wiki hack, not nice
695 if ($obj_type === "wiki" && $item["context_sub_obj_type"] === "wpg"
696 && $item["context_sub_obj_id"] > 0) {
697 $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
698 if ($wptitle != "") {
699 $add = "_" . ilWikiUtil::makeUrlTitle($wptitle);
700 }
701 }
702
703 $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" .
704 $obj_type . "_" . $item["ref_id"] . $add;
705
706 // lm page hack, not nice
707 if (
708 ($item["context_sub_obj_type"] ?? "") === "pg" &&
709 $item["context_sub_obj_id"] > 0 &&
710 in_array($obj_type, ["lm"], true)) {
711 $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" .
712 "pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"];
713 }
714
715 // blog posting hack, not nice
716 if ($obj_type === "blog" && ($item["context_sub_obj_type"] ?? "") === "blp"
717 && $item["context_sub_obj_id"] > 0) {
718 $url_target = "./goto.php?client_id=" . rawurlencode(CLIENT_ID) . "&target=" .
719 "blog_" . $item["ref_id"] . "_" . $item["context_sub_obj_id"];
720 }
721
722 $context_opened = false;
723 $loc_stop = $item["loc_stop"] ?? "";
724 if ($item["loc_context"] != null &&
725 $item["loc_context"] != $loc_stop
726 ) {
727 $tpl->setCurrentBlock("context");
728 $context_opened = true;
729 $cont_loc = new ilLocatorGUI();
730 $cont_loc->addContextItems($item["loc_context"], true, (int) $loc_stop);
731 $tpl->setVariable("CONTEXT_LOCATOR", $cont_loc->getHTML());
732 }
733
734 //var_dump($item);
735 $no_context_title = $item["no_context_title"] ?? false;
736 if ($no_context_title !== true) {
737 if (!$context_opened) {
738 $tpl->setCurrentBlock("context");
739 }
740 $tpl->setVariable("HREF_CONTEXT_TITLE", $url_target);
741 $tpl->setVariable("CONTEXT_TITLE", $obj_title);
742 $tpl->setVariable("IMG_CONTEXT_TITLE", ilObject::_getIcon($obj_id, "big", $obj_type));
743 }
744 if ($context_opened) {
746 }
747
748 $tpl->setVariable("HREF_TITLE", $url_target);
749 }
750
751 // title
753 "VAL_TITLE",
755 $item["context_obj_type"] ?? "",
756 $item["title"] ?? "",
757 $item["content_is_lang_var"] ?? false,
758 $item["agg_ref_id"] ?? 0,
759 $item["aggregation"] ?? []
760 )
761 );
762
763
764 $tpl->setCurrentBlock("item");
765 $tpl->setVariable("ITEM_ROW_CSS", $row_css);
767 }
768
769 $content = $tpl->get();
770 if ($this->getProperty("title") != "") {
771 $title = $this->getProperty("title");
772 } else {
773 $title = $lng->txt("news_internal_news");
774 }
775 $panel = $this->ui->factory()->panel()->standard($title, $this->ui->factory()->legacy()->content($content));
776
777 $parameter_name = 'news_page';
778
779 $pagination = $this->ui->factory()->viewControl()->pagination()
780 ->withTargetURL($ilCtrl->getLinkTarget($this, "showNews"), "news_page")
781 ->withTotalEntries(count($this->getData()))
782 ->withPageSize(1)
783 ->withMaxPaginationButtons(10)
784 ->withCurrentPage($curr_cnt - 1);
785 $panel = $panel->withViewControls([$pagination]);
786
787 return $this->ui->renderer()->render($panel);
788 }
const NEWS_PUBLIC
ilAccessHandler $access
ILIAS UI Renderer $renderer
Base class for ILIAS Exception handling.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _setRead(int $a_user_id, int $a_news_id)
Set item read.
static _lookupContextObjId(int $a_news_id)
Context Object ID.
static getRenderer(string $a_context_obj_type)
static _getThreadForPosting(int $a_pos_id)
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
User class.
static userExists(array $a_usr_ids=[])
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static lookupTitle(int $a_page_id, string $lang="-")
static makeUrlTitle(string $a_par)
$c
Definition: deliver.php:25
$url
Definition: shib_logout.php:68

References ilBlockGUI\$access, $c, ilBlockGUI\$ctrl, ilBlockGUI\$lng, ilBlockGUI\$renderer, ilBlockGUI\$title, ilBlockGUI\$tpl, $url, ilBlockGUI\$user, ilObject\_exists(), ilObject\_getIcon(), ilObjForumAccess\_getThreadForPosting(), ilBlockSetting\_lookup(), ilNewsItem\_lookupContextObjId(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilNewsItem\_setRead(), CLIENT_ID, ILIAS\Repository\ctrl(), ilNewsItem\determineNewsTitle(), ilDatePresentation\formatDate(), ilTemplate\get(), ilBlockGUI\getData(), ilObjUser\getLogin(), getMediaPath(), ilObjMediaObject\getMimeType(), getNewsData(), ilBlockGUI\getProperty(), ilNewsRendererFactory\getRenderer(), IL_CAL_DATETIME, ILIAS\Repository\int(), ILIAS\Repository\lng(), ilWikiPage\lookupTitle(), ilWikiUtil\makeUrlTitle(), NEWS_PUBLIC, ILIAS\User\Profile\ChangeMail\next, ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), ilBlockGUI\setData(), HTML_Template_IT\setVariable(), ilLanguage\txt(), ILIAS\Repository\ui(), and ilObjUser\userExists().

+ Here is the call graph for this function:

◆ showNotifications()

ilNewsForContextBlockGUI::showNotifications ( )

Definition at line 811 of file class.ilNewsForContextBlockGUI.php.

811 : void
812 {
813 $ilCtrl = $this->ctrl;
814 $ilUser = $this->user;
815
817 $this->getBlockType(),
818 "view",
819 "",
820 $ilUser->getId(),
821 (int) $this->block_id
822 );
823
824 // reload data
825 $data = $this->getNewsData();
826 $this->setData($data);
827 $this->handleView();
828
829 if ($ilCtrl->isAsynch()) {
830 $this->send($this->getHTML());
831 }
832
833 $ilCtrl->returnToParent($this);
834 }

References ilBlockGUI\$ctrl, ilBlockGUI\$data, ilBlockGUI\$user, ilBlockSetting\_write(), getBlockType(), getHTML(), getNewsData(), handleView(), ilBlockGUI\send(), and ilBlockGUI\setData().

+ Here is the call graph for this function:

◆ writeSettings()

static ilNewsForContextBlockGUI::writeSettings ( array  $a_values)
static

Definition at line 1056 of file class.ilNewsForContextBlockGUI.php.

1056 : void
1057 {
1058 global $DIC;
1059
1060 $block_id = $DIC->ctrl()->getContextObjId();
1061 foreach ($a_values as $key => $value) {
1062 ilBlockSetting::_write(self::$block_type, (string) $key, (string) $value, 0, $block_id);
1063 }
1064 }

References ilBlockGUI\$block_id, $DIC, and ilBlockSetting\_write().

Referenced by ilContainerNewsSettingsGUI\save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $acache

ilNewsCache ilNewsForContextBlockGUI::$acache
protected

Definition at line 39 of file class.ilNewsForContextBlockGUI.php.

◆ $block_type

string ilNewsForContextBlockGUI::$block_type = "news"
static

◆ $cache_hit

bool ilNewsForContextBlockGUI::$cache_hit = false
protected

Definition at line 37 of file class.ilNewsForContextBlockGUI.php.

◆ $dynamic

bool ilNewsForContextBlockGUI::$dynamic = false
protected

Definition at line 38 of file class.ilNewsForContextBlockGUI.php.

◆ $gui

ILIAS News InternalGUIService ilNewsForContextBlockGUI::$gui
protected

Definition at line 35 of file class.ilNewsForContextBlockGUI.php.

◆ $help

ilHelpGUI ilNewsForContextBlockGUI::$help
protected

Definition at line 47 of file class.ilNewsForContextBlockGUI.php.

◆ $news_access

NewsAccess ilNewsForContextBlockGUI::$news_access
protected

Definition at line 36 of file class.ilNewsForContextBlockGUI.php.

◆ $obj_definition

ilObjectDefinition ilNewsForContextBlockGUI::$obj_definition
protected

Definition at line 52 of file class.ilNewsForContextBlockGUI.php.

Referenced by getInfoForData().

◆ $settings

ilSetting ilNewsForContextBlockGUI::$settings
protected

Definition at line 48 of file class.ilNewsForContextBlockGUI.php.

◆ $settings_form

ilPropertyFormGUI ilNewsForContextBlockGUI::$settings_form
protected

Definition at line 46 of file class.ilNewsForContextBlockGUI.php.

Referenced by saveSettings().

◆ $show_view_selection

bool ilNewsForContextBlockGUI::$show_view_selection
protected

Definition at line 40 of file class.ilNewsForContextBlockGUI.php.

◆ $st_data

array ilNewsForContextBlockGUI::$st_data
static

Definition at line 51 of file class.ilNewsForContextBlockGUI.php.

Referenced by __construct(), and ilPDNewsBlockGUI\__construct().

◆ $std_request

StandardGUIRequest ilNewsForContextBlockGUI::$std_request
protected

Definition at line 53 of file class.ilNewsForContextBlockGUI.php.

Referenced by addToSettingsForm().

◆ $tabs

ilTabsGUI ilNewsForContextBlockGUI::$tabs
protected

Definition at line 49 of file class.ilNewsForContextBlockGUI.php.

Referenced by initSettingsForm().

◆ $view

string ilNewsForContextBlockGUI::$view
protected

Definition at line 45 of file class.ilNewsForContextBlockGUI.php.

◆ OBJECTS_WITH_NEWS_SUBTAB

const ilNewsForContextBlockGUI::OBJECTS_WITH_NEWS_SUBTAB = ["category", "course", "group", "forum"]

object type names with settings->news settings subtab

Definition at line 34 of file class.ilNewsForContextBlockGUI.php.


The documentation for this class was generated from the following file: