ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

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
Definition: saml.php:7

References $DIC, and user().

+ 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.

115 {
116 $next_class = $this->ctrl->getNextClass($this);
117 $cmd = $this->ctrl->getCmd("show");
118
119 switch ($next_class) {
120 default:
121 if (in_array($cmd, array("show", "save", "update", "loadMore", "remove"))) {
122 $this->$cmd();
123 }
124 }
125 }

◆ getDeleteModal()

ilNewsTimelineGUI::getDeleteModal ( )
protected

Get delete modal.

Returns
string modal html

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

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

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

Referenced by show().

+ 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 353 of file class.ilNewsTimelineGUI.php.

354 {
355 include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
356 $modal = ilModalGUI::getInstance();
357 $modal->setHeading($this->lng->txt("edit"));
358 $modal->setId("ilNewsEditModal");
359 $modal->setType(ilModalGUI::TYPE_LARGE);
360
361 include_once("./Services/News/classes/class.ilNewsItemGUI.php");
363 $form->setShowTopButtons(false);
364 $modal->setBody($form->getHTML());
365
366 return $modal->getHTML();
367 }
static getEditForm($a_mode, $a_ref_id)
FORM NewsItem: Init form.
if(isset($_POST['submit'])) $form

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

Referenced by show().

+ 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.

107 {
108 return new self($a_ref_id, $a_include_auto_entries);
109 }

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

+ 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(), and show().

+ Here is the caller graph for this function:

◆ loadMore()

ilNewsTimelineGUI::loadMore ( )

Load more.

Parameters

return

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

217 {
218 include_once("./Services/News/classes/class.ilNewsItem.php");
219 $news_item = new ilNewsItem();
220 $news_item->setContextObjId($this->ctrl->getContextObjId());
221 $news_item->setContextObjType($this->ctrl->getContextObjType());
222
223 $excluded = $_POST["rendered_news"];
224
225 $news_data = $news_item->getNewsForRefId(
226 $this->ref_id,
227 false,
228 false,
229 0,
230 true,
231 false,
232 !$this->include_auto_entries,
233 false,
234 null,
235 self::$items_per_load,
236 $excluded
237 );
238
239 include_once("./Services/News/Timeline/classes/class.ilTimelineGUI.php");
240 include_once("./Services/News/classes/class.ilNewsTimelineItemGUI.php");
241 $timeline = ilTimelineGUI::getInstance();
242
243 $js_items = array();
244 foreach ($news_data as $d) {
245 $news_item = new ilNewsItem($d["id"]);
246 $item = ilNewsTimelineItemGUI::getInstance($news_item, $d["ref_id"]);
247 $item->setUserEditAll($this->getUserEditAll());
248 $timeline->addItem($item);
249 $js_items[$d["id"]] = array(
250 "id" => $d["id"],
251 "user_id" => $d["user_id"],
252 "title" => $d["title"],
253 "content" => $d["content"] . $d["content_long"],
254 "content_long" => "",
255 "priority" => $d["priority"],
256 "visibility" => $d["visibility"],
257 "content_type" => $d["content_type"]
258 );
259 }
260
261 include_once("./Services/JSON/classes/class.ilJsonUtil.php");
262 $obj = new stdClass();
263 $obj->data = $js_items;
264 $obj->html = $timeline->render(true);
265
266 echo ilJsonUtil::encode($obj);
267 exit;
268 }
$_POST["username"]
static encode($mixed, $suppress_native=false)
getUserEditAll()
Get user can edit other users postings.
static getInstance(ilNewsItem $a_news_item, $a_news_ref_id)
Get instance.
static getInstance()
Get instance.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296

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

+ Here is the call graph for this function:

◆ remove()

ilNewsTimelineGUI::remove ( )

Remove (ajax)

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

339 {
340 include_once("./Services/News/classes/class.ilNewsItemGUI.php");
341 $news_item = new ilNewsItem((int) $_POST["id"]);
342 if ($this->user->getId() == $news_item->getUserId() || $this->getUserEditAll()) {
343 $news_item->delete();
344 }
345 exit;
346 }

References $_POST, exit, and user().

+ Here is the call graph for this function:

◆ save()

ilNewsTimelineGUI::save ( )

Save (ajax)

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

275 {
276 include_once("./Services/News/classes/class.ilNewsItemGUI.php");
278 if ($form->checkInput()) {
279 $news_item = new ilNewsItem();
280 $news_item->setTitle($form->getInput("news_title"));
281 $news_item->setContent($form->getInput("news_content"));
282 $news_item->setVisibility($form->getInput("news_visibility"));
283 include_once("./Services/News/classes/class.ilNewsItemGUI.php");
285 $news_item->setContentHtml(true);
286 }
287 //$news_item->setContentLong($form->getInput("news_content_long"));
288 $news_item->setContentLong("");
289
290 $obj_id = ilObject::_lookupObjectId($this->ref_id);
291 $obj_type = ilObject::_lookupType($obj_id);
292 $news_item->setContextObjId($obj_id);
293 $news_item->setContextObjType($obj_type);
294 $news_item->setUserId($this->user->getId());
295
296 $news_set = new ilSetting("news");
297 if (!$news_set->get("enable_rss_for_internal")) {
298 $news_item->setVisibility("users");
299 }
300
301 $news_item->create();
302 }
303 exit;
304 }
static isRteActivated()
Is Rte activated.
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
ILIAS Setting Class.

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

+ 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

return

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

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

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

+ Here is the call graph for this function:

◆ update()

ilNewsTimelineGUI::update ( )

Update (ajax)

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

310 {
311 include_once("./Services/News/classes/class.ilNewsItemGUI.php");
313 if ($form->checkInput()) {
314 $news_item = new ilNewsItem((int) $_POST["id"]);
315 $news_item->setTitle($form->getInput("news_title"));
316 $news_item->setContent($form->getInput("news_content"));
317 $news_item->setVisibility($form->getInput("news_visibility"));
318 //$news_item->setContentLong($form->getInput("news_content_long"));
319 include_once("./Services/News/classes/class.ilNewsItemGUI.php");
321 $news_item->setContentHtml(true);
322 }
323 $news_item->setContentLong("");
324
325 $obj_id = ilObject::_lookupObjectId($this->ref_id);
326
327 if ($news_item->getContextObjId() == $obj_id) {
328 $news_item->setUpdateUserId($this->user->getId());
329 $news_item->update();
330 }
331 }
332 exit;
333 }

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

+ 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: