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.ilNewsItemGen.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));
312 if (!$news_set->get(
"enable_rss_for_internal"))
314 $this->form_gui->removeItemByPostVar(
"news_visibility");
318 $nv = $this->form_gui->getItemByPostVar(
"news_visibility");
335 $values[
"news_title"] = $this->news_item->getTitle();
336 $values[
"news_content"] = $this->news_item->getContent();
337 $values[
"news_visibility"] = $this->news_item->getVisibility();
338 $values[
"news_content_long"] = $this->news_item->getContentLong();
340 $this->form_gui->setValuesByArray($values);
358 if ($this->form_gui->checkInput())
361 $this->news_item->setTitle($this->form_gui->getInput(
"news_title"));
362 $this->news_item->setContent($this->form_gui->getInput(
"news_content"));
363 $this->news_item->setVisibility($this->form_gui->getInput(
"news_visibility"));
364 $this->news_item->setContentLong($this->form_gui->getInput(
"news_content_long"));
373 $this->news_item->setUserId($ilUser->getId());
376 if (!$news_set->get(
"enable_rss_for_internal"))
378 $this->news_item->setVisibility(
"users");
381 $this->news_item->create();
386 $this->form_gui->setValuesByPost();
387 return $this->form_gui->getHtml();
396 if (
$_GET[
"add_mode"] ==
"block")
398 $ilCtrl->returnToParent($this);
402 $ilCtrl->redirect($this,
"editNews");
418 if ($this->form_gui->checkInput())
421 $this->news_item->setTitle($this->form_gui->getInput(
"news_title"));
422 $this->news_item->setContent($this->form_gui->getInput(
"news_content"));
423 $this->news_item->setVisibility($this->form_gui->getInput(
"news_visibility"));
424 $this->news_item->setContentLong($this->form_gui->getInput(
"news_content_long"));
425 $this->news_item->update();
430 $this->form_gui->setValuesByPost();
431 return $this->form_gui->getHtml();
439 $ilCtrl->redirect($this,
"editNews");
459 if (
$_GET[
"add_mode"] ==
"block")
461 $ilCtrl->returnToParent($this);
480 $ilToolbar->addButton($lng->txt(
"news_add_news"),
481 $ilCtrl->getLinkTarget($this,
"createNewsItem"));
511 if (count(
$_POST[
"news_id"]) == 0)
517 $ilTabs->clearTargets();
519 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
523 $c_gui->setFormAction($ilCtrl->getFormAction($this,
"deleteNewsItems"));
524 $c_gui->setHeaderText($lng->txt(
"info_delete_sure"));
525 $c_gui->setCancel($lng->txt(
"cancel"),
"editNews");
526 $c_gui->setConfirm($lng->txt(
"confirm"),
"deleteNewsItems");
529 foreach(
$_POST[
"news_id"] as $news_id)
532 $c_gui->addItem(
"news_id[]", $news_id, $news->getTitle(),
536 return $c_gui->getHTML();
549 foreach(
$_POST[
"news_id"] as $news_id)
566 include_once(
"Services/News/classes/class.ilNewsForContextBlockGUI.php");
569 $block_gui->setParentClass(
"ilinfoscreengui");
570 $block_gui->setParentCmd(
"showSummary");
584 $data = $news_item->queryNewsForContext();
586 $block_gui->setTitle($lng->txt(
"news_block_news_for_context"));
587 $block_gui->setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
588 $block_gui->setData(
$data);
590 return $block_gui->getHTML();
612 $data = $news_item->getNewsForRefId(
$_GET[
"ref_id"],
false,
false,
613 0,
true,
false,
true,
true);
617 $perm_ref_id =
$_GET[
"ref_id"];
620 $data = $news_item->queryNewsForContext(
false, 0,
625 $data = $news_item->queryNewsForContext();
629 include_once(
"Services/News/classes/class.ilNewsForContextTableGUI.php");
632 $table_gui->setTitle($lng->txt(
"news_table_news_for_context"));
633 $table_gui->setRowTemplate(
"tpl.table_row_news_for_context.html",
"Services/News");
634 $table_gui->setData(
$data);
636 $table_gui->setDefaultOrderField(
"creation_date");
637 $table_gui->setDefaultOrderDirection(
"desc");
638 $table_gui->addMultiCommand(
"confirmDeletionNewsItems", $lng->txt(
"delete"));
639 $table_gui->setTitle($lng->txt(
"news"),
"icon_news.gif", $lng->txt(
"news"));
640 $table_gui->setSelectAllCheckbox(
"news_id");
643 return $table_gui->getHTML();
657 $ilTabs->clearTargets();
658 $ilTabs->setBackTarget($lng->txt(
"back"),
659 $ilCtrl->getParentReturnByClass(
"ilnewsitemgui"));