ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilNewsItemGUI Class Reference

User Interface for NewsItem entities. More...

+ Collaboration diagram for ilNewsItemGUI:

Public Member Functions

 __construct ()
 
 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 ()
 
 createNewsItemCmd ()
 
 editNewsItemCmd ()
 
 getValuesNewsItem (ilPropertyFormGUI $a_form)
 
 saveNewsItemCmd ()
 
 exitSaveNewsItemCmd ()
 
 updateNewsItemCmd ()
 
 exitUpdateNewsItemCmd ()
 
 cancelUpdateNewsItemCmd ()
 
 cancelSaveNewsItemCmd ()
 
 editNewsCmd ()
 
 cancelUpdate ()
 
 confirmDeletionNewsItemsCmd ()
 
 deleteNewsItemsCmd ()
 
 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_CREATE = 2
 

Protected Member Functions

 initFormNewsItem (int $a_mode)
 

Protected Attributes

NewsAccess $news_access
 
ilNewsItem $news_item = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilTabsGUI $tabs
 
ilObjUser $user
 
ilToolbarGUI $toolbar
 
Renderer $renderer
 
Factory $ui_factory
 
ilSetting $setting
 
ServerRequestInterface $http_request
 
ilUIFilterService $filter_service
 
NewsCollectionService $news_collection_service
 
DataFactory $data_factory
 
HttpService $http_service
 
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 $requested_ref_id
 
int $requested_news_item_id
 
string $add_mode
 
StandardGUIRequest $std_request
 

Private Attributes

Refinery $refinery
 
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 40 of file class.ilNewsItemGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilNewsItemGUI::__construct ( )

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

