5 include_once(
"./Services/News/classes/class.ilNewsItem.php");
7 define(
"IL_FORM_EDIT", 0);
8 define(
"IL_FORM_CREATE", 1);
9 define(
"IL_FORM_RE_EDIT", 2);
10 define(
"IL_FORM_RE_CREATE", 3);
39 include_once(
"Services/News/classes/class.ilNewsItem.php");
40 if (
$_GET[
"news_item_id"] > 0)
45 $this->ctrl->saveParameter($this, array(
"news_item_id"));
56 $lng->loadLanguageModule(
"news");
58 $ilCtrl->saveParameter($this,
"add_mode");
70 $lng->LoadLanguageModule(
"news");
84 $next_class = $this->ctrl->getNextClass($this);
85 $cmd = $this->ctrl->getCmd();
90 $html = $this->
$cmd();
105 $this->enable_edit = $a_enable_edit;
125 $this->context_obj_id = $a_context_obj_id;
145 $this->context_obj_type = $a_context_obj_type;
165 $this->context_sub_obj_id = $a_context_sub_obj_id;
185 $this->context_sub_obj_type = $a_context_sub_obj_type;
205 $this->form_edit_mode = $a_form_edit_mode;
225 return $this->form_gui->getHtml();
236 return $this->form_gui->getHtml();
248 global
$lng, $ilTabs;
250 $ilTabs->clearTargets();
253 $lng->loadLanguageModule(
"news");
255 include(
"Services/Form/classes/class.ilPropertyFormGUI.php");
261 $text_input =
new ilTextInputGUI($lng->txt(
"news_news_item_title"),
"news_title");
263 $text_input->setRequired(
true);
264 $text_input->setMaxLength(200);
265 $this->form_gui->addItem($text_input);
268 $text_area =
new ilTextAreaInputGUI($lng->txt(
"news_news_item_content"),
"news_content");
270 $text_area->setRequired(
false);
271 $this->form_gui->addItem($text_area);
274 $radio_group =
new ilRadioGroupInputGUI($lng->txt(
"news_news_item_visibility"),
"news_visibility");
275 $radio_option =
new ilRadioOption($lng->txt(
"news_visibility_users"),
"users");
276 $radio_group->addOption($radio_option);
277 $radio_option =
new ilRadioOption($lng->txt(
"news_visibility_public"),
"public");
278 $radio_group->addOption($radio_option);
279 $radio_group->
setInfo($lng->txt(
"news_news_item_visibility_info"));
280 $radio_group->setRequired(
false);
281 $radio_group->setValue(
"users");
282 $this->form_gui->addItem($radio_group);
285 $text_area =
new ilTextAreaInputGUI($lng->txt(
"news_news_item_content_long"),
"news_content_long");
286 $text_area->
setInfo($lng->txt(
"news_news_item_content_long_info"));
287 $text_area->setRequired(
false);
288 $text_area->setCols(
"40");
289 $text_area->setRows(
"8");
290 $text_area->setUseRte(
true);
291 $this->form_gui->addItem($text_area);
297 $this->form_gui->addCommandButton(
"saveNewsItem", $lng->txt(
"save"));
298 $this->form_gui->addCommandButton(
"cancelSaveNewsItem", $lng->txt(
"cancel"));
302 $this->form_gui->addCommandButton(
"updateNewsItem", $lng->txt(
"save"));
303 $this->form_gui->addCommandButton(
"cancelUpdateNewsItem", $lng->txt(
"cancel"));
306 $this->form_gui->setTitle($lng->txt(
"news_news_item_head"));
307 $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
310 if (!$news_set->get(
"enable_rss_for_internal"))
312 $this->form_gui->removeItemByPostVar(
"news_visibility");
316 $nv = $this->form_gui->getItemByPostVar(
"news_visibility");
333 $values[
"news_title"] = $this->news_item->getTitle();
334 $values[
"news_content"] = $this->news_item->getContent();
335 $values[
"news_visibility"] = $this->news_item->getVisibility();
336 $values[
"news_content_long"] = $this->news_item->getContentLong();
338 $this->form_gui->setValuesByArray($values);
356 if ($this->form_gui->checkInput())
359 $this->news_item->setTitle($this->form_gui->getInput(
"news_title"));
360 $this->news_item->setContent($this->form_gui->getInput(
"news_content"));
361 $this->news_item->setVisibility($this->form_gui->getInput(
"news_visibility"));
362 $this->news_item->setContentLong($this->form_gui->getInput(
"news_content_long"));
371 $this->news_item->setUserId($ilUser->getId());
374 if (!$news_set->get(
"enable_rss_for_internal"))
376 $this->news_item->setVisibility(
"users");
379 $this->news_item->create();
384 $this->form_gui->setValuesByPost();
385 return $this->form_gui->getHtml();
394 if (
$_GET[
"add_mode"] ==
"block")
396 $ilCtrl->returnToParent($this);
400 $ilCtrl->redirect($this,
"editNews");
416 if ($this->form_gui->checkInput())
419 $this->news_item->setTitle($this->form_gui->getInput(
"news_title"));
420 $this->news_item->setContent($this->form_gui->getInput(
"news_content"));
421 $this->news_item->setVisibility($this->form_gui->getInput(
"news_visibility"));
422 $this->news_item->setContentLong($this->form_gui->getInput(
"news_content_long"));
423 $this->news_item->update();
428 $this->form_gui->setValuesByPost();
429 return $this->form_gui->getHtml();
437 $ilCtrl->redirect($this,
"editNews");
457 if (
$_GET[
"add_mode"] ==
"block")
459 $ilCtrl->returnToParent($this);
478 $ilToolbar->addButton($lng->txt(
"news_add_news"),
479 $ilCtrl->getLinkTarget($this,
"createNewsItem"));
509 if (count(
$_POST[
"news_id"]) == 0)
515 $ilTabs->clearTargets();
517 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
521 $c_gui->setFormAction($ilCtrl->getFormAction($this,
"deleteNewsItems"));
522 $c_gui->setHeaderText($lng->txt(
"info_delete_sure"));
523 $c_gui->setCancel($lng->txt(
"cancel"),
"editNews");
524 $c_gui->setConfirm($lng->txt(
"confirm"),
"deleteNewsItems");
527 foreach(
$_POST[
"news_id"] as $news_id)
530 $c_gui->addItem(
"news_id[]", $news_id, $news->getTitle());
533 return $c_gui->getHTML();
546 foreach(
$_POST[
"news_id"] as $news_id)
563 include_once(
"Services/News/classes/class.ilNewsForContextBlockGUI.php");
566 $block_gui->setParentClass(
"ilinfoscreengui");
567 $block_gui->setParentCmd(
"showSummary");
581 $data = $news_item->queryNewsForContext();
583 $block_gui->setTitle($lng->txt(
"news_block_news_for_context"));
584 $block_gui->setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
585 $block_gui->setData($data);
587 return $block_gui->getHTML();
609 $data = $news_item->getNewsForRefId(
$_GET[
"ref_id"],
false,
false,
610 0,
true,
false,
true,
true);
614 $perm_ref_id =
$_GET[
"ref_id"];
617 $data = $news_item->queryNewsForContext(
false, 0,
622 $data = $news_item->queryNewsForContext();
626 include_once(
"Services/News/classes/class.ilNewsForContextTableGUI.php");
629 $table_gui->setTitle($lng->txt(
"news_table_news_for_context"));
630 $table_gui->setRowTemplate(
"tpl.table_row_news_for_context.html",
"Services/News");
631 $table_gui->setData($data);
633 $table_gui->setDefaultOrderField(
"creation_date");
634 $table_gui->setDefaultOrderDirection(
"desc");
635 $table_gui->addMultiCommand(
"confirmDeletionNewsItems", $lng->txt(
"delete"));
636 $table_gui->setTitle($lng->txt(
"news"));
637 $table_gui->setSelectAllCheckbox(
"news_id");
640 return $table_gui->getHTML();
654 $ilTabs->clearTargets();
655 $ilTabs->setBackTarget($lng->txt(
"back"),
656 $ilCtrl->getParentReturnByClass(
"ilnewsitemgui"));