ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilNewsForContextBlockGUI Class Reference

BlockGUI class for block NewsForContext. More...

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

Public Member Functions

 __construct ()
 
 getBlockType ()
 
 executeCommand ()
 
 getHTML ()
 
 handleView ()
 Handles show/hide notification view and removes notifications if hidden. More...
 
 getOverview ()
 
 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, string $public_feed_info)
 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"
 

Protected Member Functions

 initData (NewsCollection $collection)
 
 preloadData (array $data)
 Method will be called before rendering the block. More...
 
 getListItemForData (array $data)
 Get list item for data array. More...
 
 isRepositoryObject ()
 Returns whether block has a corresponding repository object. More...
 
 getMediaPath (int $mob_id)
 
 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

NewsAccess $news_access
 
bool $dynamic = false
 
bool $show_view_selection
 
string $view
 
ilPropertyFormGUI $settings_form
 
ilHelpGUI $help
 
ilSetting $settings
 
ilTabsGUI $tabs
 
StandardGUIRequest $std_request
 
InternalDomainService $domain
 
InternalGUIService $gui
 
bool $prevent_initial_loading = false
 
NewsCollection $collection
 
ilLogger $logger
 
ILIAS Refinery Factory $refinery
 
- 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
 

Private Member Functions

 loadNewsData ()
 
 getNewsForId (int $news_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 35 of file class.ilNewsForContextBlockGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilNewsForContextBlockGUI::__construct ( )

Reimplemented from ilBlockGUI.

Reimplemented in ilPDNewsBlockGUI.

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

65 {
66 global $DIC;
67
69
70 $this->logger = $DIC->logger()->news();
71 $this->help = $DIC["ilHelp"];
72 $this->settings = $DIC->settings();
73 $this->tabs = $DIC->tabs();
74 $this->logger = $DIC->logger()->news();
75 $this->refinery = $DIC->refinery();
76
77 $locator = $DIC->news()->internal();
78 $this->std_request = $locator->gui()->standardRequest();
79 $this->domain = $locator->domain();
80 $this->gui = $locator->gui();
81 $this->news_access = new NewsAccess($this->std_request->getRefId());
82
83 $this->lng->loadLanguageModule("news");
84 $DIC->help()->addHelpSection("news_block");
85
86 $this->setBlockId((string) $this->ctrl->getContextObjId());
87 $this->setLimit(5);
88 $this->setEnableNumInfo(true);
89
90 if (!$this->prevent_initial_loading) {
91 $this->loadNewsData();
92 }
93
94 $this->setTitle($this->lng->txt("news_internal_news"));
95 $this->setRowTemplate("tpl.block_row_news_for_context.html", "components/ILIAS/News");
96 $this->allow_moving = false;
97 $this->handleView();
98
99 $this->setPresentation(self::PRES_SEC_LIST);
100 }
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.
handleView()
Handles show/hide notification view and removes notifications if hidden.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), handleView(), ILIAS\Repository\help(), ILIAS\Repository\lng(), loadNewsData(), ILIAS\Repository\logger(), ILIAS\Repository\refinery(), ilBlockGUI\setBlockId(), ilBlockGUI\setEnableNumInfo(), ilBlockGUI\setLimit(), ilBlockGUI\setPresentation(), ilBlockGUI\setRowTemplate(), ILIAS\Repository\settings(), ilBlockGUI\setTitle(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

Member Function Documentation

◆ addToSettingsForm()

static ilNewsForContextBlockGUI::addToSettingsForm ( ilFormPropertyGUI  $a_input,
string  $public_feed_info 
)
static

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

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

870 : void {
871 global $DIC;
872
873 $lng = $DIC->language();
874 $block_id = $DIC->ctrl()->getContextObjId();
875
876 $news_set = new ilSetting("news");
877 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
878
879 $public_feed = ilBlockSetting::_lookup(
880 self::$block_type,
881 "public_feed",
882 0,
884 );
885
886 // extra rss feed
887 if ($enable_internal_rss) {
888 $radio_rss = new ilCheckboxInputGUI(
889 $lng->txt("news_public_feed"),
890 "notifications_public_feed"
891 );
892 $radio_rss->setInfo($lng->txt($public_feed_info));
893 $radio_rss->setChecked((bool) $public_feed);
894 $a_input->addSubItem($radio_rss);
895 }
896 }
ilLanguage $lng
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.
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ILIAS Setting Class.

Referenced by ilContainerNewsSettingsGUI\initForm().

+ Here is the caller graph for this function:

◆ cancelSettings()

ilNewsForContextBlockGUI::cancelSettings ( )

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

908 : void
909 {
910 $ilCtrl = $this->ctrl;
911
912 $ilCtrl->returnToParent($this);
913 }
returnToParent(object $a_gui_obj, ?string $a_anchor=null)
@inheritDoc

◆ disableJS()

ilNewsForContextBlockGUI::disableJS ( )

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

1075 : void
1076 {
1077 $ilCtrl = $this->ctrl;
1078 $ilUser = $this->user;
1079
1080 ilSession::set("il_feed_js", "n");
1081 $ilUser->writePref("il_feed_js", "n");
1082 $ilCtrl->returnToParent($this);
1083 }
ilObjUser $user
static set(string $a_var, $a_val)
Set a value.

References ilSession\set().

+ Here is the call graph for this function:

◆ downloadMob()

ilNewsForContextBlockGUI::downloadMob ( )
protected

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

1098 : void
1099 {
1100 $news_id = $this->std_request->getNewsId();
1101 $news = new ilNewsItem($news_id);
1102 $news->deliverMobFile("Standard", true);
1103 }
A news item can be created by different sources.

◆ editSettings()

ilNewsForContextBlockGUI::editSettings ( )

Show settings screen.

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

750 : string
751 {
752 $this->initSettingsForm();
753 return $this->settings_form->getHTML();
754 }

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 1085 of file class.ilNewsForContextBlockGUI.php.

1085 : void
1086 {
1087 $ilUser = $this->user;
1088 ilSession::set("il_feed_js", "y");
1089 $ilUser->writePref("il_feed_js", "y");
1090 $this->send($this->getHTML());
1091 }
send(string $output)
Send.

References send(), and ilSession\set().

+ Here is the call graph for this function:

◆ executeCommand()

ilNewsForContextBlockGUI::executeCommand ( )

Reimplemented in ilPDNewsBlockGUI.

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

252 {
253 if (strcasecmp($this->ctrl->getNextClass(), ilNewsItemGUI::class) === 0) {
254 $news_item_gui = new ilNewsItemGUI();
255 $news_item_gui->setEnableEdit($this->getEnableEdit());
256 return $this->ctrl->forwardCommand($news_item_gui);
257 }
258
259 $cmd = $this->ctrl->getCmd("getHTML");
260 return $this->$cmd();
261 }
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 217 of file class.ilNewsForContextBlockGUI.php.

217 : string
218 {
219 return self::$block_type;
220 }

References $block_type.

Referenced by getHTML(), hideNotifications(), initSettingsForm(), and showNotifications().

+ Here is the caller graph for this function:

◆ getDynamicReload()

ilNewsForContextBlockGUI::getDynamicReload ( )

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

1025 : string
1026 {
1027 $ilCtrl = $this->ctrl;
1028 $lng = $this->lng;
1029
1030 $ilCtrl->setParameterByClass(
1031 ilColumnGUI::class,
1032 "block_id",
1033 "block_" . $this->getBlockType() . "_" . $this->getBlockId()
1034 );
1035
1036 $rel_tpl = new ilTemplate("tpl.dynamic_reload.html", true, true, "components/ILIAS/News");
1037 $rel_tpl->setVariable("TXT_LOADING", $lng->txt("news_loading_news"));
1038 $rel_tpl->setVariable("BLOCK_ID", "block_" . $this->getBlockType() . "_" . $this->getBlockId());
1039 $rel_tpl->setVariable(
1040 "TARGET",
1041 $ilCtrl->getLinkTargetByClass(ilColumnGUI::class, "updateBlock", "", true)
1042 );
1043
1044 // no JS
1045 $rel_tpl->setVariable("TXT_NEWS_CLICK_HERE", $lng->txt("news_no_js_click_here"));
1046 $rel_tpl->setVariable(
1047 "TARGET_NO_JS",
1048 $ilCtrl->getLinkTarget($this, "disableJS")
1049 );
1050
1051 return $rel_tpl->get();
1052 }
special template class to simplify handling of ITX/PEAR

References $lng.

◆ getHTML()

ilNewsForContextBlockGUI::getHTML ( )

Reimplemented from ilBlockGUI.

Reimplemented in ilPDNewsBlockGUI.

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

263 : string
264 {
265 global $DIC;
266
267 $ilCtrl = $this->ctrl;
269 $ilUser = $this->user;
270
271 $news_set = new ilSetting("news");
272 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
273
274 $hide_block = ilBlockSetting::_lookup(
275 $this->getBlockType(),
276 "hide_news_block",
277 0,
278 (int) $this->block_id
279 );
280
281 if ($this->getProperty("title") != "") {
282 $this->setTitle($this->getProperty("title"));
283 }
284
285 $public_feed = ilBlockSetting::_lookup(
286 $this->getBlockType(),
287 "public_feed",
288 0,
289 (int) $this->block_id
290 );
291 if ($public_feed && $enable_internal_rss) {
292 // @todo: rss icon HTML: ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_RSS)
293 $this->addBlockCommand(
294 ILIAS_HTTP_PATH . "/feed.php?client_id=" . rawurlencode(CLIENT_ID) . "&" .
295 "ref_id=" . $this->std_request->getRefId(),
296 $lng->txt("news_feed_url")
297 );
298 }
299
300 // add edit commands
301 if ($this->news_access->canAdd()) {
302 $this->addBlockCommand(
303 $ilCtrl->getLinkTargetByClass(ilNewsItemGUI::class, "editNews"),
304 $lng->txt("edit")
305 );
306
307 $ilCtrl->setParameter($this, "add_mode", "block");
308 $this->addBlockCommand(
309 $ilCtrl->getLinkTargetByClass(ilNewsItemGUI::class, "createNewsItem"),
310 $lng->txt("add")
311 );
312 $ilCtrl->setParameter($this, "add_mode", "");
313 }
314
315 if ($this->getProperty("settings")) {
316 $ref_id = $this->std_request->getRefId();
317 $obj_def = $DIC["objDefinition"];
318 $obj_id = ilObject::_lookupObjectId($ref_id);
319 $obj_type = ilObject::_lookupType($ref_id, true);
320 $obj_class = strtolower($obj_def->getClassName($obj_type));
321 $parent_gui = "ilobj" . $obj_class . "gui";
322
323 $ilCtrl->setParameterByClass(ilContainerNewsSettingsGUI::class, "ref_id", $ref_id);
324
325 if (in_array($obj_class, self::OBJECTS_WITH_NEWS_SUBTAB)) {
326 $this->addBlockCommand(
327 $ilCtrl->getLinkTargetByClass([ilRepositoryGUI::class, $parent_gui, ilContainerNewsSettingsGUI::class], "show"),
328 $lng->txt("settings")
329 );
330 } else {
331 // not sure if this code is still used anywhere, see discussion at
332 // https://mantis.ilias.de/view.php?id=31801
333 // If ILIAS 8 beta phase does not throw this exception, we can remove this part.
334 //throw new ilException("News settings are deprecated.");
335 // the info screen will call this
336 $this->addBlockCommand(
337 $ilCtrl->getLinkTarget($this, "editSettings"),
338 $lng->txt("settings")
339 );
340 }
341 }
342
343 // do not display hidden repository news blocks for users
344 // who do not have write permission
345 if (!$this->getEnableEdit() && $this->getRepositoryMode() &&
347 $this->getBlockType(),
348 "hide_news_block",
349 0,
350 (int) $this->block_id
351 )) {
352 return "";
353 }
354
355 // do not display empty news blocks for users
356 // who do not have write permission
357 if (!$this->dynamic && !$this->getEnableEdit() && $this->getRepositoryMode() && count($this->getData()) === 0 &&
358 (
359 !$news_set->get("enable_rss_for_internal") ||
361 $this->getBlockType(),
362 "public_feed",
363 0,
364 (int) $this->block_id
365 )
366 )) {
367 return "";
368 }
369
370 $en = "";
371
372 return parent::getHTML() . $en;
373 }
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

References ilBlockGUI\$ctrl, $DIC, ilBlockGUI\$lng, ilBlockGUI\$obj_def, 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 hideNotifications(), and showNotifications().

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

◆ getJSEnabler()

ilNewsForContextBlockGUI::getJSEnabler ( )

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

1054 : string
1055 {
1056 $ilCtrl = $this->ctrl;
1057
1058 $ilCtrl->setParameterByClass(
1059 ilColumnGUI::class,
1060 "block_id",
1061 "block_" . $this->getBlockType() . "_" . $this->getBlockId()
1062 );
1063 //echo "hh";
1064 $rel_tpl = new ilTemplate("tpl.js_enabler.html", true, true, "components/ILIAS/News");
1065 $rel_tpl->setVariable("BLOCK_ID", "block_" . $this->getBlockType() . "_" . $this->getBlockId());
1066 $rel_tpl->setVariable(
1067 "TARGET",
1068 $ilCtrl->getLinkTarget($this, "enableJS", "", true, false)
1069 );
1070
1071 return $rel_tpl->get();
1072 }
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc

Referenced by ilPDNewsBlockGUI\getHTML().

+ 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 137 of file class.ilNewsForContextBlockGUI.php.

138 {
139 try {
140 $info = $this->getNewsForId($data[0]);
141 } catch (\Exception $e) {
142 $this->logger->error($e->getMessage());
143 return $this->ui->factory()->item()->standard($this->lng->txt('news_not_available'))
144 ->withDescription($this->lng->txt('news_sorry_not_accessible_anymore'));
145 }
146
147 $item = $this->ui->factory()->item()->standard(
148 $this->ui->factory()->link()->standard($info['news_title'] ?? '', $info['url'] ?? '')
149 );
150
151 $properties = [];
152
153 if ($info['ref_id'] > 0) {
154 $properties[$info['type_txt']] = $info['obj_title'];
155 }
156
157 $properties[$this->lng->txt('date')] = $info['creation_date'] ?? '';
158
159 return $item->withProperties($properties);
160 }
$info
Definition: entry_point.php:21
Common interface to all items.
Definition: Item.php:32

