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