ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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$

ilPDNewsGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilPDNewsGUI::__construct ( )

Constructor.

public

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

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

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  }
Manages favourites, currently the interface for other components, needs discussion.
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
help()
Definition: help.php:2
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilter()

ilPDNewsGUI::applyFilter ( )

change related object

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

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

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

◆ displayHeader()

ilPDNewsGUI::displayHeader ( )

display header and locator

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

References ilUtil\infoPanel().

Referenced by executeCommand().

100  {
101  $this->tpl->setTitle($this->lng->txt("news"));
102 
103  // display infopanel if something happened
105  }
static infoPanel($a_keep=true)
+ 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.

References displayHeader().

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
+ Here is the call graph for this function:

◆ resetFilter()

ilPDNewsGUI::resetFilter ( )

reset filter

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

References $_SESSION, $ilUser, and $user.

211  {
213  $this->ctrl->setParameter($this, "news_ref_id", 0);
214  $ilUser->writePref("news_sel_ref_id", 0);
215  $_SESSION["news_pd_news_per"] = "";
216  $this->ctrl->redirect($this, "view");
217  }
$_SESSION["AccountId"]
$ilUser
Definition: imgupload.php:18

◆ view()

ilPDNewsGUI::view ( )

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

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

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