ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
ilNewsTimelineGUI Class Reference

Timeline for news. More...

+ Collaboration diagram for ilNewsTimelineGUI:

Public Member Functions

 setEnableAddNews (bool $a_val)
 
 getEnableAddNews ()
 
 setPeriod (int $a_val)
 
 getPeriod ()
 
 setUserEditAll (bool $a_val)
 Set user can edit other users postings. More...
 
 getUserEditAll ()
 Get user can edit other users postings. More...
 
 executeCommand ()
 
 show (?ilPropertyFormGUI $form=null)
 
 save ()
 
 update ()
 
 remove ()
 

Static Public Member Functions

static getInstance (int $a_ref_id, bool $a_include_auto_entries)
 

Protected Member Functions

 __construct (int $a_ref_id, bool $a_include_auto_entries)
 
 readNewsData ($excluded=[])
 
 send (string $output)
 
 updateNewsItem ()
 
 getEditModal ($form=null)
 
 renderDeleteModal (ilTemplate $tpl)
 
 renderEditModal (?ilPropertyFormGUI $form, ilTemplate $tpl)
 
 downloadMob ()
 

Protected Attributes

ILIAS News InternalGUIService $gui
 
int $period = 0
 
ILIAS News Timeline TimelineManager $manager
 
ILIAS DI UIServices $ui
 
ILIAS Notes Service $notes
 
ILIAS HTTP Services $http
 
int $news_id
 
bool $include_auto_entries
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
int $ref_id
 
ilLanguage $lng
 
ilToolbarGUI $toolbar
 
ilObjUser $user
 
ilAccessHandler $access
 
bool $user_edit_all = false
 
StandardGUIRequest $std_request
 
bool $enable_add_news = true
 
NewsCollection $news_collection
 

Static Protected Attributes

static int $items_per_load = 20
 

Detailed Description

Timeline for news.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de @ilCtrl_Calls ilNewsTimelineGUI: ilLikeGUI, ilCommentGUI

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

Constructor & Destructor Documentation

◆ __construct()

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

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

57 {
58 global $DIC;
59
60 $this->ctrl = $DIC->ctrl();
61 $this->tpl = $DIC["tpl"];
62 $this->ref_id = $a_ref_id;
63 $this->lng = $DIC->language();
64 $this->toolbar = $DIC->toolbar();
65 $this->user = $DIC->user();
66 $this->include_auto_entries = $a_include_auto_entries;
67 $this->access = $DIC->access();
68 $this->http = $DIC->http();
69 $this->notes = $DIC->notes();
70
71 $this->std_request = $DIC->news()
72 ->internal()
73 ->gui()
74 ->standardRequest();
75
76 $this->news_id = $this->std_request->getNewsId();
77
78 $this->lng->loadLanguageModule("news");
79 $this->lng->loadLanguageModule("cont");
80 $this->ui = $DIC->ui();
81 $this->manager = $DIC->news()->internal()->domain()->timeline();
82 $this->gui = $DIC->news()->internal()->gui();
83 }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ downloadMob()

ilNewsTimelineGUI::downloadMob ( )
protected

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

494 : void
495 {
496 $news_id = $this->std_request->getNewsId();
497 $news = new ilNewsItem($news_id);
498 $news->deliverMobFile("Standard", true);
499 }
A news item can be created by different sources.

◆ executeCommand()

ilNewsTimelineGUI::executeCommand ( )
Exceptions
ilCtrlException

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