References Vendor\Package\$e, $info, getNewsForId(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ getMediaPath()

ilNewsForContextBlockGUI::getMediaPath ( int  $mob_id)
protected

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

678 : string
679 {
680 $media_path = "";
681 if ($mob_id > 0) {
682 $mob = new ilObjMediaObject($mob_id);
683 $media_path = $mob->getStandardSrc();
684 }
685 return $media_path;
686 }

◆ getNewsForId()

ilNewsForContextBlockGUI::getNewsForId ( int  $news_id)
private

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

162 : array
163 {
164 $item = $this->collection->getById($news_id);
165 if ($item === null) {
166 throw new \InvalidArgumentException("News item with id {$news_id} not found.");
167 }
168
169 $grouping = $this->collection->getGroupingFor($item);
170
171 $creation_date = new ilDateTime($item->getCreationDate()->format('c'), IL_CAL_DATETIME);
174 $item->getContextObjType(),
175 $item->getTitle(),
176 $item->isContentIsLangVar(),
177 $grouping ? $grouping['agg_ref_id'] : 0,
178 $grouping ? $grouping['aggregation'] : [],
179 )
180 );
181
182 $info = [
183 'ref_id' => $item->getContextRefId(),
184 'creation_date' => ilDatePresentation::formatDate($creation_date),
185 'news_title' => $title,
186 ];
187
188 // title image type
189 if ($item->getContextRefId() > 0) {
190 $obj_id = $item->getContextObjId();
191 $type = $item->getContextObjType();
192
193 $lang_type = in_array($type, ['sahs', 'lm', 'htlm']) ? 'lres' : 'obj_' . $type;
194
195 $type_txt = ($this->obj_def->isPlugin($item->getContextObjType()))
196 ? ilObjectPlugin::lookupTxtById($item->getContextObjType(), $lang_type)
197 : $this->lng->txt($lang_type);
198
199 $info['type_txt'] = $type_txt;
200 $info['type_icon'] = ilObject::_getIcon($obj_id, 'tiny', $type);
201 $info['obj_title'] = ilStr::shortenWords(ilObject::_lookupTitle($obj_id));
202 $info['user_read'] = $this->collection->isReadByUser($this->user->getId(), $news_id);
203
204 $this->ctrl->setParameter($this, 'news_context', $item->getContextRefId());
205 } else {
206 $this->ctrl->setParameter($this, 'news_context', '');
207 }
208
209 $this->ctrl->setParameter($this, 'news_id', $item->getId());
210 $info['url'] = $this->ctrl->getLinkTarget($this, 'showNews');
211 $this->ctrl->clearParameters($this);
212
213 return $info;
214 }
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.
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 _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.

