ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilNewsItemGUI Class Reference

User Interface for NewsItem entities. More...

+ Collaboration diagram for ilNewsItemGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getHTML ()
 Get html. More...
 
 executeCommand ()
 Execute command. More...
 
 setEnableEdit ($a_enable_edit=0)
 Set EnableEdit. More...
 
 getEnableEdit ()
 Get EnableEdit. More...
 
 setContextObjId ($a_context_obj_id)
 Set ContextObjId. More...
 
 getContextObjId ()
 Get ContextObjId. More...
 
 setContextObjType ($a_context_obj_type)
 Set ContextObjType. More...
 
 getContextObjType ()
 Get ContextObjType. More...
 
 setContextSubObjId ($a_context_sub_obj_id)
 Set ContextSubObjId. More...
 
 getContextSubObjId ()
 Get ContextSubObjId. More...
 
 setContextSubObjType ($a_context_sub_obj_type)
 Set ContextSubObjType. More...
 
 getContextSubObjType ()
 Get ContextSubObjType. More...
 
 setFormEditMode ($a_form_edit_mode)
 Set FormEditMode. More...
 
 getFormEditMode ()
 Get FormEditMode. More...
 
 createNewsItem ()
 FORM NewsItem: Create NewsItem. More...
 
 editNewsItem ()
 FORM NewsItem: Edit form. More...
 
 getValuesNewsItem (\ilPropertyFormGUI $a_form)
 FORM NewsItem: Get current values for NewsItem form. More...
 
 saveNewsItem ()
 FORM NewsItem: Save NewsItem. More...
 
 exitSaveNewsItem ()
 
 updateNewsItem ()
 FORM NewsItem: Save NewsItem. More...
 
 exitUpdateNewsItem ()
 
 cancelUpdateNewsItem ()
 FORM NewsItem: Save NewsItem. More...
 
 cancelSaveNewsItem ()
 FORM NewsItem: Save NewsItem. More...
 
 editNews ()
 Edit news. More...
 
 cancelUpdate ()
 Cancel update. More...
 
 confirmDeletionNewsItems ()
 Confirmation Screen. More...
 
 deleteNewsItems ()
 Delete news items. More...
 
 getNewsForContextBlock ()
 BLOCK NewsForContext: Get block HTML. More...
 
 getNewsForContextTable ()
 TABLE NewsForContext: Get table HTML. More...
 
 setTabs ()
 Set tabs. More...
 

Static Public Member Functions

static getEditForm ($a_mode, $a_ref_id)
 FORM NewsItem: Init form. More...
 
static isRteActivated ()
 Is Rte activated. More...
 

Protected Member Functions

 initFormNewsItem ($a_mode)
 FORM NewsItem: Init form. More...
 

Protected Attributes

 $ctrl
 
 $lng
 
 $tabs
 
 $user
 
 $toolbar
 
 $enable_edit = 0
 
 $context_obj_id
 
 $context_obj_type
 
 $context_sub_obj_id
 
 $context_sub_obj_type
 
 $form_edit_mode
 

Detailed Description

User Interface for NewsItem entities.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilNewsItemGUI::__construct ( )

Constructor.

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

References $_GET, $DIC, $ilCtrl, $lng, setContextObjId(), setContextObjType(), setContextSubObjId(), setContextSubObjType(), setEnableEdit(), and user().

