ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjBlogGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
33 {
34  protected \ILIAS\Repository\Profile\ProfileGUI $profile_gui;
35  protected \ILIAS\Repository\Profile\ProfileAdapter $profile;
36  protected \ILIAS\Blog\Access\BlogAccess $blog_access;
37  protected \ILIAS\Blog\InternalDomainService $domain;
38  protected \ILIAS\Blog\InternalGUIService $gui;
39  protected string $rendered_content = "";
40  protected \ILIAS\Notes\Service $notes;
41  protected \ILIAS\Blog\ReadingTime\BlogSettingsGUI $reading_time_gui;
42  protected \ILIAS\Blog\ReadingTime\ReadingTimeManager $reading_time_manager;
43 
45  protected ilHelpGUI $help;
46  protected ilTabsGUI $tabs;
49 
50  protected string $month = "";
51  protected array $items = [];
52  protected string $keyword = "";
53  protected ?int $author = null;
54  protected bool $month_default = false;
55  protected int $gtp = 0;
56  protected string $edt;
57  protected int $blpg = 0;
58  protected int $old_nr = 0;
59  protected int $ppage = 0;
60  protected int $user_page = 0;
61  public bool $prtf_embed = false; // note: this is currently set in ilPortfolioPageGUI, should use getter/setter
62  protected string $prvm; //preview mode (fsc|emb)
63  protected int $ntf = 0;
64  protected int $apid = 0;
65  protected string $new_type = "";
66  protected int $prt_id = 0;
67  protected bool $disable_notes = false;
69  protected \ILIAS\HTTP\Services $http;
70  protected \ILIAS\DI\UIServices $ui;
71  protected \ILIAS\Style\Content\GUIService $content_style_gui;
72  protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
73 
74  public function __construct(
75  int $a_id = 0,
76  int $a_id_type = self::REPOSITORY_NODE_ID,
77  int $a_parent_node_id = 0
78  ) {
79  global $DIC;
80 
81  // other services
82  $cs = $DIC->contentStyle();
83  $this->tool_context = $DIC->globalScreen()->tool()->context();
84  $this->notes = $DIC->notes();
85 
86  // internal service
87  $service = $DIC->blog()->internal();
88 
89  $this->domain = $domain = $service->domain();
90  $this->gui = $gui = $service->gui();
91 
92  $this->settings = $domain->settings();
93  $this->user = $domain->user();
94  $this->tree = $domain->repositoryTree();
95  $this->rbac_review = $domain->rbac()->review();
96  $this->rbacadmin = $domain->rbac()->admin();
97  $this->lng = $domain->lng();
98 
99  $gui = $service->gui();
100  $this->gui = $gui;
101  $this->help = $gui->help();
102  $this->tabs = $gui->tabs();
103  $this->toolbar = $gui->toolbar();
104  $this->ui = $gui->ui();
105  $this->locator = $gui->locator();
106  $this->http = $gui->http();
107 
108  $this->nav_history = $DIC["ilNavigationHistory"];
109  $this->ctrl = $gui->ctrl();
110 
111  $this->blog_request = $gui->standardRequest();
112 
114  $this->gtp = $req->getGotoPage();
115  $this->edt = $req->getEditing();
116  $this->blpg = $req->getBlogPage();
117  $this->old_nr = $req->getOldNr();
118  $this->ppage = $req->getPPage();
119  $this->user_page = $req->getUserPage();
120  $this->new_type = $req->getNewType();
121  $this->prvm = $req->getPreviewMode();
122  $this->ntf = $req->getNotification();
123  $this->apid = $req->getApId();
124  $this->month = $req->getMonth();
125  $this->keyword = $req->getKeyword();
126  $this->author = $req->getAuthor();
127  $this->prt_id = $req->getPrtId();
128 
129  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
130 
131  $blog_page = $this->blog_request->getBlogPage();
132  if ($blog_page > 0 &&
133  ilBlogPosting::lookupBlogId($blog_page) !== $this->object->getId()) {
134  throw new ilException("Posting ID does not match blog.");
135  }
136 
137  $blog_id = 0;
138  if ($this->object) {
139  // gather postings by month
140  $this->items = $this->buildPostingList($this->object->getId());
141  if ($this->items) {
142  // current month (if none given or empty)
143  if (!$this->month || !$this->items[$this->month]) {
144  $m = array_keys($this->items);
145  $this->month = array_shift($m);
146  $this->month_default = true;
147  }
148  }
149 
150  $this->ctrl->setParameter($this, "bmn", $this->month);
151  $blog_id = $this->object->getId();
152  }
153 
154  $this->lng->loadLanguageModule("blog");
155  $this->ctrl->saveParameter($this, "prvm");
156 
157  $this->content_style_gui = $cs->gui();
158  if (is_object($this->object)) {
159  if ($this->id_type !== self::REPOSITORY_NODE_ID) {
160  $this->content_style_domain = $cs->domain()->styleForObjId($this->object->getId());
161  } else {
162  $this->content_style_domain = $cs->domain()->styleForRefId($this->object->getRefId());
163  }
164  }
165 
166  $this->reading_time_gui = new \ILIAS\Blog\ReadingTime\BlogSettingsGUI($blog_id);
167  $this->reading_time_manager = $domain->readingTime();
168  $this->notes = $DIC->notes();
169  $owner = $this->object?->getOwner() ?? 0;
170  $this->blog_access = $domain->blogAccess(
171  $this->getAccessHandler(),
172  $this->node_id,
173  $this->id_type,
174  $this->user->getId(),
175  $owner
176  );
177  $this->profile = $domain->profile();
178  $this->profile_gui = $gui->profile();
179  }
180 
181  public function getType(): string
182  {
183  return "blog";
184  }
185 
186  public function getItems(): array
187  {
188  return $this->items;
189  }
190 
191 
192  protected function initCreationForms(string $new_type): array
193  {
194  $forms = parent::initCreationForms($new_type);
195 
196  if ($this->id_type === self::WORKSPACE_NODE_ID) {
197  unset($forms[self::CFORM_IMPORT], $forms[self::CFORM_CLONE]);
198  }
199 
200  return $forms;
201  }
202 
203  protected function afterSave(ilObject $new_object): void
204  {
205  $ilCtrl = $this->ctrl;
206 
207  $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
208  $ilCtrl->redirect($this, "");
209  }
210 
211  protected function setSettingsSubTabs(string $a_active): void
212  {
213  $tree = $this->tree;
215 
216  // general properties
217  $this->tabs_gui->addSubTab(
218  "properties",
219  $this->lng->txt("blog_properties"),
220  $this->ctrl->getLinkTarget($this, 'edit')
221  );
222 
223  $this->tabs_gui->addSubTab(
224  "style",
225  $this->lng->txt("obj_sty"),
226  $this->ctrl->getLinkTargetByClass("ilobjectcontentstylesettingsgui", "")
227  );
228 
229  // notification settings for blogs in courses and groups
230  if ($this->id_type === self::REPOSITORY_NODE_ID) {
231  $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
232  $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
233 
234  if ($grp_ref_id > 0 || $crs_ref_id > 0) {
235  if ($access->checkAccess('write', '', $this->ref_id)) {
236  $this->tabs_gui->addSubTab(
237  'notifications',
238  $this->lng->txt("notifications"),
239  $this->ctrl->getLinkTargetByClass("ilobjnotificationsettingsgui", '')
240  );
241  }
242  }
243  }
244 
245  $this->tabs_gui->activateSubTab($a_active);
246  }
247 
248  protected function initEditCustomForm(
249  ilPropertyFormGUI $a_form
250  ): void {
251  $lng = $this->lng;
253  $obj_service = $this->getObjectService();
254 
255  $this->setSettingsSubTabs("properties");
256 
257  if ($this->id_type === self::REPOSITORY_NODE_ID) {
258  $appr = new ilCheckboxInputGUI($lng->txt("blog_enable_approval"), "approval");
259  $appr->setInfo($lng->txt("blog_enable_approval_info"));
260  $a_form->addItem($appr);
261  }
262 
263  $notes = new ilCheckboxInputGUI($lng->txt("blog_enable_notes"), "notes");
264  $a_form->addItem($notes);
265 
266  if ($ilSetting->get('enable_global_profiles')) {
267  $rss = new ilCheckboxInputGUI($lng->txt("blog_enable_rss"), "rss");
268  $rss->setInfo($lng->txt("blog_enable_rss_info"));
269  $a_form->addItem($rss);
270  }
271 
272 
273  // navigation
274 
275  $nav = new ilFormSectionHeaderGUI();
276  $nav->setTitle($lng->txt("blog_settings_navigation"));
277  $a_form->addItem($nav);
278 
279  $nav_mode = new ilRadioGroupInputGUI($lng->txt("blog_nav_mode"), "nav");
280  $nav_mode->setRequired(true);
281  $a_form->addItem($nav_mode);
282 
283  $opt = new ilRadioOption($lng->txt("blog_nav_mode_month_list"), (string) ilObjBlog::NAV_MODE_LIST);
284  $opt->setInfo($lng->txt("blog_nav_mode_month_list_info"));
285  $nav_mode->addOption($opt);
286 
287 
288  $mon_num = new ilNumberInputGUI($lng->txt("blog_nav_mode_month_list_num_month"), "nav_list_mon");
289  $mon_num->setInfo($lng->txt("blog_nav_mode_month_list_num_month_info"));
290  $mon_num->setSize(3);
291  $mon_num->setMinValue(1);
292  $opt->addSubItem($mon_num);
293 
294  $detail_num = new ilNumberInputGUI($lng->txt("blog_nav_mode_month_list_num_month_with_post"), "nav_list_mon_with_post");
295  $detail_num->setInfo($lng->txt("blog_nav_mode_month_list_num_month_with_post_info"));
296  //$detail_num->setRequired(true);
297  $detail_num->setSize(3);
298  //$detail_num->setMinValue(0);
299  $opt->addSubItem($detail_num);
300 
301  $opt = new ilRadioOption($lng->txt("blog_nav_mode_month_single"), (string) ilObjBlog::NAV_MODE_MONTH);
302  $opt->setInfo($lng->txt("blog_nav_mode_month_single_info"));
303  $nav_mode->addOption($opt);
304 
305  $order_options = array();
306  if ($this->object->getOrder()) {
307  foreach ($this->object->getOrder() as $item) {
308  $order_options[] = $lng->txt("blog_" . $item);
309  }
310  }
311 
312  if (!in_array($lng->txt("blog_navigation"), $order_options)) {
313  $order_options[] = $lng->txt("blog_navigation");
314  }
315 
316  if ($this->id_type === self::REPOSITORY_NODE_ID) {
317  if (!in_array($lng->txt("blog_authors"), $order_options)) {
318  $order_options[] = $lng->txt("blog_authors");
319  }
320 
321  $auth = new ilCheckboxInputGUI($lng->txt("blog_enable_nav_authors"), "nav_authors");
322  $auth->setInfo($lng->txt("blog_enable_nav_authors_info"));
323  $a_form->addItem($auth);
324  }
325 
326  $keyw = new ilCheckboxInputGUI($lng->txt("blog_enable_keywords"), "keywords");
327  $keyw->setInfo($lng->txt("blog_enable_keywords_info"));
328  $a_form->addItem($keyw);
329 
330  if (!in_array($lng->txt("blog_keywords"), $order_options)) {
331  $order_options[] = $lng->txt("blog_keywords");
332  }
333 
334  $order = new ilNonEditableValueGUI($lng->txt("blog_nav_sortorder"), "order");
335  $order->setMultiValues($order_options);
336  $order->setValue(array_shift($order_options));
337  $order->setMulti(true, true, false);
338  $a_form->addItem($order);
339 
340 
341  // presentation (frame)
342 
343  $pres = new ilFormSectionHeaderGUI();
344  $pres->setTitle($lng->txt("blog_presentation_frame"));
345  $a_form->addItem($pres);
346 
347  if ($this->id_type === self::REPOSITORY_NODE_ID) {
348  $obj_service->commonSettings()->legacyForm($a_form, $this->object)->addTileImage();
349  }
350 
351  $ppic = new ilCheckboxInputGUI($lng->txt("blog_profile_picture"), "ppic");
352  $a_form->addItem($ppic);
353 
354  if ($this->id_type === self::REPOSITORY_NODE_ID) {
355  $ppic->setInfo($lng->txt("blog_profile_picture_repository_info"));
356  }
357 
358  $blga_set = new ilSetting("blga");
359  if ($blga_set->get("banner")) {
360  $dimensions = " (" . $blga_set->get("banner_width") . "x" .
361  $blga_set->get("banner_height") . ")";
362 
363  $img = new ilImageFileInputGUI($lng->txt("blog_banner") . $dimensions, "banner");
364  $a_form->addItem($img);
365 
366  // show existing file
367  $file = $this->object->getImageFullPath(true);
368  if ($file) {
369  $img->setImage(ilWACSignedPath::signFile($file));
370  }
371  }
372 
373  $this->reading_time_gui->addSettingToForm($a_form);
374 
375  /* #15000
376  $bg_color = new ilColorPickerInputGUI($lng->txt("blog_background_color"), "bg_color");
377  $a_form->addItem($bg_color);
378 
379  $font_color = new ilColorPickerInputGUI($lng->txt("blog_font_color"), "font_color");
380  $a_form->addItem($font_color);
381  */
382 
383  // presentation (overview)
384 
385  $list = new ilFormSectionHeaderGUI();
386  $list->setTitle($lng->txt("blog_presentation_overview"));
387  $a_form->addItem($list);
388 
389 
390  $post_num = new ilNumberInputGUI($lng->txt("blog_list_num_postings"), "ov_list_post_num");
391  $post_num->setInfo($lng->txt("blog_list_num_postings_info"));
392  $post_num->setSize(3);
393  $post_num->setMinValue(1);
394  $post_num->setRequired(true);
395  $a_form->addItem($post_num);
396 
397  $abs_shorten = new ilCheckboxInputGUI($lng->txt("blog_abstract_shorten"), "abss");
398  $a_form->addItem($abs_shorten);
399 
400  $abs_shorten_len = new ilNumberInputGUI($lng->txt("blog_abstract_shorten_length"), "abssl");
401  $abs_shorten_len->setSize(5);
402  $abs_shorten_len->setRequired(true);
403  $abs_shorten_len->setSuffix($lng->txt("blog_abstract_shorten_characters"));
404  $abs_shorten_len->setMinValue(50, true);
405  $abs_shorten->addSubItem($abs_shorten_len);
406 
407  $abs_img = new ilCheckboxInputGUI($lng->txt("blog_abstract_image"), "absi");
408  $abs_img->setInfo($lng->txt("blog_abstract_image_info"));
409  $a_form->addItem($abs_img);
410 
411  $abs_img_width = new ilNumberInputGUI($lng->txt("blog_abstract_image_width"), "absiw");
412  $abs_img_width->setSize(5);
413  $abs_img_width->setRequired(true);
414  $abs_img_width->setSuffix($lng->txt("blog_abstract_image_pixels"));
415  $abs_img_width->setMinValue(32, true);
416  $abs_img->addSubItem($abs_img_width);
417 
418  $abs_img_height = new ilNumberInputGUI($lng->txt("blog_abstract_image_height"), "absih");
419  $abs_img_height->setSize(5);
420  $abs_img_height->setRequired(true);
421  $abs_img_height->setSuffix($lng->txt("blog_abstract_image_pixels"));
422  $abs_img_height->setMinValue(32, true);
423  $abs_img->addSubItem($abs_img_height);
424  }
425 
426  protected function getEditFormCustomValues(array &$a_values): void
427  {
428  if ($this->id_type === self::REPOSITORY_NODE_ID) {
429  $a_values["approval"] = $this->object->hasApproval();
430  $a_values["nav_authors"] = $this->object->hasAuthors();
431  }
432  $a_values["keywords"] = $this->object->hasKeywords();
433  $a_values["notes"] = $this->object->getNotesStatus();
434  $a_values["ppic"] = $this->object->hasProfilePicture();
435  /*
436  $a_values["bg_color"] = $this->object->getBackgroundColor();
437  $a_values["font_color"] = $this->object->getFontColor();
438  */
439  $a_values["banner"] = $this->object->getImage();
440  $a_values["rss"] = $this->object->hasRSS();
441  $a_values["abss"] = $this->object->hasAbstractShorten();
442  $a_values["absi"] = $this->object->hasAbstractImage();
443  $a_values["nav"] = $this->object->getNavMode();
444  $a_values["nav_list_mon_with_post"] = $this->object->getNavModeListMonthsWithPostings();
445  $a_values["nav_list_mon"] = $this->object->getNavModeListMonths();
446  $a_values["ov_list_post_num"] = $this->object->getOverviewPostings();
447 
448  // #13420
449  $a_values["abssl"] = $this->object->getAbstractShortenLength() ?: ilObjBlog::ABSTRACT_DEFAULT_SHORTEN_LENGTH;
450  $a_values["absiw"] = $this->object->getAbstractImageWidth() ?: ilObjBlog::ABSTRACT_DEFAULT_IMAGE_WIDTH;
451  $a_values["absih"] = $this->object->getAbstractImageHeight() ?: ilObjBlog::ABSTRACT_DEFAULT_IMAGE_HEIGHT;
452  $a_values = $this->reading_time_gui->addValueToArray($a_values);
453  }
454 
455  protected function updateCustom(ilPropertyFormGUI $form): void
456  {
457  $lng = $this->lng;
458  $obj_service = $this->getObjectService();
459 
460  if ($this->id_type === self::REPOSITORY_NODE_ID) {
461  $this->object->setApproval((bool) $form->getInput("approval"));
462  $this->object->setAuthors((bool) $form->getInput("nav_authors"));
463  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
464  }
465  $this->object->setKeywords((bool) $form->getInput("keywords"));
466  $this->object->setNotesStatus((bool) $form->getInput("notes"));
467  $this->object->setProfilePicture((bool) $form->getInput("ppic"));
468  $this->object->setRSS((bool) $form->getInput("rss"));
469  $this->object->setAbstractShorten((bool) $form->getInput("abss"));
470  $this->object->setAbstractShortenLength((int) $form->getInput("abssl"));
471  $this->object->setAbstractImage((bool) $form->getInput("absi"));
472  $this->object->setAbstractImageWidth((int) $form->getInput("absiw"));
473  $this->object->setAbstractImageHeight((int) $form->getInput("absih"));
474  $this->object->setNavMode((int) $form->getInput("nav"));
475  $this->object->setNavModeListMonthsWithPostings((int) $form->getInput("nav_list_mon_with_post"));
476  $this->object->setNavModeListMonths((int) $form->getInput("nav_list_mon"));
477  $this->object->setOverviewPostings((int) $form->getInput("ov_list_post_num"));
478  $this->reading_time_gui->saveSettingFromForm($form);
479 
480  $order = (array) $form->getInput("order");
481 
482  foreach ($order as $idx => $value) {
483  if ($value == $lng->txt("blog_navigation")) {
484  $order[$idx] = "navigation";
485  } elseif ($value == $lng->txt("blog_keywords")) {
486  $order[$idx] = "keywords";
487  } else {
488  $order[$idx] = "authors";
489  }
490  }
491  $this->object->setOrder($order);
492  // banner field is optional
493  $banner = $form->getItemByPostVar("banner");
494  if ($banner) {
495  if ($_FILES["banner"]["tmp_name"]) {
496  $this->object->uploadImage($_FILES["banner"]);
497  } elseif ($banner->getDeletionFlag()) {
498  $this->object->deleteImage();
499  }
500  }
501  }
502 
503  protected function setTabs(): void
504  {
505  $lng = $this->lng;
506  $ilHelp = $this->help;
507 
508  if ($this->id_type === self::WORKSPACE_NODE_ID) {
509  $this->ctrl->setParameter($this, "wsp_id", $this->node_id);
510  }
511 
512  $ilHelp->setScreenIdComponent("blog");
513 
514  if ($this->checkPermissionBool("read")) {
515  $this->ctrl->setParameterByClass(self::class, "bmn", null);
516  $this->tabs_gui->addTab(
517  "content",
518  $lng->txt("content"),
519  $this->ctrl->getLinkTarget($this, "")
520  );
521  }
522  if ($this->checkPermissionBool("read") && !$this->prtf_embed) {
523  $this->tabs_gui->addTab(
524  "id_info",
525  $lng->txt("info_short"),
526  $this->ctrl->getLinkTargetByClass(array("ilobjbloggui", "ilinfoscreengui"), "showSummary")
527  );
528  }
529 
530  if ($this->checkPermissionBool("write")) {
531  $this->tabs_gui->addTab(
532  "settings",
533  $lng->txt("settings"),
534  $this->ctrl->getLinkTarget($this, "edit")
535  );
536 
537  if (!$this->prtf_embed) {
538  if ($this->id_type === self::REPOSITORY_NODE_ID) {
539  $this->tabs_gui->addTab(
540  "contributors",
541  $lng->txt("blog_contributors"),
542  $this->ctrl->getLinkTarget($this, "contributors")
543  );
544  }
545 
546  if ($this->id_type === self::REPOSITORY_NODE_ID) {
547  $this->tabs_gui->addTab(
548  "export",
549  $lng->txt("export"),
550  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
551  );
552  }
553  }
554  }
555 
556  if (!$this->prtf_embed) {
557  if ($this->blog_access->mayContribute()) {
558  $this->tabs_gui->addNonTabbedLink(
559  "preview",
560  $lng->txt("blog_preview"),
561  $this->ctrl->getLinkTarget($this, "preview")
562  );
563  }
564  parent::setTabs();
565  }
566  }
567 
568  public function executeCommand(): void
569  {
570  $ilCtrl = $this->ctrl;
571  $tpl = $this->tpl;
572  $ilTabs = $this->tabs;
573  $lng = $this->lng;
574  $ilNavigationHistory = $this->nav_history;
575 
576 
577  $next_class = $ilCtrl->getNextClass($this);
578 
579  if ($next_class !== "ilexportgui") {
580  $this->triggerAssignmentTool();
581  }
582 
583  // goto link to blog posting
584  if ($this->gtp > 0) {
585  $page_id = $this->gtp;
586  if (ilBlogPosting::exists($this->object_id, $page_id)) {
587  // #12312
588  $ilCtrl->setCmdClass("ilblogpostinggui");
589  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $page_id);
590  if ($this->edt === "edit") {
591  $ilCtrl->redirectByClass("ilblogpostinggui", "edit");
592  } else {
593  $ilCtrl->redirectByClass("ilblogpostinggui", "previewFullscreen");
594  }
595  } else {
596  $this->tpl->setOnScreenMessage('failure', $lng->txt("blog_posting_not_found"));
597  }
598  }
599 
600 
601  $cmd = $ilCtrl->getCmd();
602 
603  // add entry to navigation history
604  if (($this->id_type === self::REPOSITORY_NODE_ID) && !$this->getCreationMode() &&
605  $this->getAccessHandler()->checkAccess("read", "", $this->node_id)) {
606  // see #22067
607  $link = $ilCtrl->getLinkTargetByClass(["ilrepositorygui", "ilObjBlogGUI"], "preview");
608  $ilNavigationHistory->addItem($this->node_id, $link, "blog");
609  }
610  switch ($next_class) {
611  case 'ilblogpostinggui':
612  $this->ctrl->saveParameter($this, "user_page");
613  if (!$this->prtf_embed) {
615  }
616 
617  if (!$this->checkPermissionBool("read") && !$this->prtf_embed) {
618  $this->tpl->setOnScreenMessage('info', $lng->txt("no_permission"));
619  return;
620  }
621 
622  // #9680
623  if ($this->id_type === self::REPOSITORY_NODE_ID) {
624  $this->setLocator();
625  }
626 
627  $style_sheet_id = $this->content_style_domain->getEffectiveStyleId();
628 
629  $bpost_gui = new ilBlogPostingGUI(
630  $this->node_id,
631  $this->getAccessHandler(),
632  $this->blpg,
633  $this->old_nr,
634  ($this->object->getNotesStatus() && !$this->disable_notes),
635  $this->blog_access->mayEditPosting($this->blpg),
636  $style_sheet_id
637  );
638 
639  // keep preview mode through notes gui (has its own commands)
640  switch ($cmd) {
641  // blog preview
642  case "previewFullscreen":
643  $ilCtrl->setParameter($this, "prvm", "fsc");
644  break;
645 
646  // blog in portfolio
647  case "previewEmbedded":
648  $ilCtrl->setParameter($this, "prvm", "emb");
649  break;
650 
651  // edit
652  default:
653  $this->setContentStyleSheet();
654 
655 
656  if (!$this->prtf_embed) {
657  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $this->blpg);
658  $this->tabs_gui->addNonTabbedLink(
659  "preview",
660  $lng->txt("blog_preview"),
661  $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "previewFullscreen")
662  );
663  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", "");
664  } else {
665  $this->ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $this->ppage);
666  $this->tabs_gui->addNonTabbedLink(
667  "preview",
668  $lng->txt("blog_preview"),
669  $this->ctrl->getLinkTargetByClass("ilobjportfoliogui", "preview")
670  );
671  $this->ctrl->setParameterByClass("ilobjportfoliogui", "user_page", "");
672  }
673  break;
674  }
675 
676  // keep preview mode through notes gui
677  if ($this->prvm) {
678  $cmd = "preview" . (($this->prvm === "fsc") ? "Fullscreen" : "Embedded");
679  }
680  if (in_array($cmd, array("previewFullscreen", "previewEmbedded"))) {
681  $this->renderToolbarNavigation($this->items, true);
682  }
683  $ret = $ilCtrl->forwardCommand($bpost_gui);
684  if (!$ilTabs->back_target) {
685  $ilCtrl->setParameter($this, "bmn", "");
686  $ilTabs->setBackTarget(
687  $lng->txt("back"),
688  $ilCtrl->getLinkTarget($this, "")
689  );
690  }
691 
692  if ($ret != "") {
693  // $is_owner = $this->object->getOwner() == $ilUser->getId();
694  $is_owner = $this->blog_access->mayContribute();
695  $is_active = $bpost_gui->getBlogPosting()->getActive();
696 
697  // do not show inactive postings
698  if (($cmd === "previewFullscreen" || $cmd === "previewEmbedded")
699  && !$is_owner && !$is_active) {
700  $this->ctrl->redirect($this, "preview");
701  }
702 
703  switch ($cmd) {
704  // blog preview
705  case "previewFullscreen":
706  $this->addHeaderActionForCommand($cmd);
707  $this->filterInactivePostings();
708  $nav = $this->renderNavigation("preview", $cmd);
709  $this->renderFullScreen($ret, $nav);
710  break;
711 
712  // blog in portfolio
713  case "previewEmbedded":
714  $this->addHeaderActionForCommand($cmd);
715  $this->filterInactivePostings();
716  $nav = $this->renderNavigation("gethtml", $cmd);
717  // this is important for embedded blog pages!
718  $this->rendered_content = $this->buildEmbedded($ret, $nav);
719  return;
720 
721  // ilias/editor
722  default:
723  // infos about draft status / snippet
724  $info = array();
725  if (!$is_active) {
726  // single author blog (owner) in personal workspace
727  if ($this->id_type === self::WORKSPACE_NODE_ID) {
728  $info[] = $lng->txt("blog_draft_info");
729  } else {
730  $info[] = $lng->txt("blog_draft_info_contributors");
731  }
732  }
733  $public_action = false;
734  if ($cmd !== "history" && $cmd !== "edit" && $is_active && empty($info)) {
735  $info[] = $lng->txt("blog_new_posting_info");
736  $public_action = true;
737  }
738  if ($this->object->hasApproval() && !$bpost_gui->getBlogPosting()->isApproved()) {
739  // #9737
740  $info[] = $lng->txt("blog_posting_edit_approval_info");
741  }
742  if ($public_action) {
743  $this->tpl->setOnScreenMessage('success', implode("<br />", $info));
744  } else {
745  if (count($info) > 0) {
746  $this->tpl->setOnScreenMessage('info', implode("<br />", $info));
747  }
748  }
749 
750  // revert to edit cmd to avoid confusion
751  $tpl->setContent($ret);
752  if ($cmd !== "edit") {
753  $this->addHeaderActionForCommand("render");
754  $nav = $this->renderNavigation("render", $cmd, "", $is_owner);
755  $tpl->setRightContent($nav);
756  } else {
757  $this->tabs->setBackTarget("", "");
758  }
759  break;
760  }
761  }
762  break;
763 
764  case "ilinfoscreengui":
765  $this->prepareOutput();
766  $this->addHeaderActionForCommand("render");
767  $this->infoScreenForward();
768  break;
769 
770  case "ilnotegui":
771  $this->preview();
772  break;
773 
774  case "ilcommonactiondispatchergui":
776  $gui->enableCommentsSettings(false);
777  $this->prepareOutput();
778  $this->ctrl->forwardCommand($gui);
779  break;
780 
781  case "ilpermissiongui":
782  $this->prepareOutput();
783  $ilTabs->activateTab("id_permissions");
784  $perm_gui = new ilPermissionGUI($this);
785  $this->ctrl->forwardCommand($perm_gui);
786  break;
787 
788  case "ilobjectcopygui":
789  $this->prepareOutput();
790  $cp = new ilObjectCopyGUI($this);
791  $cp->setType("blog");
792  $this->ctrl->forwardCommand($cp);
793  break;
794 
795  case 'ilrepositorysearchgui':
796  $this->prepareOutput();
797  $ilTabs->activateTab("contributors");
798  $rep_search = new ilRepositorySearchGUI();
799  $rep_search->setTitle($this->lng->txt("blog_add_contributor"));
800  $rep_search->setCallback($this, 'addContributor', $this->object->getAllLocalRoles($this->node_id));
801  $this->ctrl->setReturn($this, 'contributors');
802  $this->ctrl->forwardCommand($rep_search);
803  break;
804 
805  case 'ilexportgui':
806  $this->prepareOutput();
807  $ilTabs->activateTab("export");
808  $exp_gui = new ilExportGUI($this);
809  $exp_gui->addFormat("xml");
810  $exp_gui->addFormat("html", "", $this, "buildExportFile"); // #13419
811  if (ilObjBlogAccess::isCommentsExportPossible($this->object->getId())) {
812  $exp_gui->addFormat("html_comments", "HTML (" . $this->lng->txt("blog_incl_comments") . ")", $this, "buildExportFile");
813  }
814  $ilCtrl->forwardCommand($exp_gui);
815  break;
816 
817  case "ilobjectcontentstylesettingsgui":
818  $this->checkPermission("write");
819  $this->prepareOutput();
820  $this->addHeaderAction();
821  $ilTabs->activateTab("settings");
822  $this->setSettingsSubTabs("style");
823 
824 
825  if ($this->id_type === self::REPOSITORY_NODE_ID) {
826  $settings_gui = $this->content_style_gui
827  ->objectSettingsGUIForRefId(
828  null,
829  $this->object->getRefId()
830  );
831  } else {
832  $settings_gui = $this->content_style_gui
833  ->objectSettingsGUIForObjId(
834  null,
835  $this->object->getId()
836  );
837  }
838  $this->ctrl->forwardCommand($settings_gui);
839  break;
840 
841 
842  case "ilblogexercisegui":
843  $this->ctrl->setReturn($this, "render");
844  $gui = $this->gui->exercise()->ilBlogExerciseGUI($this->node_id);
845  $this->ctrl->forwardCommand($gui);
846  break;
847 
848  case 'ilobjnotificationsettingsgui':
849  $this->prepareOutput();
850  $ilTabs->activateTab("settings");
851  $this->setSettingsSubTabs("notifications");
852  $gui = new ilObjNotificationSettingsGUI($this->object->getRefId());
853  $this->ctrl->forwardCommand($gui);
854  break;
855 
856  default:
857  if ($cmd !== "gethtml") {
858  // desktop item handling, must be toggled before header action
859  if ($cmd === "addToDesk" || $cmd === "removeFromDesk") {
860  $this->{$cmd . "Object"}();
861  if ($this->prvm) {
862  $cmd = "preview";
863  } else {
864  $cmd = "render";
865  }
866  $ilCtrl->setCmd($cmd);
867  }
868  $this->addHeaderActionForCommand($cmd);
869  }
870  if (!$this->prtf_embed) {
871  parent::executeCommand();
872  return;
873  }
874 
875  $this->setTabs();
876 
877  if (!$cmd) {
878  $cmd = "render";
879  }
880  $this->rendered_content = (string) $this->$cmd();
881  }
882  }
883 
884  public function getRenderedContent(): string
885  {
887  }
888 
889  protected function triggerAssignmentTool(): void
890  {
891  $be = $this->domain->exercise($this->node_id);
892  $be_gui = $this->gui->exercise()->ilBlogExerciseGUI($this->node_id);
893  $assignments = $be->getAssignmentsOfBlog();
894  if (count($assignments) > 0) {
895  $ass_ids = array_map(static function ($i) {
896  return $i["ass_id"];
897  }, $assignments);
898  $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::SHOW_EXC_ASSIGNMENT_INFO, true);
899  $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::EXC_ASS_IDS, $ass_ids);
900  $this->tool_context->current()->addAdditionalData(
902  $be_gui->getActionButtons()
903  );
904  }
905  }
906 
910  public function infoScreen(): void
911  {
912  $this->ctrl->setCmd("showSummary");
913  $this->ctrl->setCmdClass("ilinfoscreengui");
914  $this->infoScreenForward();
915  }
916 
917  public function infoScreenForward(): void
918  {
919  $ilTabs = $this->tabs;
920 
921  $ilTabs->activateTab("id_info");
922 
923  $this->checkPermission("visible");
924 
925  $info = new ilInfoScreenGUI($this);
926 
927  if ($this->id_type !== self::WORKSPACE_NODE_ID) {
928  $info->enablePrivateNotes();
929  }
930 
931  if ($this->checkPermissionBool("read")) {
932  $info->enableNews();
933  }
934 
935  // no news editing for files, just notifications
936  $info->enableNewsEditing(false);
937  if ($this->checkPermissionBool("write")) {
938  $news_set = new ilSetting("news");
939  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
940 
941  if ($enable_internal_rss) {
942  $info->setBlockProperty("news", "settings", "1");
943  $info->setBlockProperty("news", "public_notifications_option", "1");
944  }
945  }
946 
947  // standard meta data
948  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
949 
950  $this->ctrl->forwardCommand($info);
951  }
952 
956  public function createPosting(): void
957  {
958  $ilCtrl = $this->ctrl;
959  $ilUser = $this->user;
960 
961  $title = $this->blog_request->getTitle();
962  if ($title) {
963  // create new posting
964  $posting = new ilBlogPosting();
965  $posting->setTitle($title);
966  $posting->setBlogId($this->object->getId());
967  $posting->setActive(false);
968  $posting->setAuthor($ilUser->getId());
969  $posting->create(false);
970 
971  // switch month list to current month (will include new posting)
972  $ilCtrl->setParameter($this, "bmn", date("Y-m"));
973 
974  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $posting->getId());
975  $ilCtrl->redirectByClass("ilblogpostinggui", "edit");
976  } else {
977  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_title"), true);
978  $ilCtrl->redirect($this, "render");
979  }
980  }
981 
985  public function render(): void
986  {
987  $tpl = $this->tpl;
988  $ilTabs = $this->tabs;
989  $ilCtrl = $this->ctrl;
990  $lng = $this->lng;
991  $ilToolbar = new ilToolbarGUI();
992 
993  if (!$this->checkPermissionBool("read")) {
994  $this->tpl->setOnScreenMessage('info', $lng->txt("no_permission"));
995  return;
996  }
997 
998  $ilTabs->activateTab("content");
999 
1000  // toolbar
1001  if ($this->blog_access->mayContribute()) {
1002  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "createPosting"));
1003 
1004  $title = new ilTextInputGUI($lng->txt("title"), "title");
1005  $title->setSize(30);
1006  $ilToolbar->addStickyItem($title, true);
1007  $tpl->addOnLoadCode("
1008  document.getElementById('title').setAttribute('data-blog-input', 'posting-title');
1009  document.getElementById('title').setAttribute('placeholder', ' ');
1010  ");
1011 
1012  $this->gui->button(
1013  $lng->txt("blog_add_posting"),
1014  "createPosting"
1015  )->submit()->toToolbar(true, $ilToolbar);
1016 
1017  // #18763
1018  $keys = array_keys($this->items);
1019  $first = array_shift($keys);
1020  if ($first != $this->month) {
1021  $ilToolbar->addSeparator();
1022 
1023  $ilCtrl->setParameter($this, "bmn", $first);
1024  $url = $ilCtrl->getLinkTarget($this, "");
1025  $ilCtrl->setParameter($this, "bmn", $this->month);
1026 
1027  $this->gui->link(
1028  $lng->txt("blog_show_latest"),
1029  $url
1030  )->emphasised()->toToolbar(true, $ilToolbar);
1031  }
1032 
1033  // print/pdf
1034  $print_view = $this->getPrintView();
1035  $modal_elements = $print_view->getModalElements(
1036  $this->ctrl->getLinkTarget(
1037  $this,
1038  "printViewSelection"
1039  )
1040  );
1041  $ilToolbar->addSeparator();
1042  $ilToolbar->addComponent($modal_elements->button);
1043  $ilToolbar->addComponent($modal_elements->modal);
1044  }
1045 
1046  // $is_owner = ($this->object->getOwner() == $ilUser->getId());
1047  $is_owner = $this->blog_access->mayContribute();
1048 
1049  $list_items = $this->getListItems($is_owner);
1050 
1051  $list = $nav = "";
1052  if ($list_items) {
1053  $list = $this->renderList($list_items, "preview", "", $is_owner);
1054  $nav = $this->renderNavigation("render", "edit", "", $is_owner);
1055  }
1056 
1057  $this->setContentStyleSheet();
1058 
1059  $tpl->setContent($ilToolbar->getHTML() . $list);
1060  $tpl->setRightContent($nav);
1061  }
1062 
1066  public function getHTML(): string
1067  {
1068  $ilUser = $this->user;
1069  $ilCtrl = $this->ctrl;
1070  $lng = $this->lng;
1071 
1072  // getHTML() is called by ilRepositoryGUI::show()
1073  if ($this->id_type === self::REPOSITORY_NODE_ID) {
1074  return "";
1075  }
1076 
1077  // there is no way to do a permissions check here, we have no wsp
1078 
1079  $this->filterInactivePostings();
1080 
1081  $list_items = $this->getListItems();
1082  $list = $nav = "";
1083  if ($list_items) {
1084  $list = $this->renderList($list_items, "previewEmbedded");
1085  $nav = $this->renderNavigation("gethtml", "previewEmbedded");
1086  }
1087  // quick editing in portfolio
1088  elseif ($this->prt_id) {
1089  // see renderList()
1090  if (ilObject::_lookupOwner($this->prt_id) === $ilUser->getId()) {
1091  // see ilPortfolioPageTableGUI::fillRow()
1092  $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->user_page);
1093  $link = $ilCtrl->getLinkTargetByClass(array("ilportfoliopagegui", "ilobjbloggui"), "render");
1094  $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", "");
1095 
1096  $this->toolbar->addComponent($this->ui->factory()->button()->standard(
1097  $this->lng->txt("blog_edit"),
1098  $link
1099  ));
1100  }
1101  }
1102 
1103  return $this->buildEmbedded($list, $nav);
1104  }
1105 
1109  protected function getListItems(
1110  bool $a_show_inactive = false
1111  ): array {
1112  if ($this->author) {
1113  $list_items = array();
1114  foreach ($this->items as $month => $items) {
1115  foreach ($items as $id => $item) {
1116  if ($item["author"] == $this->author ||
1117  (isset($item["editors"]) && in_array($this->author, $item["editors"]))) {
1118  $list_items[$id] = $item;
1119  }
1120  }
1121  }
1122  } elseif ($this->keyword) {
1123  $list_items = $this->filterItemsByKeyword($this->items, $this->keyword);
1124  } else {
1125  $max = $this->object->getOverviewPostings();
1126  if ($this->month_default && $max) {
1127  $list_items = array();
1128  foreach ($this->items as $month => $postings) {
1129  foreach ($postings as $id => $item) {
1130  if (!$a_show_inactive &&
1131  !ilBlogPosting::_lookupActive($id, "blp")) {
1132  continue;
1133  }
1134  $list_items[$id] = $item;
1135 
1136  if (count($list_items) >= $max) {
1137  break(2);
1138  }
1139  }
1140  }
1141  } else {
1142  $list_items = $this->items[$this->month] ?? [];
1143  }
1144  }
1145  return $list_items;
1146  }
1147 
1151  public function preview(): void
1152  {
1153  $lng = $this->lng;
1155 
1156  if (!$this->checkPermissionBool("read")) {
1157  $this->tpl->setOnScreenMessage('info', $lng->txt("no_permission"));
1158  return;
1159  }
1160 
1161  $this->filterInactivePostings();
1162 
1163  $list_items = $this->getListItems();
1164 
1165  $list = $nav = "";
1166  if ($list_items) {
1167  $list = $this->renderList($list_items, "previewFullscreen");
1168  $nav = $this->renderNavigation("preview", "previewFullscreen");
1169  $this->renderToolbarNavigation($this->items);
1170  }
1171 
1172  $this->renderFullScreen($list, $nav);
1173  }
1174 
1178  public function export(
1179  bool $a_with_comments = false
1180  ): void {
1181  $zip = $this->buildExportFile($a_with_comments);
1182  ilFileDelivery::deliverFileLegacy($zip, $this->object->getTitle() . ".zip", '', false, true);
1183  }
1184 
1185 
1186  // --- helper functions
1187 
1191  protected function buildEmbedded(
1192  string $a_content,
1193  string $a_nav
1194  ): string {
1195  $wtpl = new ilTemplate("tpl.blog_embedded.html", true, true, "Modules/Blog");
1196  $wtpl->setVariable("VAL_LIST", $a_content);
1197  $wtpl->setVariable("VAL_NAVIGATION", $a_nav);
1198  return $wtpl->get();
1199  }
1200 
1204  public function renderFullScreen(
1205  string $a_content,
1206  string $a_navigation
1207  ): void {
1208  $tpl = $this->tpl;
1209  $ilUser = $this->user;
1210  $ilTabs = $this->tabs;
1211  $ilLocator = $this->locator;
1212 
1213  $owner = $this->object->getOwner();
1214 
1215  $ilTabs->clearTargets();
1216  $tpl->setLocator();
1217 
1218  $back_caption = "";
1219  $back = "";
1220 
1221  // back (edit)
1222  if ($owner === $ilUser->getId()) {
1223  // from shared/deeplink
1224  if ($this->id_type === self::WORKSPACE_NODE_ID) {
1225  $back = "ilias.php?baseClass=ilDashboardGUI&cmd=jumpToWorkspace&wsp_id=" . $this->node_id;
1226  }
1227  // from editor (#10073)
1228  elseif ($this->blog_access->mayContribute()) {
1229  $this->ctrl->setParameter($this, "prvm", "");
1230  if ($this->blpg === 0) {
1231  $back = $this->ctrl->getLinkTarget($this, "");
1232  } else {
1233  $this->ctrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
1234  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $this->blpg);
1235  $back = $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "preview");
1236  }
1237  $this->ctrl->setParameter($this, "prvm", $this->prvm);
1238  }
1239 
1240  $back_caption = $this->lng->txt("blog_back_to_blog_owner");
1241  }
1242  // back
1243  elseif ($ilUser->getId() && $ilUser->getId() !== ANONYMOUS_USER_ID) {
1244  // workspace (always shared)
1245  if ($this->id_type === self::WORKSPACE_NODE_ID) {
1246  $back = "ilias.php?baseClass=ilDashboardGUI&cmd=jumpToWorkspace&dsh=" . $owner;
1247  }
1248  // contributor
1249  elseif ($this->blog_access->mayContribute()) {
1250  $back = $this->ctrl->getLinkTarget($this, "");
1251  $back_caption = $this->lng->txt("blog_back_to_blog_owner");
1252  }
1253  // listgui / parent container
1254  else {
1255  $tree = $this->tree;
1256  $parent_id = $tree->getParentId($this->node_id);
1258  }
1259  }
1260 
1261  $this->renderFullscreenHeader($tpl, $owner);
1262 
1263  // #13564
1264  $this->ctrl->setParameter($this, "bmn", "");
1265  //$tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
1266  $this->ctrl->setParameter($this, "bmn", $this->month);
1267 
1268  $this->setContentStyleSheet();
1269 
1270  // content
1271  $tpl->setContent($a_content);
1272  $tpl->setRightContent($a_navigation);
1273  }
1274 
1278  public function renderFullscreenHeader(
1280  int $a_user_id,
1281  bool $a_export = false
1282  ): void {
1283  $ilUser = $this->user;
1284 
1285  if (!$a_export) {
1287  $this->object->getType(),
1289  $this->object->getId(),
1290  $ilUser->getId()
1291  );
1292  }
1293 
1294  // repository blogs are multi-author
1295  $name = "";
1296  if ($this->id_type !== self::REPOSITORY_NODE_ID) {
1297  $name = ilObjUser::_lookupName($a_user_id);
1298  $name = $name["lastname"] . ", " . $name["firstname"];
1299  }
1300 
1301  // show banner?
1302  $banner = "";
1303  $blga_set = new ilSetting("blga");
1304  $banner_width = "";
1305  $banner_height = "";
1306  if ($blga_set->get("banner")) {
1307  $banner = ilWACSignedPath::signFile($this->object->getImageFullPath());
1308  $banner_width = $blga_set->get("banner_width");
1309  $banner_height = $blga_set->get("banner_height");
1310  if ($a_export) {
1311  $banner = basename($banner);
1312  }
1313  }
1314 
1315  $ppic = "";
1316  if ($this->object->hasProfilePicture()) {
1317  // repository (multi-user)
1318  if ($this->id_type === self::REPOSITORY_NODE_ID) {
1319  // #15030
1320  if ($this->blpg > 0 && !$a_export) {
1321  $post = new ilBlogPosting($this->blpg);
1322  $author_id = $post->getAuthor();
1323  if ($author_id) {
1324  $ppic = $this->profile_gui->getPicturePath($author_id);
1325  $name = $this->profile_gui->getNamePresentation($author_id);
1326  //$name = $name["lastname"] . ", " . $name["firstname"];
1327  }
1328  }
1329  }
1330  // workspace (author == owner)
1331  else {
1332  $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
1333  if ($a_export) {
1334  $ppic = basename($ppic);
1335  }
1336  }
1337  }
1338  $a_tpl->resetHeaderBlock(false);
1339  $a_tpl->setBanner($banner);
1340  $a_tpl->setTitleIcon($ppic);
1341  $a_tpl->setTitle($this->object->getTitle());
1342  if ($this->id_type === self::REPOSITORY_NODE_ID) {
1343  $a_tpl->setDescription($this->object->getDescription());
1344  } else {
1345  $a_tpl->setDescription($name);
1346  }
1347  }
1348 
1352  protected function buildPostingList(
1353  int $a_obj_id
1354  ): array {
1355  $author_found = false;
1356 
1357  $items = array();
1358  foreach (ilBlogPosting::getAllPostings($a_obj_id) as $posting) {
1359  if ($this->author &&
1360  ($posting["author"] == $this->author ||
1361  (is_array($posting["editors"] ?? false) && in_array($this->author, $posting["editors"])))) {
1362  $author_found = true;
1363  }
1364 
1365  $month = substr($posting["created"]->get(IL_CAL_DATE), 0, 7);
1366  $items[$month][$posting["id"]] = $posting;
1367  }
1368 
1369  if ($this->author && !$author_found) {
1370  $this->author = null;
1371  }
1372 
1373  return $items;
1374  }
1375 
1379  public function renderList(
1380  array $items,
1381  string $a_cmd = "preview",
1382  string $a_link_template = "",
1383  bool $a_show_inactive = false,
1384  string $a_export_directory = ""
1385  ): string {
1386  $lng = $this->lng;
1387  $ilCtrl = $this->ctrl;
1388  $ilUser = $this->user;
1389  $ui_factory = $this->ui->factory();
1390  $ui_renderer = $this->ui->renderer();
1391 
1392  $wtpl = new ilTemplate("tpl.blog_list.html", true, true, "Modules/Blog");
1393 
1394  // quick editing in portfolio
1395  if ($this->prt_id > 0 &&
1396  stripos($a_cmd, "embedded") !== false && ilObject::_lookupOwner($this->prt_id) === $ilUser->getId()) {
1397  // see ilPortfolioPageTableGUI::fillRow()
1398  $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->user_page);
1399  $link = $ilCtrl->getLinkTargetByClass(array("ilportfoliopagegui", "ilobjbloggui"), "render");
1400  $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", "");
1401  $b = $this->ui->factory()->button()->standard(
1402  $this->lng->txt("blog_edit"),
1403  $link
1404  );
1405  $this->toolbar->addComponent($b);
1406  }
1407 
1408  $is_admin = $this->isAdmin();
1409 
1410  $last_month = null;
1411  $is_empty = true;
1412  foreach ($items as $item) {
1413  // only published items
1414  $is_active = ilBlogPosting::_lookupActive($item["id"], "blp");
1415  if (!$is_active && !$a_show_inactive) {
1416  continue;
1417  }
1418 
1419  $is_empty = false;
1420 
1421  $month = "";
1422  if (!$this->keyword && !$this->author) {
1423  $month = substr($item["created"]->get(IL_CAL_DATE), 0, 7);
1424  }
1425 
1426  if (!$last_month || $last_month != $month) {
1427  if ($last_month) {
1428  $wtpl->setCurrentBlock("month_bl");
1429  $wtpl->parseCurrentBlock();
1430  }
1431 
1432  // title according to current "filter"/navigation
1433  if ($this->keyword) {
1434  $title = $lng->txt("blog_keyword") . ": " . $this->keyword;
1435  } elseif ($this->author) {
1436  $title = $lng->txt("blog_author") . ": " . $this->profile_gui->getNamePresentation($this->author);
1437  } else {
1438  $title = $this->gui->presentation()->util()->getMonthPresentation($month);
1439  $last_month = $month;
1440  }
1441 
1442  $wtpl->setVariable("TXT_CURRENT_MONTH", $title);
1443  }
1444 
1445  if (!$a_link_template) {
1446  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
1447  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $item["id"]);
1448  $preview = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_cmd);
1449  } else {
1450  $preview = $this->buildExportLink($a_link_template, "posting", (string) $item["id"]);
1451  }
1452  $more_link = $preview;
1453 
1454  // actions
1455  $posting_edit = $this->blog_access->mayEditPosting($item["id"], $item["author"]);
1456  if (($posting_edit || $is_admin) && !$a_link_template && $a_cmd === "preview") {
1457  $actions = [];
1458 
1459  if ($is_active && $this->object->hasApproval() && !$item["approved"]) {
1460  if ($is_admin) {
1461  $ilCtrl->setParameter($this, "apid", $item["id"]);
1462  $actions[] = $ui_factory->link()->standard(
1463  $lng->txt("blog_approve"),
1464  $ilCtrl->getLinkTarget($this, "approve")
1465  );
1466  $ilCtrl->setParameter($this, "apid", "");
1467  }
1468 
1469  $wtpl->setVariable("APPROVAL", $lng->txt("blog_needs_approval"));
1470  }
1471 
1472  if ($posting_edit) {
1473  $actions[] = $ui_factory->link()->standard(
1474  $lng->txt("edit_content"),
1475  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit")
1476  );
1477  $more_link = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit");
1478 
1479  // #11858
1480  if ($is_active) {
1481  $actions[] = $ui_factory->link()->standard(
1482  $lng->txt("blog_toggle_draft"),
1483  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deactivatePageToList")
1484  );
1485  } else {
1486  $actions[] = $ui_factory->link()->standard(
1487  $lng->txt("blog_toggle_final"),
1488  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "activatePageToList")
1489  );
1490  }
1491 
1492  $actions[] = $ui_factory->link()->standard(
1493  $lng->txt("rename"),
1494  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edittitle")
1495  );
1496 
1497  if ($this->object->hasKeywords()) { // #13616
1498  $actions[] = $ui_factory->link()->standard(
1499  $lng->txt("blog_edit_keywords"),
1500  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords")
1501  );
1502  }
1503 
1504  $actions[] = $ui_factory->link()->standard(
1505  $lng->txt("blog_edit_date"),
1506  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editdate")
1507  );
1508 
1509  $actions[] = $ui_factory->link()->standard(
1510  $lng->txt("delete"),
1511  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen")
1512  );
1513  } elseif ($is_admin) {
1514  // #10513
1515  if ($is_active) {
1516  $ilCtrl->setParameter($this, "apid", $item["id"]);
1517  $actions[] = $ui_factory->link()->standard(
1518  $lng->txt("blog_toggle_draft_admin"),
1519  $ilCtrl->getLinkTarget($this, "deactivateAdmin")
1520  );
1521  $ilCtrl->setParameter($this, "apid", "");
1522  }
1523 
1524  $actions[] = $ui_factory->link()->standard(
1525  $lng->txt("delete"),
1526  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen")
1527  );
1528  }
1529 
1530  $dd = $ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt("actions"));
1531 
1532  $wtpl->setCurrentBlock("actions");
1533  $wtpl->setVariable("ACTION_SELECTOR", $ui_renderer->render($dd));
1534  $wtpl->parseCurrentBlock();
1535  }
1536 
1537  // comments
1538  if ($this->object->getNotesStatus() && !$a_link_template && !$this->disable_notes) {
1539  // count (public) notes
1540  $notes_context = $this->notes
1541  ->data()
1542  ->context(
1543  $this->obj_id,
1544  (int) $item["id"],
1545  "blp"
1546  );
1547  $count = $this->notes
1548  ->domain()
1549  ->getNrOfCommentsForContext($notes_context);
1550 
1551  if ($a_cmd !== "preview") {
1552  $wtpl->setCurrentBlock("comments");
1553  $wtpl->setVariable("TEXT_COMMENTS", $lng->txt("blog_comments"));
1554  $wtpl->setVariable("URL_COMMENTS", $preview);
1555  $wtpl->setVariable("COUNT_COMMENTS", $count);
1556  $wtpl->parseCurrentBlock();
1557  }
1558  }
1559 
1560  // permanent link
1561  if ($this->node_id !== null &&
1562  $a_cmd !== "preview" &&
1563  $a_cmd !== "previewEmbedded") {
1564  if ($this->id_type === self::WORKSPACE_NODE_ID) {
1565  $goto = $this->gui->permanentLink(0, (int) $this->node_id)->getPermanentLink((int) $item["id"]);
1566  } else {
1567  $goto = $this->gui->permanentLink((int) $this->node_id)->getPermanentLink((int) $item["id"]);
1568  }
1569  $wtpl->setCurrentBlock("permalink");
1570  $wtpl->setVariable("URL_PERMALINK", $goto);
1571  $wtpl->setVariable("TEXT_PERMALINK", $lng->txt("blog_link"));
1572  $wtpl->parseCurrentBlock();
1573  }
1574 
1575  $snippet = ilBlogPostingGUI::getSnippet(
1576  $item["id"],
1577  $this->object->hasAbstractShorten(),
1578  $this->object->getAbstractShortenLength(),
1579  "&hellip;",
1580  $this->object->hasAbstractImage(),
1581  $this->object->getAbstractImageWidth(),
1582  $this->object->getAbstractImageHeight(),
1583  $a_export_directory
1584  );
1585 
1586  if ($snippet) {
1587  $wtpl->setCurrentBlock("more");
1588  $wtpl->setVariable("URL_MORE", $more_link);
1589  $wtpl->setVariable("TEXT_MORE", $lng->txt("blog_list_more"));
1590  $wtpl->parseCurrentBlock();
1591  }
1592 
1593 
1594 
1595  if (!$is_active) {
1596  $wtpl->setCurrentBlock("draft_text");
1597  $wtpl->setVariable("DRAFT_TEXT", $lng->txt("blog_draft_text"));
1598  $wtpl->parseCurrentBlock();
1599  $wtpl->setVariable("DRAFT_CLASS", " ilBlogListItemDraft");
1600  }
1601 
1602  // reading time
1603  $reading_time = $this->reading_time_manager->getReadingTime(
1604  $this->object->getId(),
1605  $item["id"]
1606  );
1607  if (!is_null($reading_time)) {
1608  $this->lng->loadLanguageModule("copg");
1609  $wtpl->setCurrentBlock("reading_time");
1610  $wtpl->setVariable(
1611  "READING_TIME",
1612  $this->lng->txt("copg_est_reading_time") . ": " .
1613  sprintf($this->lng->txt("copg_x_minutes"), $reading_time)
1614  );
1615  $wtpl->parseCurrentBlock();
1616  }
1617 
1618  $wtpl->setCurrentBlock("posting");
1619 
1620  $author = "";
1621  if ($this->id_type === self::REPOSITORY_NODE_ID) {
1622  $authors = array();
1623 
1624  $author_id = $item["author"];
1625  if ($author_id) {
1626  $authors[] = $this->profile_gui->getNamePresentation($author_id);
1627  }
1628 
1629  if (isset($item["editors"])) {
1630  foreach ($item["editors"] as $editor_id) {
1631  $authors[] = $this->profile_gui->getNamePresentation($editor_id);
1632  }
1633  }
1634 
1635  if ($authors) {
1636  $author = implode(", ", $authors) . " - ";
1637  }
1638  }
1639 
1640  // title
1641  $wtpl->setVariable("URL_TITLE", $preview);
1642  $wtpl->setVariable("TITLE", $item["title"]);
1643 
1644  $kw = ilBlogPosting::getKeywords($this->obj_id, $item["id"]);
1645  natcasesort($kw);
1646  $keywords = (count($kw) > 0)
1647  ? "<br>" . $this->lng->txt("keywords") . ": " . implode(", ", $kw)
1648  : "";
1649 
1650  $wtpl->setVariable("DATETIME", $author .
1651  ilDatePresentation::formatDate($item["created"]) . $keywords);
1652 
1653  // content
1654  $wtpl->setVariable("CONTENT", $snippet);
1655 
1656  $wtpl->parseCurrentBlock();
1657  }
1658 
1659  // permalink
1660  if ($a_cmd === "previewFullscreen") {
1661  $ref_id = ($this->id_type === self::WORKSPACE_NODE_ID)
1662  ? 0
1663  : $this->node_id;
1664  $wsp_id = ($this->id_type === self::WORKSPACE_NODE_ID)
1665  ? $this->node_id
1666  : 0;
1667  $this->gui->permanentLink($ref_id, $wsp_id)->setPermanentLink();
1668  }
1669 
1670  if (!$is_empty || $a_show_inactive) {
1671  return $wtpl->get();
1672  }
1673  return "";
1674  }
1675 
1679  protected function buildExportLink(
1680  string $a_template,
1681  string $a_type,
1682  string $a_id
1683  ): string {
1684  return \ILIAS\Blog\Export\BlogHtmlExport::buildExportLink($a_template, $a_type, $a_id, $this->getKeywords(false));
1685  }
1686 
1687 
1691  protected function renderNavigationByDate(
1692  array $a_items,
1693  string $a_list_cmd = "render",
1694  string $a_posting_cmd = "preview",
1695  ?string $a_link_template = null,
1696  bool $a_show_inactive = false,
1697  int $a_blpg = 0
1698  ): string {
1699  $ilCtrl = $this->ctrl;
1700 
1701  $blpg = ($a_blpg > 0)
1702  ? $a_blpg
1703  : $this->blpg;
1704 
1705 
1706  // gather page active status
1707  foreach ($a_items as $month => $postings) {
1708  foreach (array_keys($postings) as $id) {
1709  $active = ilBlogPosting::_lookupActive($id, "blp");
1710  if (!$a_show_inactive && !$active) {
1711  unset($a_items[$month][$id]);
1712  } else {
1713  $a_items[$month][$id]["active"] = $active;
1714  }
1715  }
1716  if (!count($a_items[$month])) {
1717  unset($a_items[$month]);
1718  }
1719  }
1720 
1721  // list month (incl. postings)
1722  if ($this->object->getNavMode() === ilObjBlog::NAV_MODE_LIST || $a_link_template) {
1723  //$max_detail_postings = $this->object->getNavModeListPostings();
1724  $max_months = $this->object->getNavModeListMonths();
1725 
1726  $wtpl = new ilTemplate("tpl.blog_list_navigation_by_date.html", true, true, "Modules/Blog");
1727 
1728  $ilCtrl->setParameter($this, "blpg", "");
1729 
1730  $counter = $mon_counter = $last_year = 0;
1731  foreach ($a_items as $month => $postings) {
1732  if (!$a_link_template && $max_months && $mon_counter >= $max_months) {
1733  break;
1734  }
1735 
1736  $add_year = false;
1737  $year = substr($month, 0, 4);
1738  if (!$last_year || $year != $last_year) {
1739  // #13562
1740  $add_year = true;
1741  $last_year = $year;
1742  }
1743 
1744  $mon_counter++;
1745 
1746  $month_name = ilCalendarUtil::_numericMonthToString((int) substr($month, 5));
1747  if (!$a_link_template) {
1748  $ilCtrl->setParameter($this, "bmn", $month);
1749  $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1750  } else {
1751  $month_url = $this->buildExportLink($a_link_template, "list", (string) $month);
1752  }
1753 
1754  // list postings for month
1755  //if($counter < $max_detail_postings)
1756  if ($mon_counter <= $this->object->getNavModeListMonthsWithPostings()) {
1757  if ($add_year) {
1758  $wtpl->setCurrentBlock("navigation_year_details");
1759  $wtpl->setVariable("YEAR", $year);
1760  $wtpl->parseCurrentBlock();
1761  }
1762 
1763  foreach ($postings as $id => $posting) {
1764  //if($max_detail_postings && $counter >= $max_detail_postings)
1765  //{
1766  // break;
1767  //}
1768 
1769  $counter++;
1770 
1771  $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1772  ", ".*/ $posting["title"];
1773 
1774  if (!$a_link_template) {
1775  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1776  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1777  $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1778  } else {
1779  $url = $this->buildExportLink($a_link_template, "posting", (string) $id);
1780  }
1781 
1782  if (!$posting["active"]) {
1783  $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1784  } elseif ($this->object->hasApproval() && !$posting["approved"]) {
1785  $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1786  }
1787 
1788  $wtpl->setCurrentBlock("navigation_item");
1789  $wtpl->setVariable("NAV_ITEM_URL", $url);
1790  $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1791  $wtpl->parseCurrentBlock();
1792  }
1793 
1794  $wtpl->setCurrentBlock("navigation_month_details");
1795  $wtpl->setVariable("NAV_MONTH", $month_name);
1796  $wtpl->setVariable("URL_MONTH", $month_url);
1797  }
1798  // summarized month
1799  else {
1800  if ($add_year) {
1801  $wtpl->setCurrentBlock("navigation_year");
1802  $wtpl->setVariable("YEAR", $year);
1803  $wtpl->parseCurrentBlock();
1804  }
1805 
1806  $wtpl->setCurrentBlock("navigation_month");
1807  $wtpl->setVariable("MONTH_NAME", $month_name);
1808  $wtpl->setVariable("URL_MONTH", $month_url);
1809  $wtpl->setVariable("MONTH_COUNT", count($postings));
1810  }
1811  $wtpl->parseCurrentBlock();
1812  }
1813  if (!$a_link_template) {
1814  $this->ctrl->setParameterByClass(self::class, "bmn", null);
1815  $url = $this->ctrl->getLinkTargetByClass(self::class, $a_list_cmd);
1816  } else {
1817  $url = "index.html";
1818  }
1819 
1820  $wtpl->setVariable(
1821  "STARTING_PAGE",
1822  $this->ui->renderer()->render(
1823  $this->ui->factory()->link()->standard(
1824  $this->lng->txt("blog_starting_page"),
1825  $url
1826  )
1827  )
1828  );
1829  }
1830  // single month
1831  else {
1832  $wtpl = new ilTemplate("tpl.blog_list_navigation_month.html", true, true, "Modules/Blog");
1833 
1834  $ilCtrl->setParameter($this, "blpg", "");
1835 
1836  $month_options = array();
1837  foreach ($a_items as $month => $postings) {
1838  $month_name = $this->gui->presentation()->util()->getMonthPresentation($month);
1839 
1840  $month_options[$month] = $month_name;
1841 
1842  if ($month == $this->month) {
1843  if (!$a_link_template) {
1844  $ilCtrl->setParameter($this, "bmn", $month);
1845  $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1846  } else {
1847  $month_url = $this->buildExportLink($a_link_template, "list", (string) $month);
1848  }
1849 
1850  foreach ($postings as $id => $posting) {
1851  $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1852  ", ".*/ $posting["title"];
1853 
1854  if (!$a_link_template) {
1855  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1856  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1857  $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1858  } else {
1859  $url = $this->buildExportLink($a_link_template, "posting", (string) $id);
1860  }
1861 
1862  if (!$posting["active"]) {
1863  $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1864  } elseif ($this->object->hasApproval() && !$posting["approved"]) {
1865  $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1866  }
1867 
1868  $wtpl->setCurrentBlock("navigation_item");
1869  $wtpl->setVariable("NAV_ITEM_URL", $url);
1870  $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1871  $wtpl->parseCurrentBlock();
1872  }
1873 
1874  $wtpl->setCurrentBlock("navigation_month_details");
1875  if ($blpg > 0) {
1876  $wtpl->setVariable("NAV_MONTH", $month_name);
1877  $wtpl->setVariable("URL_MONTH", $month_url);
1878  }
1879  $wtpl->parseCurrentBlock();
1880  }
1881  }
1882 
1883  if ($blpg === 0) {
1884  $wtpl->setCurrentBlock("option_bl");
1885  foreach ($month_options as $value => $caption) {
1886  $wtpl->setVariable("OPTION_VALUE", $value);
1887  $wtpl->setVariable("OPTION_CAPTION", $caption);
1888  if ($value == $this->month) {
1889  $wtpl->setVariable("OPTION_SEL", ' selected="selected"');
1890  }
1891  $wtpl->parseCurrentBlock();
1892  }
1893 
1894  $wtpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this, $a_list_cmd));
1895  }
1896  }
1897  $ilCtrl->setParameter($this, "bmn", $this->month);
1898  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
1899  return $wtpl->get();
1900  }
1901 
1905  protected function renderNavigationByKeywords(
1906  string $a_list_cmd = "render",
1907  bool $a_show_inactive = false,
1908  string $a_link_template = "",
1909  int $a_blpg = 0
1910  ): string {
1911  $ilCtrl = $this->ctrl;
1912 
1913  $blpg = ($a_blpg > 0)
1914  ? $a_blpg
1915  : $this->blpg;
1916 
1917  $keywords = $this->getKeywords($a_show_inactive, $blpg);
1918  if ($keywords) {
1919  $wtpl = new ilTemplate("tpl.blog_list_navigation_keywords.html", true, true, "Modules/Blog");
1920 
1921  $max = max($keywords);
1922 
1923  $wtpl->setCurrentBlock("keyword");
1924  foreach ($keywords as $keyword => $counter) {
1925  if (!$a_link_template) {
1926  $ilCtrl->setParameter($this, "kwd", urlencode((string) $keyword)); // #15885
1927  $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1928  $ilCtrl->setParameter($this, "kwd", "");
1929  } else {
1930  $url = $this->buildExportLink($a_link_template, "keyword", (string) $keyword);
1931  }
1932 
1933  $wtpl->setVariable("TXT_KEYWORD", $keyword);
1934  $wtpl->setVariable("CLASS_KEYWORD", ilTagging::getRelevanceClass($counter, $max));
1935  $wtpl->setVariable("URL_KEYWORD", $url);
1936  $wtpl->parseCurrentBlock();
1937  }
1938 
1939  return $wtpl->get();
1940  }
1941  return "";
1942  }
1943 
1944  protected function renderNavigationByAuthors(
1945  array $a_items,
1946  string $a_list_cmd = "render",
1947  bool $a_show_inactive = false
1948  ): string {
1949  $ilCtrl = $this->ctrl;
1950 
1951  $authors = array();
1952  foreach ($a_items as $month => $items) {
1953  foreach ($items as $item) {
1954  if (($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp"))) {
1955  if ($item["author"]) {
1956  $authors[] = $item["author"];
1957  }
1958 
1959  if (isset($item["editors"])) {
1960  foreach ($item["editors"] as $editor_id) {
1961  if ($editor_id != $item["author"]) {
1962  $authors[] = $editor_id;
1963  }
1964  }
1965  }
1966  }
1967  }
1968  }
1969 
1970  $authors = array_unique($authors);
1971 
1972  // filter out deleted users
1973  $authors = array_filter($authors, function ($id) {
1974  return ilObject::_lookupType($id) == "usr";
1975  });
1976 
1977  if (count($authors) > 1) {
1978  $list = array();
1979  foreach ($authors as $user_id) {
1980  if ($user_id) {
1981  $ilCtrl->setParameter($this, "ath", $user_id);
1982  $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1983  $ilCtrl->setParameter($this, "ath", "");
1984 
1985  $base_name = ilUserUtil::getNamePresentation($user_id);
1986  if (substr($base_name, 0, 1) == "[") {
1987  $name = ilUserUtil::getNamePresentation($user_id, true);
1988  $sort = $name;
1989  } else {
1991  $user_id,
1992  true,
1993  false,
1994  "",
1995  false,
1996  true,
1997  false
1998  );
1999  $name_arr = ilObjUser::_lookupName($user_id);
2000  $sort = $name_arr["lastname"] . " " . $name_arr["firstname"];
2001  }
2002 
2003  $idx = trim(strip_tags($sort)) . "///" . $user_id; // #10934
2004  $list[$idx] = array($name, $url);
2005  }
2006  }
2007  ksort($list);
2008 
2009  $wtpl = new ilTemplate("tpl.blog_list_navigation_authors.html", true, true, "Modules/Blog");
2010 
2011  $wtpl->setCurrentBlock("author");
2012  foreach ($list as $author) {
2013  $wtpl->setVariable("TXT_AUTHOR", $author[0]);
2014  $wtpl->setVariable("URL_AUTHOR", $author[1]);
2015  $wtpl->parseCurrentBlock();
2016  }
2017 
2018  return $wtpl->get();
2019  }
2020  return "";
2021  }
2022 
2026  public function renderToolbarNavigation(
2027  array $a_items,
2028  bool $single_posting = false
2029  ): void {
2030  $nav_renderer = $this->gui->navigation()->toolbarNavigationRenderer();
2031  $nav_renderer->renderToolbarNavigation(
2032  $this->blog_access,
2033  $a_items,
2034  $this->blpg,
2035  $single_posting,
2036  $this->prtf_embed,
2037  $this->month,
2038  $this->user_page
2039  );
2040  }
2041 
2045  public function renderNavigation(
2046  string $a_list_cmd = "render",
2047  string $a_posting_cmd = "preview",
2048  string $a_link_template = null,
2049  bool $a_show_inactive = false,
2050  int $a_blpg = 0
2051  ): string {
2053  $a_items = $this->items;
2054  $blpg = ($a_blpg > 0)
2055  ? $a_blpg
2056  : $this->blpg;
2057 
2058  if ($this->object->getOrder()) {
2059  $order = array_flip($this->object->getOrder());
2060  } else {
2061  $order = array(
2062  "navigation" => 0
2063  ,"keywords" => 2
2064  ,"authors" => 1
2065  );
2066  }
2067 
2068  $wtpl = new ilTemplate("tpl.blog_list_navigation.html", true, true, "Modules/Blog");
2069 
2070  $blocks = array();
2071 
2072  // by date
2073  if (count($a_items)) {
2074  $blocks[$order["navigation"]] = array(
2075  $this->lng->txt("blog_navigation"),
2076  $this->renderNavigationByDate($a_items, $a_list_cmd, $a_posting_cmd, $a_link_template, $a_show_inactive, $a_blpg)
2077  );
2078  }
2079 
2080  if ($this->object->hasKeywords()) {
2081  // keywords
2082  $may_edit_keywords = ($blpg > 0 &&
2083  $this->blog_access->mayEditPosting($blpg) &&
2084  $a_list_cmd !== "preview" &&
2085  $a_list_cmd !== "gethtml" &&
2086  !$a_link_template);
2087  $keywords = $this->renderNavigationByKeywords($a_list_cmd, $a_show_inactive, (string) $a_link_template, $a_blpg);
2088  if ($keywords || $may_edit_keywords) {
2089  if (!$keywords) {
2090  $keywords = $this->lng->txt("blog_no_keywords");
2091  }
2092  $cmd = null;
2093  $blocks[$order["keywords"]] = array(
2094  $this->lng->txt("blog_keywords"),
2095  $keywords,
2096  $cmd
2097  ? array($cmd, $this->lng->txt("blog_edit_keywords"))
2098  : null
2099  );
2100  }
2101  }
2102 
2103  // is not part of (html) export
2104  if (!$a_link_template) {
2105  // authors
2106  if ($this->id_type === self::REPOSITORY_NODE_ID &&
2107  $this->object->hasAuthors()) {
2108  $authors = $this->renderNavigationByAuthors($a_items, $a_list_cmd, $a_show_inactive);
2109  if ($authors) {
2110  $blocks[$order["authors"]] = array($this->lng->txt("blog_authors"), $authors);
2111  }
2112  }
2113 
2114  // rss
2115  if ($this->object->hasRSS() &&
2116  $ilSetting->get('enable_global_profiles') &&
2117  $a_list_cmd === "preview") {
2118  // #10827
2119  $blog_id = $this->node_id;
2120  if ($this->id_type !== self::WORKSPACE_NODE_ID) {
2121  $blog_id .= "_cll";
2122  }
2123  $url = ILIAS_HTTP_PATH . "/feed.php?blog_id=" . $blog_id .
2124  "&client_id=" . rawurlencode(CLIENT_ID);
2125 
2126  $wtpl->setVariable("RSS_BUTTON", ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_RSS, $url));
2127  }
2128  }
2129 
2130  if (count($blocks)) {
2131  global $DIC;
2132 
2133  $ui_factory = $DIC->ui()->factory();
2134  $ui_renderer = $DIC->ui()->renderer();
2135 
2136  ksort($blocks);
2137  foreach ($blocks as $block) {
2138  $title = $block[0];
2139 
2140  $content = $block[1];
2141 
2142  $secondary_panel = $ui_factory->panel()->secondary()->legacy($title, $ui_factory->legacy($content));
2143 
2144  if (isset($block[2]) && is_array($block[2])) {
2145  $link = $ui_factory->button()->shy($block[2][1], $block[2][0]);
2146  $secondary_panel = $secondary_panel->withFooter($link);
2147  }
2148 
2149  $wtpl->setCurrentBlock("block_bl");
2150  $wtpl->setVariable("BLOCK", $ui_renderer->render($secondary_panel));
2151  $wtpl->parseCurrentBlock();
2152  }
2153  }
2154 
2155  return $wtpl->get();
2156  }
2157 
2161  public function getKeywords(
2162  bool $a_show_inactive,
2163  ?int $a_posting_id = null
2164  ): array {
2165  $keywords = array();
2166  if ($a_posting_id) {
2167  foreach (ilBlogPosting::getKeywords($this->obj_id, $a_posting_id) as $keyword) {
2168  if (isset($keywords[$keyword])) {
2169  $keywords[$keyword]++;
2170  } else {
2171  $keywords[$keyword] = 1;
2172  }
2173  }
2174  } else {
2175  foreach ($this->items as $month => $items) {
2176  foreach ($items as $item) {
2177  if ($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp")) {
2178  foreach (ilBlogPosting::getKeywords($this->obj_id, $item["id"]) as $keyword) {
2179  if (isset($keywords[$keyword])) {
2180  $keywords[$keyword]++;
2181  } else {
2182  $keywords[$keyword] = 1;
2183  }
2184  }
2185  }
2186  }
2187  }
2188  }
2189 
2190  // #15881
2191  $tmp = array();
2192  foreach ($keywords as $keyword => $counter) {
2193  $tmp[] = array("keyword" => $keyword, "counter" => $counter);
2194  }
2195  $tmp = ilArrayUtil::sortArray($tmp, "keyword", "ASC");
2196 
2197  $keywords = array();
2198  foreach ($tmp as $item) {
2199  $keywords[(string) $item["keyword"]] = $item["counter"];
2200  }
2201  return $keywords;
2202  }
2203 
2207  public function buildExportFile(
2208  bool $a_include_comments = false,
2209  bool $print_version = false
2210  ): string {
2211  $type = "html";
2212  $format = explode("_", $this->blog_request->getFormat());
2213  if (($format[1] ?? "") === "comments" || $a_include_comments) {
2214  $a_include_comments = true;
2215  $type = "html_comments";
2216  }
2217 
2218  // create export file
2219  ilExport::_createExportDirectory($this->object->getId(), $type, "blog");
2220  $exp_dir = ilExport::_getExportDirectory($this->object->getId(), $type, "blog");
2221 
2222  $subdir = $this->object->getType() . "_" . $this->object->getId();
2223  if ($print_version) {
2224  $subdir .= "print";
2225  }
2226 
2227  $blog_export = new \ILIAS\Blog\Export\BlogHtmlExport($this, $exp_dir, $subdir);
2228  $blog_export->setPrintVersion($print_version);
2229  $blog_export->includeComments($a_include_comments);
2230  return $blog_export->exportHTML();
2231  }
2232 
2233  public function getNotesSubId(): int
2234  {
2235  return $this->blpg;
2236  }
2237 
2238  public function disableNotes(bool $a_value = false): void
2239  {
2240  $this->disable_notes = $a_value;
2241  }
2242 
2243  protected function addHeaderActionForCommand(
2244  string $a_cmd
2245  ): void {
2246  $ilUser = $this->user;
2247  $ilCtrl = $this->ctrl;
2248  // preview?
2249  if ($a_cmd === "preview" || $a_cmd === "previewEmbedded" || $a_cmd === "previewFullscreen" || $this->prvm) {
2250  // notification
2251  if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
2252  if (!$this->prvm) {
2253  $ilCtrl->setParameter($this, "prvm", "fsc");
2254  }
2255  $this->insertHeaderAction($this->initHeaderAction(null, null, true));
2256  if (!$this->prvm) {
2257  $ilCtrl->setParameter($this, "prvm", "");
2258  }
2259  }
2260  } else {
2261  $this->addHeaderAction();
2262  }
2263  }
2264 
2265  protected function initHeaderAction(
2266  ?string $sub_type = null,
2267  ?int $sub_id = null,
2268  bool $is_preview = false
2269  ): ?ilObjectListGUI {
2270  $ilUser = $this->user;
2271  $ilCtrl = $this->ctrl;
2272  if (!$this->obj_id) {
2273  return null;
2274  }
2275  $sub_type = $sub_id = null;
2276  if ($this->blpg > 0) {
2277  $sub_type = "blp";
2278  $sub_id = $this->blpg;
2279  }
2280 
2281  $lg = parent::initHeaderAction($sub_type, $sub_id);
2282  if (!$lg) {
2283  return null;
2284  }
2285  $lg->enableComments(false);
2286  $lg->enableNotes(false);
2287 
2288  if ($is_preview) {
2289  if ($this->blpg > 0) {
2290  if (($this->object->getNotesStatus() && !$this->disable_notes)) {
2291  $lg->enableComments(true);
2292  }
2293  $lg->enableNotes(true);
2294  }
2295  $lg->enableTags(false);
2296 
2297  if (!$this->prtf_embed) {
2299  $ilCtrl->setParameter($this, "ntf", 1);
2300  $link = $ilCtrl->getLinkTarget($this, "setNotification");
2301  $ilCtrl->setParameter($this, "ntf", "");
2302  if (ilNotification::hasOptOut($this->obj_id)) {
2303  $lg->addCustomCommand($link, "blog_notification_toggle_off");
2304  }
2305 
2306  $lg->addHeaderIcon(
2307  "not_icon",
2308  ilUtil::getImagePath("object/notification_on.svg"),
2309  $this->lng->txt("blog_notification_activated")
2310  );
2311  } else {
2312  $ilCtrl->setParameter($this, "ntf", 2);
2313  $link = $ilCtrl->getLinkTarget($this, "setNotification");
2314  $ilCtrl->setParameter($this, "ntf", "");
2315  $lg->addCustomCommand($link, "blog_notification_toggle_on");
2316 
2317  $lg->addHeaderIcon(
2318  "not_icon",
2319  ilUtil::getImagePath("object/notification_off.svg"),
2320  $this->lng->txt("blog_notification_deactivated")
2321  );
2322  }
2323  }
2324 
2325  // #11758
2326  if ($this->blog_access->mayContribute()) {
2327  $ilCtrl->setParameter($this, "prvm", "");
2328 
2329  $ilCtrl->setParameter($this, "bmn", "");
2330  $ilCtrl->setParameter($this, "blpg", "");
2331  $link = $ilCtrl->getLinkTarget($this, "");
2332  $ilCtrl->setParameter($this, "blpg", $sub_id);
2333  $ilCtrl->setParameter($this, "bmn", $this->month);
2334  $lg->addCustomCommand($link, "blog_edit"); // #11868
2335 
2336  if ($sub_id && $this->blog_access->mayEditPosting($sub_id)) {
2337  $link = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit");
2338  $lg->addCustomCommand($link, "blog_edit_posting");
2339  }
2340 
2341  $ilCtrl->setParameter($this, "prvm", "fsc");
2342  }
2343 
2344  $ilCtrl->setParameter($this, "ntf", "");
2345  }
2346 
2347  return $lg;
2348  }
2349 
2350  protected function setNotification(): void
2351  {
2352  $ilUser = $this->user;
2353  $ilCtrl = $this->ctrl;
2354 
2355  switch ($this->ntf) {
2356  case 1:
2358  break;
2359 
2360  case 2:
2362  break;
2363  }
2364 
2365  $ilCtrl->redirect($this, "preview");
2366  }
2367 
2371  public static function lookupSubObjectTitle(
2372  int $a_blog_id,
2373  int $a_posting_id
2374  ): string {
2375  // page might be deleted, so setting halt on errors to false
2376  $post = new ilBlogPosting($a_posting_id);
2377  if ($post->getBlogId() === $a_blog_id) {
2378  return $post->getTitle();
2379  }
2380  return "";
2381  }
2382 
2386  protected function filterInactivePostings(): void
2387  {
2388  foreach ($this->items as $month => $postings) {
2389  foreach ($postings as $id => $item) {
2390  if (!ilBlogPosting::_lookupActive($id, "blp")) {
2391  unset($this->items[$month][$id]);
2392  } elseif ($this->object->hasApproval() && !$item["approved"]) {
2393  unset($this->items[$month][$id]);
2394  }
2395  }
2396  if (!count($this->items[$month])) {
2397  unset($this->items[$month]);
2398  }
2399  }
2400 
2401  if ($this->items && !isset($this->items[$this->month])) {
2402  $keys = array_keys($this->items);
2403  $this->month = array_shift($keys);
2404  }
2405  }
2406 
2407  public function filterItemsByKeyword(
2408  array $a_items,
2409  string $a_keyword
2410  ): array {
2411  $res = [];
2412  foreach ($a_items as $month => $items) {
2413  foreach ($items as $item) {
2414  if (in_array(
2415  $a_keyword,
2416  ilBlogPosting::getKeywords($this->obj_id, $item["id"])
2417  )) {
2418  $res[] = $item;
2419  }
2420  }
2421  }
2422  return $res;
2423  }
2424 
2428  protected function isAdmin(): bool
2429  {
2430  return ($this->checkPermissionBool("redact") ||
2431  $this->checkPermissionBool("write"));
2432  }
2433 
2434  protected function addLocatorItems(): void
2435  {
2436  $ilLocator = $this->locator;
2437 
2438  if (is_object($this->object)) {
2439  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "preview"), "", $this->node_id);
2440  }
2441  }
2442 
2443  public function approve(): void
2444  {
2445  if ($this->isAdmin() && $this->apid > 0) {
2446  $post = new ilBlogPosting($this->apid);
2447  $post->setApproved(true);
2448  $post->setBlogNodeId($this->node_id, ($this->id_type == self::WORKSPACE_NODE_ID));
2449  $post->update(true, false, true, "new"); // #13434
2450 
2451  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
2452  }
2453 
2454  $this->ctrl->redirect($this, "render");
2455  }
2456 
2457 
2458  //
2459  // contributors
2460  //
2461 
2462  public function contributors(): void
2463  {
2464  $ilTabs = $this->tabs;
2465  $ilToolbar = $this->toolbar;
2466  $ilCtrl = $this->ctrl;
2467  $lng = $this->lng;
2468  $tpl = $this->tpl;
2469 
2470  if (!$this->checkPermissionBool("write")) {
2471  return;
2472  }
2473 
2474  $ilTabs->activateTab("contributors");
2475 
2476  $local_roles = $this->object->getAllLocalRoles($this->node_id);
2477 
2478  // add member
2480  $this,
2481  $ilToolbar,
2482  array(
2483  'auto_complete_name' => $lng->txt('user'),
2484  'submit_name' => $lng->txt('add'),
2485  'add_search' => true,
2486  'add_from_container' => $this->node_id,
2487  'user_type' => $local_roles
2488  ),
2489  true
2490  );
2491 
2492  $other_roles = $this->object->getRolesWithContributeOrRedact($this->node_id);
2493  if ($other_roles) {
2494  $this->tpl->setOnScreenMessage('info', sprintf($lng->txt("blog_contribute_other_roles"), implode(", ", $other_roles)));
2495  }
2496 
2497  $tbl = $this->gui->contributor()->ilContributorTableGUI(
2498  $this,
2499  "contributors",
2500  $this->object->getAllLocalRoles($this->node_id)
2501  );
2502 
2503  $tpl->setContent($tbl->getHTML());
2504  }
2505 
2509  public function addUserFromAutoComplete(): void
2510  {
2511  $lng = $this->lng;
2512 
2513  $user_login = $this->blog_request->getUserLogin();
2514  $user_type = $this->blog_request->getUserType();
2515 
2516  if (trim($user_login) === '') {
2517  $this->tpl->setOnScreenMessage('failure', $lng->txt('msg_no_search_string'));
2518  $this->contributors();
2519  return;
2520  }
2521  $users = explode(',', $user_login);
2522 
2523  $user_ids = array();
2524  foreach ($users as $user) {
2525  $user_id = ilObjUser::_lookupId($user);
2526 
2527  if (!$user_id) {
2528  $this->tpl->setOnScreenMessage('failure', $lng->txt('user_not_known'));
2529  $this->contributors();
2530  return;
2531  }
2532 
2533  $user_ids[] = (int) $user_id;
2534  }
2535 
2536  $this->addContributor($user_ids, $user_type);
2537  }
2538 
2542  public function addContributor(
2543  array $a_user_ids = array(),
2544  ?string $a_user_type = null
2545  ): void {
2546  $ilCtrl = $this->ctrl;
2547  $lng = $this->lng;
2548  $rbacreview = $this->rbac_review;
2549  $rbacadmin = $this->rbacadmin;
2550  $a_user_type = (int) $a_user_type;
2551 
2552  if (!$this->checkPermissionBool("write")) {
2553  return;
2554  }
2555 
2556  if (!count($a_user_ids) || !$a_user_type) {
2557  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"));
2558  $this->contributors();
2559  return;
2560  }
2561 
2562  // get contributor role
2563  $local_roles = array_keys($this->object->getAllLocalRoles($this->node_id));
2564  if (!in_array($a_user_type, $local_roles)) {
2565  $this->tpl->setOnScreenMessage('failure', $lng->txt("missing_perm"));
2566  $this->contributors();
2567  return;
2568  }
2569 
2570  foreach ($a_user_ids as $user_id) {
2571  $user_id = (int) $user_id;
2572  $a_user_type = (int) $a_user_type;
2573  if (!$rbacreview->isAssigned($user_id, $a_user_type)) {
2574  $rbacadmin->assignUser($a_user_type, $user_id);
2575  }
2576  }
2577 
2578  $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
2579  $ilCtrl->redirect($this, "contributors");
2580  }
2581 
2585  public function confirmRemoveContributor(): void
2586  {
2587  $ids = $this->blog_request->getIds();
2588 
2589  if (count($ids) === 0) {
2590  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("select_one"), true);
2591  $this->ctrl->redirect($this, "contributors");
2592  }
2593 
2594  $confirm = new ilConfirmationGUI();
2595  $confirm->setHeaderText($this->lng->txt('blog_confirm_delete_contributors'));
2596  $confirm->setFormAction($this->ctrl->getFormAction($this, 'removeContributor'));
2597  $confirm->setConfirm($this->lng->txt('delete'), 'removeContributor');
2598  $confirm->setCancel($this->lng->txt('cancel'), 'contributors');
2599 
2600  foreach ($ids as $user_id) {
2601  $confirm->addItem(
2602  'id[]',
2603  (string) $user_id,
2604  $this->profile_gui->getNamePresentation($user_id, false, "", true)
2605  );
2606  }
2607 
2608  $this->tpl->setContent($confirm->getHTML());
2609  }
2610 
2611  public function removeContributor(): void
2612  {
2613  $ilCtrl = $this->ctrl;
2614  $lng = $this->lng;
2615  $rbacadmin = $this->rbacadmin;
2616 
2617  $ids = $this->blog_request->getIds();
2618 
2619  if (count($ids) === 0) {
2620  $this->tpl->setOnScreenMessage('failure', $lng->txt("select_one"), true);
2621  $ilCtrl->redirect($this, "contributors");
2622  }
2623 
2624  // get contributor role
2625  $local_roles = array_keys($this->object->getAllLocalRoles($this->node_id));
2626  if (!$local_roles) {
2627  $this->tpl->setOnScreenMessage('failure', $lng->txt("missing_perm"));
2628  $this->contributors();
2629  return;
2630  }
2631 
2632  foreach ($ids as $user_id) {
2633  foreach ($local_roles as $role_id) {
2634  $rbacadmin->deassignUser($role_id, $user_id);
2635  }
2636  }
2637 
2638  $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
2639  $this->ctrl->redirect($this, "contributors");
2640  }
2641 
2642  public function deactivateAdmin(): void
2643  {
2644  if ($this->checkPermissionBool("write") && $this->apid > 0) {
2645  // ilBlogPostingGUI::deactivatePage()
2646  $post = new ilBlogPosting($this->apid);
2647  $post->setApproved(false);
2648  $post->setActive(false);
2649  $post->update(true, false, false);
2650 
2651  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
2652  }
2653 
2654  $this->ctrl->redirect($this, "render");
2655  }
2656 
2657 
2661 
2662  public function setContentStyleSheet(
2663  ilGlobalTemplateInterface $a_tpl = null
2664  ): void {
2665  $tpl = $this->tpl;
2666 
2667  if ($a_tpl) {
2668  $ctpl = $a_tpl;
2669  } else {
2670  $ctpl = $tpl;
2671  }
2672 
2673  $this->content_style_gui->addCss(
2674  $ctpl,
2675  $this->object->getRefId(),
2676  $this->object->getId()
2677  );
2678  }
2679 
2683  public static function _goto(string $a_target): void
2684  {
2685  global $DIC;
2686 
2687  $ilCtrl = $DIC->ctrl();
2688  $access = $DIC->access();
2689 
2690  $id = explode("_", $a_target);
2691  if (substr($a_target, -3) === "wsp") {
2692  $ilCtrl->setParameterByClass("ilSharedResourceGUI", "wsp_id", $id[0]);
2693 
2694  if (count($id) >= 2) {
2695  if (is_numeric($id[1])) {
2696  $ilCtrl->setParameterByClass("ilSharedResourceGUI", "gtp", $id[1]);
2697  } else {
2698  $ilCtrl->setParameterByClass("ilSharedResourceGUI", "kwd", $id[1]);
2699  }
2700  if (($id[2] ?? "") === "edit") {
2701  $ilCtrl->setParameterByClass("ilSharedResourceGUI", "edt", $id[2]);
2702  }
2703  }
2704  $ilCtrl->redirectByClass("ilSharedResourceGUI", "");
2705  } else {
2706  $ilCtrl->setParameterByClass("ilRepositoryGUI", "ref_id", $id[0]);
2707 
2708  if (count($id) >= 2) {
2709  if (is_numeric($id[1])) {
2710  $ilCtrl->setParameterByClass("ilRepositoryGUI", "gtp", $id[1]);
2711  } else {
2712  $ilCtrl->setParameterByClass("ilRepositoryGUI", "kwd", $id[1]);
2713  }
2714 
2715  if (($id[2] ?? "") === "edit") {
2716  $ilCtrl->setParameterByClass("ilRepositoryGUI", "edt", $id[2]);
2717  }
2718  }
2719  if ($access->checkAccess("read", "", (int) $id[0])) {
2720  $ilCtrl->redirectByClass("ilRepositoryGUI", "preview");
2721  }
2722  if ($access->checkAccess("visible", "", (int) $id[0])) {
2723  $ilCtrl->redirectByClass("ilRepositoryGUI", "infoScreen");
2724  }
2725  }
2726  }
2727 
2731  protected function exportWithComments(): void
2732  {
2733  $this->export(true);
2734  }
2735 
2739 
2740  public function getPrintView(): \ILIAS\Export\PrintProcessGUI
2741  {
2742  $style_sheet_id = $this->content_style_domain->getEffectiveStyleId();
2743 
2745  $blog = $this->object;
2746  $provider = new \ILIAS\Blog\BlogPrintViewProviderGUI(
2747  $this->lng,
2748  $this->ctrl,
2749  $blog,
2750  $this->node_id,
2751  $this->access_handler,
2752  $style_sheet_id,
2753  $this->blog_request->getObjIds()
2754  );
2755 
2756  return new \ILIAS\Export\PrintProcessGUI(
2757  $provider,
2758  $this->http,
2759  $this->ui,
2760  $this->lng
2761  );
2762  }
2763 
2764  public function printViewSelection(): void
2765  {
2766  $view = $this->getPrintView();
2767  $view->sendForm();
2768  }
2769 
2770  public function printPostings(): void
2771  {
2772  $print_view = $this->getPrintView();
2773  $print_view->sendPrintView();
2774  }
2775 
2776  protected function forwardExport(): void
2777  {
2778  $this->ctrl->redirectByClass(ilExportGUI::class);
2779  }
2780 }
ilNavigationHistory $nav_history
setLocator()
set Locator
checkPermission(string $perm, string $cmd="", string $type="", int $ref_id=null)
ILIAS Blog InternalDomainService $domain
filterInactivePostings()
Filter inactive items from items list.
export(bool $a_with_comments=false)
Build and deliver export file.
ilRbacReview $rbac_review
const ABSTRACT_DEFAULT_IMAGE_WIDTH
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
addUserFromAutoComplete()
Autocomplete submit.
setLocator()
Insert locator.
renderNavigationByKeywords(string $a_list_cmd="render", bool $a_show_inactive=false, string $a_link_template="", int $a_blpg=0)
Build navigation by keywords block.
Class ilInfoScreenGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ANONYMOUS_USER_ID
Definition: constants.php:27
preview()
Render fullscreen presentation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
ILIAS Blog ReadingTime ReadingTimeManager $reading_time_manager
static getAllPostings(int $a_blog_id, int $a_limit=1000, int $a_offset=0)
Get all postings of blog.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
getItemByPostVar(string $a_post_var)
static _numericMonthToString(int $a_month, bool $a_long=true)
numeric month to string
addHeaderActionForCommand(string $a_cmd)
buildPostingList(int $a_obj_id)
Gather all blog postings.
insertHeaderAction(?ilObjectListGUI $list_gui=null)
Insert header action into main template.
renderNavigationByDate(array $a_items, string $a_list_cmd="render", string $a_posting_cmd="preview", ?string $a_link_template=null, bool $a_show_inactive=false, int $a_blpg=0)
Build navigation by date block.
Class ilBlogPosting GUI class.
static exists(int $a_blog_id, int $a_posting_id)
Checks whether a posting exists.
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Help GUI class.
setContentStyleSheet(ilGlobalTemplateInterface $a_tpl=null)
ILIAS DI UIServices $ui
renderNavigationByAuthors(array $a_items, string $a_list_cmd="render", bool $a_show_inactive=false)
assignUser(int $a_rol_id, int $a_usr_id)
Assigns an user to a role.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
StandardGUIRequest $blog_request
exportWithComments()
Handle export choice.
resetHeaderBlock(bool $a_reset_header_action=true)
Reset all header properties: title, icon, description, alerts, action menu.
static _lookupName(int $a_user_id)
lookup user name
static _lookupId($a_user_str)
const NAV_MODE_LIST
prepareOutput(bool $show_sub_objects=true)
static _lookupOwner(int $obj_id)
Lookup owner user ID for object ID.
static _goto(string $a_target)
Deep link.
updateCustom(ilPropertyFormGUI $form)
ILIAS Blog InternalGUIService $gui
static getRelevanceClass(int $cnt, int $max)
const ABSTRACT_DEFAULT_SHORTEN_LENGTH
renderFullScreen(string $a_content, string $a_navigation)
Build fullscreen context.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
initEditCustomForm(ilPropertyFormGUI $a_form)
ILIAS Blog Access BlogAccess $blog_access
catch(\Exception $e) $req
Definition: xapiproxy.php:93
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
ILIAS Style Content GUIService $content_style_gui
getEditFormCustomValues(array &$a_values)
global $DIC
Definition: feed.php:28
ilToolbarGUI $toolbar
$provider
Definition: ltitoken.php:83
Export User Interface Class.
getListItems(bool $a_show_inactive=false)
Filter blog postings by month, keyword or author.
initHeaderAction(?string $sub_type=null, ?int $sub_id=null, bool $is_preview=false)
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
ILIAS Repository Profile ProfileAdapter $profile
static http()
Fetches the global http state from ILIAS.
This class represents a property in a property form.
__construct(VocabulariesInterface $vocabularies)
UIFactory $ui_factory
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
disableNotes(bool $a_value=false)
setContent(string $a_html)
Sets content for standard template.
static setNotification(int $type, int $user_id, int $id, bool $status=true)
Set notification status for object and user.
const ABSTRACT_DEFAULT_IMAGE_HEIGHT
Class ilObjBlogGUI.
confirmRemoveContributor()
Used in ilContributorTableGUI.
static _createExportDirectory(int $a_obj_id, string $a_export_type="xml", string $a_obj_type="")
const CLIENT_ID
Definition: constants.php:41
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
static isCommentsExportPossible(int $blog_id)
ILIAS Style Content Object ObjectFacade $content_style_domain
ilGlobalTemplateInterface $tpl
afterSave(ilObject $new_object)
$url
Definition: ltiregstart.php:35
render()
Render object context.
ContextServices $tool_context
static fillAutoCompleteToolbar(object $parent_object, ilToolbarGUI $toolbar=null, array $a_options=[], bool $a_sticky=false)
array( auto_complete_name = $lng->txt(&#39;user&#39;), auto_complete_size = 15, user_type = array(ilCoursePar...
initCreationForms(string $new_type)
loadStandardTemplate()
This loads the standard template "tpl.adm_content.html" and "tpl.statusline.html" the CONTENT and STA...
getParentId(int $a_node_id)
get parent id of given node
buildExportFile(bool $a_include_comments=false, bool $print_version=false)
Build export file.
setSettingsSubTabs(string $a_active)
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
getKeywords(bool $a_show_inactive, ?int $a_posting_id=null)
Get keywords for single posting or complete blog.
setRequired(bool $a_required)
renderFullscreenHeader(ilGlobalTemplateInterface $a_tpl, int $a_user_id, bool $a_export=false)
Render banner, user name.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
Last visited history for repository items.
static get(string $a_type, string $a_href="")
Get icon html.
createPosting()
Create new posting.
static _getPersonalPicturePath(int $a_usr_id, string $a_size="small", bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
static lookupBlogId(int $a_posting_id)
ILIAS Blog ReadingTime BlogSettingsGUI $reading_time_gui
This class represents an image file property in a property form.
activateTab(string $a_id)
const IL_CAL_DATE
renderNavigation(string $a_list_cmd="render", string $a_posting_cmd="preview", string $a_link_template=null, bool $a_show_inactive=false, int $a_blpg=0)
Build navigation blocks.
infoScreen()
this one is called from the info button in the repository
isAdmin()
Check if user has admin access (approve, may edit & deactivate all postings)
ILIAS HTTP Services $http
global $ilSetting
Definition: privfeed.php:18
addContributor(array $a_user_ids=array(), ?string $a_user_type=null)
Centralized method to add contributors.
ILIAS Repository Profile ProfileGUI $profile_gui
setDescription(string $a_descr)
Sets description below title in standard template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getSnippet(int $a_id, bool $a_truncate=false, int $a_truncate_length=500, string $a_truncate_sign="...", bool $a_include_picture=false, int $a_picture_width=144, int $a_picture_height=144, string $a_export_directory=null)
Get first text paragraph of page.
addItem(string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
static hasNotification(int $type, int $user_id, int $id)
Check notification status for object and user.
static lookupSubObjectTitle(int $a_blog_id, int $a_posting_id)
Get title for blog posting (used in ilNotesGUI)
static signFile(string $path_to_file)
ilLocatorGUI $locator
static getKeywords(int $a_obj_id, int $a_posting_id)
filterItemsByKeyword(array $a_items, string $a_keyword)
setRightContent(string $a_html)
Sets content of right column.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
renderToolbarNavigation(array $a_items, bool $single_posting=false)
Toolbar navigation.
Class ilRbacAdmin Core functions for role based access control.
buildEmbedded(string $a_content, string $a_nav)
Combine content (list/posting) and navigation to html chunk.
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
const NAV_MODE_MONTH
renderList(array $items, string $a_cmd="preview", string $a_link_template="", bool $a_show_inactive=false, string $a_export_directory="")
Build posting month list.
static _lookupType(int $id, bool $reference=false)
ilRbacAdmin $rbacadmin
$post
Definition: ltitoken.php:49
addHeaderAction()
Add header action menu.
$service
Definition: ltiservices.php:43
UIRenderer $ui_renderer
ilSetting $settings
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
buildExportLink(string $a_template, string $a_type, string $a_id)
Build export link.
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
deassignUser(int $a_rol_id, int $a_usr_id)
Deassigns a user from a role.
ILIAS Notes Service $notes
getHTML()
Return embeddable HTML chunk.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
ilAccessHandler $access
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static hasOptOut(int $obj_id)
Is opt out (disable notification) allowed?