References $info, ilBlockGUI\$title, ilObject\_getIcon(), ilObject\_lookupTitle(), ILIAS\Repository\ctrl(), ilNewsItem\determineNewsTitle(), ilDatePresentation\formatDate(), IL_CAL_DATETIME, ILIAS\Repository\lng(), ilObjectPlugin\lookupTxtById(), ilStr\shortenWords(), and ILIAS\Repository\user().

Referenced by getListItemForData().

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

◆ getNoItemFoundContent()

ilNewsForContextBlockGUI::getNoItemFoundContent ( )

Reimplemented from ilBlockGUI.

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

1093 : string
1094 {
1095 return $this->lng->txt("news_no_news_items");
1096 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getOverview()

ilNewsForContextBlockGUI::getOverview ( )

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

410 : string
411 {
413
414 return '<div class="small">' . (count($this->getData())) . " " . $lng->txt("news_news_items") . "</div>";
415 }

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 227 of file class.ilNewsForContextBlockGUI.php.

227 : string
228 {
229 global $DIC;
230
231 $ilCtrl = $DIC->ctrl();
232
233 if (strcasecmp($ilCtrl->getCmdClass(), ilNewsItemGUI::class) === 0) {
234 return IL_SCREEN_FULL;
235 }
236
237 switch ($ilCtrl->getCmd()) {
238 case "showNews":
239 case "showFeedUrl":
240 return IL_SCREEN_CENTER;
241
242 case "editSettings":
243 case "saveSettings":
244 return IL_SCREEN_FULL;
245
246 default:
247 return IL_SCREEN_SIDE;
248 }
249 }
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 378 of file class.ilNewsForContextBlockGUI.php.

378 : void
379 {
380 // it seems like this method does not change any state, so it may be removed in the future
381
382 /*$ilUser = $this->user;
383
384 $this->view = (string) ilBlockSetting::_lookup(
385 $this->getBlockType(),
386 "view",
387 $ilUser->getId(),
388 (int) $this->block_id
389 );
390
391 // check whether notices and messages exist
392 $got_notices = $got_messages = false;
393 foreach ($this->data as $row) {
394 if ((int) ($row["priority"] ?? 0) === 0) {
395 $got_notices = true;
396 }
397 if ((int) ($row["priority"] ?? 0) === 1) {
398 $got_messages = true;
399 }
400 }
401 $this->show_view_selection = false;
402
403 if ($got_notices && $got_messages) {
404 $this->show_view_selection = true;
405 } elseif ($got_notices) {
406 $this->view = "";
407 }*/
408 }

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

+ Here is the caller graph for this function:

◆ hideNotifications()

ilNewsForContextBlockGUI::hideNotifications ( )

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

723 : void
724 {
725 $ilCtrl = $this->ctrl;
726 $ilUser = $this->user;
727
729 $this->getBlockType(),
730 "view",
731 "hide_notifications",
732 $ilUser->getId(),
733 (int) $this->block_id
734 );
735
736 // reload data
737 $this->loadNewsData();
738 $this->handleView();
739
740 if ($ilCtrl->isAsynch()) {
741 $this->send($this->getHTML());
742 }
743
744 $ilCtrl->returnToParent($this);
745 }
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\$user, ilBlockSetting\_write(), getBlockType(), getHTML(), handleView(), loadNewsData(), and ilBlockGUI\send().