59  {
60  global $DIC;
61 
62  $this->lng = $DIC->language();
63  $this->tabs = $DIC->tabs();
64  $this->user = $DIC->user();
65  $this->toolbar = $DIC->toolbar();
66  $ilCtrl = $DIC->ctrl();
67  $lng = $DIC->language();
68 
69  $this->ctrl = $ilCtrl;
70 
71  include_once("Services/News/classes/class.ilNewsItem.php");
72  if ($_GET["news_item_id"] > 0) {
73  $this->news_item = new ilNewsItem($_GET["news_item_id"]);
74  }
75 
76  $this->ctrl->saveParameter($this, array("news_item_id"));
77 
78  // Init EnableEdit.
79  $this->setEnableEdit(false);
80 
81  // Init Context.
82  $this->setContextObjId($ilCtrl->getContextObjId());
83  $this->setContextObjType($ilCtrl->getContextObjType());
84  $this->setContextSubObjId($ilCtrl->getContextSubObjId());
85  $this->setContextSubObjType($ilCtrl->getContextSubObjType());
86 
87  $lng->loadLanguageModule("news");
88 
89  $ilCtrl->saveParameter($this, "add_mode");
90  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
setContextObjId($a_context_obj_id)
Set ContextObjId.
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
setContextObjType($a_context_obj_type)
Set ContextObjType.
setEnableEdit($a_enable_edit=0)
Set EnableEdit.
+ Here is the call graph for this function:

Member Function Documentation

◆ cancelSaveNewsItem()

ilNewsItemGUI::cancelSaveNewsItem ( )

FORM NewsItem: Save NewsItem.

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

References $_GET, $ctrl, $ilCtrl, and editNews().

546  {
548 
549  if ($_GET["add_mode"] == "block") {
550  $ilCtrl->returnToParent($this);
551  } else {
552  return $this->editNews();
553  }
554  }
$_GET["client_id"]
editNews()
Edit news.
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ cancelUpdate()

ilNewsItemGUI::cancelUpdate ( )

Cancel update.

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

References editNews().

585  {
586  return $this->editNews();
587  }
editNews()
Edit news.
+ Here is the call graph for this function:

◆ cancelUpdateNewsItem()

ilNewsItemGUI::cancelUpdateNewsItem ( )

FORM NewsItem: Save NewsItem.

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

References editNews().

537  {
538  return $this->editNews();
539  }
editNews()
Edit news.
+ Here is the call graph for this function:

◆ confirmDeletionNewsItems()

ilNewsItemGUI::confirmDeletionNewsItems ( )

Confirmation Screen.

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

References $_POST, $ctrl, $ilCtrl, $lng, $tabs, editNews(), getEnableEdit(), and ilUtil\sendFailure().

593  {
595  $lng = $this->lng;
596  $ilTabs = $this->tabs;
597 
598  if (!$this->getEnableEdit()) {
599  return;
600  }
601 
602  // check whether at least one item is selected
603  if (count($_POST["news_id"]) == 0) {
604  ilUtil::sendFailure($lng->txt("no_checkbox"));
605  return $this->editNews();
606  }
607 
608  $ilTabs->clearTargets();
609 
610  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
611  $c_gui = new ilConfirmationGUI();
612 
613  // set confirm/cancel commands
614  $c_gui->setFormAction($ilCtrl->getFormAction($this, "deleteNewsItems"));
615  $c_gui->setHeaderText($lng->txt("info_delete_sure"));
616  $c_gui->setCancel($lng->txt("cancel"), "editNews");
617  $c_gui->setConfirm($lng->txt("confirm"), "deleteNewsItems");
618 
619  // add items to delete
620  foreach ($_POST["news_id"] as $news_id) {
621  $news = new ilNewsItem($news_id);
622  $c_gui->addItem("news_id[]", $news_id, $news->getTitle());
623  }
624 
625  return $c_gui->getHTML();
626  }
editNews()
Edit news.
getEnableEdit()
Get EnableEdit.
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ createNewsItem()

ilNewsItemGUI::createNewsItem ( )

FORM NewsItem: Create NewsItem.

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

References $form, IL_FORM_CREATE, and initFormNewsItem().

260  {
262  return $form->getHtml();
263  }
initFormNewsItem($a_mode)
FORM NewsItem: Init form.
if(isset($_POST['submit'])) $form
const IL_FORM_CREATE
+ Here is the call graph for this function:

◆ deleteNewsItems()

ilNewsItemGUI::deleteNewsItems ( )

Delete news items.

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

References $_POST, editNews(), and getEnableEdit().

632  {
633  if (!$this->getEnableEdit()) {
634  return;
635  }
636  // delete all selected news items
637  foreach ($_POST["news_id"] as $news_id) {
638  $news = new ilNewsItem($news_id);
639  $news->delete();
640  }
641 
642  return $this->editNews();
643  }
editNews()
Edit news.
getEnableEdit()
Get EnableEdit.
$_POST["username"]
+ Here is the call graph for this function:

◆ editNews()

ilNewsItemGUI::editNews ( )

Edit news.

Returns
html

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

References $ctrl, $ilCtrl, $lng, $tabs, $toolbar, getEnableEdit(), getNewsForContextTable(), and setTabs().

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

562  {
563  $ilTabs = $this->tabs;
564  $ilToolbar = $this->toolbar;
565  $lng = $this->lng;
567 
568  $this->setTabs();
569 
570  $ilToolbar->addButton(
571  $lng->txt("news_add_news"),
572  $ilCtrl->getLinkTarget($this, "createNewsItem")
573  );
574 
575  if (!$this->getEnableEdit()) {
576  return;
577  }
578  return $this->getNewsForContextTable();
579  }
getEnableEdit()
Get EnableEdit.
global $ilCtrl
Definition: ilias.php:18
getNewsForContextTable()
TABLE NewsForContext: Get table HTML.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editNewsItem()

ilNewsItemGUI::editNewsItem ( )

FORM NewsItem: Edit form.

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

References $form, getValuesNewsItem(), IL_FORM_EDIT, and initFormNewsItem().

270  {
272  $this->getValuesNewsItem($form);
273  return $form->getHtml();
274  }
getValuesNewsItem(\ilPropertyFormGUI $a_form)
FORM NewsItem: Get current values for NewsItem form.
initFormNewsItem($a_mode)
FORM NewsItem: Init form.
if(isset($_POST['submit'])) $form
const IL_FORM_EDIT
+ Here is the call graph for this function:

◆ executeCommand()

ilNewsItemGUI::executeCommand ( )

Execute command.

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

References $ctrl, $html, $ilCtrl, ilNewsItem\_lookupContextObjId(), and getContextObjId().

112  {
114 
115  // check, if news item id belongs to context
116  if (is_object($this->news_item) && $this->news_item->getId() > 0
117  && ilNewsItem::_lookupContextObjId($this->news_item->getId()) != $this->getContextObjId()) {
118  throw new ilException("News ID does not match object context.");
119  }
120 
121 
122  // get next class and command
123  $next_class = $this->ctrl->getNextClass($this);
124  $cmd = $this->ctrl->getCmd();
125 
126  switch ($next_class) {
127  default:
128  $html = $this->$cmd();
129  break;
130  }
131 
132  return $html;
133  }
getContextObjId()
Get ContextObjId.
global $ilCtrl
Definition: ilias.php:18
static _lookupContextObjId($a_news_id)
Context Object ID.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ exitSaveNewsItem()

ilNewsItemGUI::exitSaveNewsItem ( )

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

References $_GET, $ctrl, and $ilCtrl.

Referenced by saveNewsItem().

461  {
463 
464  if ($_GET["add_mode"] == "block") {
465  $ilCtrl->returnToParent($this);
466  } else {
467  $ilCtrl->redirect($this, "editNews");
468  }
469  }
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ exitUpdateNewsItem()

ilNewsItemGUI::exitUpdateNewsItem ( )

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

References $ctrl, and $ilCtrl.

Referenced by updateNewsItem().

526  {
528 
529  $ilCtrl->redirect($this, "editNews");
530  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ getContextObjId()

ilNewsItemGUI::getContextObjId ( )

Get ContextObjId.

Returns
int

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

References $context_obj_id.

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

171  {
172  return $this->context_obj_id;
173  }
+ Here is the caller graph for this function:

◆ getContextObjType()

ilNewsItemGUI::getContextObjType ( )

Get ContextObjType.

Returns
int

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

References $context_obj_type.

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

191  {
193  }
+ Here is the caller graph for this function:

◆ getContextSubObjId()

ilNewsItemGUI::getContextSubObjId ( )

Get ContextSubObjId.

Returns
int

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

References $context_sub_obj_id.

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

211  {
213  }
+ Here is the caller graph for this function:

◆ getContextSubObjType()

ilNewsItemGUI::getContextSubObjType ( )

Get ContextSubObjType.

Returns
int

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

References $context_sub_obj_type.

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

231  {
233  }
+ Here is the caller graph for this function:

◆ getEditForm()

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

FORM NewsItem: Init form.

Parameters
int$a_modeForm Edit Mode (IL_FORM_EDIT | IL_FORM_CREATE)
Returns
ilPropertyFormGUI form

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

References $DIC, $form, $lng, ilNewsItem\_getDefaultVisibilityForRefId(), IL_FORM_CREATE, IL_FORM_RE_CREATE, ilRadioOption\setInfo(), ilFormPropertyGUI\setInfo(), and ilFileInputGUI\setSuffixes().

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

301  {
302  global $DIC;
303 
304  $lng = $DIC->language();
305 
306  $lng->loadLanguageModule("news");
307 
308  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
309 
310  $form = new ilPropertyFormGUI();
311 
312  // Property Title
313  $text_input = new ilTextInputGUI($lng->txt("news_news_item_title"), "news_title");
314  $text_input->setInfo("");
315  $text_input->setRequired(true);
316  $text_input->setMaxLength(200);
317  $form->addItem($text_input);
318 
319  // Property Content
320  $text_area = new ilTextAreaInputGUI($lng->txt("news_news_item_content"), "news_content");
321  $text_area->setInfo("");
322  $text_area->setRequired(false);
323  $text_area->setRows("4");
324  $text_area->setUseRte(true);
325  $form->addItem($text_area);
326 
327  // Property Visibility
328  $radio_group = new ilRadioGroupInputGUI($lng->txt("news_news_item_visibility"), "news_visibility");
329  $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "users");
330  $radio_group->addOption($radio_option);
331  $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "public");
332  $radio_group->addOption($radio_option);
333  $radio_group->setInfo($lng->txt("news_news_item_visibility_info"));
334  $radio_group->setRequired(false);
335  $radio_group->setValue("users");
336  $form->addItem($radio_group);
337 
338  // media
339  $media = new ilFileInputGUI($lng->txt('news_media'), 'media');
340  $media->setSuffixes(array("jpeg", "jpg", "png", "gif", "mp4", "mp3"));
341  $media->setRequired(false);
342  $media->setALlowDeletion(true);
343  $media->setValue(" ");
344  $form->addItem($media);
345 
346  // Property ContentLong
347  /*
348  $text_area = new ilTextAreaInputGUI($lng->txt("news_news_item_content_long"), "news_content_long");
349  $text_area->setInfo($lng->txt("news_news_item_content_long_info"));
350  $text_area->setRequired(false);
351  $text_area->setCols("40");
352  $text_area->setRows("8");
353  $text_area->setUseRte(true);
354  $form->addItem($text_area);*/
355 
356 
357  // save and cancel commands
358  if (in_array($a_mode, array(IL_FORM_CREATE,IL_FORM_RE_CREATE))) {
359  $form->addCommandButton("saveNewsItem", $lng->txt("save"), "news_btn_create");
360  $form->addCommandButton("cancelSaveNewsItem", $lng->txt("cancel"), "news_btn_cancel_create");
361  } else {
362  $form->addCommandButton("updateNewsItem", $lng->txt("save"), "news_btn_update");
363  $form->addCommandButton("cancelUpdateNewsItem", $lng->txt("cancel"), "news_btn_cancel_update");
364  }
365 
366  $form->setTitle($lng->txt("news_news_item_head"));
367 
368  $news_set = new ilSetting("news");
369  if (!$news_set->get("enable_rss_for_internal")) {
370  $form->removeItemByPostVar("news_visibility");
371  } else {
372  $nv = $form->getItemByPostVar("news_visibility");
373  if (is_object($nv)) {
374  $nv->setValue(ilNewsItem::_getDefaultVisibilityForRefId($a_ref_id));
375  }
376  }
377 
378  return $form;
379  }
This class represents an option in a radio group.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
This class represents a file property in a property form.
setInfo($a_info)
Set Info.
setInfo($a_info)
Set Information Text.
This class represents a property in a property form.
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
This class represents a text area property in a property form.
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
const IL_FORM_RE_CREATE
const IL_FORM_CREATE
setSuffixes($a_suffixes)
Set Accepted Suffixes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEnableEdit()

