ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilNewsItemGUI Class Reference

User Interface for NewsItem entities. More...

+ Collaboration diagram for ilNewsItemGUI:

Public Member Functions

 __construct ()
 
 getHTML ()
 
 executeCommand ()
 
 setEnableEdit (bool $a_enable_edit=false)
 
 getEnableEdit ()
 
 setContextObjId (int $a_context_obj_id)
 
 getContextObjId ()
 
 setContextObjType (string $a_context_obj_type)
 
 getContextObjType ()
 
 setContextSubObjId (int $a_context_sub_obj_id)
 
 getContextSubObjId ()
 
 setContextSubObjType (string $a_context_sub_obj_type)
 
 getContextSubObjType ()
 
 createNewsItem ()
 
 editNewsItem ()
 
 getValuesNewsItem (ilPropertyFormGUI $a_form)
 
 saveNewsItem ()
 
 exitSaveNewsItem ()
 
 updateNewsItem ()
 
 exitUpdateNewsItem ()
 
 cancelUpdateNewsItem ()
 
 cancelSaveNewsItem ()
 
 editNews ()
 
 cancelUpdate ()
 
 confirmDeletionNewsItems ()
 
 deleteNewsItems ()
 
 getNewsForContextBlock ()
 
 getNewsForContextTable ()
 
 setTabs ()
 

Static Public Member Functions

static getEditForm (int $a_mode, int $a_ref_id)
 
static isRteActivated ()
 

Data Fields

const FORM_EDIT = 0
 
const FORM_CREATE = 1
 
const FORM_RE_EDIT = 2
 
const FORM_RE_CREATE = 2
 

Protected Member Functions

 initFormNewsItem (int $a_mode)
 

Protected Attributes

NewsAccess $news_access
 
ilNewsItem $news_item
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilTabsGUI $tabs
 
ilObjUser $user
 
ilToolbarGUI $toolbar
 
bool $enable_edit = false
 
int $context_obj_id = 0
 
string $context_obj_type = ""
 
int $context_sub_obj_id = 0
 
string $context_sub_obj_type = ""
 
int $form_edit_mode
 
int $requested_ref_id
 
int $requested_news_item_id
 
string $add_mode
 
StandardGUIRequest $std_request
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

User Interface for NewsItem entities.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilNewsItemGUI::__construct ( )

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

