ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilNewsTimelineGUI Class Reference

Timeline for news. More...

+ Collaboration diagram for ilNewsTimelineGUI:

Public Member Functions

 setUserEditAll ($a_val)
 Set user can edit other users postings. More...
 
 getUserEditAll ()
 Get user can edit other users postings. More...
 
 executeCommand ()
 Execute command. More...
 
 show ()
 Show. More...
 
 loadMore ()
 Load more. More...
 
 save ()
 Save (ajax) More...
 
 update ()
 Update (ajax) More...
 
 remove ()
 Remove (ajax) More...
 

Static Public Member Functions

static getInstance ($a_ref_id, $a_include_auto_entries)
 Get instance. More...
 

Protected Member Functions

 __construct ($a_ref_id, $a_include_auto_entries)
 Constructor. More...
 
 getEditModal ()
 Get edit modal. More...
 
 getDeleteModal ()
 Get delete modal. More...
 

Protected Attributes

 $ctrl
 
 $tpl
 
 $ref_id
 
 $lng
 
 $toolbar
 
 $user
 
 $access
 
 $user_edit_all = false
 

Static Protected Attributes

static $items_per_load = 10
 

Detailed Description

Timeline for news.

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

Definition at line 12 of file class.ilNewsTimelineGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilNewsTimelineGUI::__construct (   $a_ref_id,
  $a_include_auto_entries 
)
protected

Constructor.

Parameters
int$a_ref_idreference id

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

References $DIC, and user().

65  {
66  global $DIC;
67 
68  $this->ctrl = $DIC->ctrl();
69  $this->tpl = $DIC["tpl"];
70  $this->ref_id = $a_ref_id;
71  $this->lng = $DIC->language();
72  $this->toolbar = $DIC->toolbar();
73  $this->user = $DIC->user();
74  $this->include_auto_entries = $a_include_auto_entries;
75  $this->access = $DIC->access();
76 
77  $this->lng->loadLanguageModule("news");
78  }
user()
Definition: user.php:4
global $DIC
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilNewsTimelineGUI::executeCommand ( )

Execute command.

Definition at line 114 of file class.ilNewsTimelineGUI.php.

References $cmd, and array.

115  {
116  $next_class = $this->ctrl->getNextClass($this);
117  $cmd = $this->ctrl->getCmd("show");
118 
119  switch ($next_class)
120  {
121  default:
122  if (in_array($cmd, array("show", "save", "update", "loadMore", "remove")))
123  {
124  $this->$cmd();
125  }
126  }
127  }
$cmd
Definition: sahs_server.php:35
Create styles array
The data for the language used.

◆ getDeleteModal()

ilNewsTimelineGUI::getDeleteModal ( )
protected

Get delete modal.

Returns
string modal html

Definition at line 371 of file class.ilNewsTimelineGUI.php.

References ilSubmitButton\getInstance(), ilModalGUI\getInstance(), and ilModalGUI\TYPE_LARGE.

Referenced by show().

372  {
373  include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
374  $modal = ilModalGUI::getInstance();
375  $modal->setHeading($this->lng->txt("delete"));
376  $modal->setId("ilNewsDeleteModal");
377  $modal->setType(ilModalGUI::TYPE_LARGE);
378 
379  require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
380  $confirm = ilSubmitButton::getInstance();
381  $confirm->setCaption("delete");
382  $confirm->setId("news_btn_delete");
383  $modal->addButton($confirm);
384 
385  $cancel = ilSubmitButton::getInstance();
386  $cancel->setCaption("cancel");
387  $cancel->setId("news_btn_cancel_delete");
388  $modal->addButton($cancel);
389 
390  $modal->setBody("<p id='news_delete_news_title'></p>".
391  $this->tpl->getMessageHTML($this->lng->txt("news_really_delete_news"), "question"));
392 
393  return $modal->getHTML();
394 
395  }
static getInstance()
Get instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEditModal()

ilNewsTimelineGUI::getEditModal ( )
protected

Get edit modal.

Returns
string modal html

Definition at line 349 of file class.ilNewsTimelineGUI.php.

References ilNewsItemGUI\getEditForm(), ilModalGUI\getInstance(), IL_FORM_EDIT, and ilModalGUI\TYPE_LARGE.

Referenced by show().