ilNewsItemGUI::getEnableEdit ( )

Get EnableEdit.

Returns
boolean Edit mode on/off

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

References $enable_edit.

Referenced by confirmDeletionNewsItems(), deleteNewsItems(), editNews(), getNewsForContextBlock(), saveNewsItem(), and updateNewsItem().

151  {
152  return $this->enable_edit;
153  }
+ Here is the caller graph for this function:

◆ getFormEditMode()

ilNewsItemGUI::getFormEditMode ( )

Get FormEditMode.

Returns
int Form Edit Mode (IL_FORM_EDIT | IL_FORM_CREATE | IL_FORM_RE_EDIT | IL_FORM_RE_CREATE)

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

References $form_edit_mode.

251  {
252  return $this->form_edit_mode;
253  }

◆ getHTML()

ilNewsItemGUI::getHTML ( )

Get html.

Returns
string html

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

References $ctrl, $ilCtrl, $lng, and getNewsForContextBlock().

98  {
99  $lng = $this->lng;
101 
102  $lng->LoadLanguageModule("news");
103 
104  return $this->getNewsForContextBlock();
105  }
getNewsForContextBlock()
BLOCK NewsForContext: Get block HTML.
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ getNewsForContextBlock()

ilNewsItemGUI::getNewsForContextBlock ( )