+ Here is the call graph for this function:

◆ initData()

ilNewsForContextBlockGUI::initData ( NewsCollection  $collection)
protected

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

122 : void
123 {
124 $this->collection = $collection;
125 $this->data = $collection->pluck('id', true);
126 }
pluck(string $key, bool $wrap=false)

References $collection, and ILIAS\News\Data\NewsCollection\pluck().

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

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

◆ initSettingsForm()

ilNewsForContextBlockGUI::initSettingsForm ( )

Init setting form.

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

759 : void
760 {
762 $ilCtrl = $this->ctrl;
763 $ilTabs = $this->tabs;
764
765 $ilTabs->clearTargets();
766
767 $news_set = new ilSetting("news");
768 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
769
770 $public = ilBlockSetting::_lookup(
771 $this->getBlockType(),
772 "public_notifications",
773 0,
774 (int) $this->block_id
775 );
776 $public_feed = ilBlockSetting::_lookup(
777 $this->getBlockType(),
778 "public_feed",
779 0,
780 (int) $this->block_id
781 );
782 $hide_block = ilBlockSetting::_lookup(
783 $this->getBlockType(),
784 "hide_news_block",
785 0,
786 (int) $this->block_id
787 );
788 $hide_news_per_date = ilBlockSetting::_lookup(
789 $this->getBlockType(),
790 "hide_news_per_date",
791 0,
792 (int) $this->block_id
793 );
794 $hide_news_date = ilBlockSetting::_lookup(
795 $this->getBlockType(),
796 "hide_news_date",
797 0,
798 (int) $this->block_id
799 );
800 if (is_string($hide_news_date) && $hide_news_date !== "") {
801 $hide_news_date = explode(" ", $hide_news_date);
802 }
803
804 $this->settings_form = new ilPropertyFormGUI();
805 $this->settings_form->setTitle($lng->txt("news_settings"));
806
807 // hide news block for learners
808 if ($this->getProperty("hide_news_block_option")) {
809 $ch = new ilCheckboxInputGUI(
810 $lng->txt("news_hide_news_block"),
811 "hide_news_block"
812 );
813 $ch->setInfo($lng->txt("news_hide_news_block_info"));
814 $ch->setChecked((bool) $hide_block);
815 $this->settings_form->addItem($ch);
816
817 $hnpd = new ilCheckboxInputGUI(
818 $lng->txt("news_hide_news_per_date"),
819 "hide_news_per_date"
820 );
821 $hnpd->setChecked((bool) $hide_news_per_date);
822
823 $dt_prop = new ilDateTimeInputGUI(
824 $lng->txt("news_hide_news_date"),
825 "hide_news_date"
826 );
827 $dt_prop->setRequired(true);
828 if (isset($hide_news_date[0], $hide_news_date[1])) {
829 $dt_prop->setDate(new ilDateTime($hide_news_date[0] . " " . $hide_news_date[1], IL_CAL_DATETIME));
830 }
831 $dt_prop->setShowTime(true);
832 $hnpd->addSubItem($dt_prop);
833
834 $this->settings_form->addItem($hnpd);
835 }
836
837 // public notifications
838 if ($enable_internal_rss && $this->getProperty("public_notifications_option")) {
839 $ch = new ilCheckboxInputGUI(
840 $lng->txt("news_notifications_public"),
841 "notifications_public"
842 );
843 $ch->setInfo($lng->txt("news_notifications_public_info"));
844 $ch->setChecked((bool) $public);
845 $this->settings_form->addItem($ch);
846 }
847
848 // extra rss feed
849 if ($enable_internal_rss) {
850 $ch = new ilCheckboxInputGUI(
851 $lng->txt("news_public_feed"),
852 "notifications_public_feed"
853 );
854 $ch->setInfo($lng->txt("news_public_feed_info"));
855 $ch->setChecked((bool) $public_feed);
856 $this->settings_form->addItem($ch);
857 }
858
859 $this->settings_form->addCommandButton("saveSettings", $lng->txt("save"));
860 $this->settings_form->addCommandButton("cancelSettings", $lng->txt("cancel"));
861 $this->settings_form->setFormAction($ilCtrl->getFormAction($this));
862 }
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, ilBlockSetting\_lookup(), ilTabsGUI\clearTargets(), getBlockType(), ilBlockGUI\getProperty(), IL_CAL_DATETIME, and ilLanguage\txt().

