ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
43 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
44 {
45 global $DIC;
46
47 $this->user = $DIC->user();
48 $this->locator = $DIC["ilLocator"];
49 $this->toolbar = $DIC->toolbar();
50 $this->settings = $DIC->settings();
51 $this->tree = $DIC->repositoryTree();
52 $this->help = $DIC["ilHelp"];
53 $this->main_menu = $DIC["ilMainMenu"];
54 $this->tpl = $DIC["tpl"];
55 $ilUser = $DIC->user();
56 $this->ui = $DIC->ui();
57
58 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
59
60 $this->user_id = $ilUser->getId();
61
62 $this->lng->loadLanguageModule("prtf");
63 $this->lng->loadLanguageModule("user");
64 $this->lng->loadLanguageModule("obj");
65
66 $this->requested_ppage = (int) $_REQUEST["ppage"];
67 $this->requested_user_page = (int) $_REQUEST["user_page"];
68
69 // temp sanitization, should be done smarter in the future
70 $back = str_replace("&amp;", ":::", $_REQUEST["back_url"]);
71 $back = preg_replace(
72 "/[^a-zA-Z0-9_\.\?=:\s]/",
73 "",
74 $back
75 );
76 $this->requested_back_url = str_replace(":::", "&amp;", $back);
77
78 $this->ctrl->setParameterbyClass("ilobjportfoliogui", "back_url", rawurlencode($this->requested_back_url));
79 }
80
81 protected function addLocatorItems()
82 {
83 $ilLocator = $this->locator;
84
85 if ($this->object) {
86 $ilLocator->addItem(
87 strip_tags($this->object->getTitle()),
88 $this->ctrl->getLinkTarget($this, "view")
89 );
90 }
91
92 if ($this->page_id) {
93 $page = $this->getPageInstance($this->page_id);
94 $title = $page->getTitle();
95 if ($page->getType() == ilPortfolioPage::TYPE_BLOG) {
96 $title = ilObject::_lookupTitle($title);
97 }
98 $this->ctrl->setParameterByClass($this->getPageGUIClassName(), "ppage", $this->page_id);
99 $ilLocator->addItem(
100 $title,
101 $this->ctrl->getLinkTargetByClass($this->getPageGUIClassName(), "edit")
102 );
103 }
104 }
105
106 protected function determinePageCall()
107 {
108 // edit
109 if ($this->requested_ppage > 0) {
110 if (!$this->checkPermissionBool("write")) {
111 $this->ctrl->redirect($this, "view");
112 }
113
114 $this->page_id = $this->requested_ppage;
115 $this->page_mode = "edit";
116 $this->ctrl->setParameter($this, "ppage", $this->page_id);
117 return true;
118 }
119 // preview
120 else {
121 $this->page_id = $this->requested_user_page;
122 $this->page_mode = "preview";
123 $this->ctrl->setParameter($this, "user_page", $this->page_id);
124 return false;
125 }
126 }
127
128 protected function handlePageCall($a_cmd)
129 {
130 $this->tabs_gui->clearTargets();
131 $this->tabs_gui->setBackTarget(
132 $this->lng->txt("back"),
133 $this->ctrl->getLinkTarget($this, "view")
134 );
135
136 if (!$this->page_id) {
137 $this->ctrl->redirect($this, "view");
138 }
139
140 $page_gui = $this->getPageGUIInstance($this->page_id);
141
142 // needed for editor
144 $this->object->getStyleSheetId(),
145 $this->getType()
146 ));
147
148 $ret = $this->ctrl->forwardCommand($page_gui);
149
150 if ($ret != "" && $ret !== true) {
151 // preview (fullscreen)
152 if ($this->page_mode == "preview") {
153 // embedded call which did not generate any output (e.g. calendar month navigation)
155 // suppress (portfolio) notes for blog postings
156 $this->preview(false, $ret, ($a_cmd != "previewEmbedded"));
157 } else {
158 $this->preview(false);
159 }
160 }
161 // edit
162 else {
163 $this->setContentStyleSheet();
164 if (is_string($ret)) {
165 $this->tpl->setContent($ret);
166 }
167 }
168 }
169 }
170
176 public function setAdditional($a_additional)
177 {
178 $this->additional = $a_additional;
179 }
180
186 public function getAdditional()
187 {
188 return $this->additional;
189 }
190
197 public function setPermaLink($a_obj_id, $a_type)
198 {
199 $this->perma_link = array("obj_id" => $a_obj_id, "type" => $a_type);
200 }
201
202
203 //
204 // CREATE/EDIT
205 //
206
207 protected function setSettingsSubTabs($a_active)
208 {
209 // #17455
210 $this->lng->loadLanguageModule($this->getType());
211
212 // general properties
213 $this->tabs_gui->addSubTab(
214 "properties",
215 $this->lng->txt($this->getType() . "_properties"),
216 $this->ctrl->getLinkTarget($this, 'edit')
217 );
218
219 $this->tabs_gui->addSubTab(
220 "style",
221 $this->lng->txt("obj_sty"),
222 $this->ctrl->getLinkTarget($this, 'editStyleProperties')
223 );
224
225 $this->tabs_gui->activateSubTab($a_active);
226 }
227
228 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
229 {
230 $this->setSettingsSubTabs("properties");
231
232
233 // profile picture
234 $ppic = new ilCheckboxInputGUI($this->lng->txt("prtf_profile_picture"), "ppic");
235 $a_form->addItem($ppic);
236
237 $prfa_set = new ilSetting("prfa");
238 if ($prfa_set->get("banner")) {
240
241 $dimensions = " (" . $prfa_set->get("banner_width") . "x" .
242 $prfa_set->get("banner_height") . ")";
243
244 $img = new ilImageFileInputGUI($this->lng->txt("prtf_banner") . $dimensions, "banner");
245 $a_form->addItem($img);
246
247 // show existing file
248 $file = $this->object->getImageFullPath(true);
249 if ($file) {
250 $img->setImage($file);
251 }
252 }
253
255 $section->setTitle($this->lng->txt('obj_features'));
256 $a_form->addItem($section);
257
258 // comments
259 $comments = new ilCheckboxInputGUI($this->lng->txt("prtf_public_comments"), "comments");
260 $a_form->addItem($comments);
261
262 /* #15000
263 $bg_color = new ilColorPickerInputGUI($this->lng->txt("prtf_background_color"), "bg_color");
264 $a_form->addItem($bg_color);
265
266 $font_color = new ilColorPickerInputGUI($this->lng->txt("prtf_font_color"), "font_color");
267 $a_form->addItem($font_color);
268 */
269 }
270
271 protected function getEditFormCustomValues(array &$a_values)
272 {
273 $a_values["comments"] = $this->object->hasPublicComments();
274 $a_values["ppic"] = $this->object->hasProfilePicture();
275 /*
276 $a_values["bg_color"] = $this->object->getBackgroundColor();
277 $a_values["font_color"] = $this->object->getFontColor();
278 */
279 }
280
281 public function updateCustom(ilPropertyFormGUI $a_form)
282 {
283 $this->object->setPublicComments($a_form->getInput("comments"));
284 $this->object->setProfilePicture($a_form->getInput("ppic"));
285 /*
286 $this->object->setBackgroundColor($a_form->getInput("bg_color"));
287 $this->object->setFontcolor($a_form->getInput("font_color"));
288 */
289
290 $prfa_set = new ilSetting("prfa");
291
292 if ($_FILES["banner"]["tmp_name"]) {
293 $this->object->uploadImage($_FILES["banner"]);
294 } elseif ($prfa_set->get('banner') and $a_form->getItemByPostVar("banner")->getDeletionFlag()) {
295 $this->object->deleteImage();
296 }
297 }
298
299
300 //
301 // PAGES
302 //
303
304 abstract protected function getPageInstance($a_page_id = null, $a_portfolio_id = null);
305
306 abstract protected function getPageGUIInstance($a_page_id);
307
308 abstract public function getPageGUIClassName();
309
313 public function view()
314 {
315 $ilToolbar = $this->toolbar;
318
319 if (!$this->checkPermissionBool("write")) {
320 $this->ctrl->redirect($this, "infoScreen");
321 }
322
323 $this->tabs_gui->activateTab("pages");
324
325
326 $button = ilLinkButton::getInstance();
327 $button->setCaption("prtf_add_page");
328 $button->setUrl($this->ctrl->getLinkTarget($this, "addPage"));
329 $ilToolbar->addStickyItem($button);
330
331 if (!$ilSetting->get('disable_wsp_blogs')) {
332 $button = ilLinkButton::getInstance();
333 $button->setCaption("prtf_add_blog");
334 $button->setUrl($this->ctrl->getLinkTarget($this, "addBlog"));
335 $ilToolbar->addStickyItem($button);
336 }
337
338
339 // #16571
340 if ($this->getType() == "prtf") {
341 $ilToolbar->addSeparator();
342
343 $button = ilLinkButton::getInstance();
344 $button->setCaption("export_html");
345 $button->setUrl($this->ctrl->getLinkTarget($this, "export"));
346 $ilToolbar->addButtonInstance($button);
347
348 $button = ilLinkButton::getInstance();
349 $button->setCaption("prtf_pdf");
350 $button->setUrl($this->ctrl->getLinkTarget($this, "exportPDFSelection"));
351 $ilToolbar->addButtonInstance($button);
352 }
353
354 $table = new ilPortfolioPageTableGUI($this, "view");
355
356
357 $this->tpl->setContent($message . $table->getHTML());
358 }
359
363 protected function addPage()
364 {
365 $ilHelp = $this->help;
366
367 $this->tabs_gui->clearTargets();
368 $this->tabs_gui->setBackTarget(
369 $this->lng->txt("back"),
370 $this->ctrl->getLinkTarget($this, "view")
371 );
372
373 $ilHelp->setScreenIdComponent("prtf");
374 $ilHelp->setScreenId("add_page");
375
376
377 $form = $this->initPageForm("create");
378 $this->tpl->setContent($form->getHTML());
379 }
380
387 public function initPageForm($a_mode = "create")
388 {
389 $form = new ilPropertyFormGUI();
390 $form->setFormAction($this->ctrl->getFormAction($this));
391
392 // title
393 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
394 $ti->setMaxLength(200);
395 $ti->setRequired(true);
396 $form->addItem($ti);
397
398 // save and cancel commands
399 if ($a_mode == "create") {
401 if ($templates) {
402 $use_template = new ilRadioGroupInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
403 $use_template->setRequired(true);
404 $form->addItem($use_template);
405
406 $opt = new ilRadioOption($this->lng->txt("none"), 0);
407 $use_template->addOption($opt);
408
409 foreach ($templates as $templ) {
410 $templ->readObject();
411
412 $opt = new ilRadioOption($templ->getTitle() . $templ->getPreview(), $templ->getId());
413 $use_template->addOption($opt);
414 }
415 }
416
417 $form->setTitle($this->lng->txt("prtf_add_page") . ": " .
418 $this->object->getTitle());
419 $form->addCommandButton("savePage", $this->lng->txt("save"));
420 $form->addCommandButton("view", $this->lng->txt("cancel"));
421 } else {
422 /* edit is done directly in table gui
423 $form->setTitle($this->lng->txt("prtf_edit_page"));
424 $form->addCommandButton("updatePage", $this->lng->txt("save"));
425 $form->addCommandButton("view", $this->lng->txt("cancel"));
426 */
427 }
428
429 return $form;
430 }
431
435 public function savePage()
436 {
437 $form = $this->initPageForm("create");
438 if ($form->checkInput() && $this->checkPermissionBool("write")) {
439 $page = $this->getPageInstance();
440 $page->setType(ilPortfolioPage::TYPE_PAGE);
441 $page->setTitle($form->getInput("title"));
442
443 // use template as basis
444 $layout_id = $form->getInput("tmpl");
445 if ($layout_id) {
446 $layout_obj = new ilPageLayout($layout_id);
447 $page->setXMLContent($layout_obj->getXMLContent());
448 }
449
450 $page->create();
451
452 ilUtil::sendSuccess($this->lng->txt("prtf_page_created"), true);
453 $this->ctrl->redirect($this, "view");
454 }
455
456 $this->tabs_gui->clearTargets();
457 $this->tabs_gui->setBackTarget(
458 $this->lng->txt("back"),
459 $this->ctrl->getLinkTarget($this, "view")
460 );
461
462 $form->setValuesByPost();
463 $this->tpl->setContent($form->getHtml());
464 }
465
469 protected function addBlog()
470 {
471 $ilHelp = $this->help;
472
473 $this->tabs_gui->clearTargets();
474 $this->tabs_gui->setBackTarget(
475 $this->lng->txt("back"),
476 $this->ctrl->getLinkTarget($this, "view")
477 );
478
479 $ilHelp->setScreenIdComponent("prtf");
480 $ilHelp->setScreenId("add_blog");
481
482 $form = $this->initBlogForm();
483 $this->tpl->setContent($form->getHTML());
484 }
485
486 abstract protected function initBlogForm();
487
488 abstract protected function saveBlog();
489
494 {
495 if (!$this->checkPermissionBool("write")) {
496 return;
497 }
498
499 $title_changes = array();
500
501 if (is_array($_POST["order"])) {
502 foreach ($_POST["order"] as $k => $v) {
503 $page = $this->getPageInstance(ilUtil::stripSlashes($k));
504 if ($_POST["title"][$k]) {
505 $new_title = trim(ilUtil::stripSlashes($_POST["title"][$k]));
506 if ($page->getTitle() != $new_title) {
507 $title_changes[$page->getId()] = array("old" => $page->getTitle(), "new" => $new_title);
508 $page->setTitle($new_title);
509 }
510 }
511 $page->setOrderNr(ilUtil::stripSlashes($v));
512 $page->update();
513 }
514 ilPortfolioPage::fixOrdering($this->object->getId());
515 }
516
517 $this->object->fixLinksOnTitleChange($title_changes);
518
519 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
520 $this->ctrl->redirect($this, "view");
521 }
522
527 {
528 $prtf_pages = $_REQUEST["prtf_pages"];
529
530 if (!is_array($prtf_pages) || count($prtf_pages) == 0) {
531 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
532 $this->ctrl->redirect($this, "view");
533 } else {
534 $this->tabs_gui->activateTab("pages");
535
536 $cgui = new ilConfirmationGUI();
537 $cgui->setFormAction($this->ctrl->getFormAction($this));
538 $cgui->setHeaderText($this->lng->txt("prtf_sure_delete_portfolio_pages"));
539 $cgui->setCancel($this->lng->txt("cancel"), "view");
540 $cgui->setConfirm($this->lng->txt("delete"), "deletePortfolioPages");
541
542 foreach ($prtf_pages as $id) {
543 $id = (int) $id;
544 $page = $this->getPageInstance((int) $id);
545 if ($page->getPortfolioId() != $this->object->getId()) {
546 continue;
547 }
548
549 $title = $page->getTitle();
550 if ($page->getType() == ilPortfolioPage::TYPE_BLOG) {
551 $title = $this->lng->txt("obj_blog") . ": " . ilObject::_lookupTitle((int) $title);
552 }
553 $cgui->addItem("prtf_pages[]", $id, $title);
554 }
555
556 $this->tpl->setContent($cgui->getHTML());
557 }
558 }
559
563 public function deletePortfolioPages()
564 {
565 if (!$this->checkPermissionBool("write")) {
566 return;
567 }
568
569 if (is_array($_POST["prtf_pages"])) {
570 foreach ($_POST["prtf_pages"] as $id) {
571 $id = (int) $id;
572 $page = $this->getPageInstance($id);
573 $page->delete();
574 }
575 }
576 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_page_deleted"), true);
577 $this->ctrl->redirect($this, "view");
578 }
579
583 public function preview($a_return = false, $a_content = false, $a_show_notes = true)
584 {
587
588 $portfolio_id = $this->object->getId();
589 $user_id = $this->object->getOwner();
590
591 $this->tabs_gui->clearTargets();
592
593 $pages = ilPortfolioPage::getAllPortfolioPages($portfolio_id);
594 $current_page = $this->requested_user_page;
595
596 // validate current page
597 if ($pages && $current_page) {
598 $found = false;
599 foreach ($pages as $page) {
600 if ($page["id"] == $current_page) {
601 $found = true;
602 break;
603 }
604 }
605 if (!$found) {
606 $current_page = null;
607 }
608 }
609
610 // display first page of portfolio if none given
611 if (!$current_page && $pages) {
612 $current_page = $pages;
613 $current_page = array_shift($current_page);
614 $current_page = $current_page["id"];
615 }
616
617 // #13788 - keep page after login
618 if ($this->user_id == ANONYMOUS_USER_ID &&
619 $this->getType() == "prtf") {
620 $this->tpl->setLoginTargetPar("prtf_" . $this->object->getId() . "_" . $current_page);
621 }
622
623 $back_caption = "";
624
625 // public profile
626 if ($this->requested_back_url != "") {
628 } elseif ($_GET["baseClass"] != "ilPublicUserProfileGUI" &&
629 $this->user_id && $this->user_id != ANONYMOUS_USER_ID) {
630 if (!$this->checkPermissionBool("write")) {
631 // shared
632 if ($this->getType() == "prtf") {
633 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", $this->object->getOwner());
634 $back = $this->ctrl->getLinkTargetByClass(array("ildashboardgui", "ilportfoliorepositorygui"), "showOther");
635 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", "");
636 }
637 // listgui / parent container
638 else {
639 // #12819
641 $parent_id = $tree->getParentId($this->node_id);
643 }
644 }
645 // owner
646 else {
647 $back = $this->ctrl->getLinkTarget($this, "view");
648 if ($this->getType() == "prtf") {
649 $back_caption = $this->lng->txt("prtf_back_to_portfolio_owner");
650 } else {
651 // #19316
652 $this->lng->loadLanguageModule("prtt");
653 $back_caption = $this->lng->txt("prtt_edit");
654 }
655 }
656 }
657
658 $ilMainMenu = $this->main_menu;
659 $ilMainMenu->setMode(ilMainMenuGUI::MODE_TOPBAR_ONLY);
660 if ($back) {
661 // might already be set in ilPublicUserProfileGUI
662 $ilMainMenu->setTopBarBack($back, $back_caption);
663 }
664
665 // render tabs
666 $current_blog = null;
667 if (count($pages) > 1) {
668 foreach ($pages as $p) {
669 if ($p["type"] == ilPortfolioPage::TYPE_BLOG) {
670 // needed for blog comments (see below)
671 if ($p["id"] == $current_page) {
672 $current_blog = (int) $p["title"];
673 }
674 $p["title"] = ilObjBlog::_lookupTitle($p["title"]);
675 }
676
677 $this->ctrl->setParameter($this, "user_page", $p["id"]);
678 $this->tabs_gui->addTab(
679 "user_page_" . $p["id"],
680 $p["title"],
681 $this->ctrl->getLinkTarget($this, "preview")
682 );
683 }
684
685 $this->tabs_gui->activateTab("user_page_" . $current_page);
686 }
687
688 $this->ctrl->setParameter($this, "user_page", $current_page);
689
690 if (!$a_content) {
691 // #18291
692 if ($current_page) {
693 // get current page content
694 $page_gui = $this->getPageGUIInstance($current_page);
695 $page_gui->setEmbedded(true);
696
697 $content = $this->ctrl->getHTML($page_gui);
698 }
699 } else {
700 $content = $a_content;
701 }
702
703 if ($a_return && $this->checkPermissionBool("write")) {
704 return $content;
705 }
706
707 // blog posting comments are handled within the blog
708 $notes = "";
709 if ($a_show_notes && $this->object->hasPublicComments() && !$current_blog && $current_page) {
710 $note_gui = new ilNoteGUI($portfolio_id, $current_page, "pfpg");
711 $note_gui->setRepositoryMode(false);
712 $note_gui->enablePublicNotes(true);
713 $note_gui->enablePrivateNotes(false);
714
715 $note_gui->enablePublicNotesDeletion(($this->user_id == $user_id) &&
716 $ilSetting->get("comments_del_tutor", 1));
717
718 $next_class = $this->ctrl->getNextClass($this);
719 if ($next_class == "ilnotegui") {
720 $notes = $this->ctrl->forwardCommand($note_gui);
721 } else {
722 $notes = $note_gui->getNotesHTML();
723 }
724 }
725
726 if ($this->perma_link === null) {
727 if ($this->getType() == "prtf") {
728 $this->tpl->setPermanentLink($this->getType(), $this->object->getId(), "_" . $current_page);
729 } else {
730 $this->tpl->setPermanentLink($this->getType(), $this->object->getRefId());
731 }
732 } else {
733 $this->tpl->setPermanentLink($this->perma_link["type"], $this->perma_link["obj_id"]);
734 }
735
736 // #18208 - see ilPortfolioTemplatePageGUI::getPageContentUserId()
737 if ($this->getType() == "prtt" && !$this->checkPermissionBool("write")) {
738 $user_id = $ilUser->getId();
739 }
740
741 self::renderFullscreenHeader($this->object, $this->tpl, $user_id);
742
743 // #13564
744 $this->ctrl->setParameter($this, "user_page", "");
745 //$this->tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
746 $this->ctrl->setParameter($this, "user_page", $this->page_id);
747
748 // blog pages do their own (page) style handling
749 if (!$current_blog) {
750 $content = '<div id="ilCOPageContent" class="ilc_page_cont_PageContainer">' .
751 '<div class="ilc_page_Page">' .
752 $content .
753 '</div></div>';
754
755 $this->setContentStyleSheet($this->tpl);
756 }
757
758 $this->showEditButton($current_page);
759
760 // #10717
761 $this->tpl->setContent($content .
762 '<div class="ilClearFloat">' . $notes . '</div>');
763 }
764
765
769 protected function showEditButton($page_id)
770 {
771 if ($page_id == 0) {
772 return;
773 }
774 $page_class = ($this->getType() == "prtt")
775 ? "ilPortfolioTemplatePageGUI"
776 : "ilportfoliopagegui";
777 $button = null;
779 $this->ctrl->setParameterByClass($page_class, "ppage", $page_id);
780 $button = $this->ui->factory()->button()->standard(
781 $this->lng->txt("edit"),
782 $this->ctrl->getLinkTargetByClass($page_class, "edit")
783 );
784 } else {
785 if ($this->getType() != "prtt") {
786 $this->ctrl->setParameterByClass("ilobjbloggui", "ppage", $page_id);
787 $this->ctrl->setParameterByClass("ilobjbloggui", "prt_id", (int) $_GET["prt_id"]);
788 $button = $this->ui->factory()->button()->standard(
789 $this->lng->txt("edit"),
790 $this->ctrl->getLinkTargetByClass([$page_class, "ilobjbloggui"], "render")
791 );
792 } else { // portfolio template, blog page cannot be edited -> link to overview
793 $button = $this->ui->factory()->button()->standard(
794 $this->lng->txt("edit"),
795 $this->ctrl->getLinkTargetByClass(["ilobjportfoliotemplategui"], "view")
796 );
797 }
798 }
799 if ($button && $this->checkPermissionBool("write")) {
800 $this->tpl->setHeaderActionMenu($this->ui->renderer()->render($button));
801 }
802 }
803
811 public static function renderFullscreenHeader($a_portfolio, $a_tpl, $a_user_id, $a_export = false)
812 {
813 global $DIC;
814
815 $ilUser = $DIC->user();
816
817 if (!$a_export) {
819 $a_portfolio->getType(),
820 ($a_portfolio->getType() == "prtt")
821 ? $a_portfolio->getRefId()
822 : $a_portfolio->getId(),
823 $a_portfolio->getId(),
824 $ilUser->getId()
825 );
826 }
827
828 $name = ilObjUser::_lookupName($a_user_id);
829 $name = $name["lastname"] . ", " . ($t = $name["title"] ? $t . " " : "") . $name["firstname"];
830
831 // show banner?
832 $banner = $banner_width = $banner_height = false;
833 $prfa_set = new ilSetting("prfa");
834 if ($prfa_set->get("banner")) {
835 $banner = ilWACSignedPath::signFile($a_portfolio->getImageFullPath());
836 $banner_width = $prfa_set->get("banner_width");
837 $banner_height = $prfa_set->get("banner_height");
838 if ($a_export) {
839 $banner = basename($banner);
840 }
841 }
842
843 // profile picture
844 $ppic = null;
845 if ($a_portfolio->hasProfilePicture()) {
846 $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
847 if ($a_export) {
848 $ppic = basename($ppic);
849 }
850 }
851
852 $a_tpl->resetHeaderBlock(false);
853 // $a_tpl->setBackgroundColor($a_portfolio->getBackgroundColor());
854 // @todo fix this
855 $a_tpl->setBanner($banner, $banner_width, $banner_height, $a_export);
856 $a_tpl->setTitleIcon($ppic);
857 $a_tpl->setTitle($a_portfolio->getTitle());
858 // $a_tpl->setTitleColor($a_portfolio->getFontColor());
859 $a_tpl->setDescription($name);
860
861 // to get rid of locator in portfolio template preview
862 $a_tpl->setVariable("LOCATOR", "");
863
864 // :TODO: obsolete?
865 // $a_tpl->setBodyClass("std ilExternal ilPortfolio");
866 }
867
868 public function export()
869 {
870 $port_export = new \ILIAS\Portfolio\Export\PortfolioHtmlExport($this);
871 $zip = $port_export->exportHtml();
872
873 ilUtil::deliverFile($zip, $this->object->getTitle() . ".zip", '', false, true);
874 }
875
876
880 public function copyPageForm($a_form = null)
881 {
882 $prtf_pages = $_REQUEST["prtf_pages"];
883
884 if (!is_array($prtf_pages) || count($prtf_pages) == 0) {
885 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
886 $this->ctrl->redirect($this, "view");
887 } else {
888 $this->tabs_gui->activateTab("pages");
889
890 if (!$a_form) {
891 $a_form = $this->initCopyPageForm();
892 }
893
894 foreach ($prtf_pages as $page_id) {
895 $item = new ilHiddenInputGUI("prtf_pages[]");
896 $item->setValue((int) $page_id);
897 $a_form->addItem($item);
898 }
899
900 $this->tpl->setContent($a_form->getHTML());
901 }
902 }
903
904 public function copyPage()
905 {
906 $form = $this->initCopyPageForm();
907 if ($form->checkInput()) {
908 // existing
909 if ($form->getInput("target") == "old") {
910 $portfolio_id = $form->getInput("prtf");
911 }
912 // new
913 else {
914 $portfolio = new ilObjPortfolio();
915 $portfolio->setTitle($form->getInput("title"));
916 $portfolio->create();
917 $portfolio_id = $portfolio->getId();
918 }
919
920 // copy page(s)
921 foreach ($_POST["prtf_pages"] as $page_id) {
922 $page_id = (int) $page_id;
923 $source = $this->getPageInstance($page_id);
924 $target = $this->getPageInstance(null, $portfolio_id);
925 $target->setXMLContent($source->copyXmlContent(true)); // copy mobs
926 $target->setType($source->getType());
927 $target->setTitle($source->getTitle());
928 $target->create();
929 }
930
931 ilUtil::sendSuccess($this->lng->txt("prtf_pages_copied"), true);
932 $this->ctrl->redirect($this, "view");
933 }
934
935 $form->setValuesByPost();
936 $this->copyPageForm($form);
937 }
938
939 abstract protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form);
940
941 public function initCopyPageForm()
942 {
943 $form = new ilPropertyFormGUI();
944 $form->setFormAction($this->ctrl->getFormAction($this));
945 $form->setTitle($this->lng->txt("prtf_copy_page"));
946
947 $this->initCopyPageFormOptions($form);
948
949 $form->addCommandButton("copyPage", $this->lng->txt("save"));
950 $form->addCommandButton("view", $this->lng->txt("cancel"));
951
952 return $form;
953 }
954
955
959
960 public function setContentStyleSheet($a_tpl = null)
961 {
963
964 if ($a_tpl != null) {
965 $ctpl = $a_tpl;
966 } else {
967 $ctpl = $tpl;
968 }
969
970 $ctpl->setCurrentBlock("ContentStyle");
971 $ctpl->setVariable(
972 "LOCATION_CONTENT_STYLESHEET",
973 ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
974 );
975 $ctpl->parseCurrentBlock();
976 }
977
978 public function editStyleProperties()
979 {
980 $this->checkPermission("write");
981
982 $this->tabs_gui->activateTab("settings");
983 $this->setSettingsSubTabs("style");
984
985 $form = $this->initStylePropertiesForm();
986 $this->tpl->setContent($form->getHTML());
987 }
988
989 public function initStylePropertiesForm()
990 {
992
993 $this->lng->loadLanguageModule("style");
994
995 $form = new ilPropertyFormGUI();
996
997 $fixed_style = $ilSetting->get("fixed_content_style_id");
998 $style_id = $this->object->getStyleSheetId();
999
1000 if ($fixed_style > 0) {
1001 $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
1002 $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
1003 $this->lng->txt("global_fixed") . ")");
1004 $form->addItem($st);
1005 } else {
1007 true,
1008 false,
1009 $_GET["ref_id"]
1010 );
1011
1012 $st_styles[0] = $this->lng->txt("default");
1013 ksort($st_styles);
1014
1015 if ($style_id > 0) {
1016 // individual style
1017 if (!ilObjStyleSheet::_lookupStandard($style_id)) {
1018 $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
1019 $st->setValue(ilObject::_lookupTitle($style_id));
1020 $form->addItem($st);
1021
1022 // delete command
1023 $form->addCommandButton("editStyle", $this->lng->txt("style_edit_style"));
1024 $form->addCommandButton("deleteStyle", $this->lng->txt("style_delete_style"));
1025 }
1026 }
1027
1028 if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
1029 $style_sel = new ilSelectInputGUI(
1030 $this->lng->txt("style_current_style"),
1031 "style_id"
1032 );
1033 $style_sel->setOptions($st_styles);
1034 $style_sel->setValue($style_id);
1035 $form->addItem($style_sel);
1036
1037 $form->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
1038 $form->addCommandButton("createStyle", $this->lng->txt("sty_create_ind_style"));
1039 }
1040 }
1041
1042 $form->setTitle($this->lng->txt($this->getType() . "_style"));
1043 $form->setFormAction($this->ctrl->getFormAction($this));
1044
1045 return $form;
1046 }
1047
1048 public function createStyle()
1049 {
1050 $this->ctrl->redirectByClass("ilobjstylesheetgui", "create");
1051 }
1052
1053 public function editStyle()
1054 {
1055 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
1056 }
1057
1058 public function deleteStyle()
1059 {
1060 $this->ctrl->redirectByClass("ilobjstylesheetgui", "delete");
1061 }
1062
1063 public function saveStyleSettings()
1064 {
1066
1067 if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1068 (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1069 || $this->object->getStyleSheetId() == 0)) {
1070 $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1071 $this->object->update();
1072
1073 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1074 }
1075 $this->ctrl->redirect($this, "editStyleProperties");
1076 }
1077}
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.
static setPersonalWorkspaceQuotaCheck($a_value)
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.
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)
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)
help()
Definition: help.php:2
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
$ilUser
Definition: imgupload.php:18
ui()
Definition: ui.php:5
$a_content
Definition: workflow.php:93
$a_type
Definition: workflow.php:92
$message
Definition: xapiexit.php:14
$DIC
Definition: xapitoken.php:46