350  {
351  include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
352  $modal = ilModalGUI::getInstance();
353  $modal->setHeading($this->lng->txt("edit"));
354  $modal->setId("ilNewsEditModal");
355  $modal->setType(ilModalGUI::TYPE_LARGE);
356 
357  include_once("./Services/News/classes/class.ilNewsItemGUI.php");
358  $form = ilNewsItemGUI::getEditForm(IL_FORM_EDIT, $this->ref_id);
359  $form->setShowTopButtons(false);
360  $modal->setBody($form->getHTML());
361 
362  return $modal->getHTML();
363 
364  }
static getInstance()
Get instance.
static getEditForm($a_mode, $a_ref_id)
FORM NewsItem: Init form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstance()

static ilNewsTimelineGUI::getInstance (   $a_ref_id,
  $a_include_auto_entries 
)
static

Get instance.

Parameters
int$a_ref_idreference id
Returns
ilNewsTimelineGUI

Definition at line 106 of file class.ilNewsTimelineGUI.php.

Referenced by ilObjGroupGUI\executeCommand(), and ilObjCourseGUI\executeCommand().

107  {
108  return new self($a_ref_id, $a_include_auto_entries);
109  }
+ Here is the caller graph for this function:

◆ getUserEditAll()

ilNewsTimelineGUI::getUserEditAll ( )

Get user can edit other users postings.

Returns
bool user can edit all postings

Definition at line 95 of file class.ilNewsTimelineGUI.php.

References $user_edit_all.

Referenced by loadMore(), remove(), and show().

96  {
97  return $this->user_edit_all;
98  }
+ Here is the caller graph for this function:

◆ loadMore()

ilNewsTimelineGUI::loadMore ( )

Load more.

Parameters

Definition at line 214 of file class.ilNewsTimelineGUI.php.

References $_POST, $d, array, ilJsonUtil\encode(), exit, ilTimelineGUI\getInstance(), ilNewsTimelineItemGUI\getInstance(), and getUserEditAll().

215  {
216  include_once("./Services/News/classes/class.ilNewsItem.php");
217  $news_item = new ilNewsItem();
218  $news_item->setContextObjId($this->ctrl->getContextObjId());
219  $news_item->setContextObjType($this->ctrl->getContextObjType());
220 
221  $excluded = $_POST["rendered_news"];
222 
223  $news_data = $news_item->getNewsForRefId($this->ref_id, false, false,
224  0, true, false, !$this->include_auto_entries, false, null, self::$items_per_load, $excluded);
225 
226  include_once("./Services/News/Timeline/classes/class.ilTimelineGUI.php");
227  include_once("./Services/News/classes/class.ilNewsTimelineItemGUI.php");
228  $timeline = ilTimelineGUI::getInstance();
229 
230  $js_items = array();
231  foreach ($news_data as $d)
232  {
233  $news_item = new ilNewsItem($d["id"]);
234  $item = ilNewsTimelineItemGUI::getInstance($news_item, $d["ref_id"]);
235  $item->setUserEditAll($this->getUserEditAll());
236  $timeline->addItem($item);
237  $js_items[$d["id"]] = array(
238  "id" => $d["id"],
239  "user_id" => $d["user_id"],
240  "title" => $d["title"],
241  "content" => $d["content"].$d["content_long"],
242  "content_long" => "",
243  "priority" => $d["priority"],
244  "visibility" => $d["visibility"],
245  "content_type" => $d["content_type"]
246  );
247  }
248 
249  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
250  $obj = new stdClass();
251  $obj->data = $js_items;
252  $obj->html = $timeline->render(true);
253 
254  echo ilJsonUtil::encode($obj);
255  exit;
256  }
for($col=0; $col< 50; $col++) $d
static encode($mixed, $suppress_native=false)
Create styles array
The data for the language used.
static getInstance()
Get instance.
$_POST["username"]
static getInstance(ilNewsItem $a_news_item, $a_news_ref_id)
Get instance.
getUserEditAll()
Get user can edit other users postings.
+ Here is the call graph for this function:

◆ remove()

ilNewsTimelineGUI::remove ( )

Remove (ajax)

Definition at line 333 of file class.ilNewsTimelineGUI.php.

References $_POST, exit, getUserEditAll(), and user().

334  {
335  include_once("./Services/News/classes/class.ilNewsItemGUI.php");
336  $news_item = new ilNewsItem((int) $_POST["id"]);
337  if ($this->user->getId() == $news_item->getUserId() || $this->getUserEditAll())
338  {
339  $news_item->delete();
340  }
341  exit;
342  }
user()
Definition: user.php:4
$_POST["username"]
getUserEditAll()
Get user can edit other users postings.
+ Here is the call graph for this function:

◆ save()

ilNewsTimelineGUI::save ( )

Save (ajax)

Definition at line 262 of file class.ilNewsTimelineGUI.php.

References ilObject\_lookupObjectId(), ilObject\_lookupType(), exit, ilNewsItemGUI\getEditForm(), IL_FORM_CREATE, ilNewsItemGUI\isRteActivated(), and user().

263  {
264  include_once("./Services/News/classes/class.ilNewsItemGUI.php");
265  $form = ilNewsItemGUI::getEditForm(IL_FORM_CREATE, $this->ref_id);
266  if ($form->checkInput())
267  {
268  $news_item = new ilNewsItem();
269  $news_item->setTitle($form->getInput("news_title"));
270  $news_item->setContent($form->getInput("news_content"));
271  $news_item->setVisibility($form->getInput("news_visibility"));
272  include_once("./Services/News/classes/class.ilNewsItemGUI.php");
274  {
275  $news_item->setContentHtml(true);
276  }
277  //$news_item->setContentLong($form->getInput("news_content_long"));
278  $news_item->setContentLong("");
279 
280  $obj_id = ilObject::_lookupObjectId($this->ref_id);
281  $obj_type = ilObject::_lookupType($obj_id);
282  $news_item->setContextObjId($obj_id);
283  $news_item->setContextObjType($obj_type);
284  $news_item->setUserId($this->user->getId());
285 
286  $news_set = new ilSetting("news");
287  if (!$news_set->get("enable_rss_for_internal"))
288  {
289  $news_item->setVisibility("users");
290  }
291 
292  $news_item->create();
293  }
294  exit;
295  }
ILIAS Setting Class.
static isRteActivated()
Is Rte activated.
user()
Definition: user.php:4
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static getEditForm($a_mode, $a_ref_id)
FORM NewsItem: Init form.
+ Here is the call graph for this function:

◆ setUserEditAll()

ilNewsTimelineGUI::setUserEditAll (   $a_val)

Set user can edit other users postings.

Parameters
bool$a_valuser can edit all postings

Definition at line 85 of file class.ilNewsTimelineGUI.php.

86  {
87  $this->user_edit_all = $a_val;
88  }

◆ show()

ilNewsTimelineGUI::show ( )

Show.

Parameters

Definition at line 135 of file class.ilNewsTimelineGUI.php.

References $d, array, ilJsonUtil\encode(), getDeleteModal(), getEditModal(), ilUtil\getImagePath(), ilLinkButton\getInstance(), ilTimelineGUI\getInstance(), ilNewsTimelineItemGUI\getInstance(), getUserEditAll(), ilMediaPlayerGUI\initJavascript(), and ilUtil\sendInfo().

