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);
62 $this->lng = $DIC->language();
63 $this->tabs = $DIC->tabs();
64 $this->
user = $DIC->user();
65 $this->toolbar = $DIC->toolbar();
67 $lng = $DIC->language();
71 include_once(
"Services/News/classes/class.ilNewsItem.php");
72 if (
$_GET[
"news_item_id"] > 0) {
76 $this->ctrl->saveParameter($this,
array(
"news_item_id"));
87 $lng->loadLanguageModule(
"news");
89 $ilCtrl->saveParameter($this,
"add_mode");
102 $lng->LoadLanguageModule(
"news");
116 if (is_object($this->news_item) && $this->news_item->getId() > 0
118 throw new ilException(
"News ID does not match object context.");
123 $next_class = $this->ctrl->getNextClass($this);
124 $cmd = $this->ctrl->getCmd();
126 switch ($next_class) {
128 $html = $this->$cmd();
142 $this->enable_edit = $a_enable_edit;
162 $this->context_obj_id = $a_context_obj_id;
182 $this->context_obj_type = $a_context_obj_type;
202 $this->context_sub_obj_id = $a_context_sub_obj_id;
222 $this->context_sub_obj_type = $a_context_sub_obj_type;
242 $this->form_edit_mode = $a_form_edit_mode;
262 return $form->getHtml();
273 return $form->getHtml();
287 $ilTabs->clearTargets();
288 $form = self::getEditForm($a_mode, (
int)
$_GET[
"ref_id"]);
289 $form->setFormAction($this->ctrl->getFormAction($this));
304 $lng = $DIC->language();
306 $lng->loadLanguageModule(
"news");
308 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
315 $text_input->setRequired(
true);
316 $text_input->setMaxLength(200);
317 $form->addItem($text_input);
322 $text_area->setRequired(
false);
323 $text_area->setRows(
"4");
324 $text_area->setUseRte(
true);
325 $form->addItem($text_area);
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);
351 $form->addCommandButton(
"saveNewsItem",
$lng->txt(
"save"),
"news_btn_create");
352 $form->addCommandButton(
"cancelSaveNewsItem",
$lng->txt(
"cancel"),
"news_btn_cancel_create");
354 $form->addCommandButton(
"updateNewsItem",
$lng->txt(
"save"),
"news_btn_update");
355 $form->addCommandButton(
"cancelUpdateNewsItem",
$lng->txt(
"cancel"),
"news_btn_cancel_update");
358 $form->setTitle(
$lng->txt(
"news_news_item_head"));
361 if (!$news_set->get(
"enable_rss_for_internal")) {
362 $form->removeItemByPostVar(
"news_visibility");
364 $nv =
$form->getItemByPostVar(
"news_visibility");
365 if (is_object($nv)) {
381 $values[
"news_title"] = $this->news_item->getTitle();
382 $values[
"news_content"] = $this->news_item->getContent() . $this->news_item->getContentLong();
383 $values[
"news_visibility"] = $this->news_item->getVisibility();
385 $values[
"news_content_long"] =
"";
387 $a_form->setValuesByArray($values);
403 if (
$form->checkInput()) {
405 $this->news_item->setTitle(
$form->getInput(
"news_title"));
406 $this->news_item->setContent(
$form->getInput(
"news_content"));
407 $this->news_item->setVisibility(
$form->getInput(
"news_visibility"));
408 $this->news_item->setContentLong(
"");
409 if (self::isRteActivated()) {
410 $this->news_item->setContentHtml(
true);
421 $this->news_item->setUserId(
$ilUser->getId());
424 if (!$news_set->get(
"enable_rss_for_internal")) {
425 $this->news_item->setVisibility(
"users");
428 $this->news_item->create();
431 $form->setValuesByPost();
432 return $form->getHtml();
440 if (
$_GET[
"add_mode"] ==
"block") {
441 $ilCtrl->returnToParent($this);
443 $ilCtrl->redirect($this,
"editNews");
460 if (
$form->checkInput()) {
461 $this->news_item->setUpdateUserId(
$ilUser->getId());
462 $this->news_item->setTitle(
$form->getInput(
"news_title"));
463 $this->news_item->setContent(
$form->getInput(
"news_content"));
464 $this->news_item->setVisibility(
$form->getInput(
"news_visibility"));
466 $this->news_item->setContentLong(
"");
467 if (self::isRteActivated()) {
468 $this->news_item->setContentHtml(
true);
470 $this->news_item->update();
473 $form->setValuesByPost();
474 return $form->getHtml();
482 $ilCtrl->redirect($this,
"editNews");
502 if (
$_GET[
"add_mode"] ==
"block") {
503 $ilCtrl->returnToParent($this);
523 $ilToolbar->addButton(
524 $lng->txt(
"news_add_news"),
525 $ilCtrl->getLinkTarget($this,
"createNewsItem")
556 if (count(
$_POST[
"news_id"]) == 0) {
561 $ilTabs->clearTargets();
563 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
567 $c_gui->setFormAction(
$ilCtrl->getFormAction($this,
"deleteNewsItems"));
568 $c_gui->setHeaderText(
$lng->txt(
"info_delete_sure"));
569 $c_gui->setCancel(
$lng->txt(
"cancel"),
"editNews");
570 $c_gui->setConfirm(
$lng->txt(
"confirm"),
"deleteNewsItems");
573 foreach (
$_POST[
"news_id"] as $news_id) {
575 $c_gui->addItem(
"news_id[]", $news_id, $news->getTitle());
578 return $c_gui->getHTML();
590 foreach (
$_POST[
"news_id"] as $news_id) {
606 include_once(
"Services/News/classes/class.ilNewsForContextBlockGUI.php");
609 $block_gui->setParentClass(
"ilinfoscreengui");
610 $block_gui->setParentCmd(
"showSummary");
624 $data = $news_item->queryNewsForContext();
626 $block_gui->setTitle(
$lng->txt(
"news_block_news_for_context"));
627 $block_gui->setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
628 $block_gui->setData(
$data);
630 return $block_gui->getHTML();
650 $data = $news_item->getNewsForRefId(
661 $perm_ref_id =
$_GET[
"ref_id"];
663 $data = $news_item->queryNewsForContext(
671 $data = $news_item->queryNewsForContext();
675 include_once(
"Services/News/classes/class.ilNewsForContextTableGUI.php");
678 $table_gui->setTitle(
$lng->txt(
"news_table_news_for_context"));
679 $table_gui->setRowTemplate(
"tpl.table_row_news_for_context.html",
"Services/News");
680 $table_gui->setData(
$data);
682 $table_gui->setDefaultOrderField(
"creation_date");
683 $table_gui->setDefaultOrderDirection(
"desc");
684 $table_gui->addMultiCommand(
"confirmDeletionNewsItems",
$lng->txt(
"delete"));
685 $table_gui->setTitle(
$lng->txt(
"news"));
686 $table_gui->setSelectAllCheckbox(
"news_id");
689 return $table_gui->getHTML();
704 $ilTabs->clearTargets();
705 $ilTabs->setBackTarget(
707 $ilCtrl->getParentReturnByClass(
"ilnewsitemgui")
718 include_once(
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php");
This class represents an option in a radio group.
getContextSubObjId()
Get ContextSubObjId.
static isRteActivated()
Is Rte activated.
getValuesNewsItem($a_form)
FORM NewsItem: Get current values for NewsItem form.
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
getNewsForContextBlock()
BLOCK NewsForContext: Get block HTML.
setContextObjId($a_context_obj_id)
Set ContextObjId.
getFormEditMode()
Get FormEditMode.
User Interface for NewsItem entities.
confirmDeletionNewsItems()
Confirmation Screen.
getContextObjId()
Get ContextObjId.
BlockGUI class for block NewsForContext.
saveNewsItem()
FORM NewsItem: Save NewsItem.
getEnableEdit()
Get EnableEdit.
setInfo($a_info)
Set Info.
getContextObjType()
Get ContextObjType.
deleteNewsItems()
Delete news items.
cancelUpdateNewsItem()
FORM NewsItem: Save NewsItem.
initFormNewsItem($a_mode)
FORM NewsItem: Init form.
if(isset($_POST['submit'])) $form
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
getContextSubObjType()
Get ContextSubObjType.
This class represents a text property in a property form.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
createNewsItem()
FORM NewsItem: Create NewsItem.
editNewsItem()
FORM NewsItem: Edit form.
getNewsForContextTable()
TABLE NewsForContext: Get table HTML.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a text area property in a property form.
TableGUI class for table NewsForContext.
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
static _lookupContextObjId($a_news_id)
Context Object ID.
cancelSaveNewsItem()
FORM NewsItem: Save NewsItem.
setContextObjType($a_context_obj_type)
Set ContextObjType.
setEnableEdit($a_enable_edit=0)
Set EnableEdit.
static getEditForm($a_mode, $a_ref_id)
FORM NewsItem: Init form.
setFormEditMode($a_form_edit_mode)
Set FormEditMode.
executeCommand()
Execute command.
cancelUpdate()
Cancel update.
Confirmation screen class.
__construct()
Constructor.
updateNewsItem()
FORM NewsItem: Save NewsItem.