67 protected function __construct($a_ref_id, $a_include_auto_entries)
71 $this->ctrl = $DIC->ctrl();
72 $this->tpl = $DIC[
"tpl"];
73 $this->ref_id = $a_ref_id;
74 $this->lng = $DIC->language();
75 $this->toolbar = $DIC->toolbar();
76 $this->
user = $DIC->user();
77 $this->include_auto_entries = $a_include_auto_entries;
78 $this->access = $DIC->access();
80 $this->news_id = (int)
$_GET[
"news_id"];
83 $this->lng->loadLanguageModule(
"news");
93 $this->user_edit_all = $a_val;
112 public static function getInstance($a_ref_id, $a_include_auto_entries)
114 return new self($a_ref_id, $a_include_auto_entries);
126 $next_class = $this->ctrl->getNextClass($this);
127 $cmd = $this->ctrl->getCmd(
"show");
129 switch ($next_class) {
132 include_once(
"./Services/Like/classes/class.ilLikeFactoryGUI.php");
134 $like_gui = $likef->widget(array(
$i->getContextObjId()));
135 $ctrl->saveParameter($this,
"news_id");
136 $like_gui->setObject(
137 $i->getContextObjId(),
138 $i->getContextObjType(),
139 $i->getContextSubObjId(),
140 $i->getContextSubObjType(),
148 $ctrl->saveParameter($this,
"news_id");
149 $notes_obj_type = (
$i->getContextSubObjType() ==
"")
150 ?
$i->getContextObjType()
151 :
$i->getContextSubObjType();
153 $i->getContextObjId(),
154 $i->getContextSubObjId(),
163 if (in_array($cmd, array(
"show",
"save",
"update",
"loadMore",
"remove",
"updateNewsItem"))) {
178 if ($this->access->checkAccess(
"news_add_news",
"", $this->ref_id)) {
180 $b->setCaption(
'news_add_news');
181 $b->setOnClick(
"return il.News.create();");
182 $b->setPrimary(
true);
183 $this->toolbar->addButtonInstance($b);
186 include_once(
"./Services/News/classes/class.ilNewsItem.php");
188 $news_item->setContextObjId($this->ctrl->getContextObjId());
189 $news_item->setContextObjType($this->ctrl->getContextObjType());
191 $news_data = $news_item->getNewsForRefId(
198 !$this->include_auto_entries,
201 self::$items_per_load
204 include_once(
"./Services/News/Timeline/classes/class.ilTimelineGUI.php");
205 include_once(
"./Services/News/classes/class.ilNewsTimelineItemGUI.php");
209 $obj_ids = array_unique(array_map(
function ($a) {
210 return $a[
"context_obj_id"];
212 include_once(
"./Services/Like/classes/class.ilLikeFactoryGUI.php");
214 $like_gui = $likef->widget($obj_ids);
217 foreach ($news_data as
$d) {
221 $timeline->addItem($item);
222 $js_items[$d[
"id"]] = array(
224 "user_id" => $d[
"user_id"],
225 "title" => $d[
"title"],
226 "content" => $d[
"content"] . $d[
"content_long"],
227 "content_long" =>
"",
228 "priority" => $d[
"priority"],
229 "visibility" => $d[
"visibility"],
230 "content_type" => $d[
"content_type"],
231 "mob_id" => $d[
"mob_id"]
235 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
236 $this->tpl->addOnloadCode(
"il.News.setItems(" .
ilJsonUtil::encode($js_items) .
");");
237 $this->tpl->addOnloadCode(
"il.News.setAjaxUrl('" . $this->ctrl->getLinkTarget($this,
"",
"",
true) .
"');");
239 if (count($news_data) > 0) {
240 $ttpl =
new ilTemplate(
"tpl.news_timeline.html",
true,
true,
"Services/News");
241 $ttpl->setVariable(
"NEWS", $timeline->render());
242 $ttpl->setVariable(
"EDIT_MODAL", $this->
getEditModal());
245 $this->tpl->setContent($ttpl->get());
251 $this->lng->toJS(
"create");
252 $this->lng->toJS(
"edit");
253 $this->lng->toJS(
"update");
254 $this->lng->toJS(
"save");
256 $this->tpl->addJavaScript(
"./Services/News/js/News.js");
257 include_once(
"./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
269 include_once(
"./Services/News/classes/class.ilNewsItem.php");
271 $news_item->setContextObjId($this->ctrl->getContextObjId());
272 $news_item->setContextObjType($this->ctrl->getContextObjType());
274 $excluded =
$_POST[
"rendered_news"];
276 $news_data = $news_item->getNewsForRefId(
283 !$this->include_auto_entries,
286 self::$items_per_load,
290 include_once(
"./Services/News/Timeline/classes/class.ilTimelineGUI.php");
291 include_once(
"./Services/News/classes/class.ilNewsTimelineItemGUI.php");
295 $obj_ids = array_unique(array_map(
function ($a) {
296 return $a[
"context_obj_id"];
298 include_once(
"./Services/Like/classes/class.ilLikeFactoryGUI.php");
300 $like_gui = $likef->widget($obj_ids);
303 foreach ($news_data as
$d) {
307 $timeline->addItem($item);
308 $js_items[$d[
"id"]] = array(
310 "user_id" => $d[
"user_id"],
311 "title" => $d[
"title"],
312 "content" => $d[
"content"] . $d[
"content_long"],
313 "content_long" =>
"",
314 "priority" => $d[
"priority"],
315 "visibility" => $d[
"visibility"],
316 "content_type" => $d[
"content_type"],
317 "mob_id" => $d[
"mob_id"]
321 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
323 $obj->data = $js_items;
324 $obj->html = $timeline->render(
true);
338 if (
$_POST[
"news_action"] ==
"save") {
340 $this->ctrl->redirect($this,
"show");
342 if (
$_POST[
"news_action"] ==
"update") {
344 $this->ctrl->redirect($this,
"show");
354 include_once(
"./Services/News/classes/class.ilNewsItemGUI.php");
356 if (
$form->checkInput()) {
358 $news_item->setTitle(
$form->getInput(
"news_title"));
359 $news_item->setContent(
$form->getInput(
"news_content"));
360 $news_item->setVisibility(
$form->getInput(
"news_visibility"));
361 include_once(
"./Services/News/classes/class.ilNewsItemGUI.php");
363 $news_item->setContentHtml(
true);
366 $news_item->setContentLong(
"");
370 $news_item->setContextObjId($obj_id);
371 $news_item->setContextObjType($obj_type);
372 $news_item->setUserId($this->
user->getId());
374 $media = $_FILES[
"media"];
375 if ($media[
"name"] !=
"") {
377 $news_item->setMobId($mob->getId());
381 if (!$news_set->get(
"enable_rss_for_internal")) {
382 $news_item->setVisibility(
"users");
385 $news_item->create();
396 include_once(
"./Services/News/classes/class.ilNewsItemGUI.php");
398 if (
$form->checkInput()) {
400 $news_item->setTitle(
$form->getInput(
"news_title"));
401 $news_item->setContent(
$form->getInput(
"news_content"));
402 $news_item->setVisibility(
$form->getInput(
"news_visibility"));
404 include_once(
"./Services/News/classes/class.ilNewsItemGUI.php");
406 $news_item->setContentHtml(
true);
408 $news_item->setContentLong(
"");
410 $media = $_FILES[
"media"];
414 if ($media[
"name"] !=
"" || $_POST[
"media_delete"] !=
"") {
416 $old_mob_id = $news_item->getMobId();
418 $news_item->setMobId(0);
421 if ($media[
"name"] !=
"") {
423 $news_item->setMobId($mob->getId());
428 if ($news_item->getContextObjId() == $obj_id) {
429 $news_item->setUpdateUserId($this->
user->getId());
430 $news_item->update();
432 if ($old_mob_id > 0) {
433 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
444 public function remove()
446 include_once(
"./Services/News/classes/class.ilNewsItemGUI.php");
449 $news_item->delete();
461 include_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
463 $modal->setHeading($this->lng->txt(
"edit"));
464 $modal->setId(
"ilNewsEditModal");
467 include_once(
"./Services/News/classes/class.ilNewsItemGUI.php");
469 $form->setShowTopButtons(
false);
470 $form->setFormAction($this->ctrl->getFormAction($this));
477 $form->addItem($act);
478 $form->setId(
"news_edit_form");
480 $modal->setBody(
$form->getHTML());
482 return $modal->getHTML();
492 include_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
494 $modal->setHeading($this->lng->txt(
"delete"));
495 $modal->setId(
"ilNewsDeleteModal");
498 require_once
'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
500 $confirm->setCaption(
"delete");
501 $confirm->setId(
"news_btn_delete");
502 $modal->addButton($confirm);
505 $cancel->setCaption(
"cancel");
506 $cancel->setId(
"news_btn_cancel_delete");
507 $modal->addButton($cancel);
509 $modal->setBody(
"<p id='news_delete_news_title'></p>" .
510 $this->tpl->getMessageHTML($this->lng->txt(
"news_really_delete_news"),
"question"));
512 return $modal->getHTML();
static isRteActivated()
Is Rte activated.
static getInstance(ilNewsItem $a_news_item, $a_news_ref_id, \ilLikeGUI $a_like_gui)
Get instance.
static _lookupObjectId($a_ref_id)
lookup object id
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
__construct($a_ref_id, $a_include_auto_entries)
Constructor.
static encode($mixed, $suppress_native=false)
if(isset($_POST['submit'])) $form
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
getDeleteModal()
Get delete modal.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance()
Get instance.
getEditModal()
Get edit modal.
static getInstance()
Get instance.
setUserEditAll($a_val)
Set user can edit other users postings.
static getEditForm($a_mode, $a_ref_id)
FORM NewsItem: Init form.
executeCommand()
Execute command.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
getUserEditAll()
Get user can edit other users postings.
static getInstance($a_ref_id, $a_include_auto_entries)
Get instance.