136  {
137  // toolbar
138  if ($this->access->checkAccess("news_add_news", "", $this->ref_id))
139  {
141  $b->setCaption('news_add_news');
142  $b->setOnClick("return il.News.create();");
143  $b->setPrimary(true);
144  $this->toolbar->addButtonInstance($b);
145  }
146 
147  include_once("./Services/News/classes/class.ilNewsItem.php");
148  $news_item = new ilNewsItem();
149  $news_item->setContextObjId($this->ctrl->getContextObjId());
150  $news_item->setContextObjType($this->ctrl->getContextObjType());
151 
152  $news_data = $news_item->getNewsForRefId($this->ref_id, false, false,
153  0, true, false, !$this->include_auto_entries, false, null, self::$items_per_load);
154 
155  include_once("./Services/News/Timeline/classes/class.ilTimelineGUI.php");
156  include_once("./Services/News/classes/class.ilNewsTimelineItemGUI.php");
157  $timeline = ilTimelineGUI::getInstance();
158 
159  $js_items = array();
160  foreach ($news_data as $d)
161  {
162  $news_item = new ilNewsItem($d["id"]);
163  $item = ilNewsTimelineItemGUI::getInstance($news_item, $d["ref_id"]);
164  $item->setUserEditAll($this->getUserEditAll());
165  $timeline->addItem($item);
166  $js_items[$d["id"]] = array(
167  "id" => $d["id"],
168  "user_id" => $d["user_id"],
169  "title" => $d["title"],
170  "content" => $d["content"].$d["content_long"],
171  "content_long" => "",
172  "priority" => $d["priority"],
173  "visibility" => $d["visibility"],
174  "content_type" => $d["content_type"]
175  );
176  }
177 
178  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
179  $this->tpl->addOnloadCode("il.News.setItems(".ilJsonUtil::encode($js_items).");");
180  $this->tpl->addOnloadCode("il.News.setAjaxUrl('".$this->ctrl->getLinkTarget($this, "", "", true)."');");
181 
182  if (count($news_data) > 0)
183  {
184  $ttpl = new ilTemplate("tpl.news_timeline.html", true, true, "Services/News");
185  $ttpl->setVariable("NEWS", $timeline->render());
186  $ttpl->setVariable("EDIT_MODAL", $this->getEditModal());
187  $ttpl->setVariable("DELETE_MODAL", $this->getDeleteModal());
188  $ttpl->setVariable("LOADER", ilUtil::getImagePath("loader.svg"));
189  $this->tpl->setContent($ttpl->get());
190 
191  }
192  else
193  {
194  ilUtil::sendInfo($this->lng->txt("news_timline_add_entries_info"));
195  $this->tpl->setContent($this->getEditModal());
196  }
197 
198  $this->lng->toJS("create");
199  $this->lng->toJS("edit");
200  $this->lng->toJS("update");
201  $this->lng->toJS("save");
202 
203  $this->tpl->addJavaScript("./Services/News/js/News.js");
204  include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
206  }
static initJavascript($a_tpl=null)
Init Javascript.
for($col=0; $col< 50; $col++) $d
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static encode($mixed, $suppress_native=false)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
getDeleteModal()
Get delete modal.
Create styles array
The data for the language used.
getEditModal()
Get edit modal.
static getInstance()
Get instance.
static getInstance(ilNewsItem $a_news_item, $a_news_ref_id)
Get instance.
getUserEditAll()
Get user can edit other users postings.
+ Here is the call graph for this function:

◆ update()

ilNewsTimelineGUI::update ( )

Update (ajax)

Definition at line 300 of file class.ilNewsTimelineGUI.php.

References $_POST, ilObject\_lookupObjectId(), exit, ilNewsItemGUI\getEditForm(), IL_FORM_EDIT, ilNewsItemGUI\isRteActivated(), and user().

301  {
302  include_once("./Services/News/classes/class.ilNewsItemGUI.php");
303  $form = ilNewsItemGUI::getEditForm(IL_FORM_EDIT, $this->ref_id);
304  if ($form->checkInput())
305  {
306  $news_item = new ilNewsItem((int) $_POST["id"]);
307  $news_item->setTitle($form->getInput("news_title"));
308  $news_item->setContent($form->getInput("news_content"));
309  $news_item->setVisibility($form->getInput("news_visibility"));
310  //$news_item->setContentLong($form->getInput("news_content_long"));
311  include_once("./Services/News/classes/class.ilNewsItemGUI.php");
313  {
314  $news_item->setContentHtml(true);
315  }
316  $news_item->setContentLong("");
317 
318  $obj_id = ilObject::_lookupObjectId($this->ref_id);
319 
320  if ($news_item->getContextObjId() == $obj_id)
321  {
322  $news_item->setUpdateUserId($this->user->getId());
323  $news_item->update();
324  }
325 
326  }
327  exit;
328  }
static isRteActivated()
Is Rte activated.
user()
Definition: user.php:4
static _lookupObjectId($a_ref_id)
lookup object id
static getEditForm($a_mode, $a_ref_id)
FORM NewsItem: Init form.
$_POST["username"]
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilNewsTimelineGUI::$access
protected

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

◆ $ctrl

ilNewsTimelineGUI::$ctrl
protected

Definition at line 17 of file class.ilNewsTimelineGUI.php.

◆ $items_per_load

ilNewsTimelineGUI::$items_per_load = 10
staticprotected

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

◆ $lng

ilNewsTimelineGUI::$lng
protected

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

◆ $ref_id

ilNewsTimelineGUI::$ref_id
protected

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

◆ $toolbar

ilNewsTimelineGUI::$toolbar
protected

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

◆ $tpl

ilNewsTimelineGUI::$tpl
protected

Definition at line 22 of file class.ilNewsTimelineGUI.php.

◆ $user

ilNewsTimelineGUI::$user
protected

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

◆ $user_edit_all

ilNewsTimelineGUI::$user_edit_all = false
protected

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

Referenced by getUserEditAll().


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