BLOCK NewsForContext: Get block HTML.

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

References $data, $lng, getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), and getEnableEdit().

Referenced by getHTML().

650  {
651  $lng = $this->lng;
652 
653  include_once("Services/News/classes/class.ilNewsForContextBlockGUI.php");
654  $block_gui = new ilNewsForContextBlockGUI(get_class($this));
655 
656  $block_gui->setParentClass("ilinfoscreengui");
657  $block_gui->setParentCmd("showSummary");
658  $block_gui->setEnableEdit($this->getEnableEdit());
659 
660 
661  $news_item = new ilNewsItem();
662 
663  // changed
664  //$news_item->setContextObjId($this->ctrl->getContextObjId());
665  //$news_item->setContextObjType($this->ctrl->getContextObjType());
666  $news_item->setContextObjId($this->getContextObjId());
667  $news_item->setContextObjType($this->getContextObjType());
668  $news_item->setContextSubObjId($this->getContextSubObjId());
669  $news_item->setContextSubObjType($this->getContextSubObjType());
670 
671  $data = $news_item->queryNewsForContext();
672 
673  $block_gui->setTitle($lng->txt("news_block_news_for_context"));
674  $block_gui->setRowTemplate("tpl.block_row_news_for_context.html", "Services/News");
675  $block_gui->setData($data);
676 
677  return $block_gui->getHTML();
678  }
getContextSubObjId()
Get ContextSubObjId.
getContextObjId()
Get ContextObjId.
BlockGUI class for block NewsForContext.
getEnableEdit()
Get EnableEdit.
getContextObjType()
Get ContextObjType.
getContextSubObjType()
Get ContextSubObjType.
$data
Definition: bench.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewsForContextTable()