References $DIC, $params, ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilLanguage\loadLanguageModule(), setContextObjId(), setContextObjType(), setEnableEdit(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

55  {
56  global $DIC;
57  $this->main_tpl = $DIC->ui()->mainTemplate();
58 
59  $this->lng = $DIC->language();
60  $this->tabs = $DIC->tabs();
61  $this->user = $DIC->user();
62  $this->toolbar = $DIC->toolbar();
63  $ilCtrl = $DIC->ctrl();
64  $lng = $DIC->language();
65 
66  $this->ctrl = $ilCtrl;
67 
68  $params = $DIC->http()->request()->getQueryParams();
69  $this->requested_ref_id = (int) ($params["ref_id"] ?? 0);
70  $this->requested_news_item_id = (int) ($params["news_item_id"] ?? 0);
71  $this->add_mode = (string) ($params["add_mode"] ?? "");
72  $this->news_access = new NewsAccess($this->requested_ref_id);
73 
74  $this->std_request = new StandardGUIRequest(
75  $DIC->http(),
76  $DIC->refinery()
77  );
78 
79  if ($this->requested_news_item_id > 0) {
80  $this->news_item = new ilNewsItem($this->requested_news_item_id);
81  }
82 
83  $this->ctrl->saveParameter($this, ["news_item_id"]);
84 
85  // Init EnableEdit.
86  $this->setEnableEdit(false);
87 
88  // Init Context.
89  $this->setContextObjId($ilCtrl->getContextObjId());
90  $this->setContextObjType($ilCtrl->getContextObjType());
91  //$this->setContextSubObjId($ilCtrl->getContextSubObjId());
92  //$this->setContextSubObjType($ilCtrl->getContextSubObjType());
93 
94  $lng->loadLanguageModule("news");
95 
96  $ilCtrl->saveParameter($this, "add_mode");
97  }
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: feed.php:28
setContextObjType(string $a_context_obj_type)
setEnableEdit(bool $a_enable_edit=false)
setContextObjId(int $a_context_obj_id)
A news item can be created by different sources.
+ Here is the call graph for this function:

Member Function Documentation

◆ cancelSaveNewsItem()

ilNewsItemGUI::cancelSaveNewsItem ( )

Definition at line 414 of file class.ilNewsItemGUI.php.

References $ctrl, editNews(), and ilCtrl\returnToParent().

414  : string
415  {
416  $ilCtrl = $this->ctrl;
417 
418  if ($this->add_mode === "block") {
419  $ilCtrl->returnToParent($this);
420  } else {
421  return $this->editNews();
422  }
423  return "";
424  }
returnToParent(object $a_gui_obj, string $a_anchor=null)
+ Here is the call graph for this function:

◆ cancelUpdate()

ilNewsItemGUI::cancelUpdate ( )

Definition at line 447 of file class.ilNewsItemGUI.php.

References editNews().

447  : string
448  {
449  return $this->editNews();
450  }
+ Here is the call graph for this function:

◆ cancelUpdateNewsItem()

ilNewsItemGUI::cancelUpdateNewsItem ( )

Definition at line 409 of file class.ilNewsItemGUI.php.

References editNews().

409  : string
410  {
411  return $this->editNews();
412  }
+ Here is the call graph for this function:

◆ confirmDeletionNewsItems()

ilNewsItemGUI::confirmDeletionNewsItems ( )

Definition at line 452 of file class.ilNewsItemGUI.php.

References $ctrl, $lng, $tabs, editNews(), and ilLanguage\txt().

452  : string
453  {
454  $ilCtrl = $this->ctrl;
455  $lng = $this->lng;
456  $ilTabs = $this->tabs;
457 
458  if (!$this->news_access->canAccessManageOverview()) {
459  return "";
460  }
461 
462  // check whether at least one item is selected
463  if (count($this->std_request->getNewsIds()) === 0) {
464  $this->main_tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"));
465  return $this->editNews();
466  }
467 
468  $ilTabs->clearTargets();
469 
470  $c_gui = new ilConfirmationGUI();
471 
472  // set confirm/cancel commands
473  $c_gui->setFormAction($ilCtrl->getFormAction($this, "deleteNewsItems"));
474  $c_gui->setHeaderText($lng->txt("info_delete_sure"));
475  $c_gui->setCancel($lng->txt("cancel"), "editNews");
476  $c_gui->setConfirm($lng->txt("confirm"), "deleteNewsItems");
477 
478  // add items to delete
479  foreach ($this->std_request->getNewsIds() as $news_id) {
480  $news = new ilNewsItem($news_id);
481  if ($this->news_access->canDelete($news)) {
482  $c_gui->addItem("news_id[]", $news_id, $news->getTitle());
483  }
484  }
485 
486  return $c_gui->getHTML();
487  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
A news item can be created by different sources.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ createNewsItem()

ilNewsItemGUI::createNewsItem ( )

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

References initFormNewsItem().

178  : string
179  {
180  $form = $this->initFormNewsItem(self::FORM_CREATE);
181  return $form->getHTML();
182  }
initFormNewsItem(int $a_mode)
+ Here is the call graph for this function:

◆ deleteNewsItems()

ilNewsItemGUI::deleteNewsItems ( )

Definition at line 489 of file class.ilNewsItemGUI.php.

References editNews().

489  : string
490  {
491  if (!$this->news_access->canAccessManageOverview()) {
492  return "";
493  }
494  // delete all selected news items
495  foreach ($this->std_request->getNewsIds() as $news_id) {
496  $news = new ilNewsItem($news_id);
497  if ($this->news_access->canDelete($news)) {
498  $news->delete();
499  }
500  }
501 
502  return $this->editNews();
503  }
A news item can be created by different sources.
+ Here is the call graph for this function:

◆ editNews()

ilNewsItemGUI::editNews ( )

Definition at line 426 of file class.ilNewsItemGUI.php.

References $ctrl, $lng, $toolbar, getNewsForContextTable(), setTabs(), and ilLanguage\txt().

Referenced by cancelSaveNewsItem(), cancelUpdate(), cancelUpdateNewsItem(), confirmDeletionNewsItems(), and deleteNewsItems().

426  : string
427  {
428  $ilToolbar = $this->toolbar;
429  $lng = $this->lng;
430  $ilCtrl = $this->ctrl;
431 
432  $this->setTabs();
433  if (!$this->news_access->canAccessManageOverview()) {
434  return "";
435  }
436 
437  if ($this->news_access->canAdd()) {
438  $ilToolbar->addButton(
439  $lng->txt("news_add_news"),
440  $ilCtrl->getLinkTarget($this, "createNewsItem")
441  );
442  }
443 
444  return $this->getNewsForContextTable();
445  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ilToolbarGUI $toolbar
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editNewsItem()

ilNewsItemGUI::editNewsItem ( )

Definition at line 184 of file class.ilNewsItemGUI.php.

References getValuesNewsItem(), and initFormNewsItem().

184  : string
185  {
186  $form = $this->initFormNewsItem(self::FORM_EDIT);
187  $this->getValuesNewsItem($form);
188  return $form->getHTML();
189  }
getValuesNewsItem(ilPropertyFormGUI $a_form)
initFormNewsItem(int $a_mode)
+ Here is the call graph for this function:

◆ executeCommand()

ilNewsItemGUI::executeCommand ( )

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

References ilNewsItem\_lookupContextObjId(), ILIAS\Repository\ctrl(), and getContextObjId().

106  : string
107  {
108  // check, if news item id belongs to context
109  if (isset($this->news_item) && $this->news_item->getId() > 0
110  && ilNewsItem::_lookupContextObjId($this->news_item->getId()) !== $this->getContextObjId()) {
111  throw new ilException("News ID does not match object context.");
112  }
113 
114 
115  // get next class and command
116  $next_class = $this->ctrl->getNextClass($this);
117  $cmd = $this->ctrl->getCmd();
118 
119  switch ($next_class) {
120  default:
121  $html = $this->$cmd();
122  break;
123  }
124 
125  return $html;
126  }
static _lookupContextObjId(int $a_news_id)
Context Object ID.
+ Here is the call graph for this function:

◆ exitSaveNewsItem()

ilNewsItemGUI::exitSaveNewsItem ( )

Definition at line 339 of file class.ilNewsItemGUI.php.

References $ctrl, and ilCtrl\returnToParent().

Referenced by saveNewsItem().

339  : void
340  {
341  $ilCtrl = $this->ctrl;
342 
343  if ($this->add_mode === "block") {
344  $ilCtrl->returnToParent($this);
345  } else {
346  $ilCtrl->redirect($this, "editNews");
347  }
348  }
returnToParent(object $a_gui_obj, string $a_anchor=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exitUpdateNewsItem()

ilNewsItemGUI::exitUpdateNewsItem ( )

Definition at line 402 of file class.ilNewsItemGUI.php.

References $ctrl, and ilCtrl\redirect().

Referenced by updateNewsItem().

402  : void
403  {
404  $ilCtrl = $this->ctrl;
405 
406  $ilCtrl->redirect($this, "editNews");
407  }
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContextObjId()

ilNewsItemGUI::getContextObjId ( )

Definition at line 143 of file class.ilNewsItemGUI.php.

References $context_obj_id.

Referenced by executeCommand(), getNewsForContextBlock(), getNewsForContextTable(), and saveNewsItem().

143  : int
144  {
145  return $this->context_obj_id;
146  }
+ Here is the caller graph for this function:

◆ getContextObjType()

ilNewsItemGUI::getContextObjType ( )

Definition at line 153 of file class.ilNewsItemGUI.php.

References $context_obj_type.

Referenced by getNewsForContextBlock(), getNewsForContextTable(), and saveNewsItem().

153  : string
154  {
156  }
+ Here is the caller graph for this function:

◆ getContextSubObjId()

ilNewsItemGUI::getContextSubObjId ( )

Definition at line 163 of file class.ilNewsItemGUI.php.

References $context_sub_obj_id.

Referenced by getNewsForContextBlock(), getNewsForContextTable(), and saveNewsItem().

163  : int
164  {
166  }
+ Here is the caller graph for this function:

◆ getContextSubObjType()

ilNewsItemGUI::getContextSubObjType ( )

Definition at line 173 of file class.ilNewsItemGUI.php.

References $context_sub_obj_type.

Referenced by getNewsForContextBlock(), getNewsForContextTable(), and saveNewsItem().

173  : string
174  {
176  }
+ Here is the caller graph for this function:

◆ getEditForm()

static ilNewsItemGUI::getEditForm ( int  $a_mode,
int  $a_ref_id 
)
static

Definition at line 202 of file class.ilNewsItemGUI.php.

References $DIC, ilNewsItem\_getDefaultVisibilityForRefId(), ilLanguage\loadLanguageModule(), ilRadioOption\setInfo(), ilFormPropertyGUI\setInfo(), ilFileInputGUI\setSuffixes(), and ilLanguage\txt().

Referenced by ilNewsTimelineGUI\getEditModal(), ilNewsTimelineGUI\save(), and ilNewsTimelineGUI\update().

206  global $DIC;
207 
208  $lng = $DIC->language();
209 
210  $lng->loadLanguageModule("news");
211 
212  $form = new ilPropertyFormGUI();
213 
214  // Property Title
215  $text_input = new ilTextInputGUI($lng->txt("news_news_item_title"), "news_title");
216  $text_input->setInfo("");
217  $text_input->setRequired(true);
218  $text_input->setMaxLength(200);
219  $form->addItem($text_input);
220 
221  // Property Content
222  $text_area = new ilTextAreaInputGUI($lng->txt("news_news_item_content"), "news_content");
223  $text_area->setInfo("");
224  $text_area->setRequired(false);
225  $text_area->setRows(4);
226  $form->addItem($text_area);
227 
228  // Property Visibility
229  $radio_group = new ilRadioGroupInputGUI($lng->txt("news_news_item_visibility"), "news_visibility");
230  $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "users");
231  $radio_group->addOption($radio_option);
232  $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "public");
233  $radio_group->addOption($radio_option);
234  $radio_group->setInfo($lng->txt("news_news_item_visibility_info"));
235  $radio_group->setRequired(false);
236  $radio_group->setValue("users");
237  $form->addItem($radio_group);
238 
239  // media
240  $media = new ilFileInputGUI($lng->txt('news_media'), 'media');
241  $media->setSuffixes(["jpeg", "jpg", "png", "gif", "mp4", "mp3"]);
242  $media->setRequired(false);
243  $media->setAllowDeletion(true);
244  $media->setValue(" ");
245  $form->addItem($media);
246 
247  // save and cancel commands
248  if (in_array($a_mode, [self::FORM_CREATE, self::FORM_RE_CREATE])) {
249  $form->addCommandButton("saveNewsItem", $lng->txt("save"), "news_btn_create");
250  $form->addCommandButton("cancelSaveNewsItem", $lng->txt("cancel"), "news_btn_cancel_create");
251  } else {
252  $form->addCommandButton("updateNewsItem", $lng->txt("save"), "news_btn_update");
253  $form->addCommandButton("cancelUpdateNewsItem", $lng->txt("cancel"), "news_btn_cancel_update");
254  }
255 
256  $form->setTitle($lng->txt("news_news_item_head"));
257 
258  $news_set = new ilSetting("news");
259  if (!$news_set->get("enable_rss_for_internal")) {
260  $form->removeItemByPostVar("news_visibility");
261  } else {
262  $nv = $form->getItemByPostVar("news_visibility");
263  if (is_object($nv)) {
264  $nv->setValue(ilNewsItem::_getDefaultVisibilityForRefId($a_ref_id));
265  }
266  }
267 
268  return $form;
269  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getDefaultVisibilityForRefId(int $a_ref_id)
Get default visibility for reference id.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a file property in a property form.
setInfo(string $a_info)
setSuffixes(array $a_suffixes)
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: feed.php:28
This class represents a property in a property form.
This class represents a text area property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEnableEdit()

ilNewsItemGUI::getEnableEdit ( )

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

References $enable_edit.

Referenced by getNewsForContextBlock().

133  : bool
134  {
135  return $this->enable_edit;
136  }
+ Here is the caller graph for this function:

◆ getHTML()

ilNewsItemGUI::getHTML ( )

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

References $lng, getNewsForContextBlock(), and ilLanguage\loadLanguageModule().

99  : string
100  {
101  $lng = $this->lng;
102  $lng->loadLanguageModule("news");
103  return $this->getNewsForContextBlock();
104  }
loadLanguageModule(string $a_module)
Load language module.
+ Here is the call graph for this function:

◆ getNewsForContextBlock()

ilNewsItemGUI::getNewsForContextBlock ( )

Definition at line 505 of file class.ilNewsItemGUI.php.

References $data, $lng, getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), getEnableEdit(), ilNewsItem\queryNewsForContext(), ilNewsItem\setContextObjId(), ilNewsItem\setContextObjType(), ilNewsItem\setContextSubObjId(), ilNewsItem\setContextSubObjType(), and ilLanguage\txt().

Referenced by getHTML().

505  : string
506  {
507  $lng = $this->lng;
508 
509  $block_gui = new ilNewsForContextBlockGUI();
510 
511  $block_gui->setEnableEdit($this->getEnableEdit());
512 
513 
514  $news_item = new ilNewsItem();
515 
516  // changed
521 
523 
524  $block_gui->setTitle($lng->txt("news_block_news_for_context"));
525  $block_gui->setRowTemplate("tpl.block_row_news_for_context.html", "Services/News");
526  $block_gui->setData($data);
527 
528  return $block_gui->getHTML();
529  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setContextSubObjId(int $a_context_sub_obj_id)
setContextObjType(string $a_context_obj_type)
BlockGUI class for block NewsForContext.
setContextSubObjType(?string $a_context_sub_obj_type)
setContextObjId(int $a_context_obj_id)
A news item can be created by different sources.
queryNewsForContext(bool $a_for_rss_use=false, $a_time_period=0, string $a_starting_date="", bool $a_no_auto_generated=false, bool $a_oldest_first=false, int $a_limit=0)
Query news for a context.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewsForContextTable()

ilNewsItemGUI::getNewsForContextTable ( )

Definition at line 532 of file class.ilNewsItemGUI.php.

References $data, $lng, $requested_ref_id, getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), ilNewsItem\getNewsForRefId(), ilNewsItem\queryNewsForContext(), ilNewsItem\setContextObjId(), ilNewsItem\setContextObjType(), ilNewsItem\setContextSubObjId(), ilNewsItem\setContextSubObjType(), and ilLanguage\txt().

Referenced by editNews().

532  : string
533  {
534  $lng = $this->lng;
535 
536  $news_item = new ilNewsItem();
541 
542  $perm_ref_id = 0;
543  if (in_array($this->getContextObjType(), ["cat", "grp", "crs", "root"])) {
545  $this->requested_ref_id,
546  false,
547  false,
548  0,
549  true,
550  false,
551  true,
552  true
553  );
554  } else {
555  $perm_ref_id = $this->requested_ref_id;
556  if ($this->getContextSubObjId() > 0) {
558  false,
559  0,
560  "",
561  true,
562  true
563  );
564  } else {
566  }
567  }
568 
569  $table_gui = new ilNewsForContextTableGUI($this, "getNewsForContextTable", $perm_ref_id);
570 
571  $table_gui->setTitle($lng->txt("news_table_news_for_context"));
572  $table_gui->setRowTemplate("tpl.table_row_news_for_context.html", "Services/News");
573  $table_gui->setData($data);
574 
575  $table_gui->setDefaultOrderField("creation_date");
576  $table_gui->setDefaultOrderDirection("desc");
577  $table_gui->addMultiCommand("confirmDeletionNewsItems", $lng->txt("delete"));
578  $table_gui->setTitle($lng->txt("news"));
579  $table_gui->setSelectAllCheckbox("news_id");
580 
581 
582  return $table_gui->getHTML();
583  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setContextSubObjId(int $a_context_sub_obj_id)
getNewsForRefId(int $a_ref_id, bool $a_only_public=false, bool $a_stopnesting=false, $a_time_period=0, bool $a_prevent_aggregation=true, bool $a_forum_group_sequences=false, bool $a_no_auto_generated=false, bool $a_ignore_date_filter=false, int $a_user_id=null, int $a_limit=0, array $a_excluded=[])
Get News For Ref Id.
setContextObjType(string $a_context_obj_type)
setContextSubObjType(?string $a_context_sub_obj_type)
setContextObjId(int $a_context_obj_id)
A news item can be created by different sources.
TableGUI class for table NewsForContext.
queryNewsForContext(bool $a_for_rss_use=false, $a_time_period=0, string $a_starting_date="", bool $a_no_auto_generated=false, bool $a_oldest_first=false, int $a_limit=0)
Query news for a context.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValuesNewsItem()

ilNewsItemGUI::getValuesNewsItem ( ilPropertyFormGUI  $a_form)

Definition at line 272 of file class.ilNewsItemGUI.php.

References ilObject\_lookupTitle(), ilPropertyFormGUI\getItemByPostVar(), and ilPropertyFormGUI\setValuesByArray().

Referenced by editNewsItem().

272  : void
273  {
274  $values = [];
275 
276  $values["news_title"] = $this->news_item->getTitle();
277  $values["news_content"] = $this->news_item->getContent() . $this->news_item->getContentLong();
278  $values["news_visibility"] = $this->news_item->getVisibility();
279  //$values["news_content_long"] = $this->news_item->getContentLong();
280  $values["news_content_long"] = "";
281 
282  $a_form->setValuesByArray($values);
283 
284  if ($this->news_item->getMobId() > 0) {
285  $fi = $a_form->getItemByPostVar("media");
286  $fi->setValue(ilObject::_lookupTitle($this->news_item->getMobId()));
287  }
288  }
getItemByPostVar(string $a_post_var)
static _lookupTitle(int $obj_id)
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormNewsItem()

ilNewsItemGUI::initFormNewsItem ( int  $a_mode)
protected

Definition at line 191 of file class.ilNewsItemGUI.php.

References $tabs, ilTabsGUI\clearTargets(), and ILIAS\Repository\ctrl().

