ILIAS  release_8 Revision v8.24
class.ilObjPortfolioBaseGUI.php
Go to the documentation of this file.
1<?php
2
21
27abstract class ilObjPortfolioBaseGUI extends ilObject2GUI
28{
30 protected ilHelpGUI $help;
31 protected int $user_id = 0;
32 protected array $additional = array();
33 protected array $perma_link = [];
34 protected int $page_id = 0;
35 protected string $page_mode; // preview|edit
36 protected int $requested_ppage;
37 protected int $requested_user_page;
38 protected string $requested_back_url = "";
39 protected \ILIAS\DI\UIServices $ui;
40 protected \ILIAS\HTTP\Services $http;
41 protected \ILIAS\Style\Content\GUIService $content_style_gui;
42 protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
43
44 public function __construct(
45 int $a_id = 0,
46 int $a_id_type = self::REPOSITORY_NODE_ID,
47 int $a_parent_node_id = 0
48 ) {
49 global $DIC;
50
51 $this->user = $DIC->user();
52 $this->locator = $DIC["ilLocator"];
53 $this->toolbar = $DIC->toolbar();
54 $this->settings = $DIC->settings();
55 $this->tree = $DIC->repositoryTree();
56 $this->help = $DIC["ilHelp"];
57 $this->tpl = $DIC["tpl"];
58 $ilUser = $DIC->user();
59 $this->ui = $DIC->ui();
60
61 $this->port_request = $DIC->portfolio()
62 ->internal()
63 ->gui()
64 ->standardRequest();
65
66 $this->http = $DIC->http();
67
68 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
69
70 $this->user_id = $ilUser->getId();
71
72 $this->lng->loadLanguageModule("prtf");
73 $this->lng->loadLanguageModule("user");
74 $this->lng->loadLanguageModule("obj");
75
76 $this->requested_ppage = $this->port_request->getPortfolioPageId();
77 $this->requested_user_page = $this->port_request->getUserPage();
78
79 // temp sanitization, should be done smarter in the future
80 $back = str_replace("&amp;", ":::", $this->port_request->getBackUrl());
81 $back = preg_replace(
82 "/[^a-zA-Z0-9_\.\?=:\s]/",
83 "",
84 $back
85 );
86 $this->requested_back_url = str_replace(":::", "&amp;", $back);
87
88 $this->ctrl->setParameterByClass("ilobjportfoliogui", "back_url", rawurlencode($this->requested_back_url));
89 $cs = $DIC->contentStyle();
90 $this->content_style_gui = $cs->gui();
91 if ($this->object) {
92 $this->content_style_domain = $cs->domain()->styleForObjId($this->object->getId());
93 }
94 }
95
96 protected function addLocatorItems(): void
97 {
98 $ilLocator = $this->locator;
99
100 if ($this->object) {
101 $ilLocator->addItem(
102 strip_tags($this->object->getTitle()),
103 $this->ctrl->getLinkTarget($this, "view")
104 );
105 }
106
107 if ($this->page_id > 0) {
108 $page = $this->getPageInstance($this->page_id);
109 $title = $page->getTitle();
110 if ($page->getType() === ilPortfolioPage::TYPE_BLOG) {
111 $title = ilObject::_lookupTitle($title);
112 }
113 $this->ctrl->setParameterByClass($this->getPageGUIClassName(), "ppage", $this->page_id);
114 $ilLocator->addItem(
115 $title,
116 $this->ctrl->getLinkTargetByClass($this->getPageGUIClassName(), "edit")
117 );
118 }
119 }
120
121 protected function determinePageCall(): bool
122 {
123 // edit
124 if ($this->requested_ppage > 0) {
125 if (!$this->checkPermissionBool("write")) {
126 $this->ctrl->redirect($this, "view");
127 }
128
129 $this->page_id = $this->requested_ppage;
130 $this->page_mode = "edit";
131 $this->ctrl->setParameter($this, "ppage", $this->page_id);
132 return true;
133 }
134
135 // preview
136 $this->page_id = $this->requested_user_page;
137 $this->page_mode = "preview";
138 $this->ctrl->setParameter($this, "user_page", $this->page_id);
139 return false;
140 }
141
142 protected function handlePageCall(string $a_cmd): void
143 {
144 if (!$this->page_id) {
145 $this->ctrl->redirect($this, "view");
146 }
147
148 $page_gui = $this->getPageGUIInstance($this->page_id);
149
150 $this->tabs_gui->clearTargets();
151 $this->tabs_gui->setBackTarget(
152 $this->lng->txt("back"),
153 $this->ctrl->getLinkTarget($this, "view")
154 );
155
156 // needed for editor
157 $page_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
158
159 $ret = $this->ctrl->forwardCommand($page_gui);
160 if ($ret != "" && $ret !== true) {
161 // preview (fullscreen)
162 if ($this->page_mode === "preview") {
163 // embedded call which did not generate any output (e.g. calendar month navigation)
165 // suppress (portfolio) notes for blog postings
166 $this->preview(false, $ret, ($a_cmd !== "previewEmbedded"));
167 } else {
168 $this->preview(false);
169 }
170 }
171 // edit
172 else {
173 $this->setContentStyleSheet();
174 if (is_string($ret)) {
175 $this->tpl->setContent($ret);
176 }
177 }
178 }
179 }
180
184 public function setAdditional(array $a_additional): void
185 {
186 $this->additional = $a_additional;
187 }
188
189 public function getAdditional(): array
190 {
191 return $this->additional;
192 }
193
197 public function setPermaLink(
198 int $a_obj_id,
199 string $a_type
200 ): void {
201 $this->perma_link = array("obj_id" => $a_obj_id, "type" => $a_type);
202 }
203
204
205 //
206 // CREATE/EDIT
207 //
208
209 protected function setSettingsSubTabs(string $a_active): void
210 {
211 // #17455
212 $this->lng->loadLanguageModule($this->getType());
213
214 // general properties
215 $this->tabs_gui->addSubTab(
216 "properties",
217 $this->lng->txt($this->getType() . "_properties"),
218 $this->ctrl->getLinkTarget($this, 'edit')
219 );
220
221 $this->tabs_gui->addSubTab(
222 "style",
223 $this->lng->txt("obj_sty"),
224 $this->ctrl->getLinkTargetByClass("ilobjectcontentstylesettingsgui", "")
225 );
226
227 $this->tabs_gui->activateSubTab($a_active);
228 }
229
230 protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
231 {
232 $this->setSettingsSubTabs("properties");
233
234
235 // profile picture
236 $ppic = new ilCheckboxInputGUI($this->lng->txt("prtf_profile_picture"), "ppic");
237 $a_form->addItem($ppic);
238
239 $prfa_set = new ilSetting("prfa");
240 if ($prfa_set->get("banner")) {
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(ilWACSignedPath::signFile($file));
251 }
252 }
253
254 $section = new ilFormSectionHeaderGUI();
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): void
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 protected function updateCustom(ilPropertyFormGUI $form): void
282 {
283 $this->object->setPublicComments($form->getInput("comments"));
284 $this->object->setProfilePicture($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 (isset($_FILES["banner"]) && $_FILES["banner"]["tmp_name"]) {
293 $this->object->uploadImage($_FILES["banner"]);
294 } elseif ($prfa_set->get('banner') && $form->getItemByPostVar("banner")->getDeletionFlag()) {
295 $this->object->deleteImage();
296 }
297 }
298
299
300 //
301 // PAGES
302 //
303
304 abstract protected function getPageInstance(
305 ?int $a_page_id = null,
306 ?int $a_portfolio_id = null
308
309 abstract protected function getPageGUIInstance(int $a_page_id): ilPortfolioPageGUI;
310
311 abstract public function getPageGUIClassName(): string;
312
316 public function view(): void
317 {
318 $ilToolbar = $this->toolbar;
321
322 if (!$this->checkPermissionBool("write")) {
323 $this->ctrl->redirect($this, "infoScreen");
324 }
325
326 $this->tabs_gui->activateTab("pages");
327
328
329 $button = ilLinkButton::getInstance();
330 $button->setCaption("prtf_add_page");
331 $button->setUrl($this->ctrl->getLinkTarget($this, "addPage"));
332 $ilToolbar->addStickyItem($button);
333
334 if (!$ilSetting->get('disable_wsp_blogs')) {
335 $button = ilLinkButton::getInstance();
336 $button->setCaption("prtf_add_blog");
337 $button->setUrl($this->ctrl->getLinkTarget($this, "addBlog"));
338 $ilToolbar->addStickyItem($button);
339 }
340
341
342 // #16571
343 $modal_html = "";
344 if ($this->getType() === "prtf") {
345 $ilToolbar->addSeparator();
346
347 $ui = $this->ui;
348
349 if ($this->object->isCommentsExportPossible()) {
350 $this->lng->loadLanguageModule("note");
351 $comment_export_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
352 $comment_modal = $comment_export_helper->getCommentIncludeModalDialog(
353 $this->lng->txt("export_html"),
354 $this->lng->txt("note_html_export_include_comments"),
355 $this->ctrl->getLinkTarget($this, "export"),
356 $this->ctrl->getLinkTarget($this, "exportWithComments")
357 );
358 $button = $ui->factory()->button()->standard($this->lng->txt("export_html"), '')
359 ->withOnClick($comment_modal->getShowSignal());
360 $ilToolbar->addComponent($button);
361 $modal_html = $ui->renderer()->render($comment_modal);
362 } else {
363 $button = ilLinkButton::getInstance();
364 $button->setCaption("export_html");
365 $button->setUrl($this->ctrl->getLinkTarget($this, "export"));
366 $ilToolbar->addButtonInstance($button);
367 }
368
369 $print_view = $this->getPrintView();
370 $modal_elements = $print_view->getModalElements($this->ctrl->getLinkTarget(
371 $this,
372 "printSelection"
373 ));
374 $modal_html .= $ui->renderer()->render($modal_elements->modal);
375 $ilToolbar->addComponent($modal_elements->button);
376 }
377
378 $table = new ilPortfolioPageTableGUI($this, "view");
379
380
381 $this->tpl->setContent($table->getHTML() . $modal_html);
382 }
383
384 public function getPrintView(): \ILIAS\Export\PrintProcessGUI
385 {
386 $obj_ids = $this->port_request->getObjIds();
387 $signature = $this->port_request->getSignature();
388 $declaration = $this->port_request->getIncludeDeclaration();
389 if (count($obj_ids) === 0) {
390 $obj_ids = null;
391 }
393 $port = $this->object;
395 $this->lng,
396 $this->ctrl,
397 $port,
398 $signature,
399 $obj_ids,
400 $declaration
401 );
402 $provider = $provider->withDeclarationOfAuthorship(
404 $this->user
405 );
406 return new \ILIAS\Export\PrintProcessGUI(
407 $provider,
408 $this->http,
409 $this->ui,
410 $this->lng
411 );
412 }
413
417 protected function addPage(): void
418 {
419 $ilHelp = $this->help;
420
421 $this->tabs_gui->clearTargets();
422 $this->tabs_gui->setBackTarget(
423 $this->lng->txt("back"),
424 $this->ctrl->getLinkTarget($this, "view")
425 );
426
427 $ilHelp->setScreenIdComponent("prtf");
428 $ilHelp->setScreenId("add_page");
429
430
431 $form = $this->initPageForm("create");
432 $this->tpl->setContent($form->getHTML());
433 }
434
438 public function initPageForm(string $a_mode = "create"): ilPropertyFormGUI
439 {
440 $form = new ilPropertyFormGUI();
441 $form->setFormAction($this->ctrl->getFormAction($this));
442
443 // title
444 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
445 $ti->setMaxLength(200);
446 $ti->setRequired(true);
447 $form->addItem($ti);
448
449 // save and cancel commands
450 if ($a_mode === "create") {
452 if ($templates) {
453 $use_template = new ilRadioGroupInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
454 $use_template->setRequired(true);
455 $form->addItem($use_template);
456
457 $opt = new ilRadioOption($this->lng->txt("none"), 0);
458 $use_template->addOption($opt);
459
460 foreach ($templates as $templ) {
461 $templ->readObject();
462
463 $opt = new ilRadioOption($templ->getTitle() . $templ->getPreview(), $templ->getId());
464 $use_template->addOption($opt);
465 }
466 }
467
468 $form->setTitle($this->lng->txt("prtf_add_page") . ": " .
469 $this->object->getTitle());
470 $form->addCommandButton("savePage", $this->lng->txt("save"));
471 $form->addCommandButton("view", $this->lng->txt("cancel"));
472 }
473
474 return $form;
475 }
476
480 public function savePage(): void
481 {
482 $form = $this->initPageForm("create");
483 if ($form->checkInput() && $this->checkPermissionBool("write")) {
484 $page = $this->getPageInstance();
485 $page->setType(ilPortfolioPage::TYPE_PAGE);
486 $page->setTitle($form->getInput("title"));
487
488 // use template as basis
489 $layout_id = $form->getInput("tmpl");
490 if ($layout_id) {
491 $layout_obj = new ilPageLayout($layout_id);
492 $page->setXMLContent($layout_obj->copyXmlContent(false));
493 }
494
495 $page->create();
496
497 $this->tpl->setOnScreenMessage('success', $this->lng->txt("prtf_page_created"), true);
498 $this->ctrl->redirect($this, "view");
499 }
500
501 $this->tabs_gui->clearTargets();
502 $this->tabs_gui->setBackTarget(
503 $this->lng->txt("back"),
504 $this->ctrl->getLinkTarget($this, "view")
505 );
506
507 $form->setValuesByPost();
508 $this->tpl->setContent($form->getHTML());
509 }
510
514 protected function addBlog(): void
515 {
516 $ilHelp = $this->help;
517
518 $this->tabs_gui->clearTargets();
519 $this->tabs_gui->setBackTarget(
520 $this->lng->txt("back"),
521 $this->ctrl->getLinkTarget($this, "view")
522 );
523
524 $ilHelp->setScreenIdComponent("prtf");
525 $ilHelp->setScreenId("add_blog");
526
527 $form = $this->initBlogForm();
528 $this->tpl->setContent($form->getHTML());
529 }
530
531 abstract protected function initBlogForm(): ilPropertyFormGUI;
532
533 abstract protected function saveBlog(): void;
534
538 public function savePortfolioPagesOrdering(): void
539 {
540 if (!$this->checkPermissionBool("write")) {
541 return;
542 }
543
544 $title_changes = array();
545
546 $order = $this->port_request->getOrder();
547 $titles = $this->port_request->getTitles();
548 if (count($order) > 0) {
549 foreach ($order as $k => $v) {
550 $page = $this->getPageInstance(ilUtil::stripSlashes($k));
551 if ($titles[$k] ?? "") {
552 $new_title = $titles[$k] ?? "";
553 if ($page->getTitle() != $new_title) {
554 $title_changes[$page->getId()] = array("old" => $page->getTitle(), "new" => $new_title);
555 $page->setTitle($new_title);
556 }
557 }
558 $page->setOrderNr(ilUtil::stripSlashes($v));
559 $page->update();
560 }
561 ilPortfolioPage::fixOrdering($this->object->getId());
562 }
563
564 $this->object->fixLinksOnTitleChange($title_changes);
565
566 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
567 $this->ctrl->redirect($this, "view");
568 }
569
570 public function confirmPortfolioPageDeletion(): void
571 {
572 $prtf_pages = $this->port_request->getPortfolioPageIds();
573
574 if (count($prtf_pages) === 0) {
575 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
576 $this->ctrl->redirect($this, "view");
577 } else {
578 $this->tabs_gui->activateTab("pages");
579
580 $cgui = new ilConfirmationGUI();
581 $cgui->setFormAction($this->ctrl->getFormAction($this));
582 $cgui->setHeaderText($this->lng->txt("prtf_sure_delete_portfolio_pages"));
583 $cgui->setCancel($this->lng->txt("cancel"), "view");
584 $cgui->setConfirm($this->lng->txt("delete"), "deletePortfolioPages");
585
586 foreach ($prtf_pages as $id) {
587 $page = $this->getPageInstance($id);
588 if ($page->getPortfolioId() !== $this->object->getId()) {
589 continue;
590 }
591
592 $title = $page->getTitle();
593 if ($page->getType() === ilPortfolioPage::TYPE_BLOG) {
594 $title = $this->lng->txt("obj_blog") . ": " . ilObject::_lookupTitle((int) $title);
595 }
596 $cgui->addItem("prtf_pages[]", $id, $title);
597 }
598
599 $this->tpl->setContent($cgui->getHTML());
600 }
601 }
602
603 public function deletePortfolioPages(): void
604 {
605 if (!$this->checkPermissionBool("write")) {
606 return;
607 }
608
609 $page_ids = $this->port_request->getPortfolioPageIds();
610 foreach ($page_ids as $id) {
611 $page = $this->getPageInstance($id);
612 $page->delete();
613 }
614 $this->tpl->setOnScreenMessage('success', $this->lng->txt("prtf_portfolio_page_deleted"), true);
615 $this->ctrl->redirect($this, "view");
616 }
617
621 public function preview(
622 bool $a_return = false,
623 $a_content = false,
624 bool $a_show_notes = true
625 ): string {
626 $ilSetting = $this->settings;
627 $ilUser = $this->user;
628 $portfolio_id = $this->object->getId();
629 $user_id = $this->object->getOwner();
630
631 $content = "";
632
633 $this->tabs_gui->clearTargets();
634
635 $pages = ilPortfolioPage::getAllPortfolioPages($portfolio_id);
636 $current_page = $this->requested_user_page;
637
638 // validate current page
639 if ($pages && $current_page) {
640 $found = false;
641 foreach ($pages as $page) {
642 if ($page["id"] == $current_page) {
643 $found = true;
644 break;
645 }
646 }
647 if (!$found) {
648 $current_page = null;
649 }
650 }
651
652 // display first page of portfolio if none given
653 if (!$current_page && $pages) {
654 $current_page = $pages;
655 $current_page = array_shift($current_page);
656 $current_page = $current_page["id"];
657 }
658
659 // #13788 - keep page after login
660 if ($this->user_id === ANONYMOUS_USER_ID &&
661 $this->getType() === "prtf") {
662 $this->tpl->setLoginTargetPar("prtf_" . $this->object->getId() . "_" . $current_page);
663 }
664
665 $back_caption = "";
666
667 // public profile
668 if ($this->requested_back_url != "") {
669 $back = $this->requested_back_url;
670 } elseif (strtolower($this->port_request->getBaseClass()) !== "ilpublicuserprofilegui" &&
671 $this->user_id && $this->user_id !== ANONYMOUS_USER_ID) {
672 if (!$this->checkPermissionBool("write")) {
673 // shared
674 if ($this->getType() === "prtf") {
675 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", $this->object->getOwner());
676 $back = $this->ctrl->getLinkTargetByClass(array("ildashboardgui", "ilportfoliorepositorygui"), "showOther");
677 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", "");
678 }
679 // listgui / parent container
680 else {
681 // #12819
682 $tree = $this->tree;
683 $parent_id = $tree->getParentId($this->node_id);
684 $back = ilLink::_getStaticLink($parent_id);
685 }
686 }
687 // owner
688 else {
689 $back = $this->ctrl->getLinkTarget($this, "view");
690 if ($this->getType() === "prtf") {
691 $back_caption = $this->lng->txt("prtf_back_to_portfolio_owner");
692 } else {
693 // #19316
694 $this->lng->loadLanguageModule("prtt");
695 $back_caption = $this->lng->txt("prtt_edit");
696 }
697 }
698 }
699
700 // render tabs
701 $current_blog = null;
702 if (count($pages) > 1) {
703 foreach ($pages as $p) {
704 if ($p["type"] == ilPortfolioPage::TYPE_BLOG) {
705 // needed for blog comments (see below)
706 if ($p["id"] == $current_page) {
707 $current_blog = (int) $p["title"];
708 }
709 $p["title"] = ilObjBlog::_lookupTitle($p["title"]);
710 }
711
712 $this->ctrl->setParameter($this, "user_page", $p["id"]);
713 $this->tabs_gui->addTab(
714 "user_page_" . $p["id"],
715 $p["title"],
716 $this->ctrl->getLinkTarget($this, "preview")
717 );
718 }
719
720 $this->tabs_gui->activateTab("user_page_" . $current_page);
721 }
722
723 $this->ctrl->setParameter($this, "user_page", $current_page);
724
725
726 // blog posting comments are handled within the blog
727 // note: notes must be handled before the $this->ctrl->getHTML below, since
728 // this messes up the path since ILIAS 8
729 $notes = "";
730 if ($a_show_notes && $this->object->hasPublicComments() && !$current_blog && $current_page) {
731 $note_gui = new ilNoteGUI($portfolio_id, $current_page, "pfpg");
732
733 $note_gui->setRepositoryMode(false);
734 $note_gui->enablePublicNotes(true);
735 $note_gui->enablePrivateNotes(false);
736
737 $note_gui->enablePublicNotesDeletion(($this->user_id === $user_id) &&
738 $ilSetting->get("comments_del_tutor", '1'));
739
740 $next_class = $this->ctrl->getNextClass($this);
741 if ($next_class === "ilnotegui") {
742 $notes = $this->ctrl->forwardCommand($note_gui);
743 } else {
744 $notes = $note_gui->getCommentsHTML();
745 }
746 }
747
748 if (!$a_content) {
749 // #18291
750 if ($current_page) {
751 // get current page content
752 $page_gui = $this->getPageGUIInstance($current_page);
753 $page_gui->setEmbedded(true);
754
755 $content = $this->ctrl->getHTML($page_gui);
756 }
757 } else {
758 $content = $a_content;
759 }
760
761 if ($a_return && $this->checkPermissionBool("write")) {
762 return $content;
763 }
764
765
766 if (count($this->perma_link) === 0) {
767 if ($this->getType() === "prtf") {
768 $this->tpl->setPermanentLink($this->getType(), $this->object->getId(), "_" . $current_page);
769 } else {
770 $this->tpl->setPermanentLink($this->getType(), $this->object->getRefId());
771 }
772 } else {
773 $this->tpl->setPermanentLink($this->perma_link["type"] ?? "", $this->perma_link["obj_id"] ?? 0);
774 }
775
776 // #18208 - see ilPortfolioTemplatePageGUI::getPageContentUserId()
777 if ($this->getType() === "prtt" && !$this->checkPermissionBool("write")) {
778 $user_id = $ilUser->getId();
779 }
780
782 $obj = $this->object;
783 self::renderFullscreenHeader($obj, $this->tpl, $user_id);
784
785 // #13564
786 $this->ctrl->setParameter($this, "user_page", "");
787 //$this->tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
788 $this->ctrl->setParameter($this, "user_page", $this->page_id);
789
790 // blog pages do their own (page) style handling
791 if (!$current_blog) {
792 $content = '<div id="ilCOPageContent" class="ilc_page_cont_PageContainer">' .
793 '<div class="ilc_page_Page">' .
794 $content .
795 '</div></div>';
796
797 $this->setContentStyleSheet($this->tpl);
798 }
799
800 $this->showEditButton($current_page);
801
802 // #10717
803 $this->tpl->setContent($content .
804 '<div class="ilClearFloat">' . $notes . '</div>');
805 return "";
806 }
807
808 protected function showEditButton(
809 int $page_id
810 ): void {
811 $page_class = ($this->getType() === "prtt")
812 ? "ilPortfolioTemplatePageGUI"
813 : "ilportfoliopagegui";
814 $button = null;
815 if ($this->checkPermissionBool("write") &&
816 ($page_id === 0 || ilPortfolioPage::lookupType($page_id) === ilPortfolioPage::TYPE_PAGE)) {
817 if ($this->getType() === "prtt") {
818 $button = $this->ui->factory()->button()->standard(
819 $this->lng->txt("prtt_edit"),
820 $this->ctrl->getLinkTargetByClass(["ilobjportfoliotemplategui"], "view")
821 );
822 } else {
823 $button = $this->ui->factory()->button()->standard(
824 $this->lng->txt("prtf_edit_portfolio"),
825 $this->ctrl->getLinkTargetByClass(["ilobjportfoliogui"], "view")
826 );
827 }
828 $this->toolbar->addComponent($button);
829 $button = null;
830 }
831 if ($page_id > 0 && ilPortfolioPage::lookupType($page_id) === ilPortfolioPage::TYPE_PAGE) {
832 $this->ctrl->setParameterByClass($page_class, "ppage", $page_id);
833 $button = $this->ui->factory()->button()->standard(
834 $this->lng->txt("edit_page"),
835 $this->ctrl->getLinkTargetByClass($page_class, "edit")
836 );
837 if ($this->checkPermissionBool("write")) {
838 $this->toolbar->addComponent($button);
839 }
840 $button = null;
841 }
842 if ($button && $this->checkPermissionBool("write")) {
843 $this->tpl->setHeaderActionMenu($this->ui->renderer()->render($button));
844 }
845 }
846
850 public static function renderFullscreenHeader(
851 ilObjPortfolioBase $a_portfolio,
853 int $a_user_id,
854 bool $a_export = false
855 ): void {
856 global $DIC;
857
858 $ilUser = $DIC->user();
859
860 if (!$a_export) {
862 $a_portfolio->getType(),
863 ($a_portfolio->getType() === "prtt")
864 ? $a_portfolio->getRefId()
865 : $a_portfolio->getId(),
866 $a_portfolio->getId(),
867 $ilUser->getId()
868 );
869 }
870
871 $name = ilObjUser::_lookupName($a_user_id);
872 $name = $name["lastname"] . ", " . (($t = $name["title"]) ? $t . " " : "") . $name["firstname"];
873
874 // show banner?
875 $banner = $banner_width = $banner_height = false;
876 $prfa_set = new ilSetting("prfa");
877 if ($prfa_set->get("banner")) {
878 $banner = ilWACSignedPath::signFile($a_portfolio->getImageFullPath());
879 $banner_width = $prfa_set->get("banner_width");
880 $banner_height = $prfa_set->get("banner_height");
881 if ($a_export) {
882 $banner = basename($banner);
883 }
884 }
885
886 // profile picture
887 $ppic = null;
888 if ($a_portfolio->hasProfilePicture()) {
889 $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
890 if ($a_export) {
891 $ppic = basename($ppic);
892 }
893 }
894
895 $a_tpl->resetHeaderBlock(false);
896 // $a_tpl->setBackgroundColor($a_portfolio->getBackgroundColor());
897 // @todo fix this
898 $a_tpl->setBanner($banner);
899 $a_tpl->setTitleIcon((string) $ppic);
900 $a_tpl->setTitle($a_portfolio->getTitle());
901 // $a_tpl->setTitleColor($a_portfolio->getFontColor());
902 $a_tpl->setDescription($name);
903
904 // to get rid of locator in portfolio template preview
905 $a_tpl->setVariable("LOCATOR", "");
906
907 // :TODO: obsolete?
908 // $a_tpl->setBodyClass("std ilExternal ilPortfolio");
909 }
910
911 public function export(
912 bool $a_with_comments = false
913 ): void {
914 $port_export = new \ILIAS\Portfolio\Export\PortfolioHtmlExport($this);
915 $port_export->includeComments($a_with_comments);
916 $zip = $port_export->exportHtml();
917
918 ilFileDelivery::deliverFileLegacy($zip, $this->object->getTitle() . ".zip", '', false, true);
919 }
920
921 public function exportWithComments(): void
922 {
923 $this->export(true);
924 }
925
929 public function copyPageForm(
930 ilPropertyFormGUI $a_form = null
931 ): void {
932 $prtf_pages = $this->port_request->getPortfolioPageIds();
933
934 if (count($prtf_pages) === 0) {
935 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
936 $this->ctrl->redirect($this, "view");
937 } else {
938 $this->tabs_gui->activateTab("pages");
939
940 if (!$a_form) {
941 $a_form = $this->initCopyPageForm();
942 }
943
944 foreach ($prtf_pages as $page_id) {
945 $item = new ilHiddenInputGUI("prtf_pages[]");
946 $item->setValue($page_id);
947 $a_form->addItem($item);
948 }
949
950 $this->tpl->setContent($a_form->getHTML());
951 }
952 }
953
954 public function copyPage(): void
955 {
956 $form = $this->initCopyPageForm();
957 if ($form->checkInput()) {
958 // existing
959 if ($form->getInput("target") === "old") {
960 $portfolio_id = $form->getInput("prtf");
961 }
962 // new
963 else {
964 $portfolio = new ilObjPortfolio();
965 $portfolio->setTitle($form->getInput("title"));
966 $portfolio->create();
967 $portfolio_id = $portfolio->getId();
968 }
969
970 // copy page(s)
971 $page_ids = $this->port_request->getPortfolioPageIds();
972 foreach ($page_ids as $page_id) {
973 $source = $this->getPageInstance($page_id);
974 $target = $this->getPageInstance(null, $portfolio_id);
975 $target->setXMLContent($source->copyXmlContent(true)); // copy mobs
976 $target->setType($source->getType());
977 $target->setTitle($source->getTitle());
978 $target->create();
979 }
980
981 $this->tpl->setOnScreenMessage('success', $this->lng->txt("prtf_pages_copied"), true);
982 $this->ctrl->redirect($this, "view");
983 }
984
985 $form->setValuesByPost();
986 $this->copyPageForm($form);
987 }
988
989 abstract protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form): void;
990
992 {
993 $form = new ilPropertyFormGUI();
994 $form->setFormAction($this->ctrl->getFormAction($this));
995 $form->setTitle($this->lng->txt("prtf_copy_page"));
996
997 $this->initCopyPageFormOptions($form);
998
999 $form->addCommandButton("copyPage", $this->lng->txt("save"));
1000 $form->addCommandButton("view", $this->lng->txt("cancel"));
1001
1002 return $form;
1003 }
1004
1005
1009
1010 public function setContentStyleSheet(
1011 ilGlobalTemplateInterface $a_tpl = null
1012 ): void {
1013 $tpl = $this->tpl;
1014
1015 if ($a_tpl) {
1016 $ctpl = $a_tpl;
1017 } else {
1018 $ctpl = $tpl;
1019 }
1020
1021 $this->content_style_gui->addCss(
1022 $ctpl,
1023 $this->object->getRefId(),
1024 $this->object->getId()
1025 );
1026 }
1027}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Help GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addItem(string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
Notes GUI class.
Portfolio view gui base class.
ILIAS Style Content GUIService $content_style_gui
ILIAS Style Content Object ObjectFacade $content_style_domain
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
addBlog()
Show portfolio blog page creation form.
addPage()
Show portfolio page creation form.
setPermaLink(int $a_obj_id, string $a_type)
Set custom perma link (used in public profile?)
view()
Show list of portfolio pages.
savePage()
Create new portfolio page.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
copyPageForm(ilPropertyFormGUI $a_form=null)
Select target portfolio for page(s) copy.
updateCustom(ilPropertyFormGUI $form)
Insert custom update form values into object.
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
getPageInstance(?int $a_page_id=null, ?int $a_portfolio_id=null)
setAdditional(array $a_additional)
Set Additonal Information (used in public profile?)
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
getPageGUIInstance(int $a_page_id)
static renderFullscreenHeader(ilObjPortfolioBase $a_portfolio, ilGlobalTemplateInterface $a_tpl, int $a_user_id, bool $a_export=false)
Render banner, user name.
setContentStyleSheet(ilGlobalTemplateInterface $a_tpl=null)
savePortfolioPagesOrdering()
Save ordering of portfolio pages.
initPageForm(string $a_mode="create")
Init portfolio page form.
export(bool $a_with_comments=false)
addLocatorItems()
Functions to be overwritten.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getImageFullPath(bool $a_as_thumb=false)
Get banner image incl.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupName(int $a_user_id)
lookup user name
static _getPersonalPicturePath(int $a_usr_id, string $a_size="small", bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
New implementation of ilObjectGUI.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
ilLocatorGUI $locator
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static activeLayouts(int $a_module=0)
Get active layouts.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupType($a_page_id)
static getAllPortfolioPages(int $a_portfolio_id)
Get pages of portfolio.
static fixOrdering(int $a_portfolio_id)
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
getItemByPostVar(string $a_post_var)
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static signFile(string $path_to_file)
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
$img
Definition: imgupload.php:83
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDescription(string $a_descr)
Sets description below title in standard template.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setVariable(string $variable, $value='')
Sets the given variable to the given value.
resetHeaderBlock(bool $a_reset_header_action=true)
Reset all header properties: title, icon, description, alerts, action menu.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$provider
Definition: ltitoken.php:83
if($format !==null) $name
Definition: metadata.php:247
$source
Definition: metadata.php:93
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
Class ChatMainBarProvider \MainMenu\Provider.
global $ilSetting
Definition: privfeed.php:17
$lng
$comments