ilNewsItemGUI::getNewsForContextTable ( )

TABLE NewsForContext: Get table HTML.

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

References $_GET, $data, $lng, getContextObjId(), getContextObjType(), getContextSubObjId(), and getContextSubObjType().

Referenced by editNews().

686  {
687  $lng = $this->lng;
688 
689  $news_item = new ilNewsItem();
690  $news_item->setContextObjId($this->getContextObjId());
691  $news_item->setContextObjType($this->getContextObjType());
692  $news_item->setContextSubObjId($this->getContextSubObjId());
693  $news_item->setContextSubObjType($this->getContextSubObjType());
694 
695  $perm_ref_id = 0;
696  if (in_array($this->getContextObjType(), array("cat", "grp", "crs", "root"))) {
697  $data = $news_item->getNewsForRefId(
698  $_GET["ref_id"],
699  false,
700  false,
701  0,
702  true,
703  false,
704  true,
705  true
706  );
707  } else {
708  $perm_ref_id = $_GET["ref_id"];
709  if ($this->getContextSubObjId() > 0) {
710  $data = $news_item->queryNewsForContext(
711  false,
712  0,
713  "",
714  true,
715  true
716  );
717  } else {
718  $data = $news_item->queryNewsForContext();
719  }
720  }
721 
722  include_once("Services/News/classes/class.ilNewsForContextTableGUI.php");
723  $table_gui = new ilNewsForContextTableGUI($this, "getNewsForContextTable", $perm_ref_id);
724 
725  $table_gui->setTitle($lng->txt("news_table_news_for_context"));
726  $table_gui->setRowTemplate("tpl.table_row_news_for_context.html", "Services/News");
727  $table_gui->setData($data);
728 
729  $table_gui->setDefaultOrderField("creation_date");
730  $table_gui->setDefaultOrderDirection("desc");
731  $table_gui->addMultiCommand("confirmDeletionNewsItems", $lng->txt("delete"));
732  $table_gui->setTitle($lng->txt("news"));
733  $table_gui->setSelectAllCheckbox("news_id");
734 
735 
736  return $table_gui->getHTML();
737  }
getContextSubObjId()
Get ContextSubObjId.
$_GET["client_id"]
getContextObjId()
Get ContextObjId.
getContextObjType()
Get ContextObjType.
getContextSubObjType()
Get ContextSubObjType.
TableGUI class for table NewsForContext.
$data
Definition: bench.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValuesNewsItem()

