ILIAS  release_7 Revision v7.30-3-g800a261c036
ilPDNewsGUI Class Reference

News on PD. More...

+ Collaboration diagram for ilPDNewsGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 execute command More...
 
 displayHeader ()
 display header and locator More...
 
 view ()
 
 applyFilter ()
 change related object More...
 
 resetFilter ()
 reset filter More...
 

Protected Attributes

 $tpl
 
 $lng
 
 $ctrl
 
 $help
 
 $user
 
 $fav_manager
 

Detailed Description

News on PD.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

@ilCtrl_Calls ilPDNewsGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilPDNewsGUI::__construct ( )

Constructor.

@access public

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

54 {
55 global $DIC;
56
57 $this->help = $DIC["ilHelp"];
58 $this->user = $DIC->user();
59 $tpl = $DIC["tpl"];
60 $lng = $DIC->language();
61 $ilCtrl = $DIC->ctrl();
62 $ilHelp = $DIC["ilHelp"];
63
64 $ilHelp->setScreenIdComponent("news");
65
66 // initiate variables
67 $this->tpl = $tpl;
68 $this->lng = $lng;
69 $this->ctrl = $ilCtrl;
70
71 $lng->loadLanguageModule("news");
72
73 $this->ctrl->saveParameter($this, "news_ref_id");
74 $this->fav_manager = new ilFavouritesManager();
75 }
user()
Definition: user.php:4
Manages favourites, currently the interface for other components, needs discussion.
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2

References $DIC, $lng, $tpl, help(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilter()

ilPDNewsGUI::applyFilter ( )

change related object

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

197 {
199
200 $this->ctrl->setParameter($this, "news_ref_id", $_POST["news_ref_id"]);
201 $ilUser->writePref("news_sel_ref_id", $_POST["news_ref_id"]);
202 if ($_POST["news_per"] > 0) {
203 $_SESSION["news_pd_news_per"] = $_POST["news_per"];
204 }
205 $this->ctrl->redirect($this, "view");
206 }
$_POST["username"]
$_SESSION["AccountId"]
$ilUser
Definition: imgupload.php:18

References $_POST, $_SESSION, $ilUser, and $user.

◆ displayHeader()

ilPDNewsGUI::displayHeader ( )

display header and locator

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

100 {
101 $this->tpl->setTitle($this->lng->txt("news"));
102 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_nwss.svg"));
103
104 // display infopanel if something happened
106 }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static infoPanel($a_keep=true)

References ilUtil\getImagePath(), and ilUtil\infoPanel().

Referenced by executeCommand().

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

◆ executeCommand()

ilPDNewsGUI::executeCommand ( )

execute command

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

81 {
82 $next_class = $this->ctrl->getNextClass();
83
84 switch ($next_class) {
85
86 default:
87 $cmd = $this->ctrl->getCmd("view");
88 $this->displayHeader();
89 $this->$cmd();
90 break;
91 }
92 $this->tpl->printToStdout();
93 return true;
94 }
displayHeader()
display header and locator

References displayHeader().

+ Here is the call graph for this function:

◆ resetFilter()

ilPDNewsGUI::resetFilter ( )

reset filter

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

212 {
214 $this->ctrl->setParameter($this, "news_ref_id", 0);
215 $ilUser->writePref("news_sel_ref_id", 0);
216 $_SESSION["news_pd_news_per"] = "";
217 $this->ctrl->redirect($this, "view");
218 }

References $_SESSION, $ilUser, and $user.

◆ view()

ilPDNewsGUI::view ( )

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

112 {
116 $ilCtrl = $this->ctrl;
117
118 $ref_ids = array();
119 $obj_ids = array();
120 $pd_items = $this->fav_manager->getFavouritesOfUser($ilUser->getId());
121 foreach ($pd_items as $item) {
122 $ref_ids[] = $item["ref_id"];
123 $obj_ids[] = $item["obj_id"];
124 }
125
126 $sel_ref_id = ($_GET["news_ref_id"] > 0)
127 ? $_GET["news_ref_id"]
128 : $ilUser->getPref("news_sel_ref_id");
129
130 include_once("./Services/News/classes/class.ilNewsItem.php");
131 $per = ($_SESSION["news_pd_news_per"] != "")
132 ? $_SESSION["news_pd_news_per"]
134 $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $per);
135
136 // related objects (contexts) of news
137 $contexts[0] = $lng->txt("news_all_items");
138
139 $conts = array();
140 $sel_has_news = false;
141 foreach ($ref_ids as $ref_id) {
142 $obj_id = ilObject::_lookupObjId($ref_id);
143 $title = ilObject::_lookupTitle($obj_id);
144
145 $conts[$ref_id] = $title;
146 if ($sel_ref_id == $ref_id) {
147 $sel_has_news = true;
148 }
149 }
150
151 $cnt = array();
152 $nitem = new ilNewsItem();
153 $news_items = $nitem->_getNewsItemsOfUser(
154 $ilUser->getId(),
155 false,
156 true,
157 $per,
158 $cnt
159 );
160
161 // reset selected news ref id, if no news are given for id
162 if (!$sel_has_news) {
163 $sel_ref_id = "";
164 }
165 asort($conts);
166 foreach ($conts as $ref_id => $title) {
167 $contexts[$ref_id] = $title . " (" . (int) $cnt[$ref_id] . ")";
168 }
169
170
171 if ($sel_ref_id > 0) {
172 $obj_id = ilObject::_lookupObjId($sel_ref_id);
173 $obj_type = ilObject::_lookupType($obj_id);
174 $nitem->setContextObjId($obj_id);
175 $nitem->setContextObjType($obj_type);
176 $news_items = $nitem->getNewsForRefId(
177 $sel_ref_id,
178 false,
179 false,
180 $per,
181 true
182 );
183 }
184
185 include_once("./Services/News/classes/class.ilPDNewsTableGUI.php");
186 $pd_news_table = new ilPDNewsTableGUI($this, "view", $contexts, $sel_ref_id);
187 $pd_news_table->setData($news_items);
188 $pd_news_table->setNoEntriesText($lng->txt("news_no_news_items"));
189
190 $tpl->setContent($pd_news_table->getHTML());
191 }
$_GET["client_id"]
static filterObjIdsPerNews($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
Checks whether news are available for.
static _lookupUserPDPeriod($a_user_id)
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
Personal desktop news table.

References $_GET, $_SESSION, $ctrl, $ilUser, $lng, $tpl, $user, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilNewsItem\_lookupUserPDPeriod(), and ilNewsItem\filterObjIdsPerNews().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilPDNewsGUI::$ctrl
protected

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

Referenced by view().

◆ $fav_manager

ilPDNewsGUI::$fav_manager
protected

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

◆ $help

ilPDNewsGUI::$help
protected

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

◆ $lng

ilPDNewsGUI::$lng
protected

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

Referenced by __construct(), and view().

◆ $tpl

ilPDNewsGUI::$tpl
protected

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

Referenced by __construct(), and view().

◆ $user

ilPDNewsGUI::$user
protected

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

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


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