Referenced by createNewsItem(), editNewsItem(), saveNewsItem(), and updateNewsItem().

192  {
193  $ilTabs = $this->tabs;
194 
195  $ilTabs->clearTargets();
196  $form = self::getEditForm($a_mode, $this->requested_ref_id);
197  $form->setFormAction($this->ctrl->getFormAction($this));
198 
199  return $form;
200  }
clearTargets()
clear all targets
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRteActivated()

static ilNewsItemGUI::isRteActivated ( )
static

Definition at line 598 of file class.ilNewsItemGUI.php.

Referenced by ilNewsTimelineGUI\save(), and ilNewsTimelineGUI\update().

598  : bool
599  {
600  return false;
601  }
+ Here is the caller graph for this function:

◆ saveNewsItem()

ilNewsItemGUI::saveNewsItem ( )

Definition at line 291 of file class.ilNewsItemGUI.php.

References $ilUser, $user, ilObjMediaObject\_saveTempFileAsMediaObject(), exitSaveNewsItem(), getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), and initFormNewsItem().

291  : string
292  {
294 
295  if (!$this->news_access->canAdd()) {
296  return "";
297  }
298 
299  $form = $this->initFormNewsItem(self::FORM_CREATE);
300  if ($form->checkInput()) {
301  $this->news_item = new ilNewsItem();
302  $this->news_item->setTitle($form->getInput("news_title"));
303  $this->news_item->setContent($form->getInput("news_content"));
304  $this->news_item->setVisibility($form->getInput("news_visibility"));
305 
306  $media = $_FILES["media"];
307  if ($media["name"] != "") {
308  $mob = ilObjMediaObject::_saveTempFileAsMediaObject($media["name"], $media["tmp_name"], true);
309  $this->news_item->setMobId($mob->getId());
310  }
311 
312 
313  $this->news_item->setContentLong("");
314  if (self::isRteActivated()) {
315  $this->news_item->setContentHtml(true);
316  }
317 
318  // changed
319  $this->news_item->setContextObjId($this->getContextObjId());
320  $this->news_item->setContextObjType($this->getContextObjType());
321  $this->news_item->setContextSubObjId($this->getContextSubObjId());
322  $this->news_item->setContextSubObjType($this->getContextSubObjType());
323  $this->news_item->setUserId($ilUser->getId());
324 
325  $news_set = new ilSetting("news");
326  if (!$news_set->get("enable_rss_for_internal")) {
327  $this->news_item->setVisibility("users");
328  }
329 
330  $this->news_item->create();
331  $this->exitSaveNewsItem();
332  } else {
333  $form->setValuesByPost();
334  return $form->getHTML();
335  }
336  return "";
337  }
static _saveTempFileAsMediaObject(string $name, string $tmp_name, bool $upload=true)
Create new media object and update page in db and return new media object.
A news item can be created by different sources.
initFormNewsItem(int $a_mode)
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ setContextObjId()