132 : void
133 {
135
136 $next_class = $this->ctrl->getNextClass($this);
137 $cmd = $this->ctrl->getCmd("show");
138
139 switch ($next_class) {
140 case "illikegui":
141 $item = $this->manager->getNewsItem($this->news_id);
142 $likef = new ilLikeFactoryGUI();
143 $like_gui = $likef->widget([$item->getContextObjId()]);
144 $ctrl->saveParameter($this, "news_id");
145 $like_gui->setObject(
146 $item->getContextObjId(),
147 $item->getContextObjType(),
148 $item->getContextSubObjId(),
149 (string) $item->getContextSubObjType(),
150 $this->news_id
151 );
152 $ret = $ctrl->forwardCommand($like_gui);
153 break;
154
155 case strtolower(ilCommentGUI::class):
156 $item = $this->manager->getNewsItem($this->news_id);
157 $ctrl->saveParameter($this, "news_id");
158 $notes_obj_type = ($item->getContextSubObjType() === null)
159 ? $item->getContextObjType()
160 : $item->getContextSubObjType();
161 $comment_gui = $this->notes->gui()->getCommentsGUI(
162 $item->getContextObjId(),
163 $item->getContextSubObjId(),
164 $notes_obj_type,
165 $item->getId()
166 );
167 $comment_gui->setShowHeader(false);
168 $ret = $ctrl->forwardCommand($comment_gui);
169 break;
170
171 default:
172 if (in_array($cmd, ["show", "save", "update", "loadMore", "remove", "updateNewsItem", "downloadMob"])) {
173 $this->$cmd();
174 }
175 }
176 }
saveParameter(object $a_gui_obj, $a_parameter)
@inheritDoc
forwardCommand(object $a_gui_object)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\ctrl(), ilCtrl\forwardCommand(), and ilCtrl\saveParameter().

+ Here is the call graph for this function:

◆ getEditModal()

ilNewsTimelineGUI::getEditModal (   $form = null)
protected

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

447 {
448 if (is_null($form)) {
450 }
451 $form->setShowTopButtons(false);
452 $form->setFormAction($this->ctrl->getFormAction($this));
453
454
455 //
456 $hi = new ilHiddenInputGUI("id");
457 $form->addItem($hi);
458 $act = new ilHiddenInputGUI("news_action");
459 $form->addItem($act);
460 $form->setId("news_edit_form");
461
462 $modal = $this->gui->ui()->factory()->modal()->roundtrip(
463 $this->lng->txt("edit"),
464 $this->ui->factory()->legacy()->content($form->getHTML())
465 );
466
467 return $modal;
468 }
This class represents a hidden form property in a property form.
static getEditForm(int $a_mode, int $a_ref_id)
This describes commonalities between the different modals.
Definition: Modal.php:35

References ILIAS\Repository\ctrl(), ilNewsItemGUI\FORM_EDIT, ilNewsItemGUI\getEditForm(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getEnableAddNews()

ilNewsTimelineGUI::getEnableAddNews ( )

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

90 : bool
91 {
93 }

References $enable_add_news.

◆ getInstance()

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

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

126 return new self($a_ref_id, $a_include_auto_entries);
127 }

Referenced by ilObjCourseGUI\executeCommand(), ilObjGroupGUI\executeCommand(), and ILIAS\News\Dashboard\InternalGUIService\getTimelineGUI().

+ Here is the caller graph for this function:

◆ getPeriod()

ilNewsTimelineGUI::getPeriod ( )

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

100 : int
101 {
102 return $this->period;
103 }

References $period.

◆ getUserEditAll()

ilNewsTimelineGUI::getUserEditAll ( )

Get user can edit other users postings.

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

117 : bool
118 {
120 }

References $user_edit_all.

◆ readNewsData()

ilNewsTimelineGUI::readNewsData (   $excluded = [])
protected

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

