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