Referenced by editSettings().

+ 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 222 of file class.ilNewsForContextBlockGUI.php.

222 : bool
223 {
224 return false;
225 }

◆ loadNewsData()

ilNewsForContextBlockGUI::loadNewsData ( )
private

Reimplemented in ilPDNewsBlockGUI.

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

102 : void
103 {
104 if ($this->std_request->getRefId() === 0) {
105 $this->initData(new NewsCollection());
106 return;
107 }
108
109 $collection = $this->domain->collection()->getNewsForContext(
110 new NewsContext($this->std_request->getRefId(), $this->ctrl->getContextObjId(), $this->ctrl->getContextObjType()),
111 new NewsCriteria(read_user_id: $this->user->getId()),
112 $this->user->getId(),
113 true
114 );
115
116 if ($this->ctrl->getContextObjType() !== 'frm') {
118 }
120 }
Optimized News Collection with memory-efficient data structures to support large news feeds.
getNewsForContext(int $context_obj_id, string $context_obj_type)
groupForums(bool $group_posting_sequence)
News Context DTO represents a context where news items can be associated with.
Definition: NewsContext.php:29
News Criteria DTO for querying news items supports caching, JSON serialization, and validation.
initData(NewsCollection $collection)

References $collection, ILIAS\Repository\ctrl(), ILIAS\News\Data\NewsCollection\getNewsForContext(), ILIAS\News\Data\NewsCollection\groupFiles(), ILIAS\News\Data\NewsCollection\groupForums(), initData(), and ILIAS\Repository\user().

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

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

