57         $this->main_tpl = $DIC->ui()->mainTemplate();
    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();
    66         $this->
ctrl = $ilCtrl;
    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);
    74         $this->std_request = $DIC->news()
    79         if ($this->requested_news_item_id > 0) {
    80             $this->news_item = 
new ilNewsItem($this->requested_news_item_id);
    83         $this->
ctrl->saveParameter($this, [
"news_item_id"]);
    96         $ilCtrl->saveParameter($this, 
"add_mode");
   109         if (isset($this->news_item) && $this->news_item->getId() > 0
   111             throw new ilException(
"News ID does not match object context.");
   116         $next_class = $this->
ctrl->getNextClass($this);
   117         $cmd = $this->
ctrl->getCmd();
   119         switch ($next_class) {
   121                 $html = $this->$cmd();
   130         $this->enable_edit = $a_enable_edit;
   140         $this->context_obj_id = $a_context_obj_id;
   150         $this->context_obj_type = $a_context_obj_type;
   160         $this->context_sub_obj_id = $a_context_sub_obj_id;
   170         $this->context_sub_obj_type = $a_context_sub_obj_type;
   181         return $form->getHTML();
   188         return $form->getHTML();
   196         $form = self::getEditForm($a_mode, $this->requested_ref_id);
   197         $form->setFormAction($this->
ctrl->getFormAction($this));
   208         $lng = $DIC->language();
   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);
   224         $text_area->setRequired(
false);
   225         $text_area->setRows(4);
   226         $form->addItem($text_area);
   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);
   241         $media->
setSuffixes([
"jpeg", 
"jpg", 
"png", 
"gif", 
"mp4", 
"mp3", 
"pdf"]);
   242         $media->setRequired(
false);
   243         $media->setAllowDeletion(
true);
   244         $media->setValue(
" ");
   245         $form->addItem($media);
   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");
   252             $form->addCommandButton(
"updateNewsItem", $lng->
txt(
"save"), 
"news_btn_update");
   253             $form->addCommandButton(
"cancelUpdateNewsItem", $lng->
txt(
"cancel"), 
"news_btn_cancel_update");
   256         $form->setTitle($lng->
txt(
"news_news_item_head"));
   259         if (!$news_set->get(
"enable_rss_for_internal")) {
   260             $form->removeItemByPostVar(
"news_visibility");
   262             $nv = $form->getItemByPostVar(
"news_visibility");
   263             if (is_object($nv)) {
   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();
   280         $values[
"news_content_long"] = 
"";
   284         if ($this->news_item->getMobId() > 0) {
   295         if (!$this->news_access->canAdd()) {
   300         if ($form->checkInput()) {
   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"));
   306             $media = $_FILES[
"media"];
   307             if ($media[
"name"] != 
"") {
   309                 $this->news_item->setMobId($mob->getId());
   313             $this->news_item->setContentLong(
"");
   314             if (self::isRteActivated()) {
   315                 $this->news_item->setContentHtml(
true);
   323             $this->news_item->setUserId($ilUser->getId());
   326             if (!$news_set->get(
"enable_rss_for_internal")) {
   327                 $this->news_item->setVisibility(
"users");
   330             $this->news_item->create();
   333             $form->setValuesByPost();
   334             return $form->getHTML();
   343         if ($this->add_mode === 
"block") {
   346             $ilCtrl->redirect($this, 
"editNews");
   354         if (!$this->news_access->canEdit($this->news_item)) {
   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"));
   365             $this->news_item->setContentLong(
"");
   367             $media = $_FILES[
"media"];
   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();
   376                 $this->news_item->setMobId(0);
   379             if ($media[
"name"] != 
"") {
   381                 $this->news_item->setMobId($mob->getId());
   384             if (self::isRteActivated()) {
   385                 $this->news_item->setContentHtml(
true);
   387             $this->news_item->update();
   389             if ($old_mob_id > 0) {
   396             $form->setValuesByPost();
   397             return $form->getHTML();
   406         $ilCtrl->
redirect($this, 
"editNews");
   418         if ($this->add_mode === 
"block") {
   433         if (!$this->news_access->canAccessManageOverview()) {
   437         if ($this->news_access->canAdd()) {
   438             $ilToolbar->addButton(
   439                 $lng->
txt(
"news_add_news"),
   440                 $ilCtrl->getLinkTarget($this, 
"createNewsItem")
   458         if (!$this->news_access->canAccessManageOverview()) {
   463         if (count($this->std_request->getNewsIds()) === 0) {
   464             $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
"no_checkbox"));
   468         $ilTabs->clearTargets();
   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");
   479         foreach ($this->std_request->getNewsIds() as $news_id) {
   481             if ($this->news_access->canDelete($news)) {
   482                 $c_gui->addItem(
"news_id[]", $news_id, $news->getTitle());
   486         return $c_gui->getHTML();
   491         if (!$this->news_access->canAccessManageOverview()) {
   495         foreach ($this->std_request->getNewsIds() as $news_id) {
   497             if ($this->news_access->canDelete($news)) {
   524         $block_gui->setTitle($lng->
txt(
"news_block_news_for_context"));
   525         $block_gui->setRowTemplate(
"tpl.block_row_news_for_context.html", 
"components/ILIAS/News");
   526         $block_gui->setData(
$data);
   528         return $block_gui->getHTML();
   545                 $this->requested_ref_id,
   571         $table_gui->setTitle($lng->
txt(
"news_table_news_for_context"));
   572         $table_gui->setRowTemplate(
"tpl.table_row_news_for_context.html", 
"components/ILIAS/News");
   573         $table_gui->setData(
$data);
   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");
   582         return $table_gui->getHTML();
   591         $ilTabs->clearTargets();
   592         $ilTabs->setBackTarget(
   594             (string) $ilCtrl->getParentReturn($this)
 string $context_sub_obj_type
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
int $requested_news_item_id
 
static _getDefaultVisibilityForRefId(int $a_ref_id)
Get default visibility for reference id. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
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...
 
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
 
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
 
setContextSubObjId(int $a_context_sub_obj_id)
 
ilGlobalTemplateInterface $main_tpl
 
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. 
 
User Interface for NewsItem entities. 
 
confirmDeletionNewsItems()
 
setContextObjType(string $a_context_obj_type)
 
loadLanguageModule(string $a_module)
Load language module. 
 
BlockGUI class for block NewsForContext. 
 
getValuesNewsItem(ilPropertyFormGUI $a_form)
 
setContextSubObjType(string $a_context_sub_obj_type)
 
setContextSubObjType(?string $a_context_sub_obj_type)
 
returnToParent(object $a_gui_obj, string $a_anchor=null)
 
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, array $a_exclude=[])
Query news for a context. 
 
static _lookupTitle(int $obj_id)
 
static getEditForm(int $a_mode, int $a_ref_id)
 
setContextObjId(int $a_context_obj_id)
 
setContextObjType(string $a_context_obj_type)
 
clearTargets()
clear all targets 
 
setEnableEdit(bool $a_enable_edit=false)
 
setContextObjId(int $a_context_obj_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
A news item can be created by different sources. 
 
initFormNewsItem(int $a_mode)
 
This class represents a text area property in a property form. 
 
TableGUI class for table NewsForContext. 
 
static _lookupType(int $id, bool $reference=false)
 
static _lookupContextObjId(int $a_news_id)
Context Object ID. 
 
setContextSubObjId(int $a_context_sub_obj_id)
 
StandardGUIRequest $std_request