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