◆ makeClickable()

ilNewsForContextBlockGUI::makeClickable ( string  $a_str)

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

688 : string
689 {
690 // this fixes bug 8744. We assume that strings that contain < and >
691 // already contain html, we do not handle these
692 if (is_int(strpos($a_str, ">")) && is_int(strpos($a_str, "<"))) {
693 return $a_str;
694 }
695
696 return ilUtil::makeClickable($a_str);
697 }
static makeClickable(string $a_text, bool $detectGotoLinks=false, ?string $ilias_http_path=null)

References ilUtil\makeClickable().

+ Here is the call graph for this function:

◆ preloadData()

ilNewsForContextBlockGUI::preloadData ( array  $data)
protected

Method will be called before rendering the block.

It lazily loads the required news items.

Reimplemented from ilBlockGUI.

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

131 : void
132 {
133 parent::preloadData($data);
134 $this->collection->load(array_column($data, 0));
135 }

References ilBlockGUI\$data.

◆ saveSettings()

ilNewsForContextBlockGUI::saveSettings ( )

Reimplemented in ilPDNewsBlockGUI.

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

915 : string
916 {
917 $ilCtrl = $this->ctrl;
918
919 $this->initSettingsForm();
920 $form = $this->settings_form;
921 if ($form->checkInput()) {
922 $news_set = new ilSetting("news");
923 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
924
925 if ($enable_internal_rss) {
927 $this->getBlockType(),
928 "public_notifications",
929 $form->getInput("notifications_public"),
930 0,
931 (int) $this->block_id
932 );
934 $this->getBlockType(),
935 "public_feed",
936 $form->getInput("notifications_public_feed"),
937 0,
938 (int) $this->block_id
939 );
940 }
941
942 if ($this->getProperty("hide_news_block_option")) {
944 $this->getBlockType(),
945 "hide_news_block",
946 $form->getInput("hide_news_block"),
947 0,
948 (int) $this->block_id
949 );
951 $this->getBlockType(),
952 "hide_news_per_date",
953 $form->getInput("hide_news_per_date"),
954 0,
955 (int) $this->block_id
956 );
957
958 // hide date
959 $hd = $this->settings_form->getItemByPostVar("hide_news_date");
960 $hide_date = $hd->getDate();
961 if ($hide_date instanceof ilDateTime && $form->getInput("hide_news_per_date")) {
963 $this->getBlockType(),
964 "hide_news_date",
965 $hide_date->get(IL_CAL_DATETIME),
966 0,
967 (int) $this->block_id
968 );
969 } else {
971 $this->getBlockType(),
972 "hide_news_date",
973 "",
974 0,
975 (int) $this->block_id
976 );
977 }
978 }
979
980 $this->domain->collection()->invalidateCache($this->user->getId());
981
982 $ilCtrl->returnToParent($this);
983 } else {
984 $this->settings_form->setValuesByPost();
985 return $this->settings_form->getHTML();
986 }
987 return "";
988 }

References ilBlockSetting\_write(), IL_CAL_DATETIME, and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ showFeedUrl()

ilNewsForContextBlockGUI::showFeedUrl ( )

Reimplemented in ilPDNewsBlockGUI.

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