ilNewsItemGUI::getValuesNewsItem ( \ilPropertyFormGUI  $a_form)

FORM NewsItem: Get current values for NewsItem form.

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

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

Referenced by editNewsItem().

386  {
387  $values = array();
388 
389  $values["news_title"] = $this->news_item->getTitle();
390  $values["news_content"] = $this->news_item->getContent() . $this->news_item->getContentLong();
391  $values["news_visibility"] = $this->news_item->getVisibility();
392  //$values["news_content_long"] = $this->news_item->getContentLong();
393  $values["news_content_long"] = "";
394 
395  $a_form->setValuesByArray($values);
396 
397  if ($this->news_item->getMobId() > 0) {
398  $fi = $a_form->getItemByPostVar("media");
399  $fi->setValue(ilObject::_lookupTitle($this->news_item->getMobId()));
400  }
401  }
static _lookupTitle($a_id)
lookup object title
$values
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormNewsItem()

ilNewsItemGUI::initFormNewsItem (   $a_mode)
protected

FORM NewsItem: Init form.

Parameters
int$a_modeForm Edit Mode (IL_FORM_EDIT | IL_FORM_CREATE)
Returns
ilPropertyFormGUI form

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

References $_GET, $form, and $tabs.

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

284  {
285  $ilTabs = $this->tabs;
286 
287  $ilTabs->clearTargets();
288  $form = self::getEditForm($a_mode, (int) $_GET["ref_id"]);
289  $form->setFormAction($this->ctrl->getFormAction($this));
290 
291  return $form;
292  }
$_GET["client_id"]
if(isset($_POST['submit'])) $form
+ Here is the caller graph for this function:

◆ isRteActivated()

static ilNewsItemGUI::isRteActivated ( )
static

Is Rte activated.

Returns
bool

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

References ilObjAdvancedEditing\_getRichTextEditor().

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

764  {
765  include_once("./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php");
767  return false;
768  }
769  return true;
770  }
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveNewsItem()

ilNewsItemGUI::saveNewsItem ( )

FORM NewsItem: Save NewsItem.

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

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

