ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjBlogGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
16{
20 protected $help;
21
25 protected $tabs;
26
30 protected $nav_history;
31
35 protected $main_menu;
36
40 protected $rbacadmin;
41
42 protected $month; // [string]
43 protected $items; // [array]
44 protected $keyword; // [string]
45 protected $author; // [int]
46 protected $month_default; // [bool]
47
52 protected $gtp;
53
58 protected $edt;
59
63 protected $blpg;
64
68 protected $old_nr;
69
74 protected $ppage;
75
80 protected $user_page;
81
85 public $prtf_embed = false;
86
92 protected $prvm;
93
97 protected $ntf;
98
103 protected $apid;
104
108 protected $new_type;
109
114 protected $prt_id;
115
119 protected $ui;
120
124 protected $tool_context;
125
126 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
127 {
128 global $DIC;
129
130 $this->settings = $DIC->settings();
131 $this->help = $DIC["ilHelp"];
132 $this->tabs = $DIC->tabs();
133 $this->nav_history = $DIC["ilNavigationHistory"];
134 $this->user = $DIC->user();
135 $this->toolbar = $DIC->toolbar();
136 $this->tree = $DIC->repositoryTree();
137 $this->locator = $DIC["ilLocator"];
138 $this->main_menu = $DIC["ilMainMenu"];
139 $this->rbacreview = $DIC->rbac()->review();
140 $this->rbacadmin = $DIC->rbac()->admin();
141
142 $lng = $DIC->language();
143 $ilCtrl = $DIC->ctrl();
144
145 $this->gtp = (int) $_GET["gtp"];
146 $this->edt = $_GET["edt"];
147 $this->blpg = (int) $_REQUEST["blpg"];
148 $this->old_nr = (int) $_GET["old_nr"];
149 $this->ppage = (int) $_GET["ppage"];
150 $this->user_page = (int) $_REQUEST["user_page"];
151 $this->new_type = ilUtil::stripSlashes($_REQUEST["new_type"]);
152 $this->prvm = ilUtil::stripSlashes($_REQUEST["prvm"]);
153 $this->ntf = (int) $_GET["ntf"];
154 $this->apid = (int) $_GET["apid"];
155 $this->month = ilUtil::stripSlashes($_REQUEST["bmn"]);
156 $this->keyword = ilUtil::stripSlashes($_REQUEST["kwd"]);
157 $this->author = (int) $_REQUEST["ath"];
158 $this->prt_id = (int) $_REQUEST["prt_id"];
159 $this->ui = $DIC->ui();
160
161 $this->tool_context = $DIC->globalScreen()->tool()->context();
162
163 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
164
165 if ($_REQUEST["blpg"] > 0 && ilBlogPosting::lookupBlogId($_REQUEST["blpg"]) != $this->object->getId()) {
166 throw new ilException("Posting ID does not match blog.");
167 }
168
169 if ($this->object) {
170 // gather postings by month
171 $this->items = $this->buildPostingList($this->object->getId());
172 if ($this->items) {
173 // current month (if none given or empty)
174 if (!$this->month || !$this->items[$this->month]) {
175 $this->month = array_keys($this->items);
176 $this->month = array_shift($this->month);
177 $this->month_default = true;
178 }
179 }
180
181 $ilCtrl->setParameter($this, "bmn", $this->month);
182 }
183
184 $lng->loadLanguageModule("blog");
185 $ilCtrl->saveParameter($this, "prvm");
186 }
187
188 public function getType()
189 {
190 return "blog";
191 }
192
198 public function getItems()
199 {
200 return $this->items;
201 }
202
203
204 protected function initCreationForms($a_new_type)
205 {
206 $forms = parent::initCreationForms($a_new_type);
207
208 if ($this->id_type == self::WORKSPACE_NODE_ID) {
209 unset($forms[self::CFORM_IMPORT]);
210 unset($forms[self::CFORM_CLONE]);
211 }
212
213 return $forms;
214 }
215
216 protected function afterSave(ilObject $a_new_object)
217 {
218 $ilCtrl = $this->ctrl;
219
220 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
221 $ilCtrl->redirect($this, "");
222 }
223
224 protected function setSettingsSubTabs($a_active)
225 {
226 global $DIC;
227
228 $tree = $DIC->repositoryTree();
229 $access = $DIC->access();
230
231 // general properties
232 $this->tabs_gui->addSubTab(
233 "properties",
234 $this->lng->txt("blog_properties"),
235 $this->ctrl->getLinkTarget($this, 'edit')
236 );
237
238 $this->tabs_gui->addSubTab(
239 "style",
240 $this->lng->txt("obj_sty"),
241 $this->ctrl->getLinkTarget($this, 'editStyleProperties')
242 );
243
244 // notification settings for blogs in courses and groups
245 if ($this->id_type == self::REPOSITORY_NODE_ID) {
246 $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
247 $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
248
249 if ((int) $grp_ref_id > 0 || (int) $crs_ref_id > 0) {
250 if ($access->checkAccess('write', '', $this->ref_id)) {
251 $this->tabs_gui->addSubTab(
252 'notifications',
253 $this->lng->txt("notifications"),
254 $this->ctrl->getLinkTargetByClass("ilobjnotificationsettingsgui", '')
255 );
256 }
257 }
258 }
259
260 $this->tabs_gui->activateSubTab($a_active);
261 }
262
263 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
264 {
267 $obj_service = $this->getObjectService();
268
269 $this->setSettingsSubTabs("properties");
270
271 if ($this->id_type == self::REPOSITORY_NODE_ID) {
272 $appr = new ilCheckboxInputGUI($lng->txt("blog_enable_approval"), "approval");
273 $appr->setInfo($lng->txt("blog_enable_approval_info"));
274 $a_form->addItem($appr);
275 }
276
277 $notes = new ilCheckboxInputGUI($lng->txt("blog_enable_notes"), "notes");
278 $a_form->addItem($notes);
279
280 if ($ilSetting->get('enable_global_profiles')) {
281 $rss = new ilCheckboxInputGUI($lng->txt("blog_enable_rss"), "rss");
282 $rss->setInfo($lng->txt("blog_enable_rss_info"));
283 $a_form->addItem($rss);
284 }
285
286
287 // navigation
288
289 $nav = new ilFormSectionHeaderGUI();
290 $nav->setTitle($lng->txt("blog_settings_navigation"));
291 $a_form->addItem($nav);
292
293 $nav_mode = new ilRadioGroupInputGUI($lng->txt("blog_nav_mode"), "nav");
294 $nav_mode->setRequired(true);
295 $a_form->addItem($nav_mode);
296
297 $opt = new ilRadioOption($lng->txt("blog_nav_mode_month_list"), ilObjBlog::NAV_MODE_LIST);
298 $opt->setInfo($lng->txt("blog_nav_mode_month_list_info"));
299 $nav_mode->addOption($opt);
300
301
302 $mon_num = new ilNumberInputGUI($lng->txt("blog_nav_mode_month_list_num_month"), "nav_list_mon");
303 $mon_num->setInfo($lng->txt("blog_nav_mode_month_list_num_month_info"));
304 $mon_num->setSize(3);
305 $mon_num->setMinValue(1);
306 $opt->addSubItem($mon_num);
307
308 $detail_num = new ilNumberInputGUI($lng->txt("blog_nav_mode_month_list_num_month_with_post"), "nav_list_mon_with_post");
309 $detail_num->setInfo($lng->txt("blog_nav_mode_month_list_num_month_with_post_info"));
310 //$detail_num->setRequired(true);
311 $detail_num->setSize(3);
312 //$detail_num->setMinValue(0);
313 $opt->addSubItem($detail_num);
314
315 $opt = new ilRadioOption($lng->txt("blog_nav_mode_month_single"), ilObjBlog::NAV_MODE_MONTH);
316 $opt->setInfo($lng->txt("blog_nav_mode_month_single_info"));
317 $nav_mode->addOption($opt);
318
319 $order_options = array();
320 if ($this->object->getOrder()) {
321 foreach ($this->object->getOrder() as $item) {
322 $order_options[] = $lng->txt("blog_" . $item);
323 }
324 }
325
326 if (!in_array($lng->txt("blog_navigation"), $order_options)) {
327 $order_options[] = $lng->txt("blog_navigation");
328 }
329
330 if ($this->id_type == self::REPOSITORY_NODE_ID) {
331 if (!in_array($lng->txt("blog_authors"), $order_options)) {
332 $order_options[] = $lng->txt("blog_authors");
333 }
334
335 $auth = new ilCheckboxInputGUI($lng->txt("blog_enable_nav_authors"), "nav_authors");
336 $auth->setInfo($lng->txt("blog_enable_nav_authors_info"));
337 $a_form->addItem($auth);
338 }
339
340 $keyw = new ilCheckboxInputGUI($lng->txt("blog_enable_keywords"), "keywords");
341 $keyw->setInfo($lng->txt("blog_enable_keywords_info"));
342 $a_form->addItem($keyw);
343
344 if (!in_array($lng->txt("blog_keywords"), $order_options)) {
345 $order_options[] = $lng->txt("blog_keywords");
346 }
347
348 $order = new ilNonEditableValueGUI($lng->txt("blog_nav_sortorder"), "order");
349 $order->setMultiValues($order_options);
350 $order->setValue(array_shift($order_options));
351 $order->setMulti(true, true, false);
352 $a_form->addItem($order);
353
354
355 // presentation (frame)
356
357 $pres = new ilFormSectionHeaderGUI();
358 $pres->setTitle($lng->txt("blog_presentation_frame"));
359 $a_form->addItem($pres);
360
361 if ($this->id_type == self::REPOSITORY_NODE_ID) {
362 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
363 }
364
365 $ppic = new ilCheckboxInputGUI($lng->txt("blog_profile_picture"), "ppic");
366 $a_form->addItem($ppic);
367
368 if ($this->id_type == self::REPOSITORY_NODE_ID) {
369 $ppic->setInfo($lng->txt("blog_profile_picture_repository_info"));
370 }
371
372 $blga_set = new ilSetting("blga");
373 if ($blga_set->get("banner")) {
374 $dimensions = " (" . $blga_set->get("banner_width") . "x" .
375 $blga_set->get("banner_height") . ")";
376
377 $img = new ilImageFileInputGUI($lng->txt("blog_banner") . $dimensions, "banner");
378 $a_form->addItem($img);
379
380 // show existing file
381 $file = $this->object->getImageFullPath(true);
382 if ($file) {
383 $img->setImage($file);
384 }
385 }
386
387 /* #15000
388 $bg_color = new ilColorPickerInputGUI($lng->txt("blog_background_color"), "bg_color");
389 $a_form->addItem($bg_color);
390
391 $font_color = new ilColorPickerInputGUI($lng->txt("blog_font_color"), "font_color");
392 $a_form->addItem($font_color);
393 */
394
395 // presentation (overview)
396
397 $list = new ilFormSectionHeaderGUI();
398 $list->setTitle($lng->txt("blog_presentation_overview"));
399 $a_form->addItem($list);
400
401
402 $post_num = new ilNumberInputGUI($lng->txt("blog_list_num_postings"), "ov_list_post_num");
403 $post_num->setInfo($lng->txt("blog_list_num_postings_info"));
404 $post_num->setSize(3);
405 $post_num->setMinValue(1);
406 $post_num->setRequired(true);
407 $a_form->addItem($post_num);
408
409 $abs_shorten = new ilCheckboxInputGUI($lng->txt("blog_abstract_shorten"), "abss");
410 $a_form->addItem($abs_shorten);
411
412 $abs_shorten_len = new ilNumberInputGUI($lng->txt("blog_abstract_shorten_length"), "abssl");
413 $abs_shorten_len->setSize(5);
414 $abs_shorten_len->setRequired(true);
415 $abs_shorten_len->setSuffix($lng->txt("blog_abstract_shorten_characters"));
416 $abs_shorten_len->setMinValue(50, true);
417 $abs_shorten->addSubItem($abs_shorten_len);
418
419 $abs_img = new ilCheckboxInputGUI($lng->txt("blog_abstract_image"), "absi");
420 $abs_img->setInfo($lng->txt("blog_abstract_image_info"));
421 $a_form->addItem($abs_img);
422
423 $abs_img_width = new ilNumberInputGUI($lng->txt("blog_abstract_image_width"), "absiw");
424 $abs_img_width->setSize(5);
425 $abs_img_width->setRequired(true);
426 $abs_img_width->setSuffix($lng->txt("blog_abstract_image_pixels"));
427 $abs_img_width->setMinValue(32, true);
428 $abs_img->addSubItem($abs_img_width);
429
430 $abs_img_height = new ilNumberInputGUI($lng->txt("blog_abstract_image_height"), "absih");
431 $abs_img_height->setSize(5);
432 $abs_img_height->setRequired(true);
433 $abs_img_height->setSuffix($lng->txt("blog_abstract_image_pixels"));
434 $abs_img_height->setMinValue(32, true);
435 $abs_img->addSubItem($abs_img_height);
436 }
437
438 protected function getEditFormCustomValues(array &$a_values)
439 {
440 if ($this->id_type == self::REPOSITORY_NODE_ID) {
441 $a_values["approval"] = $this->object->hasApproval();
442 $a_values["nav_authors"] = $this->object->hasAuthors();
443 }
444 $a_values["keywords"] = $this->object->hasKeywords();
445 $a_values["notes"] = $this->object->getNotesStatus();
446 $a_values["ppic"] = $this->object->hasProfilePicture();
447 /*
448 $a_values["bg_color"] = $this->object->getBackgroundColor();
449 $a_values["font_color"] = $this->object->getFontColor();
450 */
451 $a_values["banner"] = $this->object->getImage();
452 $a_values["rss"] = $this->object->hasRSS();
453 $a_values["abss"] = $this->object->hasAbstractShorten();
454 $a_values["absi"] = $this->object->hasAbstractImage();
455 $a_values["nav"] = $this->object->getNavMode();
456 $a_values["nav_list_mon_with_post"] = $this->object->getNavModeListMonthsWithPostings();
457 $a_values["nav_list_mon"] = $this->object->getNavModeListMonths();
458 $a_values["ov_list_post_num"] = $this->object->getOverviewPostings();
459
460 // #13420
461 $a_values["abssl"] = $this->object->getAbstractShortenLength() ? $this->object->getAbstractShortenLength() : ilObjBlog::ABSTRACT_DEFAULT_SHORTEN_LENGTH;
462 $a_values["absiw"] = $this->object->getAbstractImageWidth() ? $this->object->getAbstractImageWidth() : ilObjBlog::ABSTRACT_DEFAULT_IMAGE_WIDTH;
463 $a_values["absih"] = $this->object->getAbstractImageHeight() ? $this->object->getAbstractImageHeight() : ilObjBlog::ABSTRACT_DEFAULT_IMAGE_HEIGHT;
464 }
465
466 protected function updateCustom(ilPropertyFormGUI $a_form)
467 {
469 $obj_service = $this->getObjectService();
470
471 if ($this->id_type == self::REPOSITORY_NODE_ID) {
472 $this->object->setApproval($a_form->getInput("approval"));
473 $this->object->setAuthors($a_form->getInput("nav_authors"));
474 $obj_service->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
475 }
476 $this->object->setKeywords($a_form->getInput("keywords"));
477 $this->object->setNotesStatus($a_form->getInput("notes"));
478 $this->object->setProfilePicture($a_form->getInput("ppic"));
479 /*
480 $this->object->setBackgroundColor($a_form->getInput("bg_color"));
481 $this->object->setFontColor($a_form->getInput("font_color"));
482 */
483 $this->object->setRSS($a_form->getInput("rss"));
484 $this->object->setAbstractShorten($a_form->getInput("abss"));
485 $this->object->setAbstractShortenLength($a_form->getInput("abssl"));
486 $this->object->setAbstractImage($a_form->getInput("absi"));
487 $this->object->setAbstractImageWidth($a_form->getInput("absiw"));
488 $this->object->setAbstractImageHeight($a_form->getInput("absih"));
489 $this->object->setNavMode($a_form->getInput("nav"));
490 $this->object->setNavModeListMonthsWithPostings($a_form->getInput("nav_list_mon_with_post"));
491 $this->object->setNavModeListMonths($a_form->getInput("nav_list_mon"));
492 $this->object->setOverviewPostings($a_form->getInput("ov_list_post_num"));
493
494 $order = $a_form->getInput("order");
495 foreach ($order as $idx => $value) {
496 if ($value == $lng->txt("blog_navigation")) {
497 $order[$idx] = "navigation";
498 } elseif ($value == $lng->txt("blog_keywords")) {
499 $order[$idx] = "keywords";
500 } else {
501 $order[$idx] = "authors";
502 }
503 }
504 $this->object->setOrder($order);
505 // banner field is optional
506 $banner = $a_form->getItemByPostVar("banner");
507 if ($banner) {
508 if ($_FILES["banner"]["tmp_name"]) {
509 $this->object->uploadImage($_FILES["banner"]);
510 } elseif ($banner->getDeletionFlag()) {
511 $this->object->deleteImage();
512 }
513 }
514 }
515
516 public function setTabs()
517 {
519 $ilHelp = $this->help;
520
521 if ($this->id_type == self::WORKSPACE_NODE_ID) {
522 $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
523 }
524
525 $ilHelp->setScreenIdComponent("blog");
526
527 if ($this->checkPermissionBool("read")) {
528 $this->tabs_gui->addTab(
529 "content",
530 $lng->txt("content"),
531 $this->ctrl->getLinkTarget($this, "")
532 );
533 }
534 if ($this->checkPermissionBool("read") && !$this->prtf_embed) {
535 $this->tabs_gui->addTab(
536 "id_info",
537 $lng->txt("info_short"),
538 $this->ctrl->getLinkTargetByClass(array("ilobjbloggui", "ilinfoscreengui"), "showSummary")
539 );
540 }
541
542 if ($this->checkPermissionBool("write")) {
543 $this->tabs_gui->addTab(
544 "settings",
545 $lng->txt("settings"),
546 $this->ctrl->getLinkTarget($this, "edit")
547 );
548
549 if (!$this->prtf_embed) {
550 if ($this->id_type == self::REPOSITORY_NODE_ID) {
551 $this->tabs_gui->addTab(
552 "contributors",
553 $lng->txt("blog_contributors"),
554 $this->ctrl->getLinkTarget($this, "contributors")
555 );
556 }
557
558 if ($this->id_type == self::REPOSITORY_NODE_ID) {
559 $this->tabs_gui->addTab(
560 "export",
561 $lng->txt("export"),
562 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
563 );
564 }
565 }
566 }
567
568 if (!$this->prtf_embed) {
569 if ($this->mayContribute()) {
570 $this->tabs_gui->addNonTabbedLink(
571 "preview",
572 $lng->txt("blog_preview"),
573 $this->ctrl->getLinkTarget($this, "preview")
574 );
575 }
576 parent::setTabs();
577 }
578 }
579
580 public function executeCommand()
581 {
582 $ilCtrl = $this->ctrl;
584 $ilTabs = $this->tabs;
586 $ilNavigationHistory = $this->nav_history;
587
588 $this->triggerAssignmentTool();
589
590 // goto link to blog posting
591 if ($this->gtp > 0) {
592 $page_id = $this->gtp;
593 if (ilBlogPosting::exists($this->object_id, $page_id)) {
594 // #12312
595 $ilCtrl->setCmdClass("ilblogpostinggui");
596 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $page_id);
597 if ($this->edt == "edit") {
598 $ilCtrl->redirectByClass("ilblogpostinggui", "edit");
599 } else {
600 $ilCtrl->redirectByClass("ilblogpostinggui", "previewFullscreen");
601 }
602 } else {
603 ilUtil::sendFailure($lng->txt("blog_posting_not_found"));
604 }
605 }
606
607 $next_class = $ilCtrl->getNextClass($this);
608 $cmd = $ilCtrl->getCmd();
609
610 if ($this->id_type == self::REPOSITORY_NODE_ID) {
611 // add entry to navigation history
612 if (!$this->getCreationMode() &&
613 $this->getAccessHandler()->checkAccess("read", "", $this->node_id)) {
614 // see #22067
615 $link = $ilCtrl->getLinkTargetByClass(["ilrepositorygui", "ilObjBlogGUI"], "preview");
616 $ilNavigationHistory->addItem($this->node_id, $link, "blog");
617 }
618 }
619
620 switch ($next_class) {
621 case 'ilblogpostinggui':
622 // see 32264
623 $this->ctrl->saveParameter($this, "user_page");
624 if (!$this->prtf_embed) {
625 $tpl->loadStandardTemplate();
626 }
627
628 if (!$this->checkPermissionBool("read") && !$this->prtf_embed) {
629 ilUtil::sendInfo($lng->txt("no_permission"));
630 return;
631 }
632
633 // #9680
634 if ($this->id_type == self::REPOSITORY_NODE_ID) {
635 $this->setLocator();
636 } else {
637 //ilFileInputGUI::setPersonalWorkspaceQuotaCheck(true);
638 }
639
641 $this->object->getStyleSheetId(),
642 "blog"
643 );
644
645 $bpost_gui = new ilBlogPostingGUI(
646 $this->node_id,
647 $this->getAccessHandler(),
648 $this->blpg,
649 $this->old_nr,
650 ($this->object->getNotesStatus() && !$this->disable_notes),
651 $this->mayEditPosting($this->blpg),
652 $style_sheet_id
653 );
654
655 // keep preview mode through notes gui (has its own commands)
656 switch ($cmd) {
657 // blog preview
658 case "previewFullscreen":
659 $ilCtrl->setParameter($this, "prvm", "fsc");
660 break;
661
662 // blog in portfolio
663 case "previewEmbedded":
664 $ilCtrl->setParameter($this, "prvm", "emb");
665 break;
666
667 // edit
668 default:
669 $this->setContentStyleSheet();
670
671
672 if (!$this->prtf_embed) {
673 $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $this->blpg);
674 $this->tabs_gui->addNonTabbedLink(
675 "preview",
676 $lng->txt("blog_preview"),
677 $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "previewFullscreen")
678 );
679 $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", "");
680 } else {
681 $this->ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $this->ppage);
682 $this->tabs_gui->addNonTabbedLink(
683 "preview",
684 $lng->txt("blog_preview"),
685 $this->ctrl->getLinkTargetByClass("ilobjportfoliogui", "preview")
686 );
687 $this->ctrl->setParameterByClass("ilobjportfoliogui", "user_page", "");
688 }
689 break;
690 }
691
692 // keep preview mode through notes gui
693 if ($this->prvm) {
694 $cmd = "preview" . (($this->prvm == "fsc") ? "Fullscreen" : "Embedded");
695 }
696 if (in_array($cmd, array("previewFullscreen", "previewEmbedded"))) {
697 $this->renderToolbarNavigation($this->items, true);
698 }
699 $ret = $ilCtrl->forwardCommand($bpost_gui);
700 if (!$ilTabs->back_target) {
701 $ilCtrl->setParameter($this, "bmn", "");
702 $ilTabs->setBackTarget(
703 $lng->txt("back"),
704 $ilCtrl->getLinkTarget($this, "")
705 );
706 }
707
708 if ($ret != "") {
709
710 // $is_owner = $this->object->getOwner() == $ilUser->getId();
711 $is_owner = $this->mayContribute();
712 $is_active = $bpost_gui->getBlogPosting()->getActive();
713
714 // do not show inactive postings
715 if (($cmd == "previewFullscreen" || $cmd == "previewEmbedded")
716 && !$is_owner && !$is_active) {
717 $this->ctrl->redirect($this, "preview");
718 }
719
720 switch ($cmd) {
721 // blog preview
722 case "previewFullscreen":
723 $this->addHeaderActionForCommand($cmd);
724 $this->filterInactivePostings();
725 $nav = $this->renderNavigation("preview", $cmd);
726 $this->renderFullScreen($ret, $nav);
727 break;
728
729 // blog in portfolio
730 case "previewEmbedded":
731 $this->addHeaderActionForCommand($cmd);
732 $this->filterInactivePostings();
733 $nav = $this->renderNavigation("gethtml", $cmd);
734 return $this->buildEmbedded($ret, $nav);
735
736 // ilias/editor
737 default:
738 // infos about draft status / snippet
739 $info = array();
740 if (!$is_active) {
741 // single author blog (owner) in personal workspace
742 if ($this->id_type == self::WORKSPACE_NODE_ID) {
743 $info[] = $lng->txt("blog_draft_info");
744 } else {
745 $info[] = $lng->txt("blog_draft_info_contributors");
746 }
747 }
748 if ($cmd != "history" && $cmd != "edit" && $is_active && empty($info)) {
749 $info[] = $lng->txt("blog_new_posting_info");
750 $public_action = true;
751 }
752 if ($this->object->hasApproval() && !$bpost_gui->getBlogPosting()->isApproved()) {
753 // #9737
754 $info[] = $lng->txt("blog_posting_edit_approval_info");
755 }
756 //TODO can we get rid of this conditional? hasMessage belongs to the old ilBlogGlobalTemplate class
757 //if(sizeof($info) && !$tpl->hasMessage("info")) // #15121
758 //{
759 if ($public_action) {
760 ilUtil::sendSuccess(implode("<br />", $info));
761 } else {
762 ilUtil::sendInfo(implode("<br />", $info));
763 }
764 //}
765 // revert to edit cmd to avoid confusion
766 $tpl->setContent($ret);
767 if ($cmd != "edit") {
768 $this->addHeaderActionForCommand("render");
769 $nav = $this->renderNavigation("render", $cmd, null, $is_owner);
770 $tpl->setRightContent($nav);
771 } else {
772 $this->tabs->setBackTarget("", "");
773 }
774 break;
775 }
776 }
777 break;
778
779 case "ilinfoscreengui":
780 $this->prepareOutput();
781 $this->addHeaderActionForCommand("render");
782 $this->infoScreenForward();
783 break;
784
785 case "ilnotegui":
786 $this->preview();
787 break;
788
789 case "ilcommonactiondispatchergui":
791 $gui->enableCommentsSettings(false);
792 $this->prepareOutput();
793 $this->ctrl->forwardCommand($gui);
794 break;
795
796 case "ilpermissiongui":
797 $this->prepareOutput();
798 $ilTabs->activateTab("id_permissions");
799 $perm_gui = new ilPermissionGUI($this);
800 $this->ctrl->forwardCommand($perm_gui);
801 break;
802
803 case "ilobjectcopygui":
804 $this->prepareOutput();
805 $cp = new ilObjectCopyGUI($this);
806 $cp->setType("blog");
807 $this->ctrl->forwardCommand($cp);
808 break;
809
810 case 'ilrepositorysearchgui':
811 $this->prepareOutput();
812 $ilTabs->activateTab("contributors");
813 $rep_search = new ilRepositorySearchGUI();
814 $rep_search->setTitle($this->lng->txt("blog_add_contributor"));
815 $rep_search->setCallback($this, 'addContributor', $this->object->getAllLocalRoles($this->node_id));
816 $this->ctrl->setReturn($this, 'contributors');
817 $ret = &$this->ctrl->forwardCommand($rep_search);
818 break;
819
820 case 'ilexportgui':
821 $this->prepareOutput();
822 $ilTabs->activateTab("export");
823 $exp_gui = new ilExportGUI($this);
824 $exp_gui->addFormat("xml");
825 $exp_gui->addFormat("html", null, $this, "buildExportFile"); // #13419
826 if (ilObjBlogAccess::isCommentsExportPossible($this->object->getId())) {
827 $exp_gui->addFormat("html_comments", "HTML (" . $this->lng->txt("blog_incl_comments") . ")", $this, "buildExportFile");
828 }
829 $ret = $ilCtrl->forwardCommand($exp_gui);
830 break;
831
832 case "ilobjstylesheetgui":
833 $this->ctrl->setReturn($this, "editStyleProperties");
834 $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
835 $style_gui->omitLocator();
836 if ($cmd == "create" || $this->new_type == "sty") {
837 $style_gui->setCreationMode(true);
838 }
839
840 if ($cmd == "confirmedDelete") {
841 $this->object->setStyleSheetId(0);
842 $this->object->update();
843 }
844
845 $ret = $this->ctrl->forwardCommand($style_gui);
846
847 if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
848 $style_id = $ret;
849 $this->object->setStyleSheetId($style_id);
850 $this->object->update();
851 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
852 }
853 break;
854
855 case "ilblogexercisegui":
856 $this->ctrl->setReturn($this, "render");
857 $gui = new ilBlogExerciseGUI($this->node_id);
858 $this->ctrl->forwardCommand($gui);
859 break;
860
861 case 'ilobjnotificationsettingsgui':
862 $this->prepareOutput();
863 $ilTabs->activateTab("settings");
864 $this->setSettingsSubTabs("notifications");
865 $gui = new ilObjNotificationSettingsGUI($this->object->getRefId());
866 $this->ctrl->forwardCommand($gui);
867 break;
868
869 default:
870 if ($cmd != "gethtml") {
871 // desktop item handling, must be toggled before header action
872 if ($cmd == "addToDesk" || $cmd == "removeFromDesk") {
873 $this->{$cmd . "Object"}();
874 if ($this->prvm) {
875 $cmd = "preview";
876 } else {
877 $cmd = "render";
878 }
879 $ilCtrl->setCmd($cmd);
880 }
881 $this->addHeaderActionForCommand($cmd);
882 }
883 if (!$this->prtf_embed) {
884 return parent::executeCommand();
885 } else {
886 $this->setTabs();
887
888 if (!$cmd) {
889 $cmd = "render";
890 }
891 return $this->$cmd();
892 }
893 }
894
895 return true;
896 }
897
903 protected function triggerAssignmentTool()
904 {
905 $be = new ilBlogExercise($this->node_id);
906 $be_gui = new ilBlogExerciseGUI($this->node_id);
907 $assignments = $be->getAssignmentsOfBlog();
908 if (count($assignments) > 0) {
909 $ass_ids = array_map(function ($i) {
910 return $i["ass_id"];
911 }, $assignments);
912 $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::SHOW_EXC_ASSIGNMENT_INFO, true);
913 $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::EXC_ASS_IDS, $ass_ids);
914 $this->tool_context->current()->addAdditionalData(
916 $be_gui->getActionButtons()
917 );
918 }
919 }
920
926 public function infoScreen()
927 {
928 $this->ctrl->setCmd("showSummary");
929 $this->ctrl->setCmdClass("ilinfoscreengui");
930 $this->infoScreenForward();
931 }
932
936 public function infoScreenForward()
937 {
938 $ilTabs = $this->tabs;
939
940 $ilTabs->activateTab("id_info");
941
942 $this->checkPermission("visible");
943
944 $info = new ilInfoScreenGUI($this);
945
946 if ($this->id_type != self::WORKSPACE_NODE_ID) {
947 $info->enablePrivateNotes();
948 }
949
950 if ($this->checkPermissionBool("read")) {
951 $info->enableNews();
952 }
953
954 // no news editing for files, just notifications
955 $info->enableNewsEditing(false);
956 if ($this->checkPermissionBool("write")) {
957 $news_set = new ilSetting("news");
958 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
959
960 if ($enable_internal_rss) {
961 $info->setBlockProperty("news", "settings", true);
962 $info->setBlockProperty("news", "public_notifications_option", true);
963 }
964 }
965
966 // standard meta data
967 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
968
969 if ($this->id_type == self::WORKSPACE_NODE_ID) {
970 $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
971 }
972
973 $this->ctrl->forwardCommand($info);
974 }
975
979 public function createPosting()
980 {
981 $ilCtrl = $this->ctrl;
983
984 $title = trim(ilUtil::stripSlashes($_POST["title"]));
985 if ($title) {
986 // create new posting
987 $posting = new ilBlogPosting();
988 $posting->setTitle($title);
989 $posting->setBlogId($this->object->getId());
990 $posting->setActive(false);
991 $posting->setAuthor($ilUser->getId());
992 $posting->create();
993
994 // switch month list to current month (will include new posting)
995 $ilCtrl->setParameter($this, "bmn", date("Y-m"));
996
997 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $posting->getId());
998 $ilCtrl->redirectByClass("ilblogpostinggui", "edit");
999 } else {
1000 ilUtil::sendFailure($this->lng->txt("msg_no_title"), true);
1001 $ilCtrl->redirect($this, "render");
1002 }
1003 }
1004
1005 // --- ObjectGUI End
1006
1007
1011 public function render()
1012 {
1013 $tpl = $this->tpl;
1014 $ilTabs = $this->tabs;
1015 $ilCtrl = $this->ctrl;
1016 $lng = $this->lng;
1017 $ilToolbar = new ilToolbarGUI();
1020
1021 if (!$this->checkPermissionBool("read")) {
1022 ilUtil::sendInfo($lng->txt("no_permission"));
1023 return;
1024 }
1025
1026 $ilTabs->activateTab("content");
1027
1028 // toolbar
1029 if ($this->mayContribute()) {
1030 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "createPosting"));
1031
1032 $title = new ilTextInputGUI($lng->txt("title"), "title");
1033 $ilToolbar->addStickyItem($title, $lng->txt("title"));
1034
1035 $button = ilSubmitButton::getInstance();
1036 $button->setCaption("blog_add_posting");
1037 $button->setCommand("createPosting");
1038 $ilToolbar->addStickyItem($button);
1039
1040 // #18763
1041 $first = array_shift((array_keys($this->items)));
1042 if ($first != $this->month) {
1043 $ilToolbar->addSeparator();
1044
1045 $ilCtrl->setParameter($this, "bmn", $first);
1046 $url = $ilCtrl->getLinkTarget($this, "");
1047 $ilCtrl->setParameter($this, "bmn", $this->month);
1048
1049 $button = ilLinkButton::getInstance();
1050 $button->setCaption("blog_show_latest");
1051 $button->setUrl($url);
1052 $ilToolbar->addButtonInstance($button);
1053 }
1054 }
1055
1056 // $is_owner = ($this->object->getOwner() == $ilUser->getId());
1057 $is_owner = $this->mayContribute();
1058
1059 $list_items = $this->getListItems($is_owner);
1060
1061 $list = $nav = "";
1062 if ($list_items) {
1063 $list = $this->renderList($list_items, "preview", null, $is_owner);
1064 $nav = $this->renderNavigation("render", "preview", null, $is_owner);
1065 }
1066
1067 $this->setContentStyleSheet();
1068
1069 $tpl->setContent($message . $ilToolbar->getHTML() . $list);
1070 $tpl->setRightContent($nav);
1071 }
1072
1078 public function getHTML()
1079 {
1081 $ilCtrl = $this->ctrl;
1082 $lng = $this->lng;
1083
1084 // getHTML() is called by ilRepositoryGUI::show()
1085 if ($this->id_type == self::REPOSITORY_NODE_ID) {
1086 return;
1087 }
1088
1089 // there is no way to do a permissions check here, we have no wsp
1090
1091 $this->filterInactivePostings();
1092
1093 $list_items = $this->getListItems();
1094
1095 $list = $nav = "";
1096 if ($list_items) {
1097 $list = $this->renderList($list_items, "previewEmbedded");
1098 $nav = $this->renderNavigation("gethtml", "previewEmbedded");
1099 }
1100 // quick editing in portfolio
1101 elseif ($this->prt_id) {
1102 // see renderList()
1103 if (ilObject::_lookupOwner($this->prt_id) == $ilUser->getId()) {
1104 // see ilPortfolioPageTableGUI::fillRow()
1105 $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->user_page);
1106 $link = $ilCtrl->getLinkTargetByClass(array("ilportfoliopagegui", "ilobjbloggui"), "render");
1107 $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", "");
1108
1109 $this->toolbar->addComponent($this->ui->factory()->button()->standard(
1110 $this->lng->txt("blog_edit"),
1111 $link
1112 ));
1113 }
1114 }
1115
1116 return $this->buildEmbedded($list, $nav);
1117 }
1118
1125 protected function getListItems($a_show_inactive = false)
1126 {
1127 if ($this->author) {
1128 $list_items = array();
1129 foreach ($this->items as $month => $items) {
1130 foreach ($items as $id => $item) {
1131 if ($item["author"] == $this->author ||
1132 (is_array($item["editors"]) && in_array($this->author, $item["editors"]))) {
1133 $list_items[$id] = $item;
1134 }
1135 }
1136 }
1137 } elseif ($this->keyword) {
1138 $list_items = $this->filterItemsByKeyword($this->items, $this->keyword);
1139 } else {
1140 $max = $this->object->getOverviewPostings();
1141 if ($this->month_default && $max) {
1142 $list_items = array();
1143 foreach ($this->items as $month => $postings) {
1144 foreach ($postings as $id => $item) {
1145 if (!$a_show_inactive &&
1146 !ilBlogPosting::_lookupActive($id, "blp")) {
1147 continue;
1148 }
1149 $list_items[$id] = $item;
1150
1151 if (sizeof($list_items) >= $max) {
1152 break(2);
1153 }
1154 }
1155 }
1156 } else {
1157 $list_items = $this->items[$this->month];
1158 }
1159 }
1160 return $list_items;
1161 }
1162
1166 public function preview()
1167 {
1168 global $DIC;
1169
1170 $lng = $DIC->language();
1171 $toolbar = $DIC->toolbar();
1172
1173 if (!$this->checkPermissionBool("read")) {
1174 ilUtil::sendInfo($lng->txt("no_permission"));
1175 return;
1176 }
1177
1178 $this->filterInactivePostings();
1179
1180 $list_items = $this->getListItems();
1181
1182 $list = $nav = "";
1183 if ($list_items) {
1184 $list = $this->renderList($list_items, "previewFullscreen");
1185 $nav = $this->renderNavigation("preview", "previewFullscreen");
1186 $this->renderToolbarNavigation($this->items);
1187 $list .= $toolbar->getHTML();
1188 }
1189
1190 $this->renderFullScreen($list, $nav);
1191 }
1192
1196 public function export($a_with_comments = false)
1197 {
1198 $zip = $this->buildExportFile($a_with_comments);
1199 ilUtil::deliverFile($zip, $this->object->getTitle() . ".zip", '', false, true);
1200 }
1201
1202
1203 // --- helper functions
1204
1212 protected function buildEmbedded($a_content, $a_nav)
1213 {
1214 $wtpl = new ilTemplate("tpl.blog_embedded.html", true, true, "Modules/Blog");
1215 $wtpl->setVariable("VAL_LIST", $a_content);
1216 $wtpl->setVariable("VAL_NAVIGATION", $a_nav);
1217 return $wtpl->get();
1218 }
1219
1226 public function renderFullScreen($a_content, $a_navigation)
1227 {
1228 $tpl = $this->tpl;
1230 $ilTabs = $this->tabs;
1231 $ilLocator = $this->locator;
1232
1233 $owner = $this->object->getOwner();
1234
1235 $ilTabs->clearTargets();
1236 $tpl->setLocator();
1237
1238 $back_caption = "";
1239
1240 // back (edit)
1241 if ($owner == $ilUser->getId()) {
1242 // from shared/deeplink
1243 if ($this->id_type == self::WORKSPACE_NODE_ID) {
1244 $back = "ilias.php?baseClass=ilDashboardGUI&cmd=jumpToWorkspace&wsp_id=" . $this->node_id;
1245 }
1246 // from editor (#10073)
1247 elseif ($this->mayContribute()) {
1248 $this->ctrl->setParameter($this, "prvm", "");
1249 if ($this->blpg == 0) {
1250 $back = $this->ctrl->getLinkTarget($this, "");
1251 } else {
1252 $this->ctrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
1253 $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $this->blpg);
1254 $back = $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "preview");
1255 }
1256 $this->ctrl->setParameter($this, "prvm", $this->prvm);
1257 }
1258
1259 $back_caption = $this->lng->txt("blog_back_to_blog_owner");
1260 }
1261 // back
1262 elseif ($ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID) {
1263 // workspace (always shared)
1264 if ($this->id_type == self::WORKSPACE_NODE_ID) {
1265 $back = "ilias.php?baseClass=ilDashboardGUI&cmd=jumpToWorkspace&dsh=" . $owner;
1266 }
1267 // contributor
1268 elseif ($this->mayContribute()) {
1269 $back = $this->ctrl->getLinkTarget($this, "");
1270 $back_caption = $this->lng->txt("blog_back_to_blog_owner");
1271 }
1272 // listgui / parent container
1273 else {
1275 $parent_id = $tree->getParentId($this->node_id);
1277 }
1278 }
1279
1280 $ilMainMenu = $this->main_menu;
1281 $ilMainMenu->setMode(ilMainMenuGUI::MODE_TOPBAR_ONLY);
1282 $ilMainMenu->setTopBarBack($back, $back_caption);
1283
1284 $this->renderFullscreenHeader($tpl, $owner);
1285
1286 // #13564
1287 $this->ctrl->setParameter($this, "bmn", "");
1288 //$tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
1289 $this->ctrl->setParameter($this, "bmn", $this->month);
1290
1291 $this->setContentStyleSheet();
1292
1293 // content
1294 $tpl->setContent($a_content);
1295 $tpl->setRightContent($a_navigation);
1296 }
1297
1305 public function renderFullscreenHeader($a_tpl, $a_user_id, $a_export = false)
1306 {
1308
1309 if (!$a_export) {
1311 $this->object->getType(),
1312 $this->node_id,
1313 $this->object->getId(),
1314 $ilUser->getId()
1315 );
1316 }
1317
1318 // repository blogs are multi-author
1319 $name = null;
1320 if ($this->id_type != self::REPOSITORY_NODE_ID) {
1321 $name = ilObjUser::_lookupName($a_user_id);
1322 $name = $name["lastname"] . ", " . ($t = $name["title"] ? $t . " " : "") . $name["firstname"];
1323 }
1324
1325 // show banner?
1326 $banner = false;
1327 $blga_set = new ilSetting("blga");
1328 if ($blga_set->get("banner")) {
1329 $banner = ilWACSignedPath::signFile($this->object->getImageFullPath());
1330 $banner_width = $blga_set->get("banner_width");
1331 $banner_height = $blga_set->get("banner_height");
1332 if ($a_export) {
1333 $banner = basename($banner);
1334 }
1335 }
1336
1337 $ppic = null;
1338 if ($this->object->hasProfilePicture()) {
1339 // repository (multi-user)
1340 if ($this->id_type == self::REPOSITORY_NODE_ID) {
1341 // #15030
1342 if ($this->blpg > 0 && !$a_export) {
1343 $post = new ilBlogPosting($this->blpg);
1344 $author_id = $post->getAuthor();
1345 if ($author_id) {
1346 $ppic = ilObjUser::_getPersonalPicturePath($author_id, "xsmall", true, true);
1347
1348 $name = ilObjUser::_lookupName($author_id);
1349 $name = $name["lastname"] . ", " . ($t = $name["title"] ? $t . " " : "") . $name["firstname"];
1350 }
1351 }
1352 }
1353 // workspace (author == owner)
1354 else {
1355 $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
1356 if ($a_export) {
1357 $ppic = basename($ppic);
1358 }
1359 }
1360 }
1361
1362 $a_tpl->resetHeaderBlock(false);
1363 $a_tpl->setBanner($banner, $banner_width, $banner_height, $a_export);
1364 $a_tpl->setTitleIcon($ppic);
1365 $a_tpl->setTitle($this->object->getTitle());
1366 $a_tpl->setDescription($name);
1367 }
1368
1375 protected function buildPostingList($a_obj_id)
1376 {
1377 $author_found = false;
1378
1379 $items = array();
1380 foreach (ilBlogPosting::getAllPostings($a_obj_id) as $posting) {
1381 if ($this->author &&
1382 ($posting["author"] == $this->author ||
1383 (is_array($posting["editors"]) && in_array($this->author, $posting["editors"])))) {
1384 $author_found = true;
1385 }
1386
1387 $month = substr($posting["created"]->get(IL_CAL_DATE), 0, 7);
1388 $items[$month][$posting["id"]] = $posting;
1389 }
1390
1391 if ($this->author && !$author_found) {
1392 $this->author = null;
1393 }
1394
1395 return $items;
1396 }
1397
1408 public function renderList(array $items, $a_cmd = "preview", $a_link_template = null, $a_show_inactive = false, $a_export_directory = null)
1409 {
1410 $lng = $this->lng;
1411 $ilCtrl = $this->ctrl;
1413
1414 $wtpl = new ilTemplate("tpl.blog_list.html", true, true, "Modules/Blog");
1415
1416 // quick editing in portfolio
1417 if ($this->prt_id > 0 &&
1418 stristr($a_cmd, "embedded")) {
1419 if (ilObject::_lookupOwner($this->prt_id) == $ilUser->getId()) {
1420 // see ilPortfolioPageTableGUI::fillRow()
1421 $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->user_page);
1422 $link = $ilCtrl->getLinkTargetByClass(array("ilportfoliopagegui", "ilobjbloggui"), "render");
1423 $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", "");
1424
1425 $list = new ilAdvancedSelectionListGUI();
1426 $list->setListTitle($lng->txt("action"));
1427 $list->addItem(
1428 sprintf($lng->txt("prtf_edit_embedded_blog"), $this->object->getTitle()),
1429 "",
1430 $link
1431 );
1432
1433 $wtpl->setCurrentBlock("prtf_edit_bl");
1434 //$wtpl->setVariable("PRTF_BLOG_EDIT", $list->getHTML());
1435 $wtpl->parseCurrentBlock();
1436 $b = $this->ui->factory()->button()->standard(
1437 $this->lng->txt("blog_edit"),
1438 $link
1439 );
1440 $this->toolbar->addComponent($b);
1441 }
1442 }
1443
1444 $is_admin = $this->isAdmin();
1445
1446 $last_month = null;
1447 $is_empty = true;
1448 foreach ($items as $item) {
1449 // only published items
1450 $is_active = ilBlogPosting::_lookupActive($item["id"], "blp");
1451 if (!$is_active && !$a_show_inactive) {
1452 continue;
1453 }
1454
1455 $is_empty = false;
1456
1457 if (!$this->keyword && !$this->author) {
1458 $month = substr($item["created"]->get(IL_CAL_DATE), 0, 7);
1459 }
1460
1461 if (!$last_month || $last_month != $month) {
1462 if ($last_month) {
1463 $wtpl->setCurrentBlock("month_bl");
1464 $wtpl->parseCurrentBlock();
1465 }
1466
1467 // title according to current "filter"/navigation
1468 if ($this->keyword) {
1469 $title = $lng->txt("blog_keyword") . ": " . $this->keyword;
1470 } elseif ($this->author) {
1471 $title = $lng->txt("blog_author") . ": " . ilUserUtil::getNamePresentation($this->author);
1472 } else {
1473 $title = ilCalendarUtil::_numericMonthToString((int) substr($month, 5)) .
1474 " " . substr($month, 0, 4);
1475
1476 $last_month = $month;
1477 }
1478
1479 $wtpl->setVariable("TXT_CURRENT_MONTH", $title);
1480 }
1481
1482 if (!$a_link_template) {
1483 $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
1484 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $item["id"]);
1485 $preview = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_cmd);
1486 } else {
1487 $preview = $this->buildExportLink($a_link_template, "posting", $item["id"]);
1488 }
1489 $more_link = $preview;
1490
1491 // actions
1492 $posting_edit = $this->mayEditPosting($item["id"], $item["author"]);
1493 if (($posting_edit || $is_admin) && !$a_link_template && $a_cmd == "preview") {
1494 $alist = new ilAdvancedSelectionListGUI();
1495 $alist->setId($item["id"]);
1496 $alist->setListTitle($lng->txt("actions"));
1497
1498 if ($is_active && $this->object->hasApproval() && !$item["approved"]) {
1499 if ($is_admin) {
1500 $ilCtrl->setParameter($this, "apid", $item["id"]);
1501 $alist->addItem(
1502 $lng->txt("blog_approve"),
1503 "approve",
1504 $ilCtrl->getLinkTarget($this, "approve")
1505 );
1506 $ilCtrl->setParameter($this, "apid", "");
1507 }
1508
1509 $wtpl->setVariable("APPROVAL", $lng->txt("blog_needs_approval"));
1510 }
1511
1512 if ($posting_edit) {
1513 $alist->addItem(
1514 $lng->txt("edit_content"),
1515 "edit",
1516 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit")
1517 );
1518 $more_link = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit");
1519
1520 // #11858
1521 if ($is_active) {
1522 $alist->addItem(
1523 $lng->txt("blog_toggle_draft"),
1524 "deactivate",
1525 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deactivatePageToList")
1526 );
1527 } else {
1528 $alist->addItem(
1529 $lng->txt("blog_toggle_final"),
1530 "activate",
1531 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "activatePageToList")
1532 );
1533 }
1534
1535 $alist->addItem(
1536 $lng->txt("rename"),
1537 "rename",
1538 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edittitle")
1539 );
1540
1541 if ($this->object->hasKeywords()) { // #13616
1542 $alist->addItem(
1543 $lng->txt("blog_edit_keywords"),
1544 "keywords",
1545 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords")
1546 );
1547 }
1548
1549 $alist->addItem(
1550 $lng->txt("blog_edit_date"),
1551 "editdate",
1552 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editdate")
1553 );
1554 $alist->addItem(
1555 $lng->txt("delete"),
1556 "delete",
1557 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen")
1558 );
1559 } elseif ($is_admin) {
1560 // #10513
1561 if ($is_active) {
1562 $ilCtrl->setParameter($this, "apid", $item["id"]);
1563 $alist->addItem(
1564 $lng->txt("blog_toggle_draft_admin"),
1565 "deactivate",
1566 $ilCtrl->getLinkTarget($this, "deactivateAdmin")
1567 );
1568 $ilCtrl->setParameter($this, "apid", "");
1569 }
1570
1571 $alist->addItem(
1572 $lng->txt("delete"),
1573 "delete",
1574 $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen")
1575 );
1576 }
1577
1578 $wtpl->setCurrentBlock("actions");
1579 $wtpl->setVariable("ACTION_SELECTOR", $alist->getHTML());
1580 $wtpl->parseCurrentBlock();
1581 }
1582
1583 // comments
1584 if ($this->object->getNotesStatus() && !$a_link_template && !$this->disable_notes) {
1585 // count (public) notes
1586 $count = sizeof(ilNote::_getNotesOfObject(
1587 $this->obj_id,
1588 $item["id"],
1589 "blp",
1591 ));
1592
1593 if ($a_cmd != "preview") {
1594 $wtpl->setCurrentBlock("comments");
1595 $wtpl->setVariable("TEXT_COMMENTS", $lng->txt("blog_comments"));
1596 $wtpl->setVariable("URL_COMMENTS", $preview);
1597 $wtpl->setVariable("COUNT_COMMENTS", $count);
1598 $wtpl->parseCurrentBlock();
1599 }
1600 /* we disabled comments in edit mode (should always be done via pagegui)
1601 else
1602 {
1603 $hash = ilCommonActionDispatcherGUI::buildAjaxHash(ilCommonActionDispatcherGUI::TYPE_WORKSPACE,
1604 $this->node_id, "blog", $this->obj_id, "blp", $item["id"]);
1605 $notes_link = "#\" onclick=\"".ilNoteGUI::getListCommentsJSCall($hash);
1606 }
1607 */
1608 }
1609
1610 // permanent link
1611 if ($a_cmd != "preview" && $a_cmd != "previewEmbedded") {
1612 if ($this->id_type == self::WORKSPACE_NODE_ID) {
1613 $goto = $this->getAccessHandler()->getGotoLink($this->node_id, $this->obj_id, "_" . $item["id"]);
1614 } else {
1615 $goto = ilLink::_getStaticLink($this->node_id, $this->getType(), true, "_" . $item["id"]);
1616 }
1617 $wtpl->setCurrentBlock("permalink");
1618 $wtpl->setVariable("URL_PERMALINK", $goto);
1619 $wtpl->setVariable("TEXT_PERMALINK", $lng->txt("blog_permanent_link"));
1620 $wtpl->parseCurrentBlock();
1621 }
1622
1624 $item["id"],
1625 $this->object->hasAbstractShorten(),
1626 $this->object->getAbstractShortenLength(),
1627 "&hellip;",
1628 $this->object->hasAbstractImage(),
1629 $this->object->getAbstractImageWidth(),
1630 $this->object->getAbstractImageHeight(),
1631 $a_export_directory
1632 );
1633
1634 if ($snippet) {
1635 $wtpl->setCurrentBlock("more");
1636 $wtpl->setVariable("URL_MORE", $more_link);
1637 $wtpl->setVariable("TEXT_MORE", $lng->txt("blog_list_more"));
1638 $wtpl->parseCurrentBlock();
1639 }
1640
1641
1642
1643 if (!$is_active) {
1644 $wtpl->setCurrentBlock("draft_text");
1645 $wtpl->setVariable("DRAFT_TEXT", $lng->txt("blog_draft_text"));
1646 $wtpl->parseCurrentBlock();
1647 $wtpl->setVariable("DRAFT_CLASS", " ilBlogListItemDraft");
1648 }
1649
1650 $wtpl->setCurrentBlock("posting");
1651
1652 $author = "";
1653 if ($this->id_type == self::REPOSITORY_NODE_ID) {
1654 $authors = array();
1655
1656 $author_id = $item["author"];
1657 if ($author_id) {
1658 $authors[] = ilUserUtil::getNamePresentation($author_id);
1659 }
1660
1661 if (is_array($item["editors"])) {
1662 foreach ($item["editors"] as $editor_id) {
1663 $authors[] = ilUserUtil::getNamePresentation($editor_id);
1664 }
1665 }
1666
1667 if ($authors) {
1668 $author = implode(", ", $authors) . " - ";
1669 }
1670 }
1671
1672 // title
1673 $wtpl->setVariable("URL_TITLE", $preview);
1674 $wtpl->setVariable("TITLE", $item["title"]);
1675
1676 $kw = ilBlogPosting::getKeywords($this->obj_id, $item["id"]);
1677 natcasesort($kw);
1678 $keywords = (count($kw) > 0)
1679 ? "<br>" . $this->lng->txt("keywords") . ": " . implode(", ", $kw)
1680 : "";
1681
1682 $wtpl->setVariable("DATETIME", $author .
1683 ilDatePresentation::formatDate($item["created"]) . $keywords);
1684
1685 // content
1686 $wtpl->setVariable("CONTENT", $snippet);
1687
1688 $wtpl->parseCurrentBlock();
1689 }
1690
1691 // permalink
1692 if ($a_cmd == "previewFullscreen") {
1693 $this->tpl->setPermanentLink(
1694 "blog",
1695 $this->node_id,
1696 ($this->id_type == self::WORKSPACE_NODE_ID)
1697 ? "_wsp"
1698 : ""
1699 );
1700 }
1701
1702 if (!$is_empty || $a_show_inactive) {
1703 return $wtpl->get();
1704 }
1705 }
1706
1713 protected function buildExportLink($a_template, $a_type, $a_id)
1714 {
1715 return \ILIAS\Blog\Export\BlogHtmlExport::buildExportLink($a_template, $a_type, $a_id, $this->getKeywords(false));
1716 }
1717
1718
1729 protected function renderNavigationByDate(array $a_items, $a_list_cmd = "render", $a_posting_cmd = "preview", $a_link_template = null, $a_show_inactive = false, $a_blpg = 0)
1730 {
1731 $ilCtrl = $this->ctrl;
1732
1733 $blpg = ($a_blpg > 0)
1734 ? $a_blpg
1735 : $this->blpg;
1736
1737
1738 // gather page active status
1739 foreach ($a_items as $month => $postings) {
1740 foreach (array_keys($postings) as $id) {
1741 $active = ilBlogPosting::_lookupActive($id, "blp");
1742 if (!$a_show_inactive && !$active) {
1743 unset($a_items[$month][$id]);
1744 } else {
1745 $a_items[$month][$id]["active"] = $active;
1746 }
1747 }
1748 if (!sizeof($a_items[$month])) {
1749 unset($a_items[$month]);
1750 }
1751 }
1752
1753 // list month (incl. postings)
1754 if ($this->object->getNavMode() == ilObjBlog::NAV_MODE_LIST || $a_link_template) {
1755 //$max_detail_postings = $this->object->getNavModeListPostings();
1756 $max_months = $this->object->getNavModeListMonths();
1757
1758 $wtpl = new ilTemplate("tpl.blog_list_navigation_by_date.html", true, true, "Modules/Blog");
1759
1760 $ilCtrl->setParameter($this, "blpg", "");
1761
1762 $counter = $mon_counter = $last_year = 0;
1763 foreach ($a_items as $month => $postings) {
1764 if (!$a_link_template && $max_months && $mon_counter >= $max_months) {
1765 break;
1766 }
1767
1768 $add_year = false;
1769 $year = substr($month, 0, 4);
1770 if (!$last_year || $year != $last_year) {
1771 // #13562
1772 $add_year = true;
1773 $last_year = $year;
1774 }
1775
1776 $mon_counter++;
1777
1778 $month_name = ilCalendarUtil::_numericMonthToString((int) substr($month, 5));
1779
1780 if (!$a_link_template) {
1781 $ilCtrl->setParameter($this, "bmn", $month);
1782 $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1783 } else {
1784 $month_url = $this->buildExportLink($a_link_template, "list", $month);
1785 }
1786
1787 // list postings for month
1788 //if($counter < $max_detail_postings)
1789 if ($mon_counter <= $this->object->getNavModeListMonthsWithPostings()) {
1790 if ($add_year) {
1791 $wtpl->setCurrentBlock("navigation_year_details");
1792 $wtpl->setVariable("YEAR", $year);
1793 $wtpl->parseCurrentBlock();
1794 }
1795
1796 foreach ($postings as $id => $posting) {
1797 //if($max_detail_postings && $counter >= $max_detail_postings)
1798 //{
1799 // break;
1800 //}
1801
1802 $counter++;
1803
1804 $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1805 ", ".*/ $posting["title"];
1806
1807 if (!$a_link_template) {
1808 $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1809 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1810 $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1811 } else {
1812 $url = $this->buildExportLink($a_link_template, "posting", $id);
1813 }
1814
1815 if (!$posting["active"]) {
1816 $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1817 } elseif ($this->object->hasApproval() && !$posting["approved"]) {
1818 $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1819 }
1820
1821 $wtpl->setCurrentBlock("navigation_item");
1822 $wtpl->setVariable("NAV_ITEM_URL", $url);
1823 $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1824 $wtpl->parseCurrentBlock();
1825 }
1826
1827 $wtpl->setCurrentBlock("navigation_month_details");
1828 $wtpl->setVariable("NAV_MONTH", $month_name);
1829 $wtpl->setVariable("URL_MONTH", $month_url);
1830 $wtpl->parseCurrentBlock();
1831 }
1832 // summarized month
1833 else {
1834 if ($add_year) {
1835 $wtpl->setCurrentBlock("navigation_year");
1836 $wtpl->setVariable("YEAR", $year);
1837 $wtpl->parseCurrentBlock();
1838 }
1839
1840 $wtpl->setCurrentBlock("navigation_month");
1841 $wtpl->setVariable("MONTH_NAME", $month_name);
1842 $wtpl->setVariable("URL_MONTH", $month_url);
1843 $wtpl->setVariable("MONTH_COUNT", sizeof($postings));
1844 $wtpl->parseCurrentBlock();
1845 }
1846 }
1847
1848 $ilCtrl->setParameter($this, "bmn", $this->month);
1849 $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
1850
1851 return $wtpl->get();
1852 }
1853 // single month
1854 else {
1855 $wtpl = new ilTemplate("tpl.blog_list_navigation_month.html", true, true, "Modules/Blog");
1856
1857 $ilCtrl->setParameter($this, "blpg", "");
1858
1859 $month_options = array();
1860 foreach ($a_items as $month => $postings) {
1861 $month_name = ilCalendarUtil::_numericMonthToString((int) substr($month, 5)) .
1862 " " . substr($month, 0, 4);
1863
1864 $month_options[$month] = $month_name;
1865
1866 if ($month == $this->month) {
1867 if (!$a_link_template) {
1868 $ilCtrl->setParameter($this, "bmn", $month);
1869 $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1870 } else {
1871 $month_url = $this->buildExportLink($a_link_template, "list", $month);
1872 }
1873
1874 foreach ($postings as $id => $posting) {
1875 $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1876 ", ".*/ $posting["title"];
1877
1878 if (!$a_link_template) {
1879 $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1880 $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1881 $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1882 } else {
1883 $url = $this->buildExportLink($a_link_template, "posting", $id);
1884 }
1885
1886 if (!$posting["active"]) {
1887 $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1888 } elseif ($this->object->hasApproval() && !$posting["approved"]) {
1889 $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1890 }
1891
1892 $wtpl->setCurrentBlock("navigation_item");
1893 $wtpl->setVariable("NAV_ITEM_URL", $url);
1894 $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1895 $wtpl->parseCurrentBlock();
1896 }
1897
1898 $wtpl->setCurrentBlock("navigation_month_details");
1899 if ($blpg > 0) {
1900 $wtpl->setVariable("NAV_MONTH", $month_name);
1901 $wtpl->setVariable("URL_MONTH", $month_url);
1902 }
1903 $wtpl->parseCurrentBlock();
1904 }
1905 }
1906
1907 if ($blpg == 0) {
1908 $wtpl->setCurrentBlock("option_bl");
1909 foreach ($month_options as $value => $caption) {
1910 $wtpl->setVariable("OPTION_VALUE", $value);
1911 $wtpl->setVariable("OPTION_CAPTION", $caption);
1912 if ($value == $this->month) {
1913 $wtpl->setVariable("OPTION_SEL", ' selected="selected"');
1914 }
1915 $wtpl->parseCurrentBlock();
1916 }
1917
1918 $wtpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this, $a_list_cmd));
1919 }
1920
1921 $ilCtrl->setParameter($this, "bmn", $this->month);
1922 $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
1923
1924 return $wtpl->get();
1925 }
1926 }
1927
1935 protected function renderNavigationByKeywords(
1936 $a_list_cmd = "render",
1937 $a_show_inactive = false,
1938 $a_link_template = false,
1939 $a_blpg = 0
1940 ) {
1941 $ilCtrl = $this->ctrl;
1942
1943 $blpg = ($a_blpg > 0)
1944 ? $a_blpg
1945 : $this->blpg;
1946
1947 $keywords = $this->getKeywords($a_show_inactive, $blpg);
1948 if ($keywords) {
1949 $wtpl = new ilTemplate("tpl.blog_list_navigation_keywords.html", true, true, "Modules/Blog");
1950
1951 $max = max($keywords);
1952
1953 $wtpl->setCurrentBlock("keyword");
1954 foreach ($keywords as $keyword => $counter) {
1955 if (!$a_link_template) {
1956 $ilCtrl->setParameter($this, "kwd", urlencode($keyword)); // #15885
1957 $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1958 $ilCtrl->setParameter($this, "kwd", "");
1959 } else {
1960 $url = $this->buildExportLink($a_link_template, "keyword", $keyword);
1961 }
1962
1963 $wtpl->setVariable("TXT_KEYWORD", $keyword);
1964 $wtpl->setVariable("CLASS_KEYWORD", ilTagging::getRelevanceClass($counter, $max));
1965 $wtpl->setVariable("URL_KEYWORD", $url);
1966 $wtpl->parseCurrentBlock();
1967 }
1968
1969 return $wtpl->get();
1970 }
1971 }
1972
1973 protected function renderNavigationByAuthors(array $a_items, $a_list_cmd = "render", $a_show_inactive = false)
1974 {
1975 $ilCtrl = $this->ctrl;
1976
1977 $authors = array();
1978 foreach ($a_items as $month => $items) {
1979 foreach ($items as $item) {
1980 if (($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp"))) {
1981 if ($item["author"]) {
1982 $authors[] = $item["author"];
1983 }
1984
1985 if (is_array($item["editors"])) {
1986 foreach ($item["editors"] as $editor_id) {
1987 if ($editor_id != $item["author"]) {
1988 $authors[] = $editor_id;
1989 }
1990 }
1991 }
1992 }
1993 }
1994 }
1995
1996 $authors = array_unique($authors);
1997 if (sizeof($authors) > 1) {
1998 $list = array();
1999 foreach ($authors as $user_id) {
2000 if ($user_id) {
2001 $ilCtrl->setParameter($this, "ath", $user_id);
2002 $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
2003 $ilCtrl->setParameter($this, "ath", "");
2004
2005 $name = ilUserUtil::getNamePresentation($user_id, true);
2006 $idx = trim(strip_tags($name)) . "///" . $user_id; // #10934
2007 $list[$idx] = array($name, $url);
2008 }
2009 }
2010 ksort($list);
2011
2012 $wtpl = new ilTemplate("tpl.blog_list_navigation_authors.html", true, true, "Modules/Blog");
2013
2014 $wtpl->setCurrentBlock("author");
2015 foreach ($list as $author) {
2016 $wtpl->setVariable("TXT_AUTHOR", $author[0]);
2017 $wtpl->setVariable("URL_AUTHOR", $author[1]);
2018 $wtpl->parseCurrentBlock();
2019 }
2020
2021 return $wtpl->get();
2022 }
2023 }
2024
2031 public function renderToolbarNavigation($a_items, $single_posting = false)
2032 {
2033 global $DIC;
2034
2035 $toolbar = $DIC->toolbar();
2036 $lng = $DIC->language();
2037 $ctrl = $DIC->ctrl();
2038
2039 $f = $DIC->ui()->factory();
2040
2041 $cmd = ($this->prtf_embed)
2042 ? "previewEmbedded"
2043 : "previewFullscreen";
2044
2045 if ($single_posting) { // single posting view
2046 $latest_posting = $this->getLatestPosting($a_items);
2047 if ($latest_posting != "" && $this->blpg != $latest_posting) {
2048 $ctrl->setParameterByClass("ilblogpostinggui", "blpg", $latest_posting);
2049 $mb = $f->button()->standard(
2050 $lng->txt("blog_latest_posting"),
2051 $ctrl->getLinkTargetByClass("ilblogpostinggui", $cmd)
2052 );
2053 } else {
2054 $mb = $f->button()->standard($lng->txt("blog_latest_posting"), "#")->withUnavailableAction();
2055 }
2056
2057 $prev_posting = $this->getPreviousPosting($a_items);
2058 if ($prev_posting != "") {
2059 $ctrl->setParameterByClass("ilblogpostinggui", "blpg", $prev_posting);
2060 $pb = $f->button()->standard(
2061 $lng->txt("previous"),
2062 $ctrl->getLinkTargetByClass("ilblogpostinggui", $cmd)
2063 );
2064 } else {
2065 $pb = $f->button()->standard($lng->txt("previous"), "#")->withUnavailableAction();
2066 }
2067
2068 $next_posting = $this->getNextPosting($a_items);
2069 if ($next_posting != "") {
2070 $ctrl->setParameterByClass("ilblogpostinggui", "blpg", $next_posting);
2071 $nb = $f->button()->standard(
2072 $lng->txt("next"),
2073 $ctrl->getLinkTargetByClass("ilblogpostinggui", $cmd)
2074 );
2075 } else {
2076 $nb = $f->button()->standard($lng->txt("next"), "#")->withUnavailableAction();
2077 }
2078 $ctrl->setParameter($this, "blpg", $this->blpg);
2079 $vc = $f->viewControl()->section($pb, $mb, $nb);
2080 $toolbar->addComponent($vc);
2081 if ($this->mayContribute() && $this->mayEditPosting($this->blpg)) {
2082 $ctrl->setParameter($this, "prvm", "");
2083
2084
2085 $ctrl->setParameter($this, "bmn", "");
2086 $ctrl->setParameter($this, "blpg", "");
2087 $link = $ctrl->getLinkTarget($this, "");
2088 $ctrl->setParameter($this, "blpg", $this->blpg);
2089 $ctrl->setParameter($this, "bmn", $this->month);
2090 $toolbar->addSeparator();
2091 $toolbar->addComponent($f->button()->standard($lng->txt("blog_edit"), $link));
2092
2093
2094 $ctrl->setParameterByClass("ilblogpostinggui", "blpg", $this->blpg);
2095 if ($this->prtf_embed) {
2096 $this->ctrl->setParameterByClass("ilobjportfoliogui", "ppage", $this->user_page);
2097 }
2098 $link = $ctrl->getLinkTargetByClass("ilblogpostinggui", "edit");
2099 $toolbar->addComponent($f->button()->standard($lng->txt("blog_edit_posting"), $link));
2100 }
2101 } else { // month view
2102 $latest_month = $this->getLatestMonth($a_items);
2103 if ($latest_month != "" && $this->month != $latest_month) {
2104 $ctrl->setParameter($this, "bmn", $latest_month);
2105 $mb = $f->button()->standard(
2106 $lng->txt("blog_latest_posting"),
2107 $ctrl->getLinkTarget($this, "preview")
2108 );
2109 } else {
2110 $mb = $f->button()->standard($lng->txt("blog_latest_posting"), "#")->withUnavailableAction();
2111 }
2112
2113 $prev_month = $this->getPreviousMonth($a_items);
2114 if ($prev_month != "") {
2115 $ctrl->setParameter($this, "bmn", $prev_month);
2116 $pb = $f->button()->standard($lng->txt("previous"), $ctrl->getLinkTarget($this, "preview"));
2117 } else {
2118 $pb = $f->button()->standard($lng->txt("previous"), "#")->withUnavailableAction();
2119 }
2120
2121 $next_month = $this->getNextMonth($a_items);
2122 if ($next_month != "") {
2123 $ctrl->setParameter($this, "bmn", $next_month);
2124 $nb = $f->button()->standard($lng->txt("next"), $ctrl->getLinkTarget($this, "preview"));
2125 } else {
2126 $nb = $f->button()->standard($lng->txt("next"), "#")->withUnavailableAction();
2127 }
2128 $ctrl->setParameter($this, "bmn", $this->month);
2129 $vc = $f->viewControl()->section($pb, $mb, $nb);
2130 $toolbar->addComponent($vc);
2131
2132 if ($this->mayContribute()) {
2133 $ctrl->setParameter($this, "prvm", "");
2134
2135 $ctrl->setParameter($this, "bmn", "");
2136 $ctrl->setParameter($this, "blpg", "");
2137 $link = $ctrl->getLinkTarget($this, "");
2138 $ctrl->setParameter($this, "blpg", $this->blpg);
2139 $ctrl->setParameter($this, "bmn", $this->month);
2140 $toolbar->addSeparator();
2141 $toolbar->addComponent($f->button()->standard($lng->txt("blog_edit"), $link));
2142 }
2143 }
2144 }
2145
2152 public function getNextMonth($a_items)
2153 {
2154 reset($a_items);
2155 $found = "";
2156 foreach ($a_items as $month => $items) {
2157 if ($month > $this->month) {
2158 $found = $month;
2159 }
2160 }
2161 return $found;
2162 }
2163
2170 public function getPreviousMonth($a_items)
2171 {
2172 reset($a_items);
2173 $found = "";
2174 foreach ($a_items as $month => $items) {
2175 if ($month < $this->month && $found == "") {
2176 $found = $month;
2177 }
2178 }
2179 return $found;
2180 }
2181
2188 public function getLatestMonth($a_items)
2189 {
2190 reset($a_items);
2191 return key($a_items);
2192 }
2193
2200 public function getNextPosting($a_items)
2201 {
2202 reset($a_items);
2203 $found = "";
2204 $next_blpg = 0;
2205 foreach ($a_items as $month => $items) {
2206 foreach ($items as $item) {
2207 if ($item["id"] == $this->blpg) {
2208 $found = true;
2209 }
2210 if (!$found) {
2211 $next_blpg = $item["id"];
2212 }
2213 }
2214 }
2215 return $next_blpg;
2216 }
2217
2224 public function getPreviousPosting($a_items)
2225 {
2226 reset($a_items);
2227 $found = "";
2228 $prev_blpg = 0;
2229 foreach ($a_items as $month => $items) {
2230 foreach ($items as $item) {
2231 if ($found && $prev_blpg == "") {
2232 $prev_blpg = $item["id"];
2233 }
2234 if ($item["id"] == $this->blpg) {
2235 $found = true;
2236 }
2237 }
2238 }
2239 return $prev_blpg;
2240 }
2241
2248 public function getLatestPosting($a_items)
2249 {
2250 reset($a_items);
2251 $month = current($a_items);
2252 if (is_array($month)) {
2253 return current($month)["id"];
2254 }
2255 return false;
2256 }
2257
2268 public function renderNavigation($a_list_cmd = "render", $a_posting_cmd = "preview", $a_link_template = null, $a_show_inactive = false, $a_blpg = 0)
2269 {
2270 $ilCtrl = $this->ctrl;
2272 $a_items = $this->items;
2273
2274 $blpg = ($a_blpg > 0)
2275 ? $a_blpg
2276 : $this->blpg;
2277
2278 if ($this->object->getOrder()) {
2279 $order = array_flip($this->object->getOrder());
2280 } else {
2281 $order = array(
2282 "navigation" => 0
2283 ,"keywords" => 2
2284 ,"authors" => 1
2285 );
2286 }
2287
2288 $wtpl = new ilTemplate("tpl.blog_list_navigation.html", true, true, "Modules/Blog");
2289
2290 $blocks = array();
2291
2292 // by date
2293 if (sizeof($a_items)) {
2294 $blocks[$order["navigation"]] = array(
2295 $this->lng->txt("blog_navigation"),
2296 $this->renderNavigationByDate($a_items, $a_list_cmd, $a_posting_cmd, $a_link_template, $a_show_inactive, $a_blpg)
2297 );
2298 }
2299
2300 if ($this->object->hasKeywords()) {
2301 // keywords
2302 $may_edit_keywords = ($blpg > 0 &&
2303 $this->mayEditPosting($blpg) &&
2304 $a_list_cmd != "preview" &&
2305 $a_list_cmd != "gethtml" &&
2306 !$a_link_template);
2307 $keywords = $this->renderNavigationByKeywords($a_list_cmd, $a_show_inactive, $a_link_template, $a_blpg);
2308 if ($keywords || $may_edit_keywords) {
2309 if (!$keywords) {
2310 $keywords = $this->lng->txt("blog_no_keywords");
2311 }
2312 $cmd = null;
2313 $blocks[$order["keywords"]] = array(
2314 $this->lng->txt("blog_keywords"),
2315 $keywords,
2316 $cmd
2317 ? array($cmd, $this->lng->txt("blog_edit_keywords"))
2318 : null
2319 );
2320 }
2321 }
2322
2323 // is not part of (html) export
2324 if (!$a_link_template) {
2325 // authors
2326 if ($this->id_type == self::REPOSITORY_NODE_ID &&
2327 $this->object->hasAuthors()) {
2328 $authors = $this->renderNavigationByAuthors($a_items, $a_list_cmd, $a_show_inactive);
2329 if ($authors) {
2330 $blocks[$order["authors"]] = array($this->lng->txt("blog_authors"), $authors);
2331 }
2332 }
2333
2334 // rss
2335 if ($this->object->hasRSS() &&
2336 $ilSetting->get('enable_global_profiles') &&
2337 $a_list_cmd == "preview") {
2338 // #10827
2339 $blog_id = $this->node_id;
2340 if ($this->id_type != self::WORKSPACE_NODE_ID) {
2341 $blog_id .= "_cll";
2342 }
2343 $url = ILIAS_HTTP_PATH . "/feed.php?blog_id=" . $blog_id .
2344 "&client_id=" . rawurlencode(CLIENT_ID);
2345
2346 $wtpl->setVariable("RSS_BUTTON", ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_RSS, $url));
2347 }
2348 }
2349
2350 if (sizeof($blocks)) {
2351 global $DIC;
2352
2353 $ui_factory = $DIC->ui()->factory();
2354 $ui_renderer = $DIC->ui()->renderer();
2355
2356 ksort($blocks);
2357 foreach ($blocks as $block) {
2358 $title = $block[0];
2359
2360 $content = $block[1];
2361
2362 $secondary_panel = $ui_factory->panel()->secondary()->legacy($title, $ui_factory->legacy($content));
2363
2364 if (isset($block[2]) && is_array($block[2])) {
2365 $link = $ui_factory->button()->shy($block[2][1], $block[2][0]);
2366 $secondary_panel = $secondary_panel->withFooter($link);
2367 }
2368
2369 $wtpl->setCurrentBlock("block_bl");
2370 $wtpl->setVariable("BLOCK", $ui_renderer->render($secondary_panel));
2371 $wtpl->parseCurrentBlock();
2372 }
2373 }
2374
2375 return $wtpl->get();
2376 }
2377
2385 public function getKeywords($a_show_inactive, $a_posting_id = null)
2386 {
2387 $keywords = array();
2388 if ($a_posting_id) {
2389 foreach (ilBlogPosting::getKeywords($this->obj_id, $a_posting_id) as $keyword) {
2390 $keywords[$keyword]++;
2391 }
2392 } else {
2393 foreach ($this->items as $month => $items) {
2394 foreach ($items as $item) {
2395 if ($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp")) {
2396 foreach (ilBlogPosting::getKeywords($this->obj_id, $item["id"]) as $keyword) {
2397 $keywords[$keyword]++;
2398 }
2399 }
2400 }
2401 }
2402 }
2403
2404 // #15881
2405 $tmp = array();
2406 foreach ($keywords as $keyword => $counter) {
2407 $tmp[] = array("keyword" => $keyword, "counter" => $counter);
2408 }
2409 $tmp = ilUtil::sortArray($tmp, "keyword", "ASC");
2410
2411 $keywords = array();
2412 foreach ($tmp as $item) {
2413 $keywords[$item["keyword"]] = $item["counter"];
2414 }
2415 return $keywords;
2416 }
2417
2423 public function buildExportFile($a_include_comments = false)
2424 {
2425 $type = "html";
2426 $format = explode("_", $_POST["format"]);
2427 if ($format[1] == "comments" || $a_include_comments) {
2428 $a_include_comments = true;
2429 $type = "html_comments";
2430 }
2431
2432 // create export file
2433 ilExport::_createExportDirectory($this->object->getId(), $type, "blog");
2434 $exp_dir = ilExport::_getExportDirectory($this->object->getId(), $type, "blog");
2435
2436 $subdir = $this->object->getType() . "_" . $this->object->getId();
2437
2438 $blog_export = new \ILIAS\Blog\Export\BlogHtmlExport($this, $exp_dir, $subdir);
2439 $blog_export->includeComments($a_include_comments);
2440 return $blog_export->exportHTML();
2441 }
2442
2443 public function getNotesSubId()
2444 {
2445 return $this->blpg;
2446 }
2447
2448 public function disableNotes($a_value = false)
2449 {
2450 $this->disable_notes = (bool) $a_value;
2451 }
2452
2453 protected function addHeaderActionForCommand($a_cmd)
2454 {
2456 $ilCtrl = $this->ctrl;
2457 // preview?
2458 if ($a_cmd == "preview" || $a_cmd == "previewEmbedded" || $a_cmd == "previewFullscreen" || $this->prvm) {
2459 // notification
2460 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
2461 if (!$this->prvm) {
2462 $ilCtrl->setParameter($this, "prvm", "fsc");
2463 }
2464 $this->insertHeaderAction($this->initHeaderAction(null, null, true));
2465 if (!$this->prvm) {
2466 $ilCtrl->setParameter($this, "prvm", "");
2467 }
2468 }
2469 } else {
2470 return parent::addHeaderAction();
2471 }
2472 }
2473
2474 protected function initHeaderAction($sub_type = null, $sub_id = null, $a_is_preview = false)
2475 {
2477 $ilCtrl = $this->ctrl;
2478 if (!$this->obj_id) {
2479 return false;
2480 }
2481 $sub_type = $sub_id = null;
2482 if ($this->blpg > 0) {
2483 $sub_type = "blp";
2484 $sub_id = $this->blpg;
2485 }
2486
2487 $lg = parent::initHeaderAction($sub_type, $sub_id);
2488 if (!$lg) {
2489 return null;
2490 }
2491 $lg->enableComments(false);
2492 $lg->enableNotes(false);
2493
2494 if ($a_is_preview) {
2495 if ($this->blpg > 0) {
2496 if (($this->object->getNotesStatus() && !$this->disable_notes)) {
2497 $lg->enableComments(true);
2498 }
2499 $lg->enableNotes(true);
2500 }
2501 $lg->enableTags(false);
2502
2503 if (!$this->prtf_embed) {
2505 $ilCtrl->setParameter($this, "ntf", 1);
2506 $link = $ilCtrl->getLinkTarget($this, "setNotification");
2507 $ilCtrl->setParameter($this, "ntf", "");
2508 if (ilNotification::hasOptOut($this->obj_id)) {
2509 $lg->addCustomCommand($link, "blog_notification_toggle_off");
2510 }
2511
2512 $lg->addHeaderIcon(
2513 "not_icon",
2514 ilUtil::getImagePath("notification_on.svg"),
2515 $this->lng->txt("blog_notification_activated")
2516 );
2517 } else {
2518 $ilCtrl->setParameter($this, "ntf", 2);
2519 $link = $ilCtrl->getLinkTarget($this, "setNotification");
2520 $ilCtrl->setParameter($this, "ntf", "");
2521 $lg->addCustomCommand($link, "blog_notification_toggle_on");
2522
2523 $lg->addHeaderIcon(
2524 "not_icon",
2525 ilUtil::getImagePath("notification_off.svg"),
2526 $this->lng->txt("blog_notification_deactivated")
2527 );
2528 }
2529 }
2530
2531 // #11758
2532 if ($this->mayContribute()) {
2533 $ilCtrl->setParameter($this, "prvm", "");
2534
2535 $ilCtrl->setParameter($this, "bmn", "");
2536 $ilCtrl->setParameter($this, "blpg", "");
2537 $link = $ilCtrl->getLinkTarget($this, "");
2538 $ilCtrl->setParameter($this, "blpg", $sub_id);
2539 $ilCtrl->setParameter($this, "bmn", $this->month);
2540 $lg->addCustomCommand($link, "blog_edit"); // #11868
2541
2542 if ($sub_id && $this->mayEditPosting($sub_id)) {
2543 $link = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit");
2544 $lg->addCustomCommand($link, "blog_edit_posting");
2545 }
2546
2547 $ilCtrl->setParameter($this, "prvm", "fsc");
2548 }
2549
2550 $ilCtrl->setParameter($this, "ntf", "");
2551 }
2552
2553 return $lg;
2554 }
2555
2556 protected function setNotification()
2557 {
2559 $ilCtrl = $this->ctrl;
2560
2561 switch ($this->ntf) {
2562 case 1:
2563 ilNotification::setNotification(ilNotification::TYPE_BLOG, $ilUser->getId(), $this->obj_id, false);
2564 break;
2565
2566 case 2:
2568 break;
2569 }
2570
2571 $ilCtrl->redirect($this, "preview");
2572 }
2573
2581 public static function lookupSubObjectTitle($a_blog_id, $a_posting_id)
2582 {
2583 // page might be deleted, so setting halt on errors to false
2584 $post = new ilBlogPosting($a_posting_id);
2585 if ($post->getBlogId() == $a_blog_id) {
2586 return $post->getTitle();
2587 }
2588 }
2589
2595 protected function filterInactivePostings()
2596 {
2597 foreach ($this->items as $month => $postings) {
2598 foreach ($postings as $id => $item) {
2599 if (!ilBlogPosting::_lookupActive($id, "blp")) {
2600 unset($this->items[$month][$id]);
2601 } elseif ($this->object->hasApproval() && !$item["approved"]) {
2602 unset($this->items[$month][$id]);
2603 }
2604 }
2605 if (!sizeof($this->items[$month])) {
2606 unset($this->items[$month]);
2607 }
2608 }
2609
2610 if ($this->items && !isset($this->items[$this->month])) {
2611 $this->month = array_shift(array_keys($this->items));
2612 }
2613 }
2614
2615 public function filterItemsByKeyWord(array $a_items, $a_keyword)
2616 {
2617 $res = array();
2618 foreach ($a_items as $month => $items) {
2619 foreach ($items as $item) {
2620 if (in_array(
2621 $a_keyword,
2622 ilBlogPosting::getKeywords($this->obj_id, $item["id"])
2623 )) {
2624 $res[] = $item;
2625 }
2626 }
2627 }
2628 return $res;
2629 }
2630
2636 protected function isAdmin()
2637 {
2638 return ($this->checkPermissionBool("redact") ||
2639 $this->checkPermissionBool("write"));
2640 }
2641
2649 protected function mayEditPosting($a_posting_id, $a_author_id = null)
2650 {
2652
2653 // single author blog (owner) in personal workspace
2654 if ($this->id_type == self::WORKSPACE_NODE_ID) {
2655 return $this->checkPermissionBool("write");
2656 }
2657
2658 // repository blogs
2659
2660 // redact allows to edit all postings
2661 if ($this->checkPermissionBool("redact")) {
2662 return true;
2663 }
2664
2665 // contribute gives access to own postings
2666 if ($this->checkPermissionBool("contribute")) {
2667 // check owner of posting
2668 if (!$a_author_id) {
2669 $post = new ilBlogPosting($a_posting_id);
2670 $a_author_id = $post->getAuthor();
2671 }
2672 if ($ilUser->getId() == $a_author_id) {
2673 return true;
2674 } else {
2675 return false;
2676 }
2677
2678 return true;
2679 }
2680 return false;
2681 }
2682
2688 protected function mayContribute()
2689 {
2690 // single author blog (owner) in personal workspace
2691 if ($this->id_type == self::WORKSPACE_NODE_ID) {
2692 return $this->checkPermissionBool("write");
2693 }
2694
2695 return ($this->checkPermissionBool("redact") ||
2696 $this->checkPermissionBool("contribute"));
2697 }
2698
2699 public function addLocatorItems()
2700 {
2701 $ilLocator = $this->locator;
2702
2703 if (is_object($this->object)) {
2704 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "preview"), "", $this->node_id);
2705 }
2706 }
2707
2708 public function approve()
2709 {
2710 if ($this->isAdmin() && $this->apid > 0) {
2711 $post = new ilBlogPosting($this->apid);
2712 $post->setApproved(true);
2713 $post->setBlogNodeId($this->node_id, ($this->id_type == self::WORKSPACE_NODE_ID));
2714 $post->update(true, false, true, "new"); // #13434
2715
2716 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2717 }
2718
2719 $this->ctrl->redirect($this, "render");
2720 }
2721
2722
2723 //
2724 // contributors
2725 //
2726
2727 public function contributors()
2728 {
2729 $ilTabs = $this->tabs;
2730 $ilToolbar = $this->toolbar;
2731 $ilCtrl = $this->ctrl;
2732 $lng = $this->lng;
2733 $tpl = $this->tpl;
2734
2735 if (!$this->checkPermissionBool("write")) {
2736 return;
2737 }
2738
2739 $ilTabs->activateTab("contributors");
2740
2741 $local_roles = $this->object->getAllLocalRoles($this->node_id);
2742
2743 // add member
2745 $this,
2746 $ilToolbar,
2747 array(
2748 'auto_complete_name' => $lng->txt('user'),
2749 'submit_name' => $lng->txt('add'),
2750 'add_search' => true,
2751 'add_from_container' => $this->node_id,
2752 'user_type' => $local_roles
2753 ),
2754 true
2755 );
2756
2757 $other_roles = $this->object->getRolesWithContributeOrRedact($this->node_id);
2758 if ($other_roles) {
2759 ilUtil::sendInfo(sprintf($lng->txt("blog_contribute_other_roles"), implode(", ", $other_roles)));
2760 }
2761
2762 $tbl = new ilContributorTableGUI($this, "contributors", $this->object->getAllLocalRoles($this->node_id));
2763
2764 $tpl->setContent($tbl->getHTML());
2765 }
2766
2770 public function addUserFromAutoComplete()
2771 {
2772 $lng = $this->lng;
2773
2774 $user_login = ilUtil::stripSlashes($_POST['user_login']);
2775 $user_type = ilUtil::stripSlashes($_POST["user_type"]);
2776
2777 if (!strlen(trim($user_login))) {
2778 ilUtil::sendFailure($lng->txt('msg_no_search_string'));
2779 return $this->contributors();
2780 }
2781 $users = explode(',', $user_login);
2782
2783 $user_ids = array();
2784 foreach ($users as $user) {
2785 $user_id = ilObjUser::_lookupId($user);
2786
2787 if (!$user_id) {
2788 ilUtil::sendFailure($lng->txt('user_not_known'));
2789 return $this->contributors();
2790 }
2791
2792 $user_ids[] = $user_id;
2793 }
2794
2795 return $this->addContributor($user_ids, $user_type);
2796 }
2797
2803 public function addContributor($a_user_ids = array(), $a_user_type = null)
2804 {
2805 $ilCtrl = $this->ctrl;
2806 $lng = $this->lng;
2809
2810 if (!$this->checkPermissionBool("write")) {
2811 return;
2812 }
2813
2814 if (!count($a_user_ids) || !$a_user_type) {
2815 ilUtil::sendFailure($lng->txt("no_checkbox"));
2816 return $this->contributors();
2817 }
2818
2819 // get contributor role
2820 $local_roles = array_keys($this->object->getAllLocalRoles($this->node_id));
2821 if (!in_array($a_user_type, $local_roles)) {
2822 ilUtil::sendFailure($lng->txt("missing_perm"));
2823 return $this->contributors();
2824 }
2825
2826 foreach ($a_user_ids as $user_id) {
2827 if (!$rbacreview->isAssigned($user_id, $a_user_type)) {
2828 $rbacadmin->assignUser($a_user_type, $user_id);
2829 }
2830 }
2831
2832 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
2833 $ilCtrl->redirect($this, "contributors");
2834 }
2835
2840 {
2842
2843 if (!is_array($ids)) {
2844 ilUtil::sendFailure($this->lng->txt("select_one"), true);
2845 $this->ctrl->redirect($this, "contributors");
2846 }
2847
2848 $confirm = new ilConfirmationGUI();
2849 $confirm->setHeaderText($this->lng->txt('blog_confirm_delete_contributors'));
2850 $confirm->setFormAction($this->ctrl->getFormAction($this, 'removeContributor'));
2851 $confirm->setConfirm($this->lng->txt('delete'), 'removeContributor');
2852 $confirm->setCancel($this->lng->txt('cancel'), 'contributors');
2853
2854 foreach ($ids as $user_id) {
2855 $confirm->addItem(
2856 'id[]',
2857 $user_id,
2858 ilUserUtil::getNamePresentation($user_id, false, false, "", true)
2859 );
2860 }
2861
2862 $this->tpl->setContent($confirm->getHTML());
2863 }
2864
2868 public function removeContributor()
2869 {
2870 $ilCtrl = $this->ctrl;
2871 $lng = $this->lng;
2873
2875
2876 if (!is_array($ids)) {
2877 ilUtil::sendFailure($lng->txt("select_one"), true);
2878 $ilCtrl->redirect($this, "contributors");
2879 }
2880
2881 // get contributor role
2882 $local_roles = array_keys($this->object->getAllLocalRoles($this->node_id));
2883 if (!$local_roles) {
2884 ilUtil::sendFailure($lng->txt("missing_perm"));
2885 return $this->contributors();
2886 }
2887
2888 foreach ($ids as $user_id) {
2889 foreach ($local_roles as $role_id) {
2890 $rbacadmin->deassignUser($role_id, $user_id);
2891 }
2892 }
2893
2894 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
2895 $this->ctrl->redirect($this, "contributors");
2896 }
2897
2898 public function deactivateAdmin()
2899 {
2900 if ($this->checkPermissionBool("write") && $this->apid > 0) {
2901 // ilBlogPostingGUI::deactivatePage()
2902 $post = new ilBlogPosting($this->apid);
2903 $post->setApproved(false);
2904 $post->setActive(false);
2905 $post->update(true, false, false);
2906
2907 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2908 }
2909
2910 $this->ctrl->redirect($this, "render");
2911 }
2912
2913
2917
2918 public function setContentStyleSheet($a_tpl = null)
2919 {
2920 $tpl = $this->tpl;
2921
2922 if ($a_tpl != null) {
2923 $ctpl = $a_tpl;
2924 } else {
2925 $ctpl = $tpl;
2926 }
2927
2928 $ctpl->setCurrentBlock("ContentStyle");
2929 $ctpl->setVariable(
2930 "LOCATION_CONTENT_STYLESHEET",
2931 ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
2932 );
2933 $ctpl->parseCurrentBlock();
2934 }
2935
2936 public function editStyleProperties()
2937 {
2938 $this->checkPermission("write");
2939
2940 $this->tabs_gui->activateTab("settings");
2941 $this->setSettingsSubTabs("style");
2942
2943 $form = $this->initStylePropertiesForm();
2944 $this->tpl->setContent($form->getHTML());
2945 }
2946
2947 public function initStylePropertiesForm()
2948 {
2950
2951 $this->lng->loadLanguageModule("style");
2952
2953 $form = new ilPropertyFormGUI();
2954
2955 $fixed_style = $ilSetting->get("fixed_content_style_id");
2956 $style_id = $this->object->getStyleSheetId();
2957
2958 if ($fixed_style > 0) {
2959 $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
2960 $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
2961 $this->lng->txt("global_fixed") . ")");
2962 $form->addItem($st);
2963 } else {
2965 true,
2966 false,
2967 $this->ref_id
2968 );
2969
2970 $st_styles[0] = $this->lng->txt("default");
2971 ksort($st_styles);
2972
2973 if ($style_id > 0) {
2974 // individual style
2975 if (!ilObjStyleSheet::_lookupStandard($style_id)) {
2976 $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
2977 $st->setValue(ilObject::_lookupTitle($style_id));
2978 $form->addItem($st);
2979
2980 // delete command
2981 $form->addCommandButton("editStyle", $this->lng->txt("style_edit_style"));
2982 $form->addCommandButton("deleteStyle", $this->lng->txt("style_delete_style"));
2983 }
2984 }
2985
2986 if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
2987 $style_sel = new ilSelectInputGUI(
2988 $this->lng->txt("style_current_style"),
2989 "style_id"
2990 );
2991 $style_sel->setOptions($st_styles);
2992 $style_sel->setValue($style_id);
2993 $form->addItem($style_sel);
2994
2995 $form->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
2996 $form->addCommandButton("createStyle", $this->lng->txt("sty_create_ind_style"));
2997 }
2998 }
2999
3000 $form->setTitle($this->lng->txt("blog_style"));
3001 $form->setFormAction($this->ctrl->getFormAction($this));
3002
3003 return $form;
3004 }
3005
3006 public function createStyle()
3007 {
3008 $this->ctrl->redirectByClass("ilobjstylesheetgui", "create");
3009 }
3010
3011 public function editStyle()
3012 {
3013 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
3014 }
3015
3016 public function deleteStyle()
3017 {
3018 $this->ctrl->redirectByClass("ilobjstylesheetgui", "delete");
3019 }
3020
3021 public function saveStyleSettings()
3022 {
3024
3025 if ($ilSetting->get("fixed_content_style_id") <= 0 &&
3026 (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
3027 || $this->object->getStyleSheetId() == 0)) {
3028 $this->object->setStyleSheetId((int) $_POST["style_id"]);
3029 $this->object->update();
3030
3031 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3032 }
3033 $this->ctrl->redirect($this, "editStyleProperties");
3034 }
3035
3041 public static function _goto($a_target)
3042 {
3043 global $DIC;
3044
3045 $ilCtrl = $DIC->ctrl();
3046 $access = $DIC->access();
3047
3048 if (substr($a_target, -3) == "wsp") {
3049 $id = explode("_", $a_target);
3050
3051 $ilCtrl->setTargetScript("ilias.php");
3052 $ilCtrl->initBaseClass("ilSharedResourceGUI");
3053 $ilCtrl->setParameterByClass("ilSharedResourceGUI", "wsp_id", $id[0]);
3054
3055 if (sizeof($id) >= 2) {
3056 if (is_numeric($id[1])) {
3057 $ilCtrl->setParameterByClass("ilSharedResourceGUI", "gtp", $id[1]);
3058 } else {
3059 $ilCtrl->setParameterByClass("ilSharedResourceGUI", "kwd", $id[1]);
3060 }
3061 if ($id[2] == "edit") {
3062 $ilCtrl->setParameterByClass("ilSharedResourceGUI", "edt", $id[2]);
3063 }
3064 }
3065 $ilCtrl->redirectByClass("ilSharedResourceGUI", "");
3066 } else {
3067 $id = explode("_", $a_target);
3068
3069 $ilCtrl->setTargetScript("ilias.php");
3070 $ilCtrl->initBaseClass("ilRepositoryGUI");
3071 $ilCtrl->setParameterByClass("ilRepositoryGUI", "ref_id", $id[0]);
3072
3073 if (sizeof($id) >= 2) {
3074 if (is_numeric($id[1])) {
3075 $ilCtrl->setParameterByClass("ilRepositoryGUI", "gtp", $id[1]);
3076 } else {
3077 $ilCtrl->setParameterByClass("ilRepositoryGUI", "kwd", $id[1]);
3078 }
3079
3080 if ($id[2] == "edit") {
3081 $ilCtrl->setParameterByClass("ilRepositoryGUI", "edt", $id[2]);
3082 }
3083 }
3084 if ($access->checkAccess("read", "", $id[0])) {
3085 $ilCtrl->redirectByClass("ilRepositoryGUI", "preview");
3086 }
3087 if ($access->checkAccess("visible", "", $id[0])) {
3088 $ilCtrl->redirectByClass("ilRepositoryGUI", "infoScreen");
3089 }
3090 }
3091 }
3092
3098 protected function exportWithComments()
3099 {
3100 $this->export(true);
3101 }
3102
3103 protected function forwardExport() : void
3104 {
3105 $this->ctrl->redirectByClass(ilExportGUI::class);
3106 }
3107}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:6
User interface class for advanced drop-down selection lists.
Class ilBlogExerciseGUI.
Class ilBlogPosting GUI class.
static getSnippet($a_id, $a_truncate=false, $a_truncate_length=500, $a_truncate_sign="...", $a_include_picture=false, $a_picture_width=144, $a_picture_height=144, $a_export_directory=null)
Get first text paragraph of page.
Class ilBlogPosting.
static getAllPostings($a_blog_id, $a_limit=1000, $a_offset=0)
Get all postings of blog.
static lookupBlogId($a_posting_id)
Lookup blog id.
static exists($a_blog_id, $a_posting_id)
Checks whether a posting exists.
static getKeywords($a_obj_id, $a_posting_id)
static _numericMonthToString($a_month, $a_long=true)
numeric month to string
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
List all contributors members of a blog.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Export User Interface Class.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
static _createExportDirectory($a_obj_id, $a_export_type="xml", $a_obj_type="")
This class represents a section header in a property form.
This class represents an image file property in a property form.
Class ilInfoScreenGUI.
static getInstance()
Factory.
This class represents a non editable value in a property form.
static _getNotesOfObject( $a_rep_obj_id, $a_obj_id, $a_obj_type, $a_type=IL_NOTE_PRIVATE, $a_incl_sub=false, $a_filter="", $a_all_public="y", $a_repository_mode=true, $a_sort_ascending=false, $a_news_id=0)
get all notes related to a specific object
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
static hasOptOut($obj_id)
Is opt out (disable notification) allowed?
This class represents a number property in a property form.
static isCommentsExportPossible($blog_id)
Is comments export possible?
Class ilObjBlogGUI.
renderNavigation($a_list_cmd="render", $a_posting_cmd="preview", $a_link_template=null, $a_show_inactive=false, $a_blpg=0)
Build navigation blocks.
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
renderNavigationByDate(array $a_items, $a_list_cmd="render", $a_posting_cmd="preview", $a_link_template=null, $a_show_inactive=false, $a_blpg=0)
Build navigation by date block.
setSettingsSubTabs($a_active)
initCreationForms($a_new_type)
Init creation froms.
getPreviousPosting($a_items)
Get previous posting.
isAdmin()
Check if user has admin access (approve, may edit & deactivate all postings)
getItems()
Get items.
renderNavigationByAuthors(array $a_items, $a_list_cmd="render", $a_show_inactive=false)
executeCommand()
execute command
addUserFromAutoComplete()
Autocomplete submit.
getType()
Functions that must be overwritten.
triggerAssignmentTool()
Trigger assignment tool.
setContentStyleSheet($a_tpl=null)
renderFullScreen($a_content, $a_navigation)
Build fullscreen context.
initHeaderAction($sub_type=null, $sub_id=null, $a_is_preview=false)
getPreviousMonth($a_items)
Get next month.
addLocatorItems()
Functions to be overwritten.
removeContributor()
Used in ilContributorTableGUI.
renderList(array $items, $a_cmd="preview", $a_link_template=null, $a_show_inactive=false, $a_export_directory=null)
Build posting month list.
disableNotes($a_value=false)
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
getHTML()
Return embeddable HTML chunk.
exportWithComments()
Handle export choice.
renderFullscreenHeader($a_tpl, $a_user_id, $a_export=false)
Render banner, user name.
static _goto($a_target)
Deep link.
getNextMonth($a_items)
Get next month.
mayEditPosting($a_posting_id, $a_author_id=null)
Check if user may edit posting.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
render()
Render object context.
getListItems($a_show_inactive=false)
Filter blog postings by month, keyword or author.
buildPostingList($a_obj_id)
Gather all blog postings.
filterInactivePostings()
Filter inactive items from items list.
filterItemsByKeyWord(array $a_items, $a_keyword)
export($a_with_comments=false)
Build and deliver export file.
mayContribute()
Check if user may contribute at all.
renderNavigationByKeywords( $a_list_cmd="render", $a_show_inactive=false, $a_link_template=false, $a_blpg=0)
Build navigation by keywords block.
setTabs()
create tabs (repository/workspace switch)
buildExportFile($a_include_comments=false)
Build export file.
static lookupSubObjectTitle($a_blog_id, $a_posting_id)
Get title for blog posting (used in ilNotesGUI)
getLatestMonth($a_items)
Get next month.
getNextPosting($a_items)
Get next posting.
buildExportLink($a_template, $a_type, $a_id)
Build export link.
addContributor($a_user_ids=array(), $a_user_type=null)
Centralized method to add contributors.
getLatestPosting($a_items)
Get previous posting.
preview()
Render fullscreen presentation.
confirmRemoveContributor()
Used in ilContributorTableGUI.
getKeywords($a_show_inactive, $a_posting_id=null)
Get keywords for single posting or complete blog.
infoScreenForward()
show information screen
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
renderToolbarNavigation($a_items, $single_posting=false)
Toolbar navigation.
createPosting()
Create new posting.
buildEmbedded($a_content, $a_nav)
Combine content (list/posting) and navigation to html chunk.
addHeaderActionForCommand($a_cmd)
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
const NAV_MODE_MONTH
const NAV_MODE_LIST
const ABSTRACT_DEFAULT_SHORTEN_LENGTH
const ABSTRACT_DEFAULT_IMAGE_WIDTH
const ABSTRACT_DEFAULT_IMAGE_HEIGHT
Handles general notification settings, see e.g.
Class ilObjStyleSheetGUI.
static _lookupStandard($a_id)
Lookup standard flag.
static _getStandardStyles( $a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static _getPersonalPicturePath( $a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false, $html_export=false)
Get path to personal picture.
static _lookupId($a_user_str)
Lookup id by login.
static _lookupName($a_user_id)
lookup user name
New implementation of ilObjectGUI.
getAccessHandler()
Get access handler.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getCreationMode()
get creation mode
setLocator()
set Locator
GUI class for the workflow of copying objects.
insertHeaderAction($a_list_gui)
Insert header action into main template.
getObjectService()
Get object service.
Class ilObject Basic functions for all objects.
static _lookupTitle($a_id)
lookup object title
static _lookupOwner($a_id)
lookup object owner
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
getItemByPostVar($a_post_var)
Get Item by POST variable.
static get($a_type, $a_href="")
Get icon html.
This class represents a property in a property form.
This class represents an option in a radio group.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
This class represents a selection list property in a property form.
ILIAS Setting Class.
static getInstance()
Factory.
static getRelevanceClass($cnt, $max)
Get style class for tag relevance.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static signFile($path_to_file)
const CLIENT_ID
Definition: constants.php:39
const ANONYMOUS_USER_ID
Definition: constants.php:25
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$preview
Definition: imgupload.php:55
$img
Definition: imgupload.php:57
$ilUser
Definition: imgupload.php:18
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
if($format !==null) $name
Definition: metadata.php:230
$format
Definition: metadata.php:218
$auth
Definition: metadata.php:59
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
$type
$url
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
ui()
Definition: ui.php:5
$message
Definition: xapiexit.php:14