990 : string
991 {
993 $ilUser = $this->user;
994
995 $title = ilObject::_lookupTitle((int) $this->block_id);
996
997 $tpl = new ilTemplate("tpl.show_feed_url.html", true, true, "components/ILIAS/News");
999 "TXT_TITLE",
1000 sprintf($lng->txt("news_feed_url_for"), $title)
1001 );
1002 $tpl->setVariable("TXT_INFO", $lng->txt("news_get_feed_info"));
1003 $tpl->setVariable("TXT_FEED_URL", $lng->txt("news_feed_url"));
1005 "VAL_FEED_URL",
1006 ILIAS_HTTP_PATH . "/feed.php?client_id=" . rawurlencode(CLIENT_ID) . "&user_id=" . $ilUser->getId() .
1007 "&obj_id=" . $this->block_id .
1008 "&hash=" . ilObjUser::_lookupFeedHash($ilUser->getId(), true)
1009 );
1011 "VAL_FEED_URL_TXT",
1012 ILIAS_HTTP_PATH . "/feed.php?client_id=" . rawurlencode(CLIENT_ID) . "&<br />user_id=" . $ilUser->getId() .
1013 "&obj_id=" . $this->block_id .
1014 "&hash=" . ilObjUser::_lookupFeedHash($ilUser->getId(), true)
1015 );
1016
1017 $panel = $this->ui->factory()->panel()->standard(
1018 $lng->txt("news_internal_news"),
1019 $this->ui->factory()->legacy()->content($tpl->get())
1020 );
1021
1022 return $this->ui->renderer()->render($panel);
1023 }
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 $lng, ILIAS\News\Common\Table\$tpl, ilObjUser\_lookupFeedHash(), ilObject\_lookupTitle(), CLIENT_ID, ILIAS\UICore\GlobalTemplate\get(), ILIAS\UICore\GlobalTemplate\setVariable(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ showNotifications()

ilNewsForContextBlockGUI::showNotifications ( )

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

699 : void
700 {
701 $ilCtrl = $this->ctrl;
702 $ilUser = $this->user;
703
705 $this->getBlockType(),
706 "view",
707 "",
708 $ilUser->getId(),
709 (int) $this->block_id
710 );
711
712 // reload data
713 $this->loadNewsData();
714 $this->handleView();
715
716 if ($ilCtrl->isAsynch()) {
717 $this->send($this->getHTML());
718 }
719
720 $ilCtrl->returnToParent($this);
721 }

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

+ Here is the call graph for this function:

◆ writeSettings()

static ilNewsForContextBlockGUI::writeSettings ( array  $a_values)
static

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

898 : void
899 {
900 global $DIC;
901
902 $block_id = $DIC->ctrl()->getContextObjId();
903 foreach ($a_values as $key => $value) {
904 ilBlockSetting::_write(self::$block_type, (string) $key, (string) $value, 0, $block_id);
905 }
906 }

References $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

◆ $block_type

string ilNewsForContextBlockGUI::$block_type = "news"
static

◆ $collection

NewsCollection ilNewsForContextBlockGUI::$collection
protected

◆ $domain

InternalDomainService ilNewsForContextBlockGUI::$domain
protected

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

◆ $dynamic

bool ilNewsForContextBlockGUI::$dynamic = false
protected

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

◆ $gui

InternalGUIService ilNewsForContextBlockGUI::$gui
protected

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

◆ $help

ilHelpGUI ilNewsForContextBlockGUI::$help
protected

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

◆ $logger

ilLogger ilNewsForContextBlockGUI::$logger
protected

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

◆ $news_access

NewsAccess ilNewsForContextBlockGUI::$news_access
protected

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

◆ $prevent_initial_loading

bool ilNewsForContextBlockGUI::$prevent_initial_loading = false
protected

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

◆ $refinery

ILIAS Refinery Factory ilNewsForContextBlockGUI::$refinery
protected

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

◆ $settings

ilSetting ilNewsForContextBlockGUI::$settings
protected

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

◆ $settings_form

ilPropertyFormGUI ilNewsForContextBlockGUI::$settings_form
protected

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

◆ $show_view_selection

bool ilNewsForContextBlockGUI::$show_view_selection
protected

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

◆ $std_request

StandardGUIRequest ilNewsForContextBlockGUI::$std_request
protected

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

◆ $tabs

ilTabsGUI ilNewsForContextBlockGUI::$tabs
protected

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

Referenced by initSettingsForm().

◆ $view

string ilNewsForContextBlockGUI::$view
protected

Definition at line 49 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 40 of file class.ilNewsForContextBlockGUI.php.


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