408  {
410 
411  if (!$this->getEnableEdit()) {
412  return;
413  }
414 
416  if ($form->checkInput()) {
417  $this->news_item = new ilNewsItem();
418  $this->news_item->setTitle($form->getInput("news_title"));
419  $this->news_item->setContent($form->getInput("news_content"));
420  $this->news_item->setVisibility($form->getInput("news_visibility"));
421 
422  // $data = $form->getInput('media');
423  // var_dump($data);
424 
425  $media = $_FILES["media"];
426  if ($media["name"] != "") {
427  $mob = ilObjMediaObject::_saveTempFileAsMediaObject($media["name"], $media["tmp_name"], true);
428  $this->news_item->setMobId($mob->getId());
429  }
430 
431 
432  $this->news_item->setContentLong("");
433  if (self::isRteActivated()) {
434  $this->news_item->setContentHtml(true);
435  }
436  //$this->news_item->setContentLong($form->getInput("news_content_long"));
437 
438  // changed
439  //$this->news_item->setContextObjId($this->ctrl->getContextObjId());
440  //$this->news_item->setContextObjType($this->ctrl->getContextObjType());
441  $this->news_item->setContextObjId($this->getContextObjId());
442  $this->news_item->setContextObjType($this->getContextObjType());
443  $this->news_item->setContextSubObjId($this->getContextSubObjId());
444  $this->news_item->setContextSubObjType($this->getContextSubObjType());
445  $this->news_item->setUserId($ilUser->getId());
446 
447  $news_set = new ilSetting("news");
448  if (!$news_set->get("enable_rss_for_internal")) {
449  $this->news_item->setVisibility("users");
450  }
451 
452  $this->news_item->create();
453  $this->exitSaveNewsItem();
454  } else {
455  $form->setValuesByPost();
456  return $form->getHtml();
457  }
458  }
getContextSubObjId()
Get ContextSubObjId.
getContextObjId()
Get ContextObjId.
getEnableEdit()
Get EnableEdit.
static _saveTempFileAsMediaObject($name, $tmp_name, $upload=true)
Create new media object and update page in db and return new media object.
getContextObjType()
Get ContextObjType.
initFormNewsItem($a_mode)
FORM NewsItem: Init form.
if(isset($_POST['submit'])) $form
getContextSubObjType()
Get ContextSubObjType.
$ilUser
Definition: imgupload.php:18
const IL_FORM_CREATE
+ Here is the call graph for this function:

◆ setContextObjId()

ilNewsItemGUI::setContextObjId (   $a_context_obj_id)

Set ContextObjId.

Parameters
int$a_context_obj_id

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

Referenced by __construct().

161  {
162  $this->context_obj_id = $a_context_obj_id;
163  }
+ Here is the caller graph for this function:

◆ setContextObjType()

ilNewsItemGUI::setContextObjType (   $a_context_obj_type)

Set ContextObjType.

Parameters
int$a_context_obj_type

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

Referenced by __construct().

181  {
182  $this->context_obj_type = $a_context_obj_type;
183  }
+ Here is the caller graph for this function:

◆ setContextSubObjId()

ilNewsItemGUI::setContextSubObjId (   $a_context_sub_obj_id)

Set ContextSubObjId.

Parameters
int$a_context_sub_obj_id

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

Referenced by __construct().

201  {
202  $this->context_sub_obj_id = $a_context_sub_obj_id;
203  }
+ Here is the caller graph for this function:

◆ setContextSubObjType()

ilNewsItemGUI::setContextSubObjType (   $a_context_sub_obj_type)

Set ContextSubObjType.

Parameters
int$a_context_sub_obj_type

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

Referenced by __construct().

221  {
222  $this->context_sub_obj_type = $a_context_sub_obj_type;
223  }
+ Here is the caller graph for this function:

◆ setEnableEdit()

ilNewsItemGUI::setEnableEdit (   $a_enable_edit = 0)

Set EnableEdit.

Parameters
boolean$a_enable_editEdit mode on/off

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

Referenced by __construct().

141  {
142  $this->enable_edit = $a_enable_edit;
143  }
+ Here is the caller graph for this function:

◆ setFormEditMode()

ilNewsItemGUI::setFormEditMode (   $a_form_edit_mode)

Set FormEditMode.

Parameters
int$a_form_edit_modeForm Edit Mode (IL_FORM_EDIT | IL_FORM_CREATE | IL_FORM_RE_EDIT | IL_FORM_RE_CREATE)

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

