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);
340 $media->
setSuffixes(array(
"jpeg",
"jpg",
"png",
"gif",
"mp4",
"mp3"));
341 $media->setRequired(
false);
342 $media->setALlowDeletion(
true);
343 $media->setValue(
" ");
344 $form->addItem($media);
359 $form->addCommandButton(
"saveNewsItem",
$lng->txt(
"save"),
"news_btn_create");
360 $form->addCommandButton(
"cancelSaveNewsItem",
$lng->txt(
"cancel"),
"news_btn_cancel_create");
362 $form->addCommandButton(
"updateNewsItem",
$lng->txt(
"save"),
"news_btn_update");
363 $form->addCommandButton(
"cancelUpdateNewsItem",
$lng->txt(
"cancel"),
"news_btn_cancel_update");
366 $form->setTitle(
$lng->txt(
"news_news_item_head"));
369 if (!$news_set->get(
"enable_rss_for_internal")) {
370 $form->removeItemByPostVar(
"news_visibility");
372 $nv =
$form->getItemByPostVar(
"news_visibility");
373 if (is_object($nv)) {
389 $values[
"news_title"] = $this->news_item->getTitle();
390 $values[
"news_content"] = $this->news_item->getContent() . $this->news_item->getContentLong();
391 $values[
"news_visibility"] = $this->news_item->getVisibility();
393 $values[
"news_content_long"] =
"";
397 if ($this->news_item->getMobId() > 0) {
416 if (
$form->checkInput()) {
418 $this->news_item->setTitle(
$form->getInput(
"news_title"));
419 $this->news_item->setContent(
$form->getInput(
"news_content"));
420 $this->news_item->setVisibility(
$form->getInput(
"news_visibility"));
425 $media = $_FILES[
"media"];
426 if ($media[
"name"] !=
"") {
428 $this->news_item->setMobId($mob->getId());
432 $this->news_item->setContentLong(
"");
433 if (self::isRteActivated()) {
434 $this->news_item->setContentHtml(
true);
445 $this->news_item->setUserId(
$ilUser->getId());
448 if (!$news_set->get(
"enable_rss_for_internal")) {
449 $this->news_item->setVisibility(
"users");
452 $this->news_item->create();
455 $form->setValuesByPost();
456 return $form->getHtml();
464 if (
$_GET[
"add_mode"] ==
"block") {
465 $ilCtrl->returnToParent($this);
467 $ilCtrl->redirect($this,
"editNews");
484 if (
$form->checkInput()) {
485 $this->news_item->setUpdateUserId(
$ilUser->getId());
486 $this->news_item->setTitle(
$form->getInput(
"news_title"));
487 $this->news_item->setContent(
$form->getInput(
"news_content"));
488 $this->news_item->setVisibility(
$form->getInput(
"news_visibility"));
490 $this->news_item->setContentLong(
"");
492 $media = $_FILES[
"media"];
496 if ($media[
"name"] !=
"" ||
$_POST[
"media_delete"] !=
"") {
497 if ($this->news_item->getMobId() > 0 &&
ilObject::_lookupType($this->news_item->getMobId()) ==
"mob") {
498 $old_mob_id = $this->news_item->getMobId();
500 $this->news_item->setMobId(0);
503 if ($media[
"name"] !=
"") {
505 $this->news_item->setMobId($mob->getId());
508 if (self::isRteActivated()) {
509 $this->news_item->setContentHtml(
true);
511 $this->news_item->update();
513 if ($old_mob_id > 0) {
520 $form->setValuesByPost();
521 return $form->getHtml();
529 $ilCtrl->redirect($this,
"editNews");
549 if (
$_GET[
"add_mode"] ==
"block") {
550 $ilCtrl->returnToParent($this);
570 $ilToolbar->addButton(
571 $lng->txt(
"news_add_news"),
572 $ilCtrl->getLinkTarget($this,
"createNewsItem")
603 if (count(
$_POST[
"news_id"]) == 0) {
608 $ilTabs->clearTargets();
610 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
614 $c_gui->setFormAction(
$ilCtrl->getFormAction($this,
"deleteNewsItems"));
615 $c_gui->setHeaderText(
$lng->txt(
"info_delete_sure"));
616 $c_gui->setCancel(
$lng->txt(
"cancel"),
"editNews");
617 $c_gui->setConfirm(
$lng->txt(
"confirm"),
"deleteNewsItems");
620 foreach (
$_POST[
"news_id"] as $news_id) {
622 $c_gui->addItem(
"news_id[]", $news_id, $news->getTitle());
625 return $c_gui->getHTML();
637 foreach (
$_POST[
"news_id"] as $news_id) {
653 include_once(
"Services/News/classes/class.ilNewsForContextBlockGUI.php");
656 $block_gui->setParentClass(
"ilinfoscreengui");
657 $block_gui->setParentCmd(
"showSummary");
671 $data = $news_item->queryNewsForContext();
673 $block_gui->setTitle(
$lng->txt(
"news_block_news_for_context"));
674 $block_gui->setRowTemplate(
"tpl.block_row_news_for_context.html",
"Services/News");
675 $block_gui->setData(
$data);
677 return $block_gui->getHTML();
697 $data = $news_item->getNewsForRefId(
708 $perm_ref_id =
$_GET[
"ref_id"];
710 $data = $news_item->queryNewsForContext(
718 $data = $news_item->queryNewsForContext();
722 include_once(
"Services/News/classes/class.ilNewsForContextTableGUI.php");
725 $table_gui->setTitle(
$lng->txt(
"news_table_news_for_context"));
726 $table_gui->setRowTemplate(
"tpl.table_row_news_for_context.html",
"Services/News");
727 $table_gui->setData(
$data);
729 $table_gui->setDefaultOrderField(
"creation_date");
730 $table_gui->setDefaultOrderDirection(
"desc");
731 $table_gui->addMultiCommand(
"confirmDeletionNewsItems",
$lng->txt(
"delete"));
732 $table_gui->setTitle(
$lng->txt(
"news"));
733 $table_gui->setSelectAllCheckbox(
"news_id");
736 return $table_gui->getHTML();
751 $ilTabs->clearTargets();
752 $ilTabs->setBackTarget(
754 $ilCtrl->getParentReturn($this)
765 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.
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.
static _lookupTitle($a_id)
lookup object title
BlockGUI class for block NewsForContext.
saveNewsItem()
FORM NewsItem: Save NewsItem.
getEnableEdit()
Get EnableEdit.
getValuesNewsItem(\ilPropertyFormGUI $a_form)
FORM NewsItem: Get current values for NewsItem form.
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.
static _lookupType($a_id, $a_reference=false)
lookup object type
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.