183 : void
184 {
185 $this->news_collection = $this->manager->getNewsData(
186 $this->ref_id,
187 $this->ctrl->getContextObjId(),
188 $this->ctrl->getContextObjType(),
189 $this->period,
190 $this->include_auto_entries,
191 self::$items_per_load,
192 $excluded
193 );
194 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ remove()

ilNewsTimelineGUI::remove ( )

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

437 : void
438 {
439 $news_item = new ilNewsItem($this->std_request->getNewsId());
440 if ($this->getUserEditAll() || $this->user->getId() === $news_item->getUserId()) {
441 $news_item->delete();
442 }
443 $this->send("");
444 }
getUserEditAll()
Get user can edit other users postings.

References send(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ renderDeleteModal()

ilNewsTimelineGUI::renderDeleteModal ( ilTemplate  $tpl)
protected

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

470 : void
471 {
472 $mbox = $this->gui->ui()->factory()->messageBox()->confirmation(
473 $this->lng->txt("news_really_delete_news")
474 );
475 $title = $this->gui->ui()->factory()->legacy()->content("<p id='news_delete_news_title'></p>");
476 $modal = $this->gui->modal($this->lng->txt("delete"))
477 ->content([$title, $mbox])
478 ->button($this->lng->txt("delete"), "#", false, "il.News.remove(); return false;");
479 $c = $modal->getTriggerButtonComponents("");
480 $tpl->setVariable("DELETE_MODAL", $this->gui->ui()->renderer()->render($c["modal"]));
481 $tpl->setVariable("SIGNAL_ID", $c["signal"]);
482 }
ilGlobalTemplateInterface $tpl
$c
Definition: deliver.php:25
setVariable(string $variable, $value='')
Sets the given variable to the given value.

References $c, ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderEditModal()

ilNewsTimelineGUI::renderEditModal ( ?ilPropertyFormGUI  $form,
ilTemplate  $tpl 
)
protected

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

484 : void
485 {
486 $edit_modal = $this->getEditModal($form);
487 $signal = $edit_modal->getShowSignal()->getId();
488 $close_signal = $edit_modal->getCloseSignal()->getId();
489 $tpl->setVariable("SHOW_EDIT_SIGNAL", $signal);
490 $tpl->setVariable("CLOSE_EDIT_SIGNAL", $close_signal);
491 $tpl->setVariable("EDIT_MODAL", $this->ui->renderer()->render($edit_modal));
492 }

References HTML_Template_IT\setVariable(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ save()

ilNewsTimelineGUI::save ( )

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

345 : void
346 {
348 if ($form->checkInput()) {
349 $news_item = new ilNewsItem();
350 $news_item->setTitle($form->getInput("news_title"));
351 $news_item->setContent($form->getInput("news_content"));
352 $news_item->setVisibility($form->getInput("news_visibility"));
354 $news_item->setContentHtml(true);
355 }
356 //$news_item->setContentLong($form->getInput("news_content_long"));
357 $news_item->setContentLong("");
358
359 $obj_id = ilObject::_lookupObjectId($this->ref_id);
360 $obj_type = ilObject::_lookupType($obj_id);
361 $news_item->setContextObjId($obj_id);
362 $news_item->setContextObjType($obj_type);
363 $news_item->setUserId($this->user->getId());
364
365 $media = $_FILES["media"];
366 if ($media["name"] != "") {
367 $mob = ilObjMediaObject::_saveTempFileAsMediaObject($media["name"], $media["tmp_name"], true);
368 $news_item->setMobId($mob->getId());
369 }
370
371 $news_set = new ilSetting("news");
372 if (!$news_set->get("enable_rss_for_internal")) {
373 $news_item->setVisibility("users");
374 }
375 $news_item->create();
376 $this->ctrl->redirect($this, "show");
377 } else {
378 $form->setValuesByPost();
379 $this->show($form);
380 $this->tpl->addOnLoadCode("il.News.create(true);");
381 }
382 }
show(?ilPropertyFormGUI $form=null)
static _saveTempFileAsMediaObject(string $name, string $tmp_name, bool $upload=true)
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
ILIAS Setting Class.

References ilObject\_lookupObjectId(), ilObject\_lookupType(), ilObjMediaObject\_saveTempFileAsMediaObject(), ILIAS\Repository\ctrl(), ilNewsItemGUI\FORM_EDIT, ilNewsItemGUI\getEditForm(), ilNewsItemGUI\isRteActivated(), show(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ send()

ilNewsTimelineGUI::send ( string  $output)
protected
Exceptions
ResponseSendingException

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

324 : void
325 {
326 $this->http->saveResponse($this->http->response()->withBody(
327 Streams::ofString($output)
328 ));
329 $this->http->sendResponse();
330 $this->http->close();
331 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ setEnableAddNews()

ilNewsTimelineGUI::setEnableAddNews ( bool  $a_val)

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

85 : void
86 {
87 $this->enable_add_news = $a_val;
88 }

◆ setPeriod()

ilNewsTimelineGUI::setPeriod ( int  $a_val)

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

95 : void
96 {
97 $this->period = $a_val;
98 }

◆ setUserEditAll()

ilNewsTimelineGUI::setUserEditAll ( bool  $a_val)

Set user can edit other users postings.

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

109 : void
110 {
111 $this->user_edit_all = $a_val;
112 }

◆ show()

ilNewsTimelineGUI::show ( ?ilPropertyFormGUI  $form = null)

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

178 : void
179 {
180 $this->tpl->setContent($this->getHTML($form));
181 }

◆ update()

ilNewsTimelineGUI::update ( )

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

387 : void
388 {
390 if ($form->checkInput()) {
391 $news_item = new ilNewsItem($this->std_request->getId());
392 $news_item->setTitle($form->getInput("news_title"));
393 $news_item->setContent($form->getInput("news_content"));
394 $news_item->setVisibility($form->getInput("news_visibility"));
395 //$news_item->setContentLong($form->getInput("news_content_long"));
397 $news_item->setContentHtml(true);
398 }
399 $news_item->setContentLong("");
400
401 $media = $_FILES["media"];
402 $old_mob_id = 0;
403
404 // delete old media object
405 if ($media["name"] != "" || $this->std_request->getDeleteMedia() > 0) {
406 if ($news_item->getMobId() > 0 && ilObject::_lookupType($news_item->getMobId()) === "mob") {
407 $old_mob_id = $news_item->getMobId();
408 }
409 $news_item->setMobId(0);
410 }
411
412 if ($media["name"] != "") {
413 $mob = ilObjMediaObject::_saveTempFileAsMediaObject($media["name"], $media["tmp_name"], true);
414 $news_item->setMobId($mob->getId());
415 }
416
417 $obj_id = ilObject::_lookupObjectId($this->ref_id);
418
419 if ($news_item->getContextObjId() === $obj_id) {
420 $news_item->setUpdateUserId($this->user->getId());
421 $news_item->update();
422
423 if ($old_mob_id > 0) {
424 $old_mob = new ilObjMediaObject($old_mob_id);
425 $old_mob->delete();
426 }
427 }
428 $this->ctrl->redirect($this, "show");
429 } else {
430 $form->setValuesByPost();
431 $this->show($form);
432 $this->tpl->addOnLoadCode("il.News.edit(" . $this->std_request->getNewsId() . ", true);");
433 }
434 }

References ilObject\_lookupObjectId(), ilObject\_lookupType(), ilObjMediaObject\_saveTempFileAsMediaObject(), ILIAS\Repository\ctrl(), ilNewsItemGUI\FORM_EDIT, ilNewsItemGUI\getEditForm(), ilNewsItemGUI\isRteActivated(), show(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ updateNewsItem()

ilNewsTimelineGUI::updateNewsItem ( )
protected

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

333 : void
334 {
335 if ($this->std_request->getNewsAction() === "save") {
336 $this->save();
337 }
338 if ($this->std_request->getNewsAction() === "update") {
339 $this->update();
340 }
341 }

Field Documentation

◆ $access

ilAccessHandler ilNewsTimelineGUI::$access
protected

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

◆ $ctrl

ilCtrl ilNewsTimelineGUI::$ctrl
protected

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

◆ $enable_add_news

bool ilNewsTimelineGUI::$enable_add_news = true
protected

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

Referenced by getEnableAddNews().

◆ $gui

ILIAS News InternalGUIService ilNewsTimelineGUI::$gui
protected

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

◆ $http

ILIAS HTTP Services ilNewsTimelineGUI::$http
protected

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

◆ $include_auto_entries

bool ilNewsTimelineGUI::$include_auto_entries
protected

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

◆ $items_per_load

int ilNewsTimelineGUI::$items_per_load = 20
staticprotected

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

◆ $lng

ilLanguage ilNewsTimelineGUI::$lng
protected

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

◆ $manager

ILIAS News Timeline TimelineManager ilNewsTimelineGUI::$manager
protected

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

◆ $news_collection

NewsCollection ilNewsTimelineGUI::$news_collection
protected

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

◆ $news_id

int ilNewsTimelineGUI::$news_id
protected

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

◆ $notes

ILIAS Notes Service ilNewsTimelineGUI::$notes
protected

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

◆ $period

int ilNewsTimelineGUI::$period = 0
protected

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

Referenced by getPeriod().

◆ $ref_id

int ilNewsTimelineGUI::$ref_id
protected

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

◆ $std_request

StandardGUIRequest ilNewsTimelineGUI::$std_request
protected

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

◆ $toolbar

ilToolbarGUI ilNewsTimelineGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilNewsTimelineGUI::$tpl
protected

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

◆ $ui

ILIAS DI UIServices ilNewsTimelineGUI::$ui
protected

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

◆ $user

ilObjUser ilNewsTimelineGUI::$user
protected

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

◆ $user_edit_all

bool ilNewsTimelineGUI::$user_edit_all = false
protected

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

Referenced by getUserEditAll().


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