241  {
242  $this->form_edit_mode = $a_form_edit_mode;
243  }

◆ setTabs()

ilNewsItemGUI::setTabs ( )

Set tabs.

Parameters

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

References $ctrl, $ilCtrl, $lng, and $tabs.

Referenced by editNews().

746  {
747  $ilTabs = $this->tabs;
749  $lng = $this->lng;
750 
751  $ilTabs->clearTargets();
752  $ilTabs->setBackTarget(
753  $lng->txt("back"),
754  $ilCtrl->getParentReturn($this)
755  );
756  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ updateNewsItem()

ilNewsItemGUI::updateNewsItem ( )

FORM NewsItem: Save NewsItem.

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

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

476  {
478 
479  if (!$this->getEnableEdit()) {
480  return "";
481  }
482 
484  if ($form->checkInput()) {
485  $this->news_item->setUpdateUserId($ilUser->getId());
486  $this->news_item->setTitle($form->getInput("news_title"));
487  $this->news_item->setContent($form->getInput("news_content"));
488  $this->news_item->setVisibility($form->getInput("news_visibility"));
489  //$this->news_item->setContentLong($form->getInput("news_content_long"));
490  $this->news_item->setContentLong("");
491 
492  $media = $_FILES["media"];
493  $old_mob_id = 0;
494 
495  // delete old media object
496  if ($media["name"] != "" || $_POST["media_delete"] != "") {
497  if ($this->news_item->getMobId() > 0 && ilObject::_lookupType($this->news_item->getMobId()) == "mob") {
498  $old_mob_id = $this->news_item->getMobId();
499  }
500  $this->news_item->setMobId(0);
501  }
502 
503  if ($media["name"] != "") {
504  $mob = ilObjMediaObject::_saveTempFileAsMediaObject($media["name"], $media["tmp_name"], true);
505  $this->news_item->setMobId($mob->getId());
506  }
507 
508  if (self::isRteActivated()) {
509  $this->news_item->setContentHtml(true);
510  }
511  $this->news_item->update();
512 
513  if ($old_mob_id > 0) {
514  $old_mob = new ilObjMediaObject($old_mob_id);
515  $old_mob->delete();
516  }
517 
518  $this->exitUpdateNewsItem();
519  } else {
520  $form->setValuesByPost();
521  return $form->getHtml();
522  }
523  }
getEnableEdit()
Get EnableEdit.
static _saveTempFileAsMediaObject($name, $tmp_name, $upload=true)
Create new media object and update page in db and return new media object.
initFormNewsItem($a_mode)
FORM NewsItem: Init form.
if(isset($_POST['submit'])) $form
$ilUser
Definition: imgupload.php:18
Class ilObjMediaObject.
const IL_FORM_EDIT
static _lookupType($a_id, $a_reference=false)
lookup object type
$_POST["username"]
+ Here is the call graph for this function:

Field Documentation

◆ $context_obj_id

ilNewsItemGUI::$context_obj_id
protected

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

Referenced by getContextObjId().

◆ $context_obj_type

ilNewsItemGUI::$context_obj_type
protected

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

Referenced by getContextObjType().

◆ $context_sub_obj_id

ilNewsItemGUI::$context_sub_obj_id
protected

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

Referenced by getContextSubObjId().

◆ $context_sub_obj_type

ilNewsItemGUI::$context_sub_obj_type
protected

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

Referenced by getContextSubObjType().

◆ $ctrl

◆ $enable_edit

ilNewsItemGUI::$enable_edit = 0
protected

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

Referenced by getEnableEdit().

◆ $form_edit_mode

ilNewsItemGUI::$form_edit_mode
protected

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

Referenced by getFormEditMode().

◆ $lng

◆ $tabs

ilNewsItemGUI::$tabs
protected

◆ $toolbar

ilNewsItemGUI::$toolbar
protected

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

Referenced by editNews().

◆ $user

ilNewsItemGUI::$user
protected

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

Referenced by saveNewsItem(), and updateNewsItem().


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