ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjPortfolioBaseGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
10abstract class ilObjPortfolioBaseGUI extends ilObject2GUI
11{
15 protected $help;
16
20 protected $main_menu;
21
22 protected $user_id; // [int]
23 protected $additional = array();
24 protected $perma_link; // [string]
25 protected $page_id; // [int]
26 protected $page_mode; // [string] preview|edit
27
32
37
41 protected $requested_back_url = "";
42
46 protected $ui;
47
48 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
49 {
50 global $DIC;
51
52 $this->user = $DIC->user();
53 $this->locator = $DIC["ilLocator"];
54 $this->toolbar = $DIC->toolbar();
55 $this->settings = $DIC->settings();
56 $this->tree = $DIC->repositoryTree();
57 $this->help = $DIC["ilHelp"];
58 $this->main_menu = $DIC["ilMainMenu"];
59 $this->tpl = $DIC["tpl"];
60 $ilUser = $DIC->user();
61 $this->ui = $DIC->ui();
62
63 $this->ui = $DIC->ui();
64
65 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
66
67 $this->user_id = $ilUser->getId();
68
69 $this->lng->loadLanguageModule("prtf");
70 $this->lng->loadLanguageModule("user");
71 $this->lng->loadLanguageModule("obj");
72
73 $this->requested_ppage = (int) $_REQUEST["ppage"];
74 $this->requested_user_page = (int) $_REQUEST["user_page"];
75
76 // temp sanitization, should be done smarter in the future
77 $back = str_replace("&amp;", ":::", $_REQUEST["back_url"]);
78 $back = preg_replace(
79 "/[^a-zA-Z0-9_\.\?=:\s]/",
80 "",
81 $back
82 );
83 $this->requested_back_url = str_replace(":::", "&amp;", $back);
84
85 $this->ctrl->setParameterbyClass("ilobjportfoliogui", "back_url", rawurlencode($this->requested_back_url));
86 }
87
88 protected function addLocatorItems()
89 {
90 $ilLocator = $this->locator;
91
92 if ($this->object) {
93 $ilLocator->addItem(
94 strip_tags($this->object->getTitle()),
95 $this->ctrl->getLinkTarget($this, "view")
96 );
97 }
98
99 if ($this->page_id) {
100 $page = $this->getPageInstance($this->page_id);
101 $title = $page->getTitle();
102 if ($page->getType() == ilPortfolioPage::TYPE_BLOG) {
103 $title = ilObject::_lookupTitle($title);
104 }
105 $this->ctrl->setParameterByClass($this->getPageGUIClassName(), "ppage", $this->page_id);
106 $ilLocator->addItem(
107 $title,
108 $this->ctrl->getLinkTargetByClass($this->getPageGUIClassName(), "edit")
109 );
110 }
111 }
112
113 protected function determinePageCall()
114 {
115 // edit
116 if ($this->requested_ppage > 0) {
117 if (!$this->checkPermissionBool("write")) {
118 $this->ctrl->redirect($this, "view");
119 }
120
121 $this->page_id = $this->requested_ppage;
122 $this->page_mode = "edit";
123 $this->ctrl->setParameter($this, "ppage", $this->page_id);
124 return true;
125 }
126 // preview
127 else {
128 $this->page_id = $this->requested_user_page;
129 $this->page_mode = "preview";
130 $this->ctrl->setParameter($this, "user_page", $this->page_id);
131 return false;
132 }
133 }
134
135 protected function handlePageCall($a_cmd)
136 {
137 if (!$this->page_id) {
138 $this->ctrl->redirect($this, "view");
139 }
140
141 $page_gui = $this->getPageGUIInstance($this->page_id);
142
143 $this->tabs_gui->clearTargets();
144 $this->tabs_gui->setBackTarget(
145 $this->lng->txt("back"),
146 $this->ctrl->getLinkTarget($this, "view")
147 );
148
149 // needed for editor
151 $this->object->getStyleSheetId(),
152 $this->getType()
153 ));
154
155 $ret = $this->ctrl->forwardCommand($page_gui);
156
157 if ($ret != "" && $ret !== true) {
158 // preview (fullscreen)
159 if ($this->page_mode == "preview") {
160 // embedded call which did not generate any output (e.g. calendar month navigation)
162 // suppress (portfolio) notes for blog postings
163 $this->preview(false, $ret, ($a_cmd != "previewEmbedded"));
164 } else {
165 $this->preview(false);
166 }
167 }
168 // edit
169 else {
170 $this->setContentStyleSheet();
171 if (is_string($ret)) {
172 $this->tpl->setContent($ret);
173 }
174 }
175 }
176 }
177
183 public function setAdditional($a_additional)
184 {
185 $this->additional = $a_additional;
186 }
187
193 public function getAdditional()
194 {
195 return $this->additional;
196 }
197
204 public function setPermaLink($a_obj_id, $a_type)
205 {
206 $this->perma_link = array("obj_id" => $a_obj_id, "type" => $a_type);
207 }
208
209
210 //
211 // CREATE/EDIT
212 //
213
214 protected function setSettingsSubTabs($a_active)
215 {
216 // #17455
217 $this->lng->loadLanguageModule($this->getType());
218
219 // general properties
220 $this->tabs_gui->addSubTab(
221 "properties",
222 $this->lng->txt($this->getType() . "_properties"),
223 $this->ctrl->getLinkTarget($this, 'edit')
224 );
225
226 $this->tabs_gui->addSubTab(
227 "style",
228 $this->lng->txt("obj_sty"),
229 $this->ctrl->getLinkTarget($this, 'editStyleProperties')
230 );
231
232 $this->tabs_gui->activateSubTab($a_active);
233 }
234
235 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
236 {
237 $this->setSettingsSubTabs("properties");
238
239
240 // profile picture
241 $ppic = new ilCheckboxInputGUI($this->lng->txt("prtf_profile_picture"), "ppic");
242 $a_form->addItem($ppic);
243
244 $prfa_set = new ilSetting("prfa");
245 if ($prfa_set->get("banner")) {
246 $dimensions = " (" . $prfa_set->get("banner_width") . "x" .
247 $prfa_set->get("banner_height") . ")";
248
249 $img = new ilImageFileInputGUI($this->lng->txt("prtf_banner") . $dimensions, "banner");
250 $a_form->addItem($img);
251
252 // show existing file
253 $file = $this->object->getImageFullPath(true);
254 if ($file) {
255 $img->setImage($file);
256 }
257 }
258
260 $section->setTitle($this->lng->txt('obj_features'));
261 $a_form->addItem($section);
262
263 // comments
264 $comments = new ilCheckboxInputGUI($this->lng->txt("prtf_public_comments"), "comments");
265 $a_form->addItem($comments);
266
267 /* #15000
268 $bg_color = new ilColorPickerInputGUI($this->lng->txt("prtf_background_color"), "bg_color");
269 $a_form->addItem($bg_color);
270
271 $font_color = new ilColorPickerInputGUI($this->lng->txt("prtf_font_color"), "font_color");
272 $a_form->addItem($font_color);
273 */
274 }
275
276 protected function getEditFormCustomValues(array &$a_values)
277 {
278 $a_values["comments"] = $this->object->hasPublicComments();
279 $a_values["ppic"] = $this->object->hasProfilePicture();
280 /*
281 $a_values["bg_color"] = $this->object->getBackgroundColor();
282 $a_values["font_color"] = $this->object->getFontColor();
283 */
284 }
285
286 public function updateCustom(ilPropertyFormGUI $a_form)
287 {
288 $this->object->setPublicComments($a_form->getInput("comments"));
289 $this->object->setProfilePicture($a_form->getInput("ppic"));
290 /*
291 $this->object->setBackgroundColor($a_form->getInput("bg_color"));
292 $this->object->setFontcolor($a_form->getInput("font_color"));
293 */
294
295 $prfa_set = new ilSetting("prfa");
296
297 if ($_FILES["banner"]["tmp_name"]) {
298 $this->object->uploadImage($_FILES["banner"]);
299 } elseif ($prfa_set->get('banner') and $a_form->getItemByPostVar("banner")->getDeletionFlag()) {
300 $this->object->deleteImage();
301 }
302 }
303
304
305 //
306 // PAGES
307 //
308
309 abstract protected function getPageInstance($a_page_id = null, $a_portfolio_id = null);
310
311 abstract protected function getPageGUIInstance($a_page_id);
312
313 abstract public function getPageGUIClassName();
314
318 public function view()
319 {
321 $ilToolbar = $this->toolbar;
324
325 if (!$this->checkPermissionBool("write")) {
326 $this->ctrl->redirect($this, "infoScreen");
327 }
328
329 $this->tabs_gui->activateTab("pages");
330
331
332 $button = ilLinkButton::getInstance();
333 $button->setCaption("prtf_add_page");
334 $button->setUrl($this->ctrl->getLinkTarget($this, "addPage"));
335 $ilToolbar->addStickyItem($button);
336
337 if (!$ilSetting->get('disable_wsp_blogs')) {
338 $button = ilLinkButton::getInstance();
339 $button->setCaption("prtf_add_blog");
340 $button->setUrl($this->ctrl->getLinkTarget($this, "addBlog"));
341 $ilToolbar->addStickyItem($button);
342 }
343
344
345 // #16571
346 $modal_html = "";
347 if ($this->getType() == "prtf") {
348 $ilToolbar->addSeparator();
349
350 $ui = $this->ui;
351
352 if ($this->object->isCommentsExportPossible()) {
353 $this->lng->loadLanguageModule("note");
354 $comment_export_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
355 $comment_modal = $comment_export_helper->getCommentIncludeModalDialog(
356 $this->lng->txt("export_html"),
357 $this->lng->txt("note_html_export_include_comments"),
358 $this->ctrl->getLinkTarget($this, "export"),
359 $this->ctrl->getLinkTarget($this, "exportWithComments")
360 );
361 $button = $ui->factory()->button()->standard($this->lng->txt("export_html"), '')
362 ->withOnClick($comment_modal->getShowSignal());
363 $ilToolbar->addComponent($button);
364 $modal_html = $ui->renderer()->render($comment_modal);
365 } else {
366 $button = ilLinkButton::getInstance();
367 $button->setCaption("export_html");
368 $button->setUrl($this->ctrl->getLinkTarget($this, "export"));
369 $ilToolbar->addButtonInstance($button);
370 }
371
372
373 $button = ilLinkButton::getInstance();
374 $button->setCaption("prtf_pdf");
375 $button->setUrl($this->ctrl->getLinkTarget($this, "exportPDFSelection"));
376 $ilToolbar->addButtonInstance($button);
377 }
378
379 $table = new ilPortfolioPageTableGUI($this, "view");
380
381
382 $this->tpl->setContent($message . $table->getHTML() . $modal_html);
383 }
384
388 protected function addPage()
389 {
390 $ilHelp = $this->help;
391
392 $this->tabs_gui->clearTargets();
393 $this->tabs_gui->setBackTarget(
394 $this->lng->txt("back"),
395 $this->ctrl->getLinkTarget($this, "view")
396 );
397
398 $ilHelp->setScreenIdComponent("prtf");
399 $ilHelp->setScreenId("add_page");
400
401
402 $form = $this->initPageForm("create");
403 $this->tpl->setContent($form->getHTML());
404 }
405
412 public function initPageForm($a_mode = "create")
413 {
414 $form = new ilPropertyFormGUI();
415 $form->setFormAction($this->ctrl->getFormAction($this));
416
417 // title
418 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
419 $ti->setMaxLength(200);
420 $ti->setRequired(true);
421 $form->addItem($ti);
422
423 // save and cancel commands
424 if ($a_mode == "create") {
426 if ($templates) {
427 $use_template = new ilRadioGroupInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
428 $use_template->setRequired(true);
429 $form->addItem($use_template);
430
431 $opt = new ilRadioOption($this->lng->txt("none"), 0);
432 $use_template->addOption($opt);
433
434 foreach ($templates as $templ) {
435 $templ->readObject();
436
437 $opt = new ilRadioOption($templ->getTitle() . $templ->getPreview(), $templ->getId());
438 $use_template->addOption($opt);
439 }
440 }
441
442 $form->setTitle($this->lng->txt("prtf_add_page") . ": " .
443 $this->object->getTitle());
444 $form->addCommandButton("savePage", $this->lng->txt("save"));
445 $form->addCommandButton("view", $this->lng->txt("cancel"));
446 } else {
447 /* edit is done directly in table gui
448 $form->setTitle($this->lng->txt("prtf_edit_page"));
449 $form->addCommandButton("updatePage", $this->lng->txt("save"));
450 $form->addCommandButton("view", $this->lng->txt("cancel"));
451 */
452 }
453
454 return $form;
455 }
456
460 public function savePage()
461 {
462 $form = $this->initPageForm("create");
463 if ($form->checkInput() && $this->checkPermissionBool("write")) {
464 $page = $this->getPageInstance();
465 $page->setType(ilPortfolioPage::TYPE_PAGE);
466 $page->setTitle($form->getInput("title"));
467
468 // use template as basis
469 $layout_id = $form->getInput("tmpl");
470 if ($layout_id) {
471 $layout_obj = new ilPageLayout($layout_id);
472 $page->setXMLContent($layout_obj->getXMLContent());
473 }
474
475 $page->create();
476
477 ilUtil::sendSuccess($this->lng->txt("prtf_page_created"), true);
478 $this->ctrl->redirect($this, "view");
479 }
480
481 $this->tabs_gui->clearTargets();
482 $this->tabs_gui->setBackTarget(
483 $this->lng->txt("back"),
484 $this->ctrl->getLinkTarget($this, "view")
485 );
486
487 $form->setValuesByPost();
488 $this->tpl->setContent($form->getHtml());
489 }
490
494 protected function addBlog()
495 {
496 $ilHelp = $this->help;
497
498 $this->tabs_gui->clearTargets();
499 $this->tabs_gui->setBackTarget(
500 $this->lng->txt("back"),
501 $this->ctrl->getLinkTarget($this, "view")
502 );
503
504 $ilHelp->setScreenIdComponent("prtf");
505 $ilHelp->setScreenId("add_blog");
506
507 $form = $this->initBlogForm();
508 $this->tpl->setContent($form->getHTML());
509 }
510
511 abstract protected function initBlogForm();
512
513 abstract protected function saveBlog();
514
519 {
520 if (!$this->checkPermissionBool("write")) {
521 return;
522 }
523
524 $title_changes = array();
525
526 if (is_array($_POST["order"])) {
527 foreach ($_POST["order"] as $k => $v) {
528 $page = $this->getPageInstance(ilUtil::stripSlashes($k));
529 if ($_POST["title"][$k]) {
530 $new_title = trim(ilUtil::stripSlashes($_POST["title"][$k]));
531 if ($page->getTitle() != $new_title) {
532 $title_changes[$page->getId()] = array("old" => $page->getTitle(), "new" => $new_title);
533 $page->setTitle($new_title);
534 }
535 }
536 $page->setOrderNr(ilUtil::stripSlashes($v));
537 $page->update();
538 }
539 ilPortfolioPage::fixOrdering($this->object->getId());
540 }
541
542 $this->object->fixLinksOnTitleChange($title_changes);
543
544 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
545 $this->ctrl->redirect($this, "view");
546 }
547
552 {
553 $prtf_pages = $_REQUEST["prtf_pages"];
554
555 if (!is_array($prtf_pages) || count($prtf_pages) == 0) {
556 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
557 $this->ctrl->redirect($this, "view");
558 } else {
559 $this->tabs_gui->activateTab("pages");
560
561 $cgui = new ilConfirmationGUI();
562 $cgui->setFormAction($this->ctrl->getFormAction($this));
563 $cgui->setHeaderText($this->lng->txt("prtf_sure_delete_portfolio_pages"));
564 $cgui->setCancel($this->lng->txt("cancel"), "view");
565 $cgui->setConfirm($this->lng->txt("delete"), "deletePortfolioPages");
566
567 foreach ($prtf_pages as $id) {
568 $id = (int) $id;
569 $page = $this->getPageInstance((int) $id);
570 if ($page->getPortfolioId() != $this->object->getId()) {
571 continue;
572 }
573
574 $title = $page->getTitle();
575 if ($page->getType() == ilPortfolioPage::TYPE_BLOG) {
576 $title = $this->lng->txt("obj_blog") . ": " . ilObject::_lookupTitle((int) $title);
577 }
578 $cgui->addItem("prtf_pages[]", $id, $title);
579 }
580
581 $this->tpl->setContent($cgui->getHTML());
582 }
583 }
584
588 public function deletePortfolioPages()
589 {
590 if (!$this->checkPermissionBool("write")) {
591 return;
592 }
593
594 if (is_array($_POST["prtf_pages"])) {
595 foreach ($_POST["prtf_pages"] as $id) {
596 $id = (int) $id;
597 $page = $this->getPageInstance($id);
598 $page->delete();
599 }
600 }
601 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_page_deleted"), true);
602 $this->ctrl->redirect($this, "view");
603 }
604
608 public function preview($a_return = false, $a_content = false, $a_show_notes = true)
609 {
612
613 $portfolio_id = $this->object->getId();
614 $user_id = $this->object->getOwner();
615
616 $this->tabs_gui->clearTargets();
617
618 $pages = ilPortfolioPage::getAllPortfolioPages($portfolio_id);
619 $current_page = $this->requested_user_page;
620
621 // validate current page
622 if ($pages && $current_page) {
623 $found = false;
624 foreach ($pages as $page) {
625 if ($page["id"] == $current_page) {
626 $found = true;
627 break;
628 }
629 }
630 if (!$found) {
631 $current_page = null;
632 }
633 }
634
635 // display first page of portfolio if none given
636 if (!$current_page && $pages) {
637 $current_page = $pages;
638 $current_page = array_shift($current_page);
639 $current_page = $current_page["id"];
640 }
641
642 // #13788 - keep page after login
643 if ($this->user_id == ANONYMOUS_USER_ID &&
644 $this->getType() == "prtf") {
645 $this->tpl->setLoginTargetPar("prtf_" . $this->object->getId() . "_" . $current_page);
646 }
647
648 $back_caption = "";
649
650 // public profile
651 if ($this->requested_back_url != "") {
653 } elseif ($_GET["baseClass"] != "ilPublicUserProfileGUI" &&
654 $this->user_id && $this->user_id != ANONYMOUS_USER_ID) {
655 if (!$this->checkPermissionBool("write")) {
656 // shared
657 if ($this->getType() == "prtf") {
658 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", $this->object->getOwner());
659 $back = $this->ctrl->getLinkTargetByClass(array("ildashboardgui", "ilportfoliorepositorygui"), "showOther");
660 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", "");
661 }
662 // listgui / parent container
663 else {
664 // #12819
666 $parent_id = $tree->getParentId($this->node_id);
668 }
669 }
670 // owner
671 else {
672 $back = $this->ctrl->getLinkTarget($this, "view");
673 if ($this->getType() == "prtf") {
674 $back_caption = $this->lng->txt("prtf_back_to_portfolio_owner");
675 } else {
676 // #19316
677 $this->lng->loadLanguageModule("prtt");
678 $back_caption = $this->lng->txt("prtt_edit");
679 }
680 }
681 }
682
683 $ilMainMenu = $this->main_menu;
684 $ilMainMenu->setMode(ilMainMenuGUI::MODE_TOPBAR_ONLY);
685 if ($back) {
686 // might already be set in ilPublicUserProfileGUI
687 $ilMainMenu->setTopBarBack($back, $back_caption);
688 }
689
690 // render tabs
691 $current_blog = null;
692 if (count($pages) > 1) {
693 foreach ($pages as $p) {
694 if ($p["type"] == ilPortfolioPage::TYPE_BLOG) {
695 // needed for blog comments (see below)
696 if ($p["id"] == $current_page) {
697 $current_blog = (int) $p["title"];
698 }
699 $p["title"] = ilObjBlog::_lookupTitle($p["title"]);
700 }
701
702 $this->ctrl->setParameter($this, "user_page", $p["id"]);
703 $this->tabs_gui->addTab(
704 "user_page_" . $p["id"],
705 $p["title"],
706 $this->ctrl->getLinkTarget($this, "preview")
707 );
708 }
709
710 $this->tabs_gui->activateTab("user_page_" . $current_page);
711 }
712
713 $this->ctrl->setParameter($this, "user_page", $current_page);
714
715 if (!$a_content) {
716 // #18291
717 if ($current_page) {
718 // get current page content
719 $page_gui = $this->getPageGUIInstance($current_page);
720 $page_gui->setEmbedded(true);
721
722 $content = $this->ctrl->getHTML($page_gui);
723 }
724 } else {
725 $content = $a_content;
726 }
727
728 if ($a_return && $this->checkPermissionBool("write")) {
729 return $content;
730 }
731
732 // blog posting comments are handled within the blog
733 $notes = "";
734 if ($a_show_notes && $this->object->hasPublicComments() && !$current_blog && $current_page) {
735 $note_gui = new ilNoteGUI($portfolio_id, $current_page, "pfpg");
736
737 $note_gui->setRepositoryMode(false);
738 $note_gui->enablePublicNotes(true);
739 $note_gui->enablePrivateNotes(false);
740
741 $note_gui->enablePublicNotesDeletion(($this->user_id == $user_id) &&
742 $ilSetting->get("comments_del_tutor", 1));
743
744 $next_class = $this->ctrl->getNextClass($this);
745 if ($next_class == "ilnotegui") {
746 $notes = $this->ctrl->forwardCommand($note_gui);
747 } else {
748 $notes = $note_gui->getNotesHTML();
749 }
750 }
751
752 if ($this->perma_link === null) {
753 if ($this->getType() == "prtf") {
754 $this->tpl->setPermanentLink($this->getType(), $this->object->getId(), "_" . $current_page);
755 } else {
756 $this->tpl->setPermanentLink($this->getType(), $this->object->getRefId());
757 }
758 } else {
759 $this->tpl->setPermanentLink($this->perma_link["type"], $this->perma_link["obj_id"]);
760 }
761
762 // #18208 - see ilPortfolioTemplatePageGUI::getPageContentUserId()
763 if ($this->getType() == "prtt" && !$this->checkPermissionBool("write")) {
764 $user_id = $ilUser->getId();
765 }
766
767 self::renderFullscreenHeader($this->object, $this->tpl, $user_id);
768
769 // #13564
770 $this->ctrl->setParameter($this, "user_page", "");
771 //$this->tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
772 $this->ctrl->setParameter($this, "user_page", $this->page_id);
773
774 // blog pages do their own (page) style handling
775 if (!$current_blog) {
776 $content = '<div id="ilCOPageContent" class="ilc_page_cont_PageContainer">' .
777 '<div class="ilc_page_Page">' .
778 $content .
779 '</div></div>';
780
781 $this->setContentStyleSheet($this->tpl);
782 }
783
784 $this->showEditButton($current_page);
785
786 // #10717
787 $this->tpl->setContent($content .
788 '<div class="ilClearFloat">' . $notes . '</div>');
789 }
790
791
795 protected function showEditButton($page_id)
796 {
797 $page_class = ($this->getType() == "prtt")
798 ? "ilPortfolioTemplatePageGUI"
799 : "ilportfoliopagegui";
800 $button = null;
801 if ($this->checkPermissionBool("write") &&
803 if ($this->getType() === "prtt") {
804 $button = $this->ui->factory()->button()->standard(
805 $this->lng->txt("prtt_edit"),
806 $this->ctrl->getLinkTargetByClass(["ilobjportfoliotemplategui"], "view")
807 );
808 } else {
809 $button = $this->ui->factory()->button()->standard(
810 $this->lng->txt("prtf_edit_portfolio"),
811 $this->ctrl->getLinkTargetByClass(["ilobjportfoliogui"], "view")
812 );
813 }
814 $this->toolbar->addComponent($button);
815 $button = null;
816 }
818 $this->ctrl->setParameterByClass($page_class, "ppage", $page_id);
819 $button = $this->ui->factory()->button()->standard(
820 $this->lng->txt("edit_page"),
821 $this->ctrl->getLinkTargetByClass($page_class, "edit")
822 );
823 if ($this->checkPermissionBool("write")) {
824 $this->toolbar->addComponent($button);
825 }
826 $button = null;
827 } else {
828 if ($this->getType() != "prtt") {
829 if ($page_id > 0) {
830 /*
831 $this->ctrl->setParameterByClass("ilobjbloggui", "ppage", $page_id);
832 $this->ctrl->setParameterByClass("ilobjbloggui", "prt_id", (int) $_GET["prt_id"]);
833 $button = $this->ui->factory()->button()->standard(
834 $this->lng->txt("edit"),
835 $this->ctrl->getLinkTargetByClass([$page_class, "ilobjbloggui"], "render")
836 );*/
837 }
838 } else { // portfolio template, blog page cannot be edited -> link to overview
839 }
840 }
841 if ($button && $this->checkPermissionBool("write")) {
842 $this->tpl->setHeaderActionMenu($this->ui->renderer()->render($button));
843 }
844 }
845
853 public static function renderFullscreenHeader($a_portfolio, $a_tpl, $a_user_id, $a_export = false)
854 {
855 global $DIC;
856
857 $ilUser = $DIC->user();
858
859 if (!$a_export) {
861 $a_portfolio->getType(),
862 ($a_portfolio->getType() == "prtt")
863 ? $a_portfolio->getRefId()
864 : $a_portfolio->getId(),
865 $a_portfolio->getId(),
866 $ilUser->getId()
867 );
868 }
869
870 $name = ilObjUser::_lookupName($a_user_id);
871 $name = $name["lastname"] . ", " . ($t = $name["title"] ? $t . " " : "") . $name["firstname"];
872
873 // show banner?
874 $banner = $banner_width = $banner_height = false;
875 $prfa_set = new ilSetting("prfa");
876 if ($prfa_set->get("banner")) {
877 $banner = ilWACSignedPath::signFile($a_portfolio->getImageFullPath());
878 $banner_width = $prfa_set->get("banner_width");
879 $banner_height = $prfa_set->get("banner_height");
880 if ($a_export) {
881 $banner = basename($banner);
882 }
883 }
884
885 // profile picture
886 $ppic = null;
887 if ($a_portfolio->hasProfilePicture()) {
888 $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
889 if ($a_export) {
890 $ppic = basename($ppic);
891 }
892 }
893
894 $a_tpl->resetHeaderBlock(false);
895 // $a_tpl->setBackgroundColor($a_portfolio->getBackgroundColor());
896 // @todo fix this
897 $a_tpl->setBanner($banner, $banner_width, $banner_height, $a_export);
898 $a_tpl->setTitleIcon($ppic);
899 $a_tpl->setTitle($a_portfolio->getTitle());
900 // $a_tpl->setTitleColor($a_portfolio->getFontColor());
901 $a_tpl->setDescription($name);
902
903 // to get rid of locator in portfolio template preview
904 $a_tpl->setVariable("LOCATOR", "");
905
906 // :TODO: obsolete?
907 // $a_tpl->setBodyClass("std ilExternal ilPortfolio");
908 }
909
910 public function export($a_with_comments = false)
911 {
912 $port_export = new \ILIAS\Portfolio\Export\PortfolioHtmlExport($this);
913 $port_export->includeComments($a_with_comments);
914 $zip = $port_export->exportHtml();
915
916 ilUtil::deliverFile($zip, $this->object->getTitle() . ".zip", '', false, true);
917 }
918
919 public function exportWithComments()
920 {
921 $this->export(true);
922 }
923
927 public function copyPageForm($a_form = null)
928 {
929 $prtf_pages = $_REQUEST["prtf_pages"];
930
931 if (!is_array($prtf_pages) || count($prtf_pages) == 0) {
932 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
933 $this->ctrl->redirect($this, "view");
934 } else {
935 $this->tabs_gui->activateTab("pages");
936
937 if (!$a_form) {
938 $a_form = $this->initCopyPageForm();
939 }
940
941 foreach ($prtf_pages as $page_id) {
942 $item = new ilHiddenInputGUI("prtf_pages[]");
943 $item->setValue((int) $page_id);
944 $a_form->addItem($item);
945 }
946
947 $this->tpl->setContent($a_form->getHTML());
948 }
949 }
950
951 public function copyPage()
952 {
953 $form = $this->initCopyPageForm();
954 if ($form->checkInput()) {
955 // existing
956 if ($form->getInput("target") == "old") {
957 $portfolio_id = $form->getInput("prtf");
958 }
959 // new
960 else {
961 $portfolio = new ilObjPortfolio();
962 $portfolio->setTitle($form->getInput("title"));
963 $portfolio->create();
964 $portfolio_id = $portfolio->getId();
965 }
966
967 // copy page(s)
968 foreach ($_POST["prtf_pages"] as $page_id) {
969 $page_id = (int) $page_id;
970 $source = $this->getPageInstance($page_id);
971 $target = $this->getPageInstance(null, $portfolio_id);
972 $target->setXMLContent($source->copyXmlContent(true)); // copy mobs
973 $target->setType($source->getType());
974 $target->setTitle($source->getTitle());
975 $target->create();
976 }
977
978 ilUtil::sendSuccess($this->lng->txt("prtf_pages_copied"), true);
979 $this->ctrl->redirect($this, "view");
980 }
981
982 $form->setValuesByPost();
983 $this->copyPageForm($form);
984 }
985
986 abstract protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form);
987
988 public function initCopyPageForm()
989 {
990 $form = new ilPropertyFormGUI();
991 $form->setFormAction($this->ctrl->getFormAction($this));
992 $form->setTitle($this->lng->txt("prtf_copy_page"));
993
994 $this->initCopyPageFormOptions($form);
995
996 $form->addCommandButton("copyPage", $this->lng->txt("save"));
997 $form->addCommandButton("view", $this->lng->txt("cancel"));
998
999 return $form;
1000 }
1001
1002
1006
1007 public function setContentStyleSheet($a_tpl = null)
1008 {
1009 $tpl = $this->tpl;
1010
1011 if ($a_tpl != null) {
1012 $ctpl = $a_tpl;
1013 } else {
1014 $ctpl = $tpl;
1015 }
1016
1017 $ctpl->setCurrentBlock("ContentStyle");
1018 $ctpl->setVariable(
1019 "LOCATION_CONTENT_STYLESHEET",
1020 ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
1021 );
1022 $ctpl->parseCurrentBlock();
1023 }
1024
1025 public function editStyleProperties()
1026 {
1027 $this->checkPermission("write");
1028
1029 $this->tabs_gui->activateTab("settings");
1030 $this->setSettingsSubTabs("style");
1031
1032 $form = $this->initStylePropertiesForm();
1033 $this->tpl->setContent($form->getHTML());
1034 }
1035
1036 public function initStylePropertiesForm()
1037 {
1039
1040 $this->lng->loadLanguageModule("style");
1041
1042 $form = new ilPropertyFormGUI();
1043
1044 $fixed_style = $ilSetting->get("fixed_content_style_id");
1045 $style_id = $this->object->getStyleSheetId();
1046
1047 if ($fixed_style > 0) {
1048 $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
1049 $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
1050 $this->lng->txt("global_fixed") . ")");
1051 $form->addItem($st);
1052 } else {
1054 true,
1055 false,
1056 $_GET["ref_id"]
1057 );
1058
1059 $st_styles[0] = $this->lng->txt("default");
1060 ksort($st_styles);
1061
1062 if ($style_id > 0) {
1063 // individual style
1064 if (!ilObjStyleSheet::_lookupStandard($style_id)) {
1065 $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
1066 $st->setValue(ilObject::_lookupTitle($style_id));
1067 $form->addItem($st);
1068
1069 // delete command
1070 $form->addCommandButton("editStyle", $this->lng->txt("style_edit_style"));
1071 $form->addCommandButton("deleteStyle", $this->lng->txt("style_delete_style"));
1072 }
1073 }
1074
1075 if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
1076 $style_sel = new ilSelectInputGUI(
1077 $this->lng->txt("style_current_style"),
1078 "style_id"
1079 );
1080 $style_sel->setOptions($st_styles);
1081 $style_sel->setValue($style_id);
1082 $form->addItem($style_sel);
1083
1084 $form->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
1085 $form->addCommandButton("createStyle", $this->lng->txt("sty_create_ind_style"));
1086 }
1087 }
1088
1089 $form->setTitle($this->lng->txt($this->getType() . "_style"));
1090 $form->setFormAction($this->ctrl->getFormAction($this));
1091
1092 return $form;
1093 }
1094
1095 public function createStyle()
1096 {
1097 $this->ctrl->redirectByClass("ilobjstylesheetgui", "create");
1098 }
1099
1100 public function editStyle()
1101 {
1102 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
1103 }
1104
1105 public function deleteStyle()
1106 {
1107 $this->ctrl->redirectByClass("ilobjstylesheetgui", "delete");
1108 }
1109
1110 public function saveStyleSettings()
1111 {
1113
1114 if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1115 (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1116 || $this->object->getStyleSheetId() == 0)) {
1117 $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1118 $this->object->update();
1119
1120 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1121 }
1122 $this->ctrl->redirect($this, "editStyleProperties");
1123 }
1124}
user()
Definition: user.php:4
$section
Definition: Utf8Test.php:83
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
This class represents a checkbox property in a property form.
Confirmation screen class.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
This class represents an image file property in a property form.
static getInstance()
Factory.
This class represents a non editable value in a property form.
Notes GUI class.
Portfolio view gui base class.
initPageForm($a_mode="create")
Init portfolio page form.
setPermaLink($a_obj_id, $a_type)
Set custom perma link (used in public profile?)
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
addBlog()
Show portfolio blog page creation form.
addPage()
Show portfolio page creation form.
view()
Show list of portfolio pages.
savePage()
Create new portfolio page.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
getAdditional()
Get Additonal Information.
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
confirmPortfolioPageDeletion()
Confirm portfolio deletion.
showEditButton($page_id)
Show edit button.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
copyPageForm($a_form=null)
Select target portfolio for page(s) copy.
deletePortfolioPages()
Delete portfolio pages.
getPageInstance($a_page_id=null, $a_portfolio_id=null)
savePortfolioPagesOrdering()
Save ordering of portfolio pages.
export($a_with_comments=false)
addLocatorItems()
Functions to be overwritten.
static renderFullscreenHeader($a_portfolio, $a_tpl, $a_user_id, $a_export=false)
Render banner, user name.
setAdditional($a_additional)
Set Additonal Information (used in public profile?)
preview($a_return=false, $a_content=false, $a_show_notes=true)
Show user page.
getPageGUIInstance($a_page_id)
static _lookupStandard($a_id)
Lookup standard flag.
static _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.
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static _getPersonalPicturePath( $a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false, $html_export=false)
Get path to personal picture.
static _lookupName($a_user_id)
lookup user name
New implementation of ilObjectGUI.
getType()
Functions that must be overwritten.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
static _lookupTitle($a_id)
lookup object title
static _lookupTitle($a_id)
lookup object title
Class ilPageLayout.
static activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
static lookupType($a_page_id)
Lookup type.
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
static fixOrdering($a_portfolio_id)
Fix ordering.
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.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
ILIAS Setting Class.
This class represents a text property in a property form.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
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 signFile($path_to_file)
const ANONYMOUS_USER_ID
Definition: constants.php:25
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$img
Definition: imgupload.php:57
$ilUser
Definition: imgupload.php:18
if($format !==null) $name
Definition: metadata.php:230
$source
Definition: metadata.php:76
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2
ui()
Definition: ui.php:5
$message
Definition: xapiexit.php:14