75 {
76 global $DIC;
77 $this->main_tpl = $DIC->ui()->mainTemplate();
78
79 $this->lng = $DIC->language();
80 $this->tabs = $DIC->tabs();
81 $this->user = $DIC->user();
82 $this->toolbar = $DIC->toolbar();
83 $this->ctrl = $DIC->ctrl();
84 $this->renderer = $DIC->ui()->renderer();
85 $this->ui_factory = $DIC->ui()->factory();
86 $this->http_request = $DIC->http()->request();
87 $this->setting = $DIC->settings();
88 $this->filter_service = $DIC->uiService()->filter();
89 $this->news_collection_service = $DIC->news()->internal()->domain()->collection();
90 $this->refinery = $DIC->refinery();
91 $this->http_service = new HttpService($DIC->http(), $this->refinery);
92 $this->data_factory = new DataFactory();
93
94 $this->std_request = $DIC->news()
95 ->internal()
96 ->gui()
97 ->standardRequest();
98
99 $query = $DIC->http()->wrapper()->query();
100
101 $this->requested_ref_id = $this->std_request->getRefId();
102 $this->requested_news_item_id = $query->has('news_item_id')
103 ? $query->retrieve('news_item_id', $this->refinery->kindlyTo()->int())
104 : 0;
105 $this->add_mode = $query->has('add_mode')
106 ? $query->retrieve('add_mode', $this->refinery->kindlyTo()->string())
107 : '';
108
109 $this->news_access = new NewsAccess($this->requested_ref_id);
110
111 if ($this->requested_news_item_id > 0) {
112 $this->news_item = new ilNewsItem($this->requested_news_item_id);
113 }
114
115 $this->ctrl->saveParameter($this, ['news_item_id']);
116
117 // Init EnableEdit.
118 $this->setEnableEdit(false);
119
120 // Init Context.
121 $this->setContextObjId($this->ctrl->getContextObjId());
122 $this->setContextObjType($this->ctrl->getContextObjType());
123 //$this->setContextSubObjId($ilCtrl->getContextSubObjId());
124 //$this->setContextSubObjType($ilCtrl->getContextSubObjType());
125
126 $this->lng->loadLanguageModule('news');
127
128 $this->ctrl->saveParameter($this, 'add_mode');
129 }
renderer()
setContextObjType(string $a_context_obj_type)
setContextObjId(int $a_context_obj_id)
setEnableEdit(bool $a_enable_edit=false)
A news item can be created by different sources.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), renderer(), setContextObjId(), setContextObjType(), setEnableEdit(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ cancelSaveNewsItemCmd()

ilNewsItemGUI::cancelSaveNewsItemCmd ( )

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

440 : void
441 {
442 if ($this->add_mode === 'block') {
443 $this->ctrl->returnToParent($this);
444 return;
445 }
446
447 $this->ctrl->redirect($this, 'editNews');
448 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ cancelUpdate()

ilNewsItemGUI::cancelUpdate ( )

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

490 : string
491 {
492 return $this->editNewsCmd();
493 }

◆ cancelUpdateNewsItemCmd()

ilNewsItemGUI::cancelUpdateNewsItemCmd ( )

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

435 : void
436 {
437 $this->ctrl->redirect($this, 'editNews');
438 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ confirmDeletionNewsItemsCmd()

ilNewsItemGUI::confirmDeletionNewsItemsCmd ( )

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

495 : string
496 {
497 if (!$this->news_access->canAccessManageOverview()) {
498 return '';
499 }
500
501 // check whether at least one item is selected
502 if (count($this->std_request->getNewsIds()) === 0) {
503 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'));
504 return $this->editNewsCmd();
505 }
506
507 $this->tabs->clearTargets();
508
509 $c_gui = new ilConfirmationGUI();
510
511 // set confirm/cancel commands
512 $c_gui->setFormAction($this->ctrl->getFormAction($this, 'deleteNewsItems'));
513 $c_gui->setHeaderText($this->lng->txt('info_delete_sure'));
514 $c_gui->setCancel($this->lng->txt('cancel'), 'editNews');
515 $c_gui->setConfirm($this->lng->txt('confirm'), 'deleteNewsItems');
516
517 // add items to delete
518 foreach ($this->std_request->getNewsIds() as $news_id) {
519 $news = new ilNewsItem($news_id);
520 if ($this->news_access->canDelete($news)) {
521 $c_gui->addItem('news_id[]', $news_id, $news->getTitle());
522 }
523 }
524
525 return $c_gui->getHTML();
526 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ createNewsItemCmd()

ilNewsItemGUI::createNewsItemCmd ( )

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

204 : string
205 {
206 return $this->initFormNewsItem(self::FORM_CREATE)->getHTML();
207 }
initFormNewsItem(int $a_mode)

References initFormNewsItem().

+ Here is the call graph for this function:

◆ deleteNewsItemsCmd()

ilNewsItemGUI::deleteNewsItemsCmd ( )

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

528 : string
529 {
530 if (!$this->news_access->canAccessManageOverview()) {
531 return '';
532 }
533
534 $deleted_count = 0;
535 $failed_count = 0;
536 foreach ($this->std_request->getNewsIds() as $news_id) {
537 $news = new ilNewsItem($news_id);
538 if (!$this->news_access->canDelete($news)) {
539 $failed_count++;
540 continue;
541 }
542
543 try {
544 $news->delete();
545 $deleted_count++;
546 } catch (Exception) {
547 $failed_count++;
548 }
549 }
550
551 if ($deleted_count > 0) {
552 $this->main_tpl->setOnScreenMessage(ilGlobalTemplateInterface::MESSAGE_TYPE_SUCCESS, $this->lng->txt('deleted'), true);
553 }
554 if ($failed_count > 0) {
555 $this->main_tpl->setOnScreenMessage(ilGlobalTemplateInterface::MESSAGE_TYPE_FAILURE, $this->lng->txt('msg_obj_already_deleted'), true);
556 }
557
558 return $this->editNewsCmd();
559 }

References ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_FAILURE, and ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_SUCCESS.

+ Here is the call graph for this function:

◆ editNewsCmd()

ilNewsItemGUI::editNewsCmd ( )

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

450 : string
451 {
452 $this->setTabs();
453
454 if (!$this->news_access->canAccessManageOverview()) {
455 return '';
456 }
457
458 if ($this->news_access->canAdd()) {
459 $this->toolbar->addComponent(
460 $this->ui_factory->button()->standard(
461 $this->lng->txt('news_add_news'),
462 $this->ctrl->getLinkTarget($this, 'createNewsItem')
463 )
464 );
465 }
466
467 $url_builder = new URLBuilder($this->data_factory->uri($this->http_request->getUri()->__toString()));
468
469 $table = new NewsItemTable(
470 $this->ui_factory,
471 $this->lng,
472 $this->http_request,
473 $this->ctrl,
474 $this->setting,
475 $this->renderer,
476 $this->news_access,
477 $this->filter_service,
478 $this->news_collection_service,
479 $this->user,
480 $this->http_service,
481 $this->main_tpl,
482 $this->refinery
483 );
484
485 $table->execute($url_builder);
486
487 return $this->renderer->render($table->getComponents($url_builder));
488 }

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), renderer(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ editNewsItemCmd()

ilNewsItemGUI::editNewsItemCmd ( )

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

209 : string
210 {
211 $form = $this->initFormNewsItem(self::FORM_EDIT);
212 $this->getValuesNewsItem($form);
213 return $form->getHTML();
214 }
getValuesNewsItem(ilPropertyFormGUI $a_form)

References getValuesNewsItem(), and initFormNewsItem().

+ Here is the call graph for this function:

◆ executeCommand()

ilNewsItemGUI::executeCommand ( )

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

131 : string
132 {
133 // check, if news item id belongs to context
134 if (
135 ($this->news_item?->getId() ?? 0) > 0
136 && ilNewsItem::_lookupContextObjId($this->news_item->getId()) !== $this->getContextObjId()
137 ) {
138 throw new ilException('News ID does not match object context.');
139 }
140
141 // get next class and command
142 $next_class = $this->ctrl->getNextClass($this);
143 $cmd = "{$this->ctrl->getCmd()}Cmd";
144
145 switch ($next_class) {
146 default:
147 $html = $this->$cmd();
148 break;
149 }
150
151 return $html;
152 }
Base class for ILIAS Exception handling.
static _lookupContextObjId(int $a_news_id)
Context Object ID.

References ilNewsItem\_lookupContextObjId(), ILIAS\Repository\ctrl(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ exitSaveNewsItemCmd()

ilNewsItemGUI::exitSaveNewsItemCmd ( )

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

365 : void
366 {
367 if ($this->add_mode === 'block') {
368 $this->ctrl->returnToParent($this);
369 } else {
370 $this->ctrl->redirect($this, 'editNews');
371 }
372 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ exitUpdateNewsItemCmd()

ilNewsItemGUI::exitUpdateNewsItemCmd ( )

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

430 : void
431 {
432 $this->ctrl->redirect($this, 'editNews');
433 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getContextObjId()

ilNewsItemGUI::getContextObjId ( )

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

169 : int
170 {
172 }

References $context_obj_id.

◆ getContextObjType()

ilNewsItemGUI::getContextObjType ( )

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

179 : string
180 {
182 }

References $context_obj_type.

◆ getContextSubObjId()

ilNewsItemGUI::getContextSubObjId ( )

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

189 : int
190 {
192 }

References $context_sub_obj_id.

◆ getContextSubObjType()

ilNewsItemGUI::getContextSubObjType ( )

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

199 : string
200 {
202 }

References $context_sub_obj_type.

◆ getEditForm()

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

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

229 global $DIC;
230
231 $lng = $DIC->language();
232
233 $lng->loadLanguageModule('news');
234
235 $form = new ilPropertyFormGUI();
236
237 // Property Title
238 $text_input = new ilTextInputGUI($lng->txt('news_news_item_title'), 'news_title');
239 $text_input->setInfo('');
240 $text_input->setRequired(true);
241 $text_input->setMaxLength(200);
242 $form->addItem($text_input);
243
244 // Property Content
245 $text_area = new ilTextAreaInputGUI($lng->txt('news_news_item_content'), 'news_content');
246 $text_area->setInfo('');
247 $text_area->setRequired(false);
248 $text_area->setRows(4);
249 $form->addItem($text_area);
250
251 // Property Visibility
252 $radio_group = new ilRadioGroupInputGUI($lng->txt('news_news_item_visibility'), 'news_visibility');
253 $radio_option = new ilRadioOption($lng->txt('news_visibility_users'), 'users');
254 $radio_group->addOption($radio_option);
255 $radio_option = new ilRadioOption($lng->txt('news_visibility_public'), 'public');
256 $radio_group->addOption($radio_option);
257 $radio_group->setInfo($lng->txt('news_news_item_visibility_info'));
258 $radio_group->setRequired(false);
259 $radio_group->setValue(ilNewsItem::getDefaultVisibility());
260 $form->addItem($radio_group);
261
262 // media
263 $media = new ilFileInputGUI($lng->txt('news_media'), 'media');
264 $media->setSuffixes(['jpeg', 'jpg', 'png', 'gif', 'mp4', 'mp3', 'pdf']);
265 $media->setRequired(false);
266 $media->setAllowDeletion(true);
267 $media->setValue(' ');
268 $form->addItem($media);
269
270 // save and cancel commands
271 if (in_array($a_mode, [self::FORM_CREATE, self::FORM_RE_CREATE])) {
272 $form->addCommandButton('saveNewsItem', $lng->txt('save'), 'news_btn_create');
273 $form->addCommandButton('cancelSaveNewsItem', $lng->txt('cancel'), 'news_btn_cancel_create');
274 } else {
275 $form->addCommandButton('updateNewsItem', $lng->txt('save'), 'news_btn_update');
276 $form->addCommandButton('cancelUpdateNewsItem', $lng->txt('cancel'), 'news_btn_cancel_update');
277 }
278
279 $form->setTitle($lng->txt('news_news_item_head'));
280
281 $news_set = new ilSetting('news');
282 if (!$news_set->get('enable_rss_for_internal')) {
283 $form->removeItemByPostVar('news_visibility');
284 return $form;
285 }
286
287 $nv = $form->getItemByPostVar('news_visibility');
288 if ($nv instanceof ilRadioGroupInputGUI) {
289 $nv->setValue(ilNewsItem::getDefaultVisibility());
290 }
291
292 return $form;
293 }
This class represents a file property in a property form.
loadLanguageModule(string $a_module)
Load language module.
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getDefaultVisibility()
Get global default visibility for news items.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
ILIAS Setting Class.
This class represents a text area property in a property form.
This class represents a text property in a property form.

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

+ Here is the caller graph for this function:

◆ getEnableEdit()

ilNewsItemGUI::getEnableEdit ( )

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

159 : bool
160 {
161 return $this->enable_edit;
162 }

References $enable_edit.

◆ getValuesNewsItem()

ilNewsItemGUI::getValuesNewsItem ( ilPropertyFormGUI  $a_form)

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

296 : void
297 {
298 $values = [];
299
300 $values['news_title'] = $this->news_item->getTitle();
301 $values['news_content'] = $this->news_item->getContent() . $this->news_item->getContentLong();
302 $values['news_visibility'] = $this->news_item->getVisibility();
303 //$values['news_content_long'] = $this->news_item->getContentLong();
304 $values['news_content_long'] = '';
305
306 $a_form->setValuesByArray($values);
307
308 if ($this->news_item->getMobId() > 0) {
309 $fi = $a_form->getItemByPostVar('media');
310 $fi->setValue(ilObject::_lookupTitle($this->news_item->getMobId()));
311 }
312 }
static _lookupTitle(int $obj_id)
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
getItemByPostVar(string $a_post_var)

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

Referenced by editNewsItemCmd().

+ 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 216 of file class.ilNewsItemGUI.php.

217 {
218 $this->tabs->clearTargets();
219 $form = self::getEditForm($a_mode, $this->requested_ref_id);
220 $form->setFormAction($this->ctrl->getFormAction($this));
221
222 return $form;
223 }
static getEditForm(int $a_mode, int $a_ref_id)

References ILIAS\Repository\ctrl(), getEditForm(), and ILIAS\Repository\tabs().

Referenced by createNewsItemCmd(), and editNewsItemCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRteActivated()

static ilNewsItemGUI::isRteActivated ( )
static

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

570 : bool
571 {
572 return false;
573 }

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

+ Here is the caller graph for this function:

◆ saveNewsItemCmd()

ilNewsItemGUI::saveNewsItemCmd ( )

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

315 : string
316 {
317 if (!$this->news_access->canAdd()) {
318 return '';
319 }
320
321 $form = $this->initFormNewsItem(self::FORM_CREATE);
322 if ($form->checkInput()) {
323 $this->news_item = new ilNewsItem();
324 $this->news_item->setTitle($form->getInput('news_title'));
325 $this->news_item->setContent($form->getInput('news_content'));
326 $this->news_item->setVisibility($form->getInput('news_visibility'));
327
328 $media_paths = $this->getUploadedMediaTempPath();
329 if (isset($media_paths['client_filename'], $media_paths['client_filename'])) {
331 $media_paths['client_filename'],
332 $media_paths['tmp_path'],
333 true
334 );
335 $this->news_item->setMobId($mob->getId());
336 }
337
338 $this->news_item->setContentLong('');
339 if (self::isRteActivated()) {
340 $this->news_item->setContentHtml(true);
341 }
342
343 // changed
344 $this->news_item->setContextObjId($this->getContextObjId());
345 $this->news_item->setContextObjType($this->getContextObjType());
346 $this->news_item->setContextSubObjId($this->getContextSubObjId());
347 $this->news_item->setContextSubObjType($this->getContextSubObjType());
348 $this->news_item->setUserId($this->user->getId());
349
350 $news_set = new ilSetting('news');
351 if (!$news_set->get('enable_rss_for_internal')) {
352 $this->news_item->setVisibility('users');
353 }
354
355 $this->news_item->create();
356 $this->main_tpl->setOnScreenMessage(ilGlobalTemplateInterface::MESSAGE_TYPE_SUCCESS, $this->lng->txt('msg_obj_created'), true);
357 $this->exitSaveNewsItemCmd();
358 } else {
359 $form->setValuesByPost();
360 return $form->getHTML();
361 }
362 return '';
363 }
static _saveTempFileAsMediaObject(string $name, string $tmp_name, bool $upload=true)

References ilObjMediaObject\_saveTempFileAsMediaObject(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_SUCCESS, and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ setContextObjId()

ilNewsItemGUI::setContextObjId ( int  $a_context_obj_id)

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

164 : void
165 {
166 $this->context_obj_id = $a_context_obj_id;
167 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setContextObjType()

ilNewsItemGUI::setContextObjType ( string  $a_context_obj_type)

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

174 : void
175 {
176 $this->context_obj_type = $a_context_obj_type;
177 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setContextSubObjId()

ilNewsItemGUI::setContextSubObjId ( int  $a_context_sub_obj_id)

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

184 : void
185 {
186 $this->context_sub_obj_id = $a_context_sub_obj_id;
187 }

◆ setContextSubObjType()

ilNewsItemGUI::setContextSubObjType ( string  $a_context_sub_obj_type)

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

194 : void
195 {
196 $this->context_sub_obj_type = $a_context_sub_obj_type;
197 }

◆ setEnableEdit()

ilNewsItemGUI::setEnableEdit ( bool  $a_enable_edit = false)

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

154 : void
155 {
156 $this->enable_edit = $a_enable_edit;
157 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setTabs()

ilNewsItemGUI::setTabs ( )

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

561 : void
562 {
563 $this->tabs->clearTargets();
564 $this->tabs->setBackTarget(
565 $this->lng->txt('back'),
566 (string) $this->ctrl->getParentReturn($this)
567 );
568 }

References ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ updateNewsItemCmd()

ilNewsItemGUI::updateNewsItemCmd ( )

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

374 : string
375 {
376 if (!$this->news_access->canEdit($this->news_item)) {
377 return '';
378 }
379
380 $form = $this->initFormNewsItem(self::FORM_EDIT);
381 if ($form->checkInput()) {
382 $this->news_item->setUpdateUserId($this->user->getId());
383 $this->news_item->setTitle($form->getInput('news_title'));
384 $this->news_item->setContent($form->getInput('news_content'));
385 $this->news_item->setVisibility($form->getInput('news_visibility'));
386 //$this->news_item->setContentLong($form->getInput('news_content_long'));
387 $this->news_item->setContentLong('');
388
389 $media_paths = $this->getUploadedMediaTempPath();
390 $media_delete = $this->std_request->getDeleteMedia();
391 $has_new_media_upload = isset($media_paths['client_filename'], $media_paths['client_filename']);
392 $old_mob_id = 0;
393
394 // delete old media object
395 if ($has_new_media_upload || $media_delete) {
396 if ($this->news_item->getMobId() > 0 && ilObject::_lookupType($this->news_item->getMobId()) === 'mob') {
397 $old_mob_id = $this->news_item->getMobId();
398 }
399 $this->news_item->setMobId(0);
400 }
401
402 if ($has_new_media_upload) {
404 $media_paths['client_filename'],
405 $media_paths['tmp_path'],
406 true
407 );
408 $this->news_item->setMobId($mob->getId());
409 }
410
411 if (self::isRteActivated()) {
412 $this->news_item->setContentHtml(true);
413 }
414 $this->news_item->update();
415
416 if ($old_mob_id > 0) {
417 $old_mob = new ilObjMediaObject($old_mob_id);
418 $old_mob->delete();
419 }
420
421 $this->main_tpl->setOnScreenMessage(ilGlobalTemplateInterface::MESSAGE_TYPE_SUCCESS, $this->lng->txt('msg_obj_modified'), true);
422 $this->exitUpdateNewsItemCmd();
423 } else {
424 $form->setValuesByPost();
425 return $form->getHTML();
426 }
427 return '';
428 }
static _lookupType(int $id, bool $reference=false)

References ilObject\_lookupType(), ilObjMediaObject\_saveTempFileAsMediaObject(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_SUCCESS, and ILIAS\Repository\user().

+ Here is the call graph for this function:

Field Documentation

◆ $add_mode

string ilNewsItemGUI::$add_mode
protected

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

◆ $context_obj_id

int ilNewsItemGUI::$context_obj_id = 0
protected

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

Referenced by getContextObjId().

◆ $context_obj_type

string ilNewsItemGUI::$context_obj_type = ''
protected

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

Referenced by getContextObjType().

◆ $context_sub_obj_id

int ilNewsItemGUI::$context_sub_obj_id = 0
protected

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

Referenced by getContextSubObjId().

◆ $context_sub_obj_type

string ilNewsItemGUI::$context_sub_obj_type = ''
protected

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

Referenced by getContextSubObjType().

◆ $ctrl

ilCtrl ilNewsItemGUI::$ctrl
protected

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

◆ $data_factory

DataFactory ilNewsItemGUI::$data_factory
protected

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

◆ $enable_edit

bool ilNewsItemGUI::$enable_edit = false
protected

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

Referenced by getEnableEdit().

◆ $filter_service

ilUIFilterService ilNewsItemGUI::$filter_service
protected

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

◆ $http_request

ServerRequestInterface ilNewsItemGUI::$http_request
protected

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

◆ $http_service

HttpService ilNewsItemGUI::$http_service
protected

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

◆ $lng

ilLanguage ilNewsItemGUI::$lng
protected

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

◆ $main_tpl

ilGlobalTemplateInterface ilNewsItemGUI::$main_tpl
private

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

◆ $news_access

NewsAccess ilNewsItemGUI::$news_access
protected

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

◆ $news_collection_service

NewsCollectionService ilNewsItemGUI::$news_collection_service
protected

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

◆ $news_item

ilNewsItem ilNewsItemGUI::$news_item = null
protected

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

◆ $refinery

Refinery ilNewsItemGUI::$refinery
private

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

◆ $renderer

Renderer ilNewsItemGUI::$renderer
protected

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

◆ $requested_news_item_id

int ilNewsItemGUI::$requested_news_item_id
protected

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

◆ $requested_ref_id

int ilNewsItemGUI::$requested_ref_id
protected

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

◆ $setting

ilSetting ilNewsItemGUI::$setting
protected

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

◆ $std_request

StandardGUIRequest ilNewsItemGUI::$std_request
protected

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

◆ $tabs

ilTabsGUI ilNewsItemGUI::$tabs
protected

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

◆ $toolbar

ilToolbarGUI ilNewsItemGUI::$toolbar
protected

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

◆ $ui_factory

Factory ilNewsItemGUI::$ui_factory
protected

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

◆ $user

ilObjUser ilNewsItemGUI::$user
protected

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

◆ FORM_CREATE

const ilNewsItemGUI::FORM_CREATE = 1

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

◆ FORM_EDIT

const ilNewsItemGUI::FORM_EDIT = 0

◆ FORM_RE_CREATE

const ilNewsItemGUI::FORM_RE_CREATE = 2

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


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