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