ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPDNewsGUI Class Reference

News on PD. More...

+ Collaboration diagram for ilPDNewsGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 displayHeader ()
 
 view ()
 
 applyFilter ()
 
 resetFilter ()
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilHelpGUI $help
 
ilObjUser $user
 
ilFavouritesManager $fav_manager
 
StandardGUIRequest $std_request
 

Detailed Description

News on PD.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de ilPDNewsGUI:

Definition at line 27 of file class.ilPDNewsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilPDNewsGUI::__construct ( )

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

References $DIC, $lng, $tpl, ILIAS\Repository\ctrl(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ilLanguage\loadLanguageModule(), and ILIAS\Repository\user().

38  {
39  global $DIC;
40 
41  $this->help = $DIC["ilHelp"];
42  $this->user = $DIC->user();
43  $tpl = $DIC->ui()->mainTemplate();
44  $lng = $DIC->language();
45  $ilCtrl = $DIC->ctrl();
46  $ilHelp = $DIC["ilHelp"];
47 
48  $ilHelp->setScreenIdComponent("news");
49 
50  $this->std_request = new StandardGUIRequest(
51  $DIC->http(),
52  $DIC->refinery()
53  );
54 
55  // initiate variables
56  $this->tpl = $tpl;
57  $this->lng = $lng;
58  $this->ctrl = $ilCtrl;
59 
60  $lng->loadLanguageModule("news");
61 
62  $this->ctrl->saveParameter($this, "news_ref_id");
63  $this->fav_manager = new ilFavouritesManager();
64  }
loadLanguageModule(string $a_module)
Load language module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
ilGlobalTemplateInterface $tpl
ilLanguage $lng
+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilter()

ilPDNewsGUI::applyFilter ( )

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

References $ilUser, $user, ILIAS\Repository\ctrl(), and ilSession\set().

167  : void
168  {
170 
171  $news_ref_id = $this->std_request->getNewsRefId();
172  $news_per = $this->std_request->getNewsPer();
173 
174  $this->ctrl->setParameter($this, "news_ref_id", $news_ref_id);
175  $ilUser->writePref("news_sel_ref_id", (string) $news_ref_id);
176  if ($news_per > 0) {
177  ilSession::set("news_pd_news_per", $news_per);
178  }
179  $this->ctrl->redirect($this, "view");
180  }
$ilUser
Definition: imgupload.php:34
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ displayHeader()

ilPDNewsGUI::displayHeader ( )

Definition at line 82 of file class.ilPDNewsGUI.php.

References ilUtil\getImagePath(), and ILIAS\Repository\lng().

Referenced by executeCommand().

82  : void
83  {
84  $this->tpl->setTitle($this->lng->txt("news"));
85  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_nwss.svg"));
86  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPDNewsGUI::executeCommand ( )

Definition at line 66 of file class.ilPDNewsGUI.php.

References ILIAS\Repository\ctrl(), and displayHeader().

66  : bool
67  {
68  $next_class = $this->ctrl->getNextClass();
69 
70  switch ($next_class) {
71 
72  default:
73  $cmd = $this->ctrl->getCmd("view");
74  $this->displayHeader();
75  $this->$cmd();
76  break;
77  }
78  $this->tpl->printToStdout();
79  return true;
80  }
+ Here is the call graph for this function:

◆ resetFilter()

ilPDNewsGUI::resetFilter ( )

Definition at line 182 of file class.ilPDNewsGUI.php.

References $ilUser, $user, ilSession\clear(), and ILIAS\Repository\ctrl().

182  : void
183  {
185  $this->ctrl->setParameter($this, "news_ref_id", 0);
186  $ilUser->writePref("news_sel_ref_id", '0');
187  ilSession::clear("news_pd_news_per");
188  $this->ctrl->redirect($this, "view");
189  }
$ilUser
Definition: imgupload.php:34
static clear(string $a_var)
+ Here is the call graph for this function:

◆ view()

ilPDNewsGUI::view ( )

Definition at line 88 of file class.ilPDNewsGUI.php.

References $ilUser, $lng, $ref_id, $tpl, $user, ilNewsItem\_getNewsItemsOfUser(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilNewsItem\_lookupUserPDPeriod(), ilNewsItem\filterObjIdsPerNews(), ilSession\get(), ILIAS\Repository\int(), ilGlobalTemplateInterface\setContent(), and ilLanguage\txt().

88  : void
89  {
91  $lng = $this->lng;
92  $tpl = $this->tpl;
93 
94  $ref_ids = [];
95  $obj_ids = [];
96  $pd_items = $this->fav_manager->getFavouritesOfUser($ilUser->getId());
97  foreach ($pd_items as $item) {
98  $ref_ids[] = (int) $item["ref_id"];
99  $obj_ids[] = (int) $item["obj_id"];
100  }
101 
102  $sel_ref_id = ($this->std_request->getNewsRefId() > 0)
103  ? $this->std_request->getNewsRefId()
104  : $ilUser->getPref("news_sel_ref_id");
105 
106  $per = (ilSession::get("news_pd_news_per") != "")
107  ? ilSession::get("news_pd_news_per")
109  $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $per);
110 
111  // related objects (contexts) of news
112  $contexts[0] = $lng->txt("news_all_items");
113 
114  $conts = [];
115  $sel_has_news = false;
116  foreach ($ref_ids as $ref_id) {
117  $obj_id = ilObject::_lookupObjId($ref_id);
118  $title = ilObject::_lookupTitle($obj_id);
119 
120  $conts[$ref_id] = $title;
121  if ((int) $sel_ref_id === $ref_id) {
122  $sel_has_news = true;
123  }
124  }
125 
126  $cnt = [];
127  $nitem = new ilNewsItem();
128  $news_items = ilNewsItem::_getNewsItemsOfUser(
129  $ilUser->getId(),
130  false,
131  true,
132  $per,
133  $cnt
134  );
135 
136  // reset selected news ref id, if no news are given for id
137  if (!$sel_has_news) {
138  $sel_ref_id = "";
139  }
140  asort($conts);
141  foreach ($conts as $ref_id => $title) {
142  $contexts[$ref_id] = $title . " (" . (int) ($cnt[$ref_id] ?? 0) . ")";
143  }
144 
145 
146  if ($sel_ref_id > 0) {
147  $obj_id = ilObject::_lookupObjId((int) $sel_ref_id);
148  $obj_type = ilObject::_lookupType($obj_id);
149  $nitem->setContextObjId($obj_id);
150  $nitem->setContextObjType($obj_type);
151  $news_items = $nitem->getNewsForRefId(
152  $sel_ref_id,
153  false,
154  false,
155  $per,
156  true
157  );
158  }
159 
160  $pd_news_table = new ilPDNewsTableGUI($this, "view", $contexts, $sel_ref_id);
161  $pd_news_table->setData($news_items);
162  $pd_news_table->setNoEntriesText($lng->txt("news_no_news_items"));
163 
164  $tpl->setContent($pd_news_table->getHTML());
165  }
static get(string $a_var)
static _lookupUserPDPeriod(int $a_user_id)
static _getNewsItemsOfUser(int $a_user_id, bool $a_only_public=false, bool $a_prevent_aggregation=false, int $a_per=0, array &$a_cnt=[])
Get all news items for a user.
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...
static filterObjIdsPerNews(array $a_obj_ids, $a_time_period=0, string $a_starting_date="", string $a_ending_date='', bool $ignore_period=false)
Checks whether news are available for.
Personal desktop news table.
static _lookupObjId(int $ref_id)
ilGlobalTemplateInterface $tpl
$ref_id
Definition: ltiauth.php:67
static _lookupTitle(int $obj_id)
setContent(string $a_html)
Sets content for standard template.
ilLanguage $lng
A news item can be created by different sources.
$ilUser
Definition: imgupload.php:34
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilPDNewsGUI::$ctrl
protected

Definition at line 31 of file class.ilPDNewsGUI.php.

◆ $fav_manager

ilFavouritesManager ilPDNewsGUI::$fav_manager
protected

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

◆ $help

ilHelpGUI ilPDNewsGUI::$help
protected

Definition at line 32 of file class.ilPDNewsGUI.php.

◆ $lng

ilLanguage ilPDNewsGUI::$lng
protected

Definition at line 30 of file class.ilPDNewsGUI.php.

Referenced by __construct(), and view().

◆ $std_request

StandardGUIRequest ilPDNewsGUI::$std_request
protected

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

◆ $tpl

ilGlobalTemplateInterface ilPDNewsGUI::$tpl
protected

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

Referenced by __construct(), and view().

◆ $user

ilObjUser ilPDNewsGUI::$user
protected

Definition at line 33 of file class.ilPDNewsGUI.php.

Referenced by applyFilter(), resetFilter(), and view().


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