ilNewsItemGUI::setContextObjId ( int  $a_context_obj_id)

Definition at line 138 of file class.ilNewsItemGUI.php.

Referenced by __construct().

138  : void
139  {
140  $this->context_obj_id = $a_context_obj_id;
141  }
+ Here is the caller graph for this function:

◆ setContextObjType()

ilNewsItemGUI::setContextObjType ( string  $a_context_obj_type)

Definition at line 148 of file class.ilNewsItemGUI.php.

Referenced by __construct().

148  : void
149  {
150  $this->context_obj_type = $a_context_obj_type;
151  }
+ Here is the caller graph for this function:

◆ setContextSubObjId()

ilNewsItemGUI::setContextSubObjId ( int  $a_context_sub_obj_id)

Definition at line 158 of file class.ilNewsItemGUI.php.

158  : void
159  {
160  $this->context_sub_obj_id = $a_context_sub_obj_id;
161  }

◆ setContextSubObjType()

ilNewsItemGUI::setContextSubObjType ( string  $a_context_sub_obj_type)

Definition at line 168 of file class.ilNewsItemGUI.php.

168  : void
169  {
170  $this->context_sub_obj_type = $a_context_sub_obj_type;
171  }

◆ setEnableEdit()

ilNewsItemGUI::setEnableEdit ( bool  $a_enable_edit = false)

