ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjBlogGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./Services/Object/classes/class.ilObject2GUI.php";
6 require_once "./Modules/Blog/classes/class.ilBlogPosting.php";
7 require_once "./Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php";
8 
23 {
24  protected $month; // [string]
25  protected $items; // [array]
26  protected $keyword; // [string]
27  protected $author; // [int]
28  protected $month_default; // [bool
29 
30  function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
31  {
32  global $lng, $ilCtrl;
33 
34  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
35 
36  if($this->object)
37  {
38  $this->month = (string)$_REQUEST["bmn"];
39  $this->keyword = (string)$_REQUEST["kwd"];
40  $this->author = (int)$_REQUEST["ath"];
41 
42  // gather postings by month
43  $this->items = $this->buildPostingList($this->object->getId());
44  if($this->items)
45  {
46  // current month (if none given or empty)
47  if(!$this->month || !$this->items[$this->month])
48  {
49  $this->month = array_keys($this->items);
50  $this->month = array_shift($this->month);
51  $this->month_default = true;
52  }
53  }
54 
55  $ilCtrl->setParameter($this, "bmn", $this->month);
56  }
57 
58  $lng->loadLanguageModule("blog");
59  $ilCtrl->saveParameter($this, "prvm");
60  }
61 
62  function getType()
63  {
64  return "blog";
65  }
66 
67  protected function initCreationForms($a_new_type)
68  {
69  $forms = parent::initCreationForms($a_new_type);
70 
71  if($this->id_type == self::WORKSPACE_NODE_ID)
72  {
73  unset($forms[self::CFORM_IMPORT]);
74  unset($forms[self::CFORM_CLONE]);
75  }
76 
77  return $forms;
78  }
79 
80  protected function afterSave(ilObject $a_new_object)
81  {
82  global $ilCtrl;
83 
84  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
85  $ilCtrl->redirect($this, "");
86  }
87 
88  protected function setSettingsSubTabs($a_active)
89  {
90  // general properties
91  $this->tabs_gui->addSubTab("properties",
92  $this->lng->txt("blog_properties"),
93  $this->ctrl->getLinkTarget($this, 'edit'));
94 
95  $this->tabs_gui->addSubTab("style",
96  $this->lng->txt("obj_sty"),
97  $this->ctrl->getLinkTarget($this, 'editStyleProperties'));
98 
99  $this->tabs_gui->activateSubTab($a_active);
100  }
101 
102  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
103  {
104  global $lng, $ilSetting;
105 
106  $this->setSettingsSubTabs("properties");
107 
108  if($this->id_type == self::REPOSITORY_NODE_ID)
109  {
110  $appr = new ilCheckboxInputGUI($lng->txt("blog_enable_approval"), "approval");
111  $appr->setInfo($lng->txt("blog_enable_approval_info"));
112  $a_form->addItem($appr);
113  }
114 
115  $notes = new ilCheckboxInputGUI($lng->txt("blog_enable_notes"), "notes");
116  $a_form->addItem($notes);
117 
118  if($ilSetting->get('enable_global_profiles'))
119  {
120  $rss = new ilCheckboxInputGUI($lng->txt("blog_enable_rss"), "rss");
121  $rss->setInfo($lng->txt("blog_enable_rss_info"));
122  $a_form->addItem($rss);
123  }
124 
125 
126  // navigation
127 
128  $nav = new ilFormSectionHeaderGUI();
129  $nav->setTitle($lng->txt("blog_settings_navigation"));
130  $a_form->addItem($nav);
131 
132  $nav_mode = new ilRadioGroupInputGUI($lng->txt("blog_nav_mode"), "nav");
133  $nav_mode->setRequired(true);
134  $a_form->addItem($nav_mode);
135 
136  $opt = new ilRadioOption($lng->txt("blog_nav_mode_month_list"), ilObjBlog::NAV_MODE_LIST);
137  $opt->setInfo($lng->txt("blog_nav_mode_month_list_info"));
138  $nav_mode->addOption($opt);
139 
140  $detail_num = new ilNumberInputGUI($lng->txt("blog_nav_mode_month_list_num_detail"), "nav_list_detail");
141  $detail_num->setInfo($lng->txt("blog_nav_mode_month_list_num_detail_info"));
142  $detail_num->setRequired(true);
143  $detail_num->setSize(3);
144  $detail_num->setMinValue(0);
145  $opt->addSubItem($detail_num);
146 
147  $mon_num = new ilNumberInputGUI($lng->txt("blog_nav_mode_month_list_num_month"), "nav_list_mon");
148  $mon_num->setInfo($lng->txt("blog_nav_mode_month_list_num_month_info"));
149  $mon_num->setSize(3);
150  $mon_num->setMinValue(1);
151  $opt->addSubItem($mon_num);
152 
153  $opt = new ilRadioOption($lng->txt("blog_nav_mode_month_single"), ilObjBlog::NAV_MODE_MONTH);
154  $opt->setInfo($lng->txt("blog_nav_mode_month_single_info"));
155  $nav_mode->addOption($opt);
156 
157  $order_options = array();
158  if($this->object->getOrder())
159  {
160  foreach($this->object->getOrder() as $item)
161  {
162  $order_options[] = $lng->txt("blog_".$item);
163  }
164  }
165 
166  if(!in_array($lng->txt("blog_navigation"), $order_options))
167  {
168  $order_options[] = $lng->txt("blog_navigation");
169  }
170 
171  if($this->id_type == self::REPOSITORY_NODE_ID)
172  {
173  if(!in_array($lng->txt("blog_authors"), $order_options))
174  {
175  $order_options[] = $lng->txt("blog_authors");
176  }
177 
178  $auth = new ilCheckboxInputGUI($lng->txt("blog_enable_nav_authors"), "nav_authors");
179  $auth->setInfo($lng->txt("blog_enable_nav_authors_info"));
180  $a_form->addItem($auth);
181  }
182 
183  $keyw = new ilCheckboxInputGUI($lng->txt("blog_enable_keywords"), "keywords");
184  $keyw->setInfo($lng->txt("blog_enable_keywords_info"));
185  $a_form->addItem($keyw);
186 
187  if(!in_array($lng->txt("blog_keywords"), $order_options))
188  {
189  $order_options[] = $lng->txt("blog_keywords");
190  }
191 
192  $order = new ilNonEditableValueGUI($lng->txt("blog_nav_sortorder"), "order");
193  $order->setMultiValues($order_options);
194  $order->setValue(array_shift($order_options));
195  $order->setMulti(true, true, false);
196  $a_form->addItem($order);
197 
198 
199  // presentation (frame)
200 
201  $pres = new ilFormSectionHeaderGUI();
202  $pres->setTitle($lng->txt("blog_presentation_frame"));
203  $a_form->addItem($pres);
204 
205  $ppic = new ilCheckboxInputGUI($lng->txt("blog_profile_picture"), "ppic");
206  $a_form->addItem($ppic);
207 
208  if($this->id_type == self::REPOSITORY_NODE_ID)
209  {
210  $ppic->setInfo($lng->txt("blog_profile_picture_repository_info"));
211  }
212 
213  $blga_set = new ilSetting("blga");
214  if($blga_set->get("banner"))
215  {
216  include_once "Services/Form/classes/class.ilFileInputGUI.php";
218 
219  $dimensions = " (".$blga_set->get("banner_width")."x".
220  $blga_set->get("banner_height").")";
221 
222  $img = new ilImageFileInputGUI($lng->txt("blog_banner").$dimensions, "banner");
223  $a_form->addItem($img);
224 
225  // show existing file
226  $file = $this->object->getImageFullPath(true);
227  if($file)
228  {
229  $img->setImage($file);
230  }
231  }
232 
233  /* #15000
234  $bg_color = new ilColorPickerInputGUI($lng->txt("blog_background_color"), "bg_color");
235  $a_form->addItem($bg_color);
236 
237  $font_color = new ilColorPickerInputGUI($lng->txt("blog_font_color"), "font_color");
238  $a_form->addItem($font_color);
239  */
240 
241  // presentation (overview)
242 
243  $list = new ilFormSectionHeaderGUI();
244  $list->setTitle($lng->txt("blog_presentation_overview"));
245  $a_form->addItem($list);
246 
247  $post_num = new ilNumberInputGUI($lng->txt("blog_list_num_postings"), "ov_list_post_num");
248  $post_num->setInfo($lng->txt("blog_list_num_postings_info"));
249  $post_num->setSize(3);
250  $post_num->setMinValue(1);
251  $post_num->setRequired(true);
252  $a_form->addItem($post_num);
253 
254  $abs_shorten = new ilCheckboxInputGUI($lng->txt("blog_abstract_shorten"), "abss");
255  $a_form->addItem($abs_shorten);
256 
257  $abs_shorten_len = new ilNumberInputGUI($lng->txt("blog_abstract_shorten_length"), "abssl");
258  $abs_shorten_len->setSize(5);
259  $abs_shorten_len->setRequired(true);
260  $abs_shorten_len->setSuffix($lng->txt("blog_abstract_shorten_characters"));
261  $abs_shorten_len->setMinValue(50, true);
262  $abs_shorten->addSubItem($abs_shorten_len);
263 
264  $abs_img = new ilCheckboxInputGUI($lng->txt("blog_abstract_image"), "absi");
265  $abs_img->setInfo($lng->txt("blog_abstract_image_info"));
266  $a_form->addItem($abs_img);
267 
268  $abs_img_width = new ilNumberInputGUI($lng->txt("blog_abstract_image_width"), "absiw");
269  $abs_img_width->setSize(5);
270  $abs_img_width->setRequired(true);
271  $abs_img_width->setSuffix($lng->txt("blog_abstract_image_pixels"));
272  $abs_img_width->setMinValue(32, true);
273  $abs_img->addSubItem($abs_img_width);
274 
275  $abs_img_height = new ilNumberInputGUI($lng->txt("blog_abstract_image_height"), "absih");
276  $abs_img_height->setSize(5);
277  $abs_img_height->setRequired(true);
278  $abs_img_height->setSuffix($lng->txt("blog_abstract_image_pixels"));
279  $abs_img_height->setMinValue(32, true);
280  $abs_img->addSubItem($abs_img_height);
281  }
282 
283  protected function getEditFormCustomValues(array &$a_values)
284  {
285  if($this->id_type == self::REPOSITORY_NODE_ID)
286  {
287  $a_values["approval"] = $this->object->hasApproval();
288  $a_values["nav_authors"] = $this->object->hasAuthors();
289  }
290  $a_values["keywords"] = $this->object->hasKeywords();
291  $a_values["notes"] = $this->object->getNotesStatus();
292  $a_values["ppic"] = $this->object->hasProfilePicture();
293  /*
294  $a_values["bg_color"] = $this->object->getBackgroundColor();
295  $a_values["font_color"] = $this->object->getFontColor();
296  */
297  $a_values["banner"] = $this->object->getImage();
298  $a_values["rss"] = $this->object->hasRSS();
299  $a_values["abss"] = $this->object->hasAbstractShorten();
300  $a_values["absi"] = $this->object->hasAbstractImage();
301  $a_values["nav"] = $this->object->getNavMode();
302  $a_values["nav_list_detail"] = $this->object->getNavModeListPostings();
303  $a_values["nav_list_mon"] = $this->object->getNavModeListMonths();
304  $a_values["ov_list_post_num"] = $this->object->getOverviewPostings();
305 
306  // #13420
307  $a_values["abssl"] = $this->object->getAbstractShortenLength() ? $this->object->getAbstractShortenLength() : ilObjBlog::ABSTRACT_DEFAULT_SHORTEN_LENGTH;
308  $a_values["absiw"] = $this->object->getAbstractImageWidth() ? $this->object->getAbstractImageWidth() : ilObjBlog::ABSTRACT_DEFAULT_IMAGE_WIDTH;
309  $a_values["absih"] = $this->object->getAbstractImageHeight() ? $this->object->getAbstractImageHeight() : ilObjBlog::ABSTRACT_DEFAULT_IMAGE_HEIGHT;
310  }
311 
312  protected function updateCustom(ilPropertyFormGUI $a_form)
313  {
314  global $lng;
315 
316  if($this->id_type == self::REPOSITORY_NODE_ID)
317  {
318  $this->object->setApproval($a_form->getInput("approval"));
319  $this->object->setAuthors($a_form->getInput("nav_authors"));
320  }
321  $this->object->setKeywords($a_form->getInput("keywords"));
322  $this->object->setNotesStatus($a_form->getInput("notes"));
323  $this->object->setProfilePicture($a_form->getInput("ppic"));
324  /*
325  $this->object->setBackgroundColor($a_form->getInput("bg_color"));
326  $this->object->setFontColor($a_form->getInput("font_color"));
327  */
328  $this->object->setRSS($a_form->getInput("rss"));
329  $this->object->setAbstractShorten($a_form->getInput("abss"));
330  $this->object->setAbstractShortenLength($a_form->getInput("abssl"));
331  $this->object->setAbstractImage($a_form->getInput("absi"));
332  $this->object->setAbstractImageWidth($a_form->getInput("absiw"));
333  $this->object->setAbstractImageHeight($a_form->getInput("absih"));
334  $this->object->setNavMode($a_form->getInput("nav"));
335  $this->object->setNavModeListPostings($a_form->getInput("nav_list_detail"));
336  $this->object->setNavModeListMonths($a_form->getInput("nav_list_mon"));
337  $this->object->setOverviewPostings($a_form->getInput("ov_list_post_num"));
338 
339  $order = $a_form->getInput("order");
340  foreach($order as $idx => $value)
341  {
342  if($value == $lng->txt("blog_navigation"))
343  {
344  $order[$idx] = "navigation";
345  }
346  else if($value == $lng->txt("blog_keywords"))
347  {
348  $order[$idx] = "keywords";
349  }
350  else
351  {
352  $order[$idx]= "authors";
353  }
354  }
355  $this->object->setOrder($order);
356 
357  // banner field is optional
358  $banner = $a_form->getItemByPostVar("banner");
359  if($banner)
360  {
361  if($_FILES["banner"]["tmp_name"])
362  {
363  $this->object->uploadImage($_FILES["banner"]);
364  }
365  else if($banner->getDeletionFlag())
366  {
367  $this->object->deleteImage();
368  }
369  }
370  }
371 
372  function setTabs()
373  {
374  global $lng, $ilHelp;
375 
376  if($this->id_type == self::WORKSPACE_NODE_ID)
377  {
378  $this->ctrl->setParameter($this,"wsp_id",$this->node_id);
379  }
380 
381  $ilHelp->setScreenIdComponent("blog");
382 
383  if ($this->checkPermissionBool("read"))
384  {
385  $this->tabs_gui->addTab("content",
386  $lng->txt("content"),
387  $this->ctrl->getLinkTarget($this, ""));
388  }
389 
390  if ($this->checkPermissionBool("read"))
391  {
392  $this->tabs_gui->addTab("id_info",
393  $lng->txt("info_short"),
394  $this->ctrl->getLinkTargetByClass(array("ilobjbloggui", "ilinfoscreengui"), "showSummary"));
395  }
396 
397  if ($this->checkPermissionBool("write"))
398  {
399  $this->tabs_gui->addTab("settings",
400  $lng->txt("settings"),
401  $this->ctrl->getLinkTarget($this, "edit"));
402 
403  if($this->id_type == self::REPOSITORY_NODE_ID)
404  {
405  $this->tabs_gui->addTab("contributors",
406  $lng->txt("blog_contributors"),
407  $this->ctrl->getLinkTarget($this, "contributors"));
408  }
409 
410  if($this->id_type == self::REPOSITORY_NODE_ID)
411  {
412  $this->tabs_gui->addTab("export",
413  $lng->txt("export"),
414  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
415  }
416  }
417 
418  if($this->mayContribute())
419  {
420  $this->tabs_gui->addNonTabbedLink("preview", $lng->txt("blog_preview"),
421  $this->ctrl->getLinkTarget($this, "preview"));
422  }
423 
424  // will add permissions if needed
425  parent::setTabs();
426  }
427 
428  function executeCommand()
429  {
430  global $ilCtrl, $tpl, $ilTabs, $lng, $ilNavigationHistory;
431 
432  // goto link to blog posting
433  if($_GET["gtp"])
434  {
435  $page_id = (int)$_GET["gtp"];
436  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
437  if(ilBlogPosting::exists($this->object_id, $page_id))
438  {
439  // #12312
440  $ilCtrl->setCmdClass("ilblogpostinggui");
441  $_GET["blpg"] = $page_id;
442  $ilCtrl->setCmd("previewFullscreen");
443  }
444  else
445  {
446  ilUtil::sendFailure($lng->txt("blog_posting_not_found"));
447  }
448  }
449 
450  $next_class = $ilCtrl->getNextClass($this);
451  $cmd = $ilCtrl->getCmd();
452 
453  if($this->id_type == self::REPOSITORY_NODE_ID)
454  {
455  $tpl->getStandardTemplate();
456 
457  // add entry to navigation history
458  if(!$this->getCreationMode() &&
459  $this->getAccessHandler()->checkAccess("read", "", $this->node_id))
460  {
461  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset");
462  $ilNavigationHistory->addItem($this->node_id, $link, "blog");
463  }
464  }
465 
466  switch($next_class)
467  {
468  case 'ilblogpostinggui':
469  // #9680
470  if($this->id_type == self::REPOSITORY_NODE_ID)
471  {
472  $this->setLocator();
473  }
474  else
475  {
476  include_once "Services/Form/classes/class.ilFileInputGUI.php";
478  }
479  $ilTabs->setBackTarget($lng->txt("back"),
480  $ilCtrl->getLinkTarget($this, ""));
481 
483  $this->object->getStyleSheetId(), "blog");
484 
485  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
486  $bpost_gui = new ilBlogPostingGUI($this->node_id,
487  $this->getAccessHandler(),
488  $_GET["blpg"],
489  $_GET["old_nr"],
490  ($this->object->getNotesStatus() && !$this->disable_notes),
491  $this->mayContribute($_GET["blpg"]),
492  $style_sheet_id);
493 
494  // keep preview mode through notes gui (has its own commands)
495  switch($cmd)
496  {
497  // blog preview
498  case "previewFullscreen":
499  $ilCtrl->setParameter($this, "prvm", "fsc");
500  break;
501 
502  // blog in portfolio
503  case "previewEmbedded":
504  $ilCtrl->setParameter($this, "prvm", "emb");
505  break;
506 
507  // edit
508  default:
509  $this->setContentStyleSheet();
510 
511  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
512  $this->tabs_gui->addNonTabbedLink("preview", $lng->txt("blog_preview"),
513  $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "previewFullscreen"));
514  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", "");
515  break;
516  }
517 
518  $ret = $ilCtrl->forwardCommand($bpost_gui);
519  if ($ret != "")
520  {
521  // keep preview mode through notes gui
522  if($_REQUEST["prvm"])
523  {
524  $cmd = "preview".(($_REQUEST["prvm"] == "fsc") ? "Fullscreen" : "Embedded");
525  }
526 
527  // $is_owner = $this->object->getOwner() == $ilUser->getId();
528  $is_owner = $this->mayContribute();
529  $is_active = $bpost_gui->getBlogPosting()->getActive();
530 
531  // do not show inactive postings
532  if(($cmd == "previewFullscreen" || $cmd == "previewEmbedded")
533  && !$is_owner && !$is_active)
534  {
535  $this->ctrl->redirect($this, "preview");
536  }
537 
538  switch($cmd)
539  {
540  // blog preview
541  case "previewFullscreen":
542  $this->addHeaderAction($cmd);
543  $this->filterInactivePostings();
544  $nav = $this->renderNavigation($this->items, "preview", $cmd);
545  $this->renderFullScreen($ret, $nav);
546  break;
547 
548  // blog in portfolio
549  case "previewEmbedded":
550  $this->filterInactivePostings();
551  $nav = $this->renderNavigation($this->items, "gethtml", $cmd);
552  return $this->buildEmbedded($ret, $nav);
553 
554  // ilias/editor
555  default:
556  // infos about draft status / snippet
557  $info = array();
558  if(!$is_active)
559  {
560  // single author blog (owner) in personal workspace
561  if($this->id_type == self::WORKSPACE_NODE_ID)
562  {
563  $info[] = $lng->txt("blog_draft_info");
564  }
565  else
566  {
567  $info[] = $lng->txt("blog_draft_info_contributors");
568  }
569  }
570  if($cmd != "history" && !$bpost_gui->getBlogPosting()->getFirstParagraphText())
571  {
572  $info[] = $lng->txt("blog_new_posting_info");
573  }
574  if($this->object->hasApproval() && !$bpost_gui->getBlogPosting()->isApproved())
575  {
576  // #9737
577  $info[] = $lng->txt("blog_posting_edit_approval_info");
578  }
579  if(sizeof($info) && !$tpl->hasMessage("info")) // #15121
580  {
581  ilUtil::sendInfo(implode("<br />", $info));
582  }
583  // revert to edit cmd to avoid confusion
584  $this->addHeaderAction("render");
585  $tpl->setContent($ret);
586  $nav = $this->renderNavigation($this->items, "render", $cmd, null, $is_owner);
587  $tpl->setRightContent($nav);
588  break;
589  }
590  }
591  break;
592 
593  case "ilinfoscreengui":
594  $this->prepareOutput();
595  $this->addHeaderAction("render");
596  $this->infoScreenForward();
597  break;
598 
599  case "ilnotegui":
600  $this->preview();
601  break;
602 
603  case "ilcommonactiondispatchergui":
604  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
606  $this->ctrl->forwardCommand($gui);
607  break;
608 
609  case "ilpermissiongui":
610  $this->prepareOutput();
611  $ilTabs->activateTab("id_permissions");
612  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
613  $perm_gui = new ilPermissionGUI($this);
614  $this->ctrl->forwardCommand($perm_gui);
615  break;
616 
617  case "ilobjectcopygui":
618  include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
619  $cp = new ilObjectCopyGUI($this);
620  $cp->setType("blog");
621  $this->ctrl->forwardCommand($cp);
622  break;
623 
624  case 'ilrepositorysearchgui':
625  $this->prepareOutput();
626  $ilTabs->activateTab("contributors");
627  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
628  $rep_search = new ilRepositorySearchGUI();
629  $rep_search->setTitle($this->lng->txt("blog_add_contributor"));
630  $rep_search->setCallback($this,'addContributor');
631  $this->ctrl->setReturn($this,'contributors');
632  $ret =& $this->ctrl->forwardCommand($rep_search);
633  break;
634 
635  case 'ilexportgui':
636  $this->prepareOutput();
637  $ilTabs->activateTab("export");
638  include_once("./Services/Export/classes/class.ilExportGUI.php");
639  $exp_gui = new ilExportGUI($this);
640  $exp_gui->addFormat("xml");
641  $exp_gui->addFormat("html", null, $this, "buildExportFile"); // #13419
642  $ret = $ilCtrl->forwardCommand($exp_gui);
643  break;
644 
645  case "ilobjstylesheetgui":
646  include_once ("./Services/Style/classes/class.ilObjStyleSheetGUI.php");
647  $this->ctrl->setReturn($this, "editStyleProperties");
648  $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
649  $style_gui->omitLocator();
650  if ($cmd == "create" || $_GET["new_type"]=="sty")
651  {
652  $style_gui->setCreationMode(true);
653  }
654 
655  if ($cmd == "confirmedDelete")
656  {
657  $this->object->setStyleSheetId(0);
658  $this->object->update();
659  }
660 
661  $ret = $this->ctrl->forwardCommand($style_gui);
662 
663  if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle")
664  {
665  $style_id = $ret;
666  $this->object->setStyleSheetId($style_id);
667  $this->object->update();
668  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
669  }
670  break;
671 
672  default:
673  if($cmd != "gethtml")
674  {
675  // desktop item handling, must be toggled before header action
676  if($cmd == "addToDesk" || $cmd == "removeFromDesk")
677  {
678  $this->{$cmd."Object"}();
679  if($_GET["prvm"])
680  {
681  $cmd = "preview";
682  }
683  else
684  {
685  $cmd = "render";
686  }
687  $ilCtrl->setCmd($cmd);
688  }
689  $this->addHeaderAction($cmd);
690  }
691  return parent::executeCommand();
692  }
693 
694  return true;
695  }
696 
702  function infoScreen()
703  {
704  $this->ctrl->setCmd("showSummary");
705  $this->ctrl->setCmdClass("ilinfoscreengui");
706  $this->infoScreenForward();
707  }
708 
712  function infoScreenForward()
713  {
714  global $ilTabs, $ilErr;
715 
716  $ilTabs->activateTab("id_info");
717 
718  if (!$this->checkPermissionBool("visible"))
719  {
720  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
721  }
722 
723  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
724  $info = new ilInfoScreenGUI($this);
725 
726  if($this->id_type != self::WORKSPACE_NODE_ID)
727  {
728  $info->enablePrivateNotes();
729  }
730 
731  if ($this->checkPermissionBool("read"))
732  {
733  $info->enableNews();
734  }
735 
736  // no news editing for files, just notifications
737  $info->enableNewsEditing(false);
738  if ($this->checkPermissionBool("write"))
739  {
740  $news_set = new ilSetting("news");
741  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
742 
743  if ($enable_internal_rss)
744  {
745  $info->setBlockProperty("news", "settings", true);
746  $info->setBlockProperty("news", "public_notifications_option", true);
747  }
748  }
749 
750  // standard meta data
751  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
752 
753  if($this->id_type == self::WORKSPACE_NODE_ID)
754  {
755  $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
756  }
757 
758  $this->ctrl->forwardCommand($info);
759  }
760 
764  function createPosting()
765  {
766  global $ilCtrl, $ilUser;
767 
768  $title = trim(ilUtil::stripSlashes($_POST["title"]));
769  if($title)
770  {
771  // create new posting
772  include_once("./Modules/Blog/classes/class.ilBlogPosting.php");
773  $posting = new ilBlogPosting();
774  $posting->setTitle($title);
775  $posting->setBlogId($this->object->getId());
776  $posting->setActive(false);
777  $posting->setAuthor($ilUser->getId());
778  $posting->create();
779 
780  // switch month list to current month (will include new posting)
781  $ilCtrl->setParameter($this, "bmn", date("Y-m"));
782 
783  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $posting->getId());
784  $ilCtrl->redirectByClass("ilblogpostinggui", "edit");
785  }
786  else
787  {
788  $ilCtrl->redirect($this, "render");
789  }
790  }
791 
792  // --- ObjectGUI End
793 
794 
798  function render()
799  {
800  global $tpl, $ilTabs, $ilCtrl, $lng, $ilToolbar, $ilUser, $tree;
801 
802  if(!$this->checkPermissionBool("read"))
803  {
804  ilUtil::sendInfo($lng->txt("no_permission"));
805  return;
806  }
807 
808  $ilTabs->activateTab("content");
809 
810  // toolbar
811  if($this->mayContribute())
812  {
813  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "createPosting"));
814 
815  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
816  $title = new ilTextInputGUI($lng->txt("title"), "title");
817  $ilToolbar->addInputItem($title, $lng->txt("title"));
818 
819  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
820  $button = ilSubmitButton::getInstance();
821  $button->setCaption("blog_add_posting");
822  $button->setCommand("createPosting");
823  $ilToolbar->addButtonInstance($button);
824 
825  // exercise blog?
826  include_once "Modules/Exercise/classes/class.ilObjExercise.php";
827  $exercises = ilObjExercise::findUserFiles($ilUser->getId(), $this->node_id);
828  if($exercises)
829  {
830  $info = array();
831  foreach($exercises as $exercise)
832  {
833  // #9988
834  $active_ref = false;
835  foreach(ilObject::_getAllReferences($exercise["obj_id"]) as $ref_id)
836  {
837  if(!$tree->isSaved($ref_id))
838  {
839  $active_ref = true;
840  break;
841  }
842  }
843  if($active_ref)
844  {
845  $part = $this->getExerciseInfo($exercise["ass_id"]);
846  if($part)
847  {
848  $info[] = $part;
849  }
850  }
851  }
852  if(sizeof($info))
853  {
854  ilUtil::sendInfo(implode("<br />", $info));
855  }
856  }
857  }
858 
859  // $is_owner = ($this->object->getOwner() == $ilUser->getId());
860  $is_owner = $this->mayContribute();
861 
862  $list_items = $this->getListItems($is_owner);
863 
864  $list = $nav = "";
865  if($list_items)
866  {
867  $list = $this->renderList($list_items, "preview", null, $is_owner);
868  $nav = $this->renderNavigation($this->items, "render", "preview", null, $is_owner);
869  }
870 
871  $this->setContentStyleSheet();
872 
873  $tpl->setContent($list);
874  $tpl->setRightContent($nav);
875  }
876 
877  function getExerciseInfo($a_assignment_id)
878  {
879  global $lng, $ilCtrl, $ilUser;
880 
881  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
882  $ass = new ilExAssignment($a_assignment_id);
883  $exercise_id = $ass->getExerciseId();
884  if(!$exercise_id)
885  {
886  return;
887  }
888 
889  // is the assignment still open?
890  $times_up = false;
891  if($ass->getDeadline() && $ass->getDeadline() - time() <= 0)
892  {
893  $times_up = true;
894  }
895 
896  // exercise goto
897  include_once "./Services/Link/classes/class.ilLink.php";
898  $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id));
899  $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc");
900 
901  $info = sprintf($lng->txt("blog_exercise_info"),
902  $ass->getTitle(),
903  "<a href=\"".$exc_link."\">".
904  ilObject::_lookupTitle($exercise_id)."</a>");
905 
906  // submit button
907  if(!$times_up)
908  {
909  $ilCtrl->setParameter($this, "exc", $exercise_id);
910  $ilCtrl->setParameter($this, "ass", $a_assignment_id);
911  $submit_link = $ilCtrl->getLinkTarget($this, "finalize");
912  $ilCtrl->setParameter($this, "ass", "");
913  $ilCtrl->setParameter($this, "exc", "");
914 
915  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
916  $button = ilLinkButton::getInstance();
917  $button->setCaption("blog_finalize_blog");
918  $button->setPrimary(true);
919  $button->setUrl($submit_link);
920  $info .= " ".$button->render();
921  }
922 
923  // submitted files
924  $submitted = ilExAssignment::getDeliveredFiles($exercise_id, $a_assignment_id, $ilUser->getId(), true);
925  if($submitted)
926  {
927  $submitted = array_pop($submitted);
928 
929  $ilCtrl->setParameter($this, "ass", $a_assignment_id);
930  $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcSubFile");
931  $ilCtrl->setParameter($this, "ass", "");
932 
935 
936  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
937  $button = ilLinkButton::getInstance();
938  $button->setCaption("download");
939  $button->setUrl($dl_link);
940 
941  $info .= "<br />".sprintf($lng->txt("blog_exercise_submitted_info"),
943  $button->render());
944 
946  }
947 
948 
949  // work instructions incl. files
950 
951  $tooltip = "";
952 
953  $ass = $ass->getInstruction();
954  if($ass)
955  {
956  $tooltip .= nl2br($ass);
957  }
958 
959  $ass_files = ilExAssignment::getFiles($exercise_id, $a_assignment_id);
960  if (count($ass_files) > 0)
961  {
962  $tooltip .= "<br /><br />";
963 
964  foreach($ass_files as $file)
965  {
966  $ilCtrl->setParameter($this, "ass", $a_assignment_id);
967  $ilCtrl->setParameter($this, "file", urlencode($file["name"]));
968  $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcAssFile");
969  $ilCtrl->setParameter($this, "file", "");
970  $ilCtrl->setParameter($this, "ass", "");
971 
972  $tooltip .= $file["name"].": <a href=\"".$dl_link."\">".
973  $lng->txt("download")."</a>";
974  }
975  }
976 
977  if($tooltip)
978  {
979  $ol_id = "exc_ass_".$a_assignment_id;
980 
981  include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
982  $overlay = new ilOverlayGUI($ol_id);
983 
984  // overlay
985  $overlay->setAnchor($ol_id."_tr");
986  $overlay->setTrigger($ol_id."_tr", "click", $ol_id."_tr");
987  $overlay->add();
988 
989  $info .= "<div id=\"".$ol_id."_tr\"><a href=\"#\">".$lng->txt("exc_instruction")."</a></div>".
990  "<div id=\"".$ol_id."\" style=\"display:none; padding:10px;\" class=\"ilOverlay\">".$tooltip."</div>";
991  }
992 
993  return "<div>".$info."</div>";
994  }
995 
997  {
998  if($_GET["ass"] && $_GET["file"])
999  {
1000  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
1001  $ass = new ilExAssignment((int)$_GET["ass"]);
1002 
1003  $ass_files = ilExAssignment::getFiles($ass->getExerciseId(), $ass->getId());
1004  if (count($ass_files) > 0)
1005  {
1006  foreach($ass_files as $file)
1007  {
1008  if($file["name"] == $_GET["file"])
1009  {
1010  ilUtil::deliverFile($file["fullpath"], $file["name"]);
1011  }
1012  }
1013  }
1014  }
1015  }
1016 
1018  {
1019  global $ilUser;
1020 
1021  if($_GET["ass"])
1022  {
1023  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
1024  $ass = new ilExAssignment((int)$_GET["ass"]);
1025 
1026  $submitted = ilExAssignment::getDeliveredFiles($ass->getExerciseId(), $ass->getId(), $ilUser->getId());
1027  if (count($submitted) > 0)
1028  {
1029  $submitted = array_pop($submitted);
1030 
1031  $user_data = ilObjUser::_lookupName($submitted["user_id"]);
1032  $title = ilObject::_lookupTitle($submitted["obj_id"])." - ".
1033  $ass->getTitle()." - ".
1034  $user_data["firstname"]." ".
1035  $user_data["lastname"]." (".
1036  $user_data["login"].").zip";
1037 
1038  ilUtil::deliverFile($submitted["filename"], $title);
1039  }
1040  }
1041  }
1042 
1048  function getHTML()
1049  {
1050  // getHTML() is called by ilRepositoryGUI::show()
1051  if($this->id_type == self::REPOSITORY_NODE_ID)
1052  {
1053  return;
1054  }
1055 
1056  // there is no way to do a permissions check here, we have no wsp
1057 
1058  $this->filterInactivePostings();
1059 
1060  $list_items = $this->getListItems();
1061 
1062  $list = $nav = "";
1063  if($list_items)
1064  {
1065  $list = $this->renderList($list_items, "previewEmbedded");
1066  $nav = $this->renderNavigation($this->items, "gethtml", "previewEmbedded");
1067  }
1068 
1069  return $this->buildEmbedded($list, $nav);
1070  }
1071 
1078  protected function getListItems($a_show_inactive = false)
1079  {
1080  if($this->author)
1081  {
1082  $list_items = array();
1083  foreach($this->items as $month => $items)
1084  {
1085  foreach($items as $id => $item)
1086  {
1087  if($item["author"] == $this->author)
1088  {
1089  $list_items[$id] = $item;
1090  }
1091  }
1092  }
1093  }
1094  else if($this->keyword)
1095  {
1096  $list_items = $this->filterItemsByKeyword($this->items, $this->keyword);
1097  }
1098  else
1099  {
1100  $max = $this->object->getOverviewPostings();
1101  if($this->month_default && $max)
1102  {
1103  $list_items = array();
1104  foreach($this->items as $month => $postings)
1105  {
1106  foreach($postings as $id => $item)
1107  {
1108  if(!$a_show_inactive &&
1109  !ilBlogPosting::_lookupActive($id, "blp"))
1110  {
1111  continue;
1112  }
1113  $list_items[$id] = $item;
1114 
1115  if(sizeof($list_items) >= $max)
1116  {
1117  break(2);
1118  }
1119  }
1120  }
1121  }
1122  else
1123  {
1124  $list_items = $this->items[$this->month];
1125  }
1126  }
1127  return $list_items;
1128  }
1129 
1133  function preview()
1134  {
1135  global $lng;
1136 
1137  if(!$this->checkPermissionBool("read"))
1138  {
1139  ilUtil::sendInfo($lng->txt("no_permission"));
1140  return;
1141  }
1142 
1143  $this->filterInactivePostings();
1144 
1145  $list_items = $this->getListItems();
1146 
1147  $list = $nav = "";
1148  if($list_items)
1149  {
1150  $list = $this->renderList($list_items, "previewFullscreen");
1151  $nav = $this->renderNavigation($this->items, "preview", "previewFullscreen");
1152  }
1153 
1154  $this->renderFullScreen($list, $nav);
1155  }
1156 
1160  function export()
1161  {
1162  $zip = $this->buildExportFile();
1163 
1164  ilUtil::deliverFile($zip, $this->object->getTitle().".zip", '', false, true);
1165  }
1166 
1167 
1168  // --- helper functions
1169 
1177  protected function buildEmbedded($a_content, $a_nav)
1178  {
1179  $wtpl = new ilTemplate("tpl.blog_embedded.html", true, true, "Modules/Blog");
1180  $wtpl->setVariable("VAL_LIST", $a_content);
1181  $wtpl->setVariable("VAL_NAVIGATION", $a_nav);
1182  return $wtpl->get();
1183  }
1184 
1191  function renderFullScreen($a_content, $a_navigation)
1192  {
1193  global $tpl, $ilUser, $ilTabs, $ilLocator;
1194 
1195  $owner = $this->object->getOwner();
1196 
1197  $ilTabs->clearTargets();
1198  $ilLocator->clearItems();
1199  $tpl->setLocator();
1200 
1201  // back (edit)
1202  if($owner == $ilUser->getId())
1203  {
1204  // from shared/deeplink
1205  if($this->id_type == self::WORKSPACE_NODE_ID)
1206  {
1207  $back = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&wsp_id=".$this->node_id;
1208  }
1209  // from editor (#10073)
1210  else if($this->mayContribute())
1211  {
1212  $prvm = $_GET["prvm"];
1213  $this->ctrl->setParameter($this, "prvm", "");
1214  if(!$_GET["blpg"])
1215  {
1216  $back = $this->ctrl->getLinkTarget($this, "");
1217  }
1218  else
1219  {
1220  $this->ctrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
1221  $this->ctrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
1222  $back = $this->ctrl->getLinkTargetByClass("ilblogpostinggui", "preview");
1223  }
1224  $this->ctrl->setParameter($this, "prvm", $prvm);
1225  }
1226  }
1227  // back
1228  else if($ilUser->getId() && $ilUser->getId() != ANONYMOUS_USER_ID)
1229  {
1230  // workspace (always shared)
1231  if($this->id_type == self::WORKSPACE_NODE_ID)
1232  {
1233  $back = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&dsh=".$owner;
1234  }
1235  // contributor
1236  else if($this->mayContribute())
1237  {
1238  $back = $this->ctrl->getLinkTarget($this, "");
1239  }
1240  // listgui / parent container
1241  else
1242  {
1243  global $tree;
1244  $parent_id = $tree->getParentId($this->node_id);
1245  include_once "Services/Link/classes/class.ilLink.php";
1247  }
1248  }
1249 
1250  global $ilMainMenu;
1251  $ilMainMenu->setMode(ilMainMenuGUI::MODE_TOPBAR_ONLY);
1252  $ilMainMenu->setTopBarBack($back);
1253 
1254  $this->renderFullscreenHeader($tpl, $owner);
1255 
1256  // #13564
1257  $this->ctrl->setParameter($this, "bmn", "");
1258  $tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
1259  $this->ctrl->setParameter($this, "bmn", $this->month);
1260 
1261  $this->setContentStyleSheet();
1262 
1263  // content
1264  $tpl->setContent($a_content);
1265  $tpl->setRightContent($a_navigation);
1266  }
1267 
1275  protected function renderFullscreenHeader($a_tpl, $a_user_id, $a_export = false)
1276  {
1277  // repository blogs are multi-author
1278  $name = null;
1279  if($this->id_type != self::REPOSITORY_NODE_ID)
1280  {
1281  $name = ilObjUser::_lookupName($a_user_id);
1282  $name = $name["lastname"].", ".($t = $name["title"] ? $t . " " : "").$name["firstname"];
1283  }
1284 
1285  // show banner?
1286  $banner = false;
1287  $blga_set = new ilSetting("blga");
1288  if($blga_set->get("banner"))
1289  {
1290  $banner = $this->object->getImageFullPath();
1291  $banner_width = $blga_set->get("banner_width");
1292  $banner_height = $blga_set->get("banner_height");
1293  if($a_export)
1294  {
1295  $banner = basename($banner);
1296  }
1297  }
1298 
1299  $ppic = null;
1300  if($this->object->hasProfilePicture())
1301  {
1302  // repository (multi-user)
1303  if($this->id_type == self::REPOSITORY_NODE_ID)
1304  {
1305  // #15030
1306  if($_GET["blpg"] && !$a_export)
1307  {
1308  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
1309  $post = new ilBlogPosting($_GET["blpg"]);
1310  $author_id = $post->getAuthor();
1311  if($author_id)
1312  {
1313  $ppic = ilObjUser::_getPersonalPicturePath($author_id, "xsmall", true, true);
1314 
1315  $name = ilObjUser::_lookupName($author_id);
1316  $name = $name["lastname"].", ".($t = $name["title"] ? $t . " " : "").$name["firstname"];
1317  }
1318  }
1319  }
1320  // workspace (author == owner)
1321  else
1322  {
1323  $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
1324  if($a_export)
1325  {
1326  $ppic = basename($ppic);
1327  }
1328  }
1329  }
1330 
1331  $a_tpl->resetHeaderBlock(false);
1332  // $a_tpl->setBackgroundColor($this->object->getBackgroundColor());
1333  $a_tpl->setBanner($banner, $banner_width, $banner_height, $a_export);
1334  $a_tpl->setTitleIcon($ppic);
1335  $a_tpl->setTitle($this->object->getTitle());
1336  // $a_tpl->setTitleColor($this->object->getFontColor());
1337  $a_tpl->setDescription($name);
1338 
1339  // to get rid of locator in repository preview
1340  $a_tpl->setVariable("LOCATOR", "");
1341 
1342  // :TODO: obsolete?
1343  // $a_tpl->setBodyClass("std ilExternal ilBlog");
1344  }
1345 
1352  protected function buildPostingList($a_obj_id)
1353  {
1354  $author_found = false;
1355 
1356  $items = array();
1357  foreach(ilBlogPosting::getAllPostings($a_obj_id) as $posting)
1358  {
1359  if($this->author && $posting["author"] == $this->author)
1360  {
1361  $author_found = true;
1362  }
1363 
1364  $month = substr($posting["created"]->get(IL_CAL_DATE), 0, 7);
1365  $items[$month][$posting["id"]] = $posting;
1366  }
1367 
1368  if($this->author && !$author_found)
1369  {
1370  $this->author = null;
1371  }
1372 
1373  return $items;
1374  }
1375 
1386  function renderList(array $items, $a_cmd = "preview", $a_link_template = null, $a_show_inactive = false, $a_export_directory = null)
1387  {
1388  global $lng, $ilCtrl;
1389 
1390  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1391  $wtpl = new ilTemplate("tpl.blog_list.html", true, true, "Modules/Blog");
1392 
1393  // quick editing in portfolio
1394  if($_REQUEST["prt_id"] &&
1395  stristr($a_cmd, "embedded"))
1396  {
1397  global $ilUser;
1398  if(ilObject::_lookupOwner($_REQUEST["prt_id"]) == $ilUser->getId())
1399  {
1400  // see ilPortfolioPageTableGUI::fillRow()
1401  $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", (int)$_REQUEST["user_page"]);
1402  $link = $ilCtrl->getLinkTargetByClass(array("ilportfoliopagegui", "ilobjbloggui"), "render");
1403  $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", "");
1404 
1405  $wtpl->setCurrentBlock("prtf_edit_bl");
1406  $wtpl->setVariable("PRTF_BLOG_URL", $link);
1407  $wtpl->setVariable("PRTF_BLOG_TITLE", sprintf($lng->txt("prtf_edit_embedded_blog"), $this->object->getTitle()));
1408  $wtpl->parseCurrentBlock();
1409  }
1410  }
1411 
1412  $can_approve = ($this->object->hasApproval() && $this->checkPermissionBool("write"));
1413  $can_deactivate = $this->checkPermissionBool("write");
1414 
1415  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
1416  $last_month = null;
1417  foreach($items as $item)
1418  {
1419  // only published items
1420  $is_active = ilBlogPosting::_lookupActive($item["id"], "blp");
1421  if(!$is_active && !$a_show_inactive)
1422  {
1423  continue;
1424  }
1425 
1426  if(!$this->keyword && !$this->author)
1427  {
1428  $month = substr($item["created"]->get(IL_CAL_DATE), 0, 7);
1429  }
1430 
1431  if(!$last_month || $last_month != $month)
1432  {
1433  if($last_month)
1434  {
1435  $wtpl->setCurrentBlock("month_bl");
1436  $wtpl->parseCurrentBlock();
1437  }
1438 
1439  // title according to current "filter"/navigation
1440  if($this->keyword)
1441  {
1442  $title = $lng->txt("blog_keyword").": ".$this->keyword;
1443  }
1444  else if($this->author)
1445  {
1446  include_once "Services/User/classes/class.ilUserUtil.php";
1447  $title = $lng->txt("blog_author").": ".ilUserUtil::getNamePresentation($this->author);
1448  }
1449  else
1450  {
1451  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
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  {
1463  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month);
1464  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $item["id"]);
1465  $preview = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_cmd);
1466  }
1467  else
1468  {
1469  $preview = $this->buildExportLink($a_link_template, "posting", $item["id"]);
1470  }
1471 
1472  // actions
1473  $item_contribute = $this->mayContribute($item["id"], $item["author"]);
1474  if(($item_contribute || $can_approve || $can_deactivate) && !$a_link_template && $a_cmd == "preview")
1475  {
1476  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
1477  $alist = new ilAdvancedSelectionListGUI();
1478  $alist->setId($item["id"]);
1479  $alist->setListTitle($lng->txt("actions"));
1480 
1481  if($is_active && $this->object->hasApproval() && !$item["approved"])
1482  {
1483  if($can_approve)
1484  {
1485  $ilCtrl->setParameter($this, "apid", $item["id"]);
1486  $alist->addItem($lng->txt("blog_approve"), "approve",
1487  $ilCtrl->getLinkTarget($this, "approve"));
1488  $ilCtrl->setParameter($this, "apid", "");
1489  }
1490 
1491  $wtpl->setVariable("APPROVAL", $lng->txt("blog_needs_approval"));
1492  }
1493 
1494  if($item_contribute)
1495  {
1496  $alist->addItem($lng->txt("edit_content"), "edit",
1497  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit"));
1498 
1499  // #11858
1500  if($is_active)
1501  {
1502  $alist->addItem($lng->txt("blog_toggle_draft"), "deactivate",
1503  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deactivatePageToList"));
1504  }
1505  else
1506  {
1507  $alist->addItem($lng->txt("blog_toggle_final"), "activate",
1508  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "activatePageToList"));
1509  }
1510 
1511  $alist->addItem($lng->txt("rename"), "rename",
1512  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edittitle"));
1513 
1514  if($this->object->hasKeywords()) // #13616
1515  {
1516  $alist->addItem($lng->txt("blog_edit_keywords"), "keywords",
1517  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords"));
1518  }
1519 
1520  $alist->addItem($lng->txt("blog_edit_date"), "editdate",
1521  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editdate"));
1522  $alist->addItem($lng->txt("delete"), "delete",
1523  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen"));
1524  }
1525  else if($can_deactivate)
1526  {
1527  // #10513
1528  if($is_active)
1529  {
1530  $ilCtrl->setParameter($this, "apid", $item["id"]);
1531  $alist->addItem($lng->txt("blog_toggle_draft_admin"), "deactivate",
1532  $ilCtrl->getLinkTarget($this, "deactivateAdmin"));
1533  $ilCtrl->setParameter($this, "apid", "");
1534  }
1535 
1536  $alist->addItem($lng->txt("delete"), "delete",
1537  $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen"));
1538  }
1539 
1540  $wtpl->setCurrentBlock("actions");
1541  $wtpl->setVariable("ACTION_SELECTOR", $alist->getHTML());
1542  $wtpl->parseCurrentBlock();
1543  }
1544 
1545  // comments
1546  if($this->object->getNotesStatus() && !$a_link_template && !$this->disable_notes)
1547  {
1548  // count (public) notes
1549  include_once("Services/Notes/classes/class.ilNote.php");
1550  $count = sizeof(ilNote::_getNotesOfObject($this->obj_id,
1551  $item["id"], "blp", IL_NOTE_PUBLIC));
1552 
1553  if($a_cmd != "preview")
1554  {
1555  $wtpl->setCurrentBlock("comments");
1556  $wtpl->setVariable("TEXT_COMMENTS", $lng->txt("blog_comments"));
1557  $wtpl->setVariable("URL_COMMENTS", $preview);
1558  $wtpl->setVariable("COUNT_COMMENTS", $count);
1559  $wtpl->parseCurrentBlock();
1560  }
1561  /* we disabled comments in edit mode (should always be done via pagegui)
1562  else
1563  {
1564  $hash = ilCommonActionDispatcherGUI::buildAjaxHash(ilCommonActionDispatcherGUI::TYPE_WORKSPACE,
1565  $this->node_id, "blog", $this->obj_id, "blp", $item["id"]);
1566  $notes_link = "#\" onclick=\"".ilNoteGUI::getListCommentsJSCall($hash);
1567  }
1568  */
1569  }
1570 
1571  // permanent link
1572  if($a_cmd != "preview" && $a_cmd != "previewEmbedded")
1573  {
1574  if($this->id_type == self::WORKSPACE_NODE_ID)
1575  {
1576  $goto = $this->getAccessHandler()->getGotoLink($this->node_id, $this->obj_id, "_".$item["id"]);
1577  }
1578  else
1579  {
1580  include_once "Services/Link/classes/class.ilLink.php";
1581  $goto = ilLink::_getStaticLink($this->node_id, $this->getType(), true, "_".$item["id"]);
1582  }
1583  $wtpl->setCurrentBlock("permalink");
1584  $wtpl->setVariable("URL_PERMALINK", $goto);
1585  $wtpl->setVariable("TEXT_PERMALINK", $lng->txt("blog_permanent_link"));
1586  $wtpl->parseCurrentBlock();
1587  }
1588 
1589  $snippet = ilBlogPostingGUI::getSnippet($item["id"],
1590  $this->object->hasAbstractShorten(),
1591  $this->object->getAbstractShortenLength(),
1592  "&hellip;",
1593  $this->object->hasAbstractImage(),
1594  $this->object->getAbstractImageWidth(),
1595  $this->object->getAbstractImageHeight(),
1596  $a_export_directory);
1597 
1598  if($snippet)
1599  {
1600  $wtpl->setCurrentBlock("more");
1601  $wtpl->setVariable("URL_MORE", $preview);
1602  $wtpl->setVariable("TEXT_MORE", $lng->txt("blog_list_more"));
1603  $wtpl->parseCurrentBlock();
1604  }
1605 
1606  $wtpl->setCurrentBlock("posting");
1607 
1608  if(!$is_active)
1609  {
1610  $wtpl->setVariable("DRAFT_CLASS", " ilBlogListItemDraft");
1611  }
1612 
1613  $author = "";
1614  if($this->id_type == self::REPOSITORY_NODE_ID)
1615  {
1616  $author_id = $item["author"];
1617  if($author_id)
1618  {
1619  include_once "Services/User/classes/class.ilUserUtil.php";
1620  $author = ilUserUtil::getNamePresentation($author_id)." - ";
1621  }
1622  }
1623 
1624  // title
1625  $wtpl->setVariable("URL_TITLE", $preview);
1626  $wtpl->setVariable("TITLE", $item["title"]);
1627  $wtpl->setVariable("DATETIME", $author.
1628  ilDatePresentation::formatDate($item["created"], IL_CAL_DATE));
1629 
1630  // content
1631  $wtpl->setVariable("CONTENT", $snippet);
1632 
1633  $wtpl->parseCurrentBlock();
1634  }
1635 
1636  // permalink
1637  if($a_cmd == "previewFullscreen")
1638  {
1639  $this->tpl->setPermanentLink("blog", $this->node_id,
1640  ($this->id_type == self::WORKSPACE_NODE_ID)
1641  ? "_wsp"
1642  : "");
1643  }
1644 
1645  return $wtpl->get();
1646  }
1647 
1658  protected function renderNavigationByDate(array $a_items, $a_list_cmd = "render", $a_posting_cmd = "preview", $a_link_template = null, $a_show_inactive = false)
1659  {
1660  global $ilCtrl;
1661 
1662  // gather page active status
1663  foreach($a_items as $month => $postings)
1664  {
1665  foreach(array_keys($postings) as $id)
1666  {
1667  $active = ilBlogPosting::_lookupActive($id, "blp");
1668  if(!$a_show_inactive && !$active)
1669  {
1670  unset($a_items[$month][$id]);
1671  }
1672  else
1673  {
1674  $a_items[$month][$id]["active"] = $active;
1675  }
1676  }
1677  if(!sizeof($a_items[$month]))
1678  {
1679  unset($a_items[$month]);
1680  }
1681  }
1682 
1683  // list month (incl. postings)
1684  if($this->object->getNavMode() == ilObjBlog::NAV_MODE_LIST || $a_link_template)
1685  {
1686  $max_detail_postings = $this->object->getNavModeListPostings();
1687  $max_months = $this->object->getNavModeListMonths();
1688 
1689  $wtpl = new ilTemplate("tpl.blog_list_navigation_by_date.html", true, true, "Modules/Blog");
1690 
1691  $ilCtrl->setParameter($this, "blpg", "");
1692 
1693  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1694  $counter = $mon_counter = $last_year = 0;
1695  foreach($a_items as $month => $postings)
1696  {
1697  if(!$a_link_template && $max_months && $mon_counter >= $max_months)
1698  {
1699  break;
1700  }
1701 
1702  $add_year = false;
1703  $year = substr($month, 0, 4);
1704  if(!$last_year || $year != $last_year)
1705  {
1706  // #13562
1707  $add_year = true;
1708  $last_year = $year;
1709  }
1710 
1711  $mon_counter++;
1712 
1713  $month_name = ilCalendarUtil::_numericMonthToString((int)substr($month, 5));
1714 
1715  if(!$a_link_template)
1716  {
1717  $ilCtrl->setParameter($this, "bmn", $month);
1718  $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1719  }
1720  else
1721  {
1722  $month_url = $this->buildExportLink($a_link_template, "list", $month);
1723  }
1724 
1725  // list postings for month
1726  if($counter < $max_detail_postings)
1727  {
1728  if($add_year)
1729  {
1730  $wtpl->setCurrentBlock("navigation_year_details");
1731  $wtpl->setVariable("YEAR", $year);
1732  $wtpl->parseCurrentBlock();
1733  }
1734 
1735  foreach($postings as $id => $posting)
1736  {
1737  if($max_detail_postings && $counter >= $max_detail_postings)
1738  {
1739  break;
1740  }
1741 
1742  $counter++;
1743 
1744  $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1745  ", ".*/ $posting["title"];
1746 
1747  if(!$a_link_template)
1748  {
1749  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1750  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1751  $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1752  }
1753  else
1754  {
1755  $url = $this->buildExportLink($a_link_template, "posting", $id);
1756  }
1757 
1758  if(!$posting["active"])
1759  {
1760  $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1761  }
1762  else if($this->object->hasApproval() && !$posting["approved"])
1763  {
1764  $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1765  }
1766 
1767  $wtpl->setCurrentBlock("navigation_item");
1768  $wtpl->setVariable("NAV_ITEM_URL", $url);
1769  $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1770  $wtpl->parseCurrentBlock();
1771  }
1772 
1773  $wtpl->setCurrentBlock("navigation_month_details");
1774  $wtpl->setVariable("NAV_MONTH", $month_name);
1775  $wtpl->setVariable("URL_MONTH", $month_url);
1776  $wtpl->parseCurrentBlock();
1777  }
1778  // summarized month
1779  else
1780  {
1781  if($add_year)
1782  {
1783  $wtpl->setCurrentBlock("navigation_year");
1784  $wtpl->setVariable("YEAR", $year);
1785  $wtpl->parseCurrentBlock();
1786  }
1787 
1788  $wtpl->setCurrentBlock("navigation_month");
1789  $wtpl->setVariable("MONTH_NAME", $month_name);
1790  $wtpl->setVariable("URL_MONTH", $month_url);
1791  $wtpl->setVariable("MONTH_COUNT", sizeof($postings));
1792  $wtpl->parseCurrentBlock();
1793  }
1794  }
1795 
1796  $ilCtrl->setParameter($this, "bmn", $this->month);
1797  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
1798 
1799  return $wtpl->get();
1800  }
1801  // single month
1802  else
1803  {
1804  $wtpl = new ilTemplate("tpl.blog_list_navigation_month.html", true, true, "Modules/Blog");
1805 
1806  $ilCtrl->setParameter($this, "blpg", "");
1807 
1808  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
1809  $month_options = array();
1810  foreach($a_items as $month => $postings)
1811  {
1812  $month_name = ilCalendarUtil::_numericMonthToString((int)substr($month, 5)).
1813  " ".substr($month, 0, 4);
1814 
1815  $month_options[$month] = $month_name;
1816 
1817  if($month == $this->month)
1818  {
1819  if(!$a_link_template)
1820  {
1821  $ilCtrl->setParameter($this, "bmn", $month);
1822  $month_url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1823  }
1824  else
1825  {
1826  $month_url = $this->buildExportLink($a_link_template, "list", $month);
1827  }
1828 
1829  foreach($postings as $id => $posting)
1830  {
1831  $caption = /* ilDatePresentation::formatDate($posting["created"], IL_CAL_DATETIME).
1832  ", ".*/ $posting["title"];
1833 
1834  if(!$a_link_template)
1835  {
1836  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $month);
1837  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $id);
1838  $url = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_posting_cmd);
1839  }
1840  else
1841  {
1842  $url = $this->buildExportLink($a_link_template, "posting", $id);
1843  }
1844 
1845  if(!$posting["active"])
1846  {
1847  $wtpl->setVariable("NAV_ITEM_DRAFT", $this->lng->txt("blog_draft"));
1848  }
1849  else if($this->object->hasApproval() && !$posting["approved"])
1850  {
1851  $wtpl->setVariable("NAV_ITEM_APPROVAL", $this->lng->txt("blog_needs_approval"));
1852  }
1853 
1854  $wtpl->setCurrentBlock("navigation_item");
1855  $wtpl->setVariable("NAV_ITEM_URL", $url);
1856  $wtpl->setVariable("NAV_ITEM_CAPTION", $caption);
1857  $wtpl->parseCurrentBlock();
1858  }
1859 
1860  $wtpl->setCurrentBlock("navigation_month_details");
1861  if($_GET["blpg"])
1862  {
1863  $wtpl->setVariable("NAV_MONTH", $month_name);
1864  $wtpl->setVariable("URL_MONTH", $month_url);
1865  }
1866  $wtpl->parseCurrentBlock();
1867  }
1868  }
1869 
1870  if(!$_GET["blpg"])
1871  {
1872  $wtpl->setCurrentBlock("option_bl");
1873  foreach($month_options as $value => $caption)
1874  {
1875  $wtpl->setVariable("OPTION_VALUE", $value);
1876  $wtpl->setVariable("OPTION_CAPTION", $caption);
1877  if($value == $this->month)
1878  {
1879  $wtpl->setVariable("OPTION_SEL", ' selected="selected"');
1880  }
1881  $wtpl->parseCurrentBlock();
1882  }
1883 
1884  $wtpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this, $a_list_cmd));
1885  }
1886 
1887  $ilCtrl->setParameter($this, "bmn", $this->month);
1888  $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", "");
1889 
1890  return $wtpl->get();
1891  }
1892  }
1893 
1901  protected function renderNavigationByKeywords($a_list_cmd = "render", $a_show_inactive = false)
1902  {
1903  global $ilCtrl;
1904 
1905  $keywords = $this->getKeywords($a_show_inactive, $_GET["blpg"]);
1906  if($keywords)
1907  {
1908  $wtpl = new ilTemplate("tpl.blog_list_navigation_keywords.html", true, true, "Modules/Blog");
1909 
1910  $max = max($keywords);
1911  include_once "Services/Tagging/classes/class.ilTagging.php";
1912 
1913  $wtpl->setCurrentBlock("keyword");
1914  foreach($keywords as $keyword => $counter)
1915  {
1916  $ilCtrl->setParameter($this, "kwd", urlencode($keyword)); // #15885
1917  $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1918  $ilCtrl->setParameter($this, "kwd", "");
1919 
1920  $wtpl->setVariable("TXT_KEYWORD", $keyword);
1921  $wtpl->setVariable("CLASS_KEYWORD", ilTagging::getRelevanceClass($counter, $max));
1922  $wtpl->setVariable("URL_KEYWORD", $url);
1923  $wtpl->parseCurrentBlock();
1924  }
1925 
1926  return $wtpl->get();
1927  }
1928  }
1929 
1930  protected function renderNavigationByAuthors(array $a_items, $a_list_cmd = "render", $a_show_inactive = false)
1931  {
1932  global $ilCtrl;
1933 
1934  $authors = array();
1935  foreach($a_items as $month => $items)
1936  {
1937  foreach($items as $item)
1938  {
1939  if(($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp")) && $item["author"])
1940  {
1941  $authors[] = $item["author"];
1942  }
1943  }
1944  }
1945 
1946  $authors = array_unique($authors);
1947  if(sizeof($authors) > 1)
1948  {
1949  include_once "Services/User/classes/class.ilUserUtil.php";
1950 
1951  $list = array();
1952  foreach($authors as $user_id)
1953  {
1954  if($user_id)
1955  {
1956  $ilCtrl->setParameter($this, "ath", $user_id);
1957  $url = $ilCtrl->getLinkTarget($this, $a_list_cmd);
1958  $ilCtrl->setParameter($this, "ath", "");
1959 
1960  $name = ilUserUtil::getNamePresentation($user_id, true);
1961  $idx = trim(strip_tags($name))."///".$user_id; // #10934
1962  $list[$idx] = array($name, $url);
1963  }
1964  }
1965  ksort($list);
1966 
1967  $wtpl = new ilTemplate("tpl.blog_list_navigation_authors.html", true, true, "Modules/Blog");
1968 
1969  $wtpl->setCurrentBlock("author");
1970  foreach($list as $author)
1971  {
1972  $wtpl->setVariable("TXT_AUTHOR", $author[0]);
1973  $wtpl->setVariable("URL_AUTHOR", $author[1]);
1974  $wtpl->parseCurrentBlock();
1975  }
1976 
1977  return $wtpl->get();
1978  }
1979  }
1980 
1991  function renderNavigation(array $a_items, $a_list_cmd = "render", $a_posting_cmd = "preview", $a_link_template = null, $a_show_inactive = false)
1992  {
1993  global $ilCtrl, $ilSetting;
1994 
1995  if($this->object->getOrder())
1996  {
1997  $order = array_flip($this->object->getOrder());
1998  }
1999  else
2000  {
2001  $order = array(
2002  "navigation" => 0
2003  ,"keywords" => 2
2004  ,"authors" => 1
2005  );
2006  }
2007 
2008  $wtpl = new ilTemplate("tpl.blog_list_navigation.html", true, true, "Modules/Blog");
2009 
2010  $blocks = array();
2011 
2012  // by date
2013  if(sizeof($a_items))
2014  {
2015  $blocks[$order["navigation"]] = array(
2016  $this->lng->txt("blog_navigation"),
2017  $this->renderNavigationByDate($a_items, $a_list_cmd, $a_posting_cmd, $a_link_template, $a_show_inactive)
2018  );
2019  }
2020 
2021  // authors
2022  if($this->id_type == self::REPOSITORY_NODE_ID &&
2023  $this->object->hasAuthors())
2024  {
2025  $authors = $this->renderNavigationByAuthors($a_items, $a_list_cmd, $a_show_inactive);
2026  if($authors)
2027  {
2028  $blocks[$order["authors"]] = array($this->lng->txt("blog_authors"), $authors);
2029  }
2030  }
2031 
2032  // is not part of (html) export
2033  if(!$a_link_template)
2034  {
2035  if($this->object->hasKeywords())
2036  {
2037  // keywords
2038  $may_edit_keywords = ($_GET["blpg"] &&
2039  $this->mayContribute($_GET["blpg"]) &&
2040  $a_list_cmd != "preview" &&
2041  $a_list_cmd != "gethtml");
2042  $keywords = $this->renderNavigationByKeywords($a_list_cmd, $a_show_inactive);
2043  if($keywords || $may_edit_keywords)
2044  {
2045  if(!$keywords)
2046  {
2047  $keywords = $this->lng->txt("blog_no_keywords");
2048  }
2049  $cmd = null;
2050  if($may_edit_keywords)
2051  {
2052  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $_GET["blpg"]);
2053  $cmd = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords");
2054  $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", "");
2055  }
2056  $blocks[$order["keywords"]] = array(
2057  $this->lng->txt("blog_keywords"),
2058  $keywords,
2059  $cmd
2060  ? array($cmd, $this->lng->txt("blog_edit_keywords"))
2061  : null
2062  );
2063  }
2064  }
2065 
2066  // rss
2067  if($this->object->hasRSS() &&
2068  $ilSetting->get('enable_global_profiles') &&
2069  $a_list_cmd == "preview")
2070  {
2071  // #10827
2072  $blog_id = $this->node_id;
2073  if($this->id_type != self::WORKSPACE_NODE_ID)
2074  {
2075  $blog_id .= "_cll";
2076  }
2077  $url = ILIAS_HTTP_PATH."/feed.php?blog_id=".$blog_id.
2078  "&client_id=".rawurlencode(CLIENT_ID);
2079 
2080  include_once("./Services/News/classes/class.ilRSSButtonGUI.php");
2081  $wtpl->setVariable("RSS_BUTTON", ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_RSS, $url));
2082  }
2083  }
2084 
2085  if(sizeof($blocks))
2086  {
2087  include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
2088 
2089  ksort($blocks);
2090  foreach($blocks as $block)
2091  {
2092  $panel = ilPanelGUI::getInstance();
2093  $panel->setPanelStyle(ilPanelGUI::PANEL_STYLE_SECONDARY);
2094  $panel->setHeadingStyle(ilPanelGUI::HEADING_STYLE_BLOCK);
2095  $panel->setHeading($block[0]);
2096  $panel->setBody($block[1]);
2097 
2098  if(isset($block[2]) && is_array($block[2]))
2099  {
2100  $panel->setFooter('<a href="'.$block[2][0].'">'.$block[2][1].'</a>');
2101  }
2102 
2103  $wtpl->setCurrentBlock("block_bl");
2104  $wtpl->setVariable("BLOCK", $panel->getHTML());
2105  $wtpl->parseCurrentBlock();
2106  }
2107  }
2108 
2109  return $wtpl->get();
2110  }
2111 
2119  function getKeywords($a_show_inactive, $a_posting_id = null)
2120  {
2121  $keywords = array();
2122  include_once("./Modules/Blog/classes/class.ilBlogPosting.php");
2123  if($a_posting_id)
2124  {
2125  foreach(ilBlogPosting::getKeywords($this->obj_id, $a_posting_id) as $keyword)
2126  {
2127  $keywords[$keyword]++;
2128  }
2129  }
2130  else
2131  {
2132  foreach($this->items as $month => $items)
2133  {
2134  foreach($items as $item)
2135  {
2136  if($a_show_inactive || ilBlogPosting::_lookupActive($item["id"], "blp"))
2137  {
2138  foreach(ilBlogPosting::getKeywords($this->obj_id, $item["id"]) as $keyword)
2139  {
2140  $keywords[$keyword]++;
2141  }
2142  }
2143  }
2144  }
2145  }
2146 
2147  // #15881
2148  $tmp = array();
2149  foreach($keywords as $keyword => $counter)
2150  {
2151  $tmp[] = array("keyword"=>$keyword, "counter"=>$counter);
2152  }
2153  $tmp = ilUtil::sortArray($tmp, "keyword", "ASC");
2154 
2155  $keywords = array();
2156  foreach($tmp as $item)
2157  {
2158  $keywords[$item["keyword"]] = $item["counter"];
2159  }
2160  return $keywords;
2161  }
2162 
2168  function buildExportFile()
2169  {
2170  // create export file
2171  include_once("./Services/Export/classes/class.ilExport.php");
2172  ilExport::_createExportDirectory($this->object->getId(), "html", "blog");
2173  $exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "blog");
2174 
2175  $subdir = $this->object->getType()."_".$this->object->getId();
2176  $export_dir = $exp_dir."/".$subdir;
2177 
2178  // initialize temporary target directory
2179  ilUtil::delDir($export_dir);
2180  ilUtil::makeDir($export_dir);
2181 
2182  // system style html exporter
2183  include_once("./Services/Style/classes/class.ilSystemStyleHTMLExport.php");
2184  $this->sys_style_html_export = new ilSystemStyleHTMLExport($export_dir);
2185  $this->sys_style_html_export->addImage("icon_blog.svg");
2186  $this->sys_style_html_export->export();
2187 
2188  // init co page html exporter
2189  include_once("./Services/COPage/classes/class.ilCOPageHTMLExport.php");
2190  $this->co_page_html_export = new ilCOPageHTMLExport($export_dir);
2191  $this->co_page_html_export->setContentStyleId($this->object->getStyleSheetId());
2192  $this->co_page_html_export->createDirectories();
2193  $this->co_page_html_export->exportStyles();
2194  $this->co_page_html_export->exportSupportScripts();
2195 
2196  // banner / profile picture
2197  $blga_set = new ilSetting("blga");
2198  if($blga_set->get("banner"))
2199  {
2200  $banner = $this->object->getImageFullPath();
2201  if($banner)
2202  {
2203  copy($banner, $export_dir."/".basename($banner));
2204  }
2205  }
2206  $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "xsmall", true, true);
2207  if($ppic)
2208  {
2209  $ppic = array_shift(explode("?", $ppic));
2210  copy($ppic, $export_dir."/".basename($ppic));
2211  }
2212 
2213  // export pages
2214  $this->exportHTMLPages($export_dir);
2215 
2216  // zip everything
2217  if (true)
2218  {
2219  // zip it all
2220  $date = time();
2221  $zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "blog").
2222  "/".$date."__".IL_INST_ID."__".
2223  $this->object->getType()."_".$this->object->getId().".zip";
2224  ilUtil::zip($export_dir, $zip_file);
2225  ilUtil::delDir($export_dir);
2226  }
2227 
2228  return $zip_file;
2229  }
2230 
2240  function exportHTMLPages($a_target_directory, $a_link_template = null, $a_tpl_callback = null, $a_co_page_html_export = null, $a_index_name = "index.html")
2241  {
2242  if(!$a_link_template)
2243  {
2244  $a_link_template = "bl{TYPE}_{ID}.html";
2245  }
2246 
2247  if($a_co_page_html_export)
2248  {
2249  $this->co_page_html_export = $a_co_page_html_export;
2250  }
2251 
2252  $nav = $this->renderNavigation($this->items, "", "", $a_link_template);
2253 
2254  // month list
2255  $has_index = false;
2256  foreach(array_keys($this->items) as $month)
2257  {
2258  $file = $this->buildExportLink($a_link_template, "list", $month);
2259  $list = $this->renderList($this->items[$month], "render", $a_link_template, false, $a_target_directory);
2260 
2261  if(!$a_tpl_callback)
2262  {
2263  $tpl = $this->buildExportTemplate();
2264  }
2265  else
2266  {
2267  $tpl = call_user_func($a_tpl_callback);
2268  }
2269 
2270  $file = $this->writeExportFile($a_target_directory, $file,
2271  $tpl, $list, $nav);
2272 
2273  if(!$has_index)
2274  {
2275  copy($file, $a_target_directory."/".$a_index_name);
2276  $has_index = true;
2277  }
2278  }
2279 
2280  // single postings
2281  include_once("./Services/COPage/classes/class.ilPageContentUsage.php");
2282  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2283  $pages = ilBlogPosting::getAllPostings($this->object->getId(), 0);
2284  foreach ($pages as $page)
2285  {
2286  if (ilBlogPosting::_exists("blp", $page["id"]))
2287  {
2288  include_once("./Modules/Blog/classes/class.ilBlogPostingGUI.php");
2289  $blp_gui = new ilBlogPostingGUI(0, null, $page["id"]);
2290  $blp_gui->setOutputMode("offline");
2291  $blp_gui->setFullscreenLink("fullscreen.html"); // #12930 - see page.xsl
2292  $blp_gui->add_date = true;
2293  $page_content = $blp_gui->showPage();
2294 
2295  $back = $this->buildExportLink($a_link_template, "list",
2296  substr($page["created"]->get(IL_CAL_DATE), 0, 7));
2297 
2298  $file = $this->buildExportLink($a_link_template, "posting", $page["id"]);
2299 
2300  if(!$a_tpl_callback)
2301  {
2302  $tpl = $this->buildExportTemplate();
2303  }
2304  else
2305  {
2306  $tpl = call_user_func($a_tpl_callback);
2307  }
2308 
2309  $this->writeExportFile($a_target_directory, $file, $tpl,
2310  $page_content, $nav, $back);
2311 
2312  $this->co_page_html_export->collectPageElements("blp:pg", $page["id"]);
2313  }
2314  }
2315  $this->co_page_html_export->exportPageElements();
2316  }
2317 
2326  protected function buildExportLink($a_template, $a_type, $a_id)
2327  {
2328  if($a_type == "list")
2329  {
2330  $a_type = "m";
2331  }
2332  else
2333  {
2334  $a_type = "p";
2335  }
2336  $link = str_replace("{TYPE}", $a_type, $a_template);
2337  return str_replace("{ID}", $a_id, $link);
2338  }
2339 
2346  protected function buildExportTemplate($a_back_url = "")
2347  {
2348  global $ilTabs, $lng;
2349 
2350  $tpl = $this->co_page_html_export->getPreparedMainTemplate();
2351 
2352  $tpl->getStandardTemplate();
2353 
2354  $ilTabs->clearTargets();
2355  if($a_back_url)
2356  {
2357  $ilTabs->setBackTarget($lng->txt("back"), $a_back_url);
2358  }
2359 
2360  $this->renderFullscreenHeader($tpl, $this->object->getOwner(), true);
2361 
2362  return $tpl;
2363  }
2364 
2375  protected function writeExportFile($a_target_directory, $a_file, $a_tpl, $a_content, $a_right_content = null)
2376  {
2377  $file = $a_target_directory."/".$a_file;
2378  // return if file is already existing
2379  if (@is_file($file))
2380  {
2381  return;
2382  }
2383 
2384  // export template: page content
2385  $ep_tpl = new ilTemplate("tpl.export_page.html", true, true,
2386  "Modules/Blog");
2387  $ep_tpl->setVariable("PAGE_CONTENT", $a_content);
2388 
2389  // export template: right content
2390  if($a_right_content)
2391  {
2392  $ep_tpl->setVariable("RIGHT_CONTENT", $a_right_content);
2393  }
2394 
2395  $a_tpl->setContent($ep_tpl->get());
2396 
2397  $content = $a_tpl->get("DEFAULT", false, false, false,
2398  true, true, true);
2399 
2400  // open file
2401  if (!file_put_contents($file, $content))
2402  {
2403  die ("<b>Error</b>: Could not open \"".$file."\" for writing".
2404  " in <b>".__FILE__."</b> on line <b>".__LINE__."</b><br />");
2405  }
2406 
2407  // set file permissions
2408  chmod($file, 0770);
2409 
2410  return $file;
2411  }
2412 
2416  protected function finalize()
2417  {
2418  global $ilCtrl, $lng;
2419 
2420  // to make exercise gui load assignment
2421  $_GET["ass_id"] = $_REQUEST["ass"];
2422 
2423  // #11173 - ref_id is needed for notifications
2424  $exc_ref_id = array_shift(ilObject::_getAllReferences($_REQUEST["exc"]));
2425 
2426  include_once "Modules/Exercise/classes/class.ilObjExerciseGUI.php";
2427  $exc_gui = new ilObjExerciseGUI(null, $exc_ref_id, true);
2428  $exc_gui->submitBlog($this->node_id);
2429 
2430  ilUtil::sendSuccess($lng->txt("blog_finalized"), true);
2431  $ilCtrl->redirect($this, "render");
2432  }
2433 
2434  function getNotesSubId()
2435  {
2436  if($_REQUEST["blpg"])
2437  {
2438  return $_REQUEST["blpg"];
2439  }
2440  return 0;
2441  }
2442 
2443  function disableNotes($a_value = false)
2444  {
2445  $this->disable_notes = (bool)$a_value;
2446  }
2447 
2448  protected function addHeaderAction($a_cmd)
2449  {
2450  global $ilUser, $ilCtrl;
2451 
2452  // preview?
2453  if($a_cmd == "preview" || $a_cmd == "previewFullscreen" || $_GET["prvm"])
2454  {
2455  // notification
2456  if($ilUser->getId() != ANONYMOUS_USER_ID)
2457  {
2458  if(!$_GET["prvm"])
2459  {
2460  $ilCtrl->setParameter($this, "prvm", "fsc");
2461  }
2462  $this->insertHeaderAction($this->initHeaderAction(null, null, true));
2463  if(!$_GET["prvm"])
2464  {
2465  $ilCtrl->setParameter($this, "prvm", "");
2466  }
2467  }
2468  }
2469  else
2470  {
2471  return parent::addHeaderAction();
2472  }
2473  }
2474 
2475  protected function initHeaderAction($sub_type = null, $sub_id = null, $a_is_preview = false)
2476  {
2477  global $ilUser, $ilCtrl;
2478 
2479  if(!$this->obj_id)
2480  {
2481  return false;
2482  }
2483 
2484  $sub_type = $sub_id = null;
2485  if($_GET["blpg"])
2486  {
2487  $sub_type = "blp";
2488  $sub_id = $_GET["blpg"];
2489  }
2490 
2491  $lg = parent::initHeaderAction($sub_type, $sub_id);
2492 
2493  if($a_is_preview)
2494  {
2495  $lg->enableComments(false);
2496  $lg->enableNotes(false);
2497  $lg->enableTags(false);
2498 
2499  include_once "./Services/Notification/classes/class.ilNotification.php";
2501  {
2502  $ilCtrl->setParameter($this, "ntf", 1);
2503  $link = $ilCtrl->getLinkTarget($this, "setNotification");
2504  $ilCtrl->setParameter($this, "ntf", "");
2505  $lg->addCustomCommand($link, "blog_notification_toggle_off");
2506 
2507  $lg->addHeaderIcon("not_icon",
2508  ilUtil::getImagePath("notification_on.svg"),
2509  $this->lng->txt("blog_notification_activated"));
2510  }
2511  else
2512  {
2513  $ilCtrl->setParameter($this, "ntf", 2);
2514  $link = $ilCtrl->getLinkTarget($this, "setNotification");
2515  $ilCtrl->setParameter($this, "ntf", "");
2516  $lg->addCustomCommand($link, "blog_notification_toggle_on");
2517 
2518  $lg->addHeaderIcon("not_icon",
2519  ilUtil::getImagePath("notification_off.svg"),
2520  $this->lng->txt("blog_notification_deactivated"));
2521  }
2522 
2523  // #11758
2524  if($this->mayContribute())
2525  {
2526  $ilCtrl->setParameter($this, "prvm", "");
2527 
2528  $ilCtrl->setParameter($this, "bmn", "");
2529  $ilCtrl->setParameter($this, "blpg", "");
2530  $link = $ilCtrl->getLinkTarget($this, "");
2531  $ilCtrl->setParameter($this, "blpg", $sub_id);
2532  $ilCtrl->setParameter($this, "bmn", $this->month);
2533  $lg->addCustomCommand($link, "blog_edit"); // #11868
2534 
2535  if($sub_id && $this->mayContribute($sub_id))
2536  {
2537  $link = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit");
2538  $lg->addCustomCommand($link, "blog_edit_posting");
2539  }
2540 
2541  $ilCtrl->setParameter($this, "prvm", "fsc");
2542  }
2543 
2544  $ilCtrl->setParameter($this, "ntf", "");
2545  }
2546 
2547  return $lg;
2548  }
2549 
2550  protected function setNotification()
2551  {
2552  global $ilUser, $ilCtrl;
2553 
2554  include_once "./Services/Notification/classes/class.ilNotification.php";
2555  switch($_GET["ntf"])
2556  {
2557  case 1:
2559  break;
2560 
2561  case 2:
2563  break;
2564  }
2565 
2566  $ilCtrl->redirect($this, "preview");
2567  }
2568 
2576  static function lookupSubObjectTitle($a_blog_id, $a_posting_id)
2577  {
2578  // page might be deleted, so setting halt on errors to false
2579  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2580  $post = new ilBlogPosting($a_posting_id);
2581  if($post->getBlogId() == $a_blog_id)
2582  {
2583  return $post->getTitle();
2584  }
2585  }
2586 
2592  protected function filterInactivePostings()
2593  {
2594  foreach($this->items as $month => $postings)
2595  {
2596  foreach($postings as $id => $item)
2597  {
2598  if(!ilBlogPosting::_lookupActive($id, "blp"))
2599  {
2600  unset($this->items[$month][$id]);
2601  }
2602  else if($this->object->hasApproval() && !$item["approved"])
2603  {
2604  unset($this->items[$month][$id]);
2605  }
2606  }
2607  if(!sizeof($this->items[$month]))
2608  {
2609  unset($this->items[$month]);
2610  }
2611  }
2612 
2613  if($this->items && !isset($this->items[$this->month]))
2614  {
2615  $this->month = array_shift(array_keys($this->items));
2616  }
2617  }
2618 
2619  protected function filterItemsByKeyWord(array $a_items, $a_keyword)
2620  {
2621  $res = array();
2622  include_once("./Modules/Blog/classes/class.ilBlogPosting.php");
2623  foreach($a_items as $month => $items)
2624  {
2625  foreach($items as $item)
2626  {
2627  if(in_array($a_keyword,
2628  ilBlogPosting::getKeywords($this->obj_id, $item["id"])))
2629  {
2630  $res[] = $item;
2631  }
2632  }
2633  }
2634  return $res;
2635  }
2636 
2644  protected function mayContribute($a_posting_id = null, $a_author_id = null)
2645  {
2646  global $ilUser;
2647 
2648  // single author blog (owner) in personal workspace
2649  if($this->id_type == self::WORKSPACE_NODE_ID)
2650  {
2651  return $this->checkPermissionBool("write");
2652  }
2653 
2654  if($this->checkPermissionBool("contribute"))
2655  {
2656  // check owner of posting
2657  if($a_posting_id)
2658  {
2659  if(!$a_author_id)
2660  {
2661  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2662  $post = new ilBlogPosting($a_posting_id);
2663  $a_author_id = $post->getAuthor();
2664  }
2665  if($ilUser->getId() == $a_author_id)
2666  {
2667  return true;
2668  }
2669  else
2670  {
2671  return false;
2672  }
2673  }
2674 
2675  return true;
2676  }
2677  return false;
2678  }
2679 
2680  function addLocatorItems()
2681  {
2682  global $ilLocator;
2683 
2684  if (is_object($this->object))
2685  {
2686  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
2687  }
2688  }
2689 
2690  function approve()
2691  {
2692  if($this->checkPermissionBool("write") && (int)$_GET["apid"])
2693  {
2694  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2695  $post = new ilBlogPosting((int)$_GET["apid"]);
2696  $post->setApproved(true);
2697  $post->setBlogNodeId($this->node_id, ($this->id_type == self::WORKSPACE_NODE_ID));
2698  $post->update(true, false, true, "new"); // #13434
2699 
2700  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2701  }
2702 
2703  $this->ctrl->redirect($this, "render");
2704  }
2705 
2706 
2707  //
2708  // contributors
2709  //
2710 
2711  function contributors()
2712  {
2713  global $ilTabs, $ilToolbar, $ilCtrl, $lng, $tpl;
2714 
2715  if(!$this->checkPermissionBool("write"))
2716  {
2717  return;
2718  }
2719 
2720  $ilTabs->activateTab("contributors");
2721 
2722  // add member
2723  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
2725  $this,
2726  $ilToolbar,
2727  array(
2728  'auto_complete_name' => $lng->txt('user'),
2729  'submit_name' => $lng->txt('add'),
2730  'add_search' => true,
2731  'add_from_container' => $this->node_id
2732  )
2733  );
2734 
2735  $other_roles = $this->object->getRolesWithContribute($this->node_id);
2736  if($other_roles)
2737  {
2738  ilUtil::sendInfo(sprintf($lng->txt("blog_contribute_other_roles"), implode(", ", $other_roles)));
2739  }
2740 
2741  include_once "Modules/Blog/classes/class.ilContributorTableGUI.php";
2742  $tbl = new ilContributorTableGUI($this, "contributors", $this->object->getLocalContributorRole($this->node_id));
2743 
2744  $tpl->setContent($tbl->getHTML());
2745  }
2746 
2750  public function addUserFromAutoComplete()
2751  {
2752  global $lng;
2753 
2754  if(!strlen(trim($_POST['user_login'])))
2755  {
2756  ilUtil::sendFailure($lng->txt('msg_no_search_string'));
2757  return $this->contributors();
2758  }
2759  $users = explode(',', $_POST['user_login']);
2760 
2761  $user_ids = array();
2762  foreach($users as $user)
2763  {
2764  $user_id = ilObjUser::_lookupId($user);
2765 
2766  if(!$user_id)
2767  {
2768  ilUtil::sendFailure($lng->txt('user_not_known'));
2769  return $this->contributors();
2770  }
2771 
2772  $user_ids[] = $user_id;
2773  }
2774 
2775  return $this->addContributor($user_ids);
2776  }
2777 
2783  public function addContributor($a_user_ids = array())
2784  {
2785  global $ilCtrl, $lng, $rbacreview, $rbacadmin;
2786 
2787  if(!$this->checkPermissionBool("write"))
2788  {
2789  return;
2790  }
2791 
2792  if(!count($a_user_ids))
2793  {
2794  ilUtil::sendFailure($lng->txt("no_checkbox"));
2795  return $this->contributors();
2796  }
2797 
2798  // get contributor role
2799  $contr_role_id = $this->object->getLocalContributorRole($this->node_id);
2800  if(!$contr_role_id)
2801  {
2802  ilUtil::sendFailure($lng->txt("missing_perm"));
2803  return $this->contributors();
2804  }
2805 
2806  foreach($a_user_ids as $user_id)
2807  {
2808  if(!$rbacreview->isAssigned($user_id, $contr_role_id))
2809  {
2810  $rbacadmin->assignUser($contr_role_id, $user_id);
2811  }
2812  }
2813 
2814  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
2815  $ilCtrl->redirect($this, "contributors");
2816  }
2817 
2821  public function confirmRemoveContributor()
2822  {
2823  $ids = $_POST["id"];
2824 
2825  if(!sizeof($ids))
2826  {
2827  ilUtil::sendFailure($this->lng->txt("select_one"), true);
2828  $this->ctrl->redirect($this, "contributors");
2829  }
2830 
2831  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
2832  $confirm = new ilConfirmationGUI();
2833  $confirm->setHeaderText($this->lng->txt('blog_confirm_delete_contributors'));
2834  $confirm->setFormAction($this->ctrl->getFormAction($this, 'removeContributor'));
2835  $confirm->setConfirm($this->lng->txt('delete'), 'removeContributor');
2836  $confirm->setCancel($this->lng->txt('cancel'), 'contributors');
2837 
2838  include_once 'Services/User/classes/class.ilUserUtil.php';
2839 
2840  foreach($ids as $user_id)
2841  {
2842  $confirm->addItem('id[]', $user_id,
2843  ilUserUtil::getNamePresentation($user_id, false, false, "", true));
2844  }
2845 
2846  $this->tpl->setContent($confirm->getHTML());
2847  }
2848 
2852  public function removeContributor()
2853  {
2854  global $ilCtrl, $lng, $rbacadmin;
2855 
2856  $ids = $_POST["id"];
2857 
2858  if(!sizeof($ids))
2859  {
2860  ilUtil::sendFailure($lng->txt("select_one"), true);
2861  $ilCtrl->redirect($this, "contributors");
2862  }
2863 
2864  // get contributor role
2865  $contr_role_id = $this->object->getLocalContributorRole($this->node_id);
2866  if(!$contr_role_id)
2867  {
2868  ilUtil::sendFailure($lng->txt("missing_perm"));
2869  return $this->contributors();
2870  }
2871 
2872  foreach($ids as $user_id)
2873  {
2874  $rbacadmin->deassignUser($contr_role_id, $user_id);
2875  }
2876 
2877  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
2878  $this->ctrl->redirect($this, "contributors");
2879  }
2880 
2884  public function addToDeskObject()
2885  {
2886  global $lng;
2887 
2888  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
2890  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
2891  }
2892 
2896  public function removeFromDeskObject()
2897  {
2898  global $lng;
2899 
2900  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
2902  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
2903  }
2904 
2905  public function deactivateAdmin()
2906  {
2907  if($this->checkPermissionBool("write") && (int)$_GET["apid"])
2908  {
2909  // ilBlogPostingGUI::deactivatePage()
2910  include_once "Modules/Blog/classes/class.ilBlogPosting.php";
2911  $post = new ilBlogPosting((int)$_GET["apid"]);
2912  $post->setApproved(false);
2913  $post->setActive(false);
2914  $post->update(true, false, false);
2915 
2916  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2917  }
2918 
2919  $this->ctrl->redirect($this, "render");
2920  }
2921 
2922 
2926 
2927  function setContentStyleSheet($a_tpl = null)
2928  {
2929  global $tpl;
2930 
2931  if ($a_tpl != null)
2932  {
2933  $ctpl = $a_tpl;
2934  }
2935  else
2936  {
2937  $ctpl = $tpl;
2938  }
2939 
2940  $ctpl->setCurrentBlock("ContentStyle");
2941  $ctpl->setVariable("LOCATION_CONTENT_STYLESHEET",
2942  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
2943  $ctpl->parseCurrentBlock();
2944  }
2945 
2947  {
2948  $this->checkPermission("write");
2949 
2950  $this->tabs_gui->activateTab("settings");
2951  $this->setSettingsSubTabs("style");
2952 
2953  $form = $this->initStylePropertiesForm();
2954  $this->tpl->setContent($form->getHTML());
2955  }
2956 
2958  {
2959  global $ilSetting;
2960 
2961  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
2962  $this->lng->loadLanguageModule("style");
2963 
2964  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2965  $form = new ilPropertyFormGUI();
2966 
2967  $fixed_style = $ilSetting->get("fixed_content_style_id");
2968  $style_id = $this->object->getStyleSheetId();
2969 
2970  if ($fixed_style > 0)
2971  {
2972  $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
2973  $st->setValue(ilObject::_lookupTitle($fixed_style)." (".
2974  $this->lng->txt("global_fixed").")");
2975  $form->addItem($st);
2976  }
2977  else
2978  {
2979  $st_styles = ilObjStyleSheet::_getStandardStyles(true, false,
2980  $_GET["ref_id"]);
2981 
2982  $st_styles[0] = $this->lng->txt("default");
2983  ksort($st_styles);
2984 
2985  if ($style_id > 0)
2986  {
2987  // individual style
2988  if (!ilObjStyleSheet::_lookupStandard($style_id))
2989  {
2990  $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
2991  $st->setValue(ilObject::_lookupTitle($style_id));
2992  $form->addItem($st);
2993 
2994  // delete command
2995  $form->addCommandButton("editStyle", $this->lng->txt("style_edit_style"));
2996  $form->addCommandButton("deleteStyle", $this->lng->txt("style_delete_style"));
2997  }
2998  }
2999 
3000  if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id))
3001  {
3002  $style_sel = new ilSelectInputGUI($this->lng->txt("style_current_style"),
3003  "style_id");
3004  $style_sel->setOptions($st_styles);
3005  $style_sel->setValue($style_id);
3006  $form->addItem($style_sel);
3007 
3008  $form->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
3009  $form->addCommandButton("createStyle", $this->lng->txt("sty_create_ind_style"));
3010  }
3011  }
3012 
3013  $form->setTitle($this->lng->txt("blog_style"));
3014  $form->setFormAction($this->ctrl->getFormAction($this));
3015 
3016  return $form;
3017  }
3018 
3019  function createStyle()
3020  {
3021  $this->ctrl->redirectByClass("ilobjstylesheetgui", "create");
3022  }
3023 
3024  function editStyle()
3025  {
3026  $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
3027  }
3028 
3029  function deleteStyle()
3030  {
3031  $this->ctrl->redirectByClass("ilobjstylesheetgui", "delete");
3032  }
3033 
3035  {
3036  global $ilSetting;
3037 
3038  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
3039  if ($ilSetting->get("fixed_content_style_id") <= 0 &&
3040  (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
3041  || $this->object->getStyleSheetId() == 0))
3042  {
3043  $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
3044  $this->object->update();
3045 
3046  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3047  }
3048  $this->ctrl->redirect($this, "editStyleProperties");
3049  }
3050 
3056  public static function _goto($a_target)
3057  {
3058  if(substr($a_target, -3) == "wsp")
3059  {
3060  $id = explode("_", $a_target);
3061 
3062  $_GET["baseClass"] = "ilSharedResourceGUI";
3063  $_GET["wsp_id"] = $id[0];
3064  if(sizeof($id) == 3)
3065  {
3066  $_GET["gtp"] = $id[1];
3067  }
3068  }
3069  else
3070  {
3071  $id = explode("_", $a_target);
3072 
3073  $_GET["baseClass"] = "ilRepositoryGUI";
3074  $_GET["ref_id"] = $id[0];
3075  $_GET["cmd"] = "preview";
3076  if(sizeof($id) == 2)
3077  {
3078  $_GET["gtp"] = $id[1];
3079  }
3080  }
3081 
3082  include("ilias.php");
3083  exit;
3084  }
3085 }
3086 
3087 ?>