Definition at line 128 of file class.ilNewsItemGUI.php.

Referenced by __construct().

128  : void
129  {
130  $this->enable_edit = $a_enable_edit;
131  }
+ Here is the caller graph for this function:

◆ setTabs()

ilNewsItemGUI::setTabs ( )

Definition at line 585 of file class.ilNewsItemGUI.php.

References $ctrl, $lng, $tabs, and ilLanguage\txt().

Referenced by editNews().

585  : void
586  {
587  $ilTabs = $this->tabs;
588  $ilCtrl = $this->ctrl;
589  $lng = $this->lng;
590 
591  $ilTabs->clearTargets();
592  $ilTabs->setBackTarget(
593  $lng->txt("back"),
594  (string) $ilCtrl->getParentReturn($this)
595  );
596  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateNewsItem()

ilNewsItemGUI::updateNewsItem ( )

Definition at line 350 of file class.ilNewsItemGUI.php.

References $ilUser, $user, ilObject\_lookupType(), ilObjMediaObject\_saveTempFileAsMediaObject(), exitUpdateNewsItem(), and initFormNewsItem().

350  : string
351  {
353 
354  if (!$this->news_access->canEdit($this->news_item)) {
355  return "";
356  }
357 
358  $form = $this->initFormNewsItem(self::FORM_EDIT);
359  if ($form->checkInput()) {
360  $this->news_item->setUpdateUserId($ilUser->getId());
361  $this->news_item->setTitle($form->getInput("news_title"));
362  $this->news_item->setContent($form->getInput("news_content"));
363  $this->news_item->setVisibility($form->getInput("news_visibility"));
364  //$this->news_item->setContentLong($form->getInput("news_content_long"));
365  $this->news_item->setContentLong("");
366 
367  $media = $_FILES["media"];
368  $old_mob_id = 0;
369 
370  // delete old media object
371  $media_delete = $this->std_request->getDeleteMedia();
372  if ($media["name"] != "" || $media_delete != "") {
373  if ($this->news_item->getMobId() > 0 && ilObject::_lookupType($this->news_item->getMobId()) === "mob") {
374  $old_mob_id = $this->news_item->getMobId();
375  }
376  $this->news_item->setMobId(0);
377  }
378 
379  if ($media["name"] != "") {
380  $mob = ilObjMediaObject::_saveTempFileAsMediaObject($media["name"], $media["tmp_name"], true);
381  $this->news_item->setMobId($mob->getId());
382  }
383 
384  if (self::isRteActivated()) {
385  $this->news_item->setContentHtml(true);
386  }
387  $this->news_item->update();
388 
389  if ($old_mob_id > 0) {
390  $old_mob = new ilObjMediaObject($old_mob_id);
391  $old_mob->delete();
392  }
393 
394  $this->exitUpdateNewsItem();
395  } else {
396  $form->setValuesByPost();
397  return $form->getHTML();
398  }
399  return "";
400  }
static _saveTempFileAsMediaObject(string $name, string $tmp_name, bool $upload=true)
Create new media object and update page in db and return new media object.
initFormNewsItem(int $a_mode)
$ilUser
Definition: imgupload.php:34
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Field Documentation

◆ $add_mode

string ilNewsItemGUI::$add_mode
protected

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

◆ $context_obj_id

int ilNewsItemGUI::$context_obj_id = 0
protected

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

Referenced by getContextObjId().

◆ $context_obj_type

string ilNewsItemGUI::$context_obj_type = ""
protected

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

Referenced by getContextObjType().

◆ $context_sub_obj_id

int ilNewsItemGUI::$context_sub_obj_id = 0
protected

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

Referenced by getContextSubObjId().

◆ $context_sub_obj_type

string ilNewsItemGUI::$context_sub_obj_type = ""
protected

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

Referenced by getContextSubObjType().

◆ $ctrl

ilCtrl ilNewsItemGUI::$ctrl
protected

◆ $enable_edit

bool ilNewsItemGUI::$enable_edit = false
protected

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

Referenced by getEnableEdit().

◆ $form_edit_mode

int ilNewsItemGUI::$form_edit_mode
protected

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

◆ $lng

ilLanguage ilNewsItemGUI::$lng
protected

◆ $main_tpl

ilGlobalTemplateInterface ilNewsItemGUI::$main_tpl
private

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

◆ $news_access

NewsAccess ilNewsItemGUI::$news_access
protected

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

◆ $news_item

ilNewsItem ilNewsItemGUI::$news_item
protected

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

◆ $requested_news_item_id

int ilNewsItemGUI::$requested_news_item_id
protected

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

◆ $requested_ref_id

int ilNewsItemGUI::$requested_ref_id
protected

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

Referenced by getNewsForContextTable().

◆ $std_request

StandardGUIRequest ilNewsItemGUI::$std_request
protected

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

◆ $tabs

ilTabsGUI ilNewsItemGUI::$tabs
protected

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

Referenced by confirmDeletionNewsItems(), initFormNewsItem(), and setTabs().

◆ $toolbar

ilToolbarGUI ilNewsItemGUI::$toolbar
protected

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

Referenced by editNews().

◆ $user

ilObjUser ilNewsItemGUI::$user
protected

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

Referenced by saveNewsItem(), and updateNewsItem().

◆ FORM_CREATE

const ilNewsItemGUI::FORM_CREATE = 1

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

◆ FORM_EDIT

const ilNewsItemGUI::FORM_EDIT = 0

◆ FORM_RE_CREATE

const ilNewsItemGUI::FORM_RE_CREATE = 2

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

◆ FORM_RE_EDIT

const ilNewsItemGUI::FORM_RE_EDIT = 2

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


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