ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjPortfolioBaseGUI.php
Go to the documentation of this file.
1<?php
2
22
28abstract class ilObjPortfolioBaseGUI extends ilObject2GUI
29{
30 protected \ILIAS\Notes\Service $notes;
31 protected \ILIAS\Portfolio\InternalGUIService $gui;
33 protected ilHelpGUI $help;
34 protected int $user_id = 0;
35 protected array $additional = array();
36 protected array $perma_link = [];
37 protected int $page_id = 0;
38 protected string $page_mode; // preview|edit
39 protected int $requested_ppage;
40 protected int $requested_user_page;
41 protected string $requested_back_url = "";
42 protected \ILIAS\DI\UIServices $ui;
43 protected \ILIAS\Style\Content\GUIService $content_style_gui;
44 protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
45
46 public function __construct(
47 int $a_id = 0,
48 int $a_id_type = self::REPOSITORY_NODE_ID,
49 int $a_parent_node_id = 0
50 ) {
51 global $DIC;
52
53 $this->user = $DIC->user();
54 $this->locator = $DIC["ilLocator"];
55 $this->toolbar = $DIC->toolbar();
56 $this->settings = $DIC->settings();
57 $this->tree = $DIC->repositoryTree();
58 $this->help = $DIC["ilHelp"];
59 $this->tpl = $DIC["tpl"];
60 $ilUser = $DIC->user();
61 $this->ui = $DIC->ui();
62
63 $this->port_request = $DIC->portfolio()
64 ->internal()
65 ->gui()
66 ->standardRequest();
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 $this->gui = $DIC->portfolio()->internal()->gui();
95 $this->notes = $DIC->notes();
96 }
97
98 protected function addLocatorItems(): void
99 {
100 $ilLocator = $this->locator;
101
102 if ($this->object) {
103 $ilLocator->addItem(
104 strip_tags($this->object->getTitle()),
105 $this->ctrl->getLinkTarget($this, "view")
106 );
107 }
108
109 if ($this->page_id > 0) {
110 $page = $this->getPageInstance($this->page_id);
111 $title = $page->getTitle();
112 $this->ctrl->setParameterByClass($this->getPageGUIClassName(), "ppage", $this->page_id);
113 $ilLocator->addItem(
114 $title,
115 $this->ctrl->getLinkTargetByClass($this->getPageGUIClassName(), "edit")
116 );
117 }
118 }
119
120 protected function determinePageCall(): bool
121 {
122 // edit
123 if ($this->requested_ppage > 0) {
124 if (!$this->checkPermissionBool("write")) {
125 $this->ctrl->redirect($this, "view");
126 }
127
128 $this->page_id = $this->requested_ppage;
129 $this->page_mode = "edit";
130 $this->ctrl->setParameter($this, "ppage", $this->page_id);
131 return true;
132 }
133
134 // preview
135 $this->page_id = $this->requested_user_page;
136 $this->page_mode = "preview";
137 $this->ctrl->setParameter($this, "user_page", $this->page_id);
138 return false;
139 }
140
141 protected function handlePageCall(string $a_cmd): void
142 {
143 if (!$this->page_id) {
144 $this->ctrl->redirect($this, "view");
145 }
146
147 $page_gui = $this->getPageGUIInstance($this->page_id);
148
149 $this->tabs_gui->clearTargets();
150 $this->tabs_gui->setBackTarget(
151 $this->lng->txt("back"),
152 $this->ctrl->getLinkTarget($this, "view")
153 );
154
155 // needed for editor
156 $page_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
157
158 $ret = $this->ctrl->forwardCommand($page_gui);
159 if ($ret != "" && $ret !== true) {
160 // preview (fullscreen)
161 if ($this->page_mode === "preview") {
162 // embedded call which did not generate any output (e.g. calendar month navigation)
164 // suppress (portfolio) notes for blog postings
165 $this->preview(false, $ret, ($a_cmd !== "previewEmbedded"));
166 } else {
167 $this->preview(false);
168 }
169 }
170 // edit
171 else {
172 $this->setContentStyleSheet();
173 if (is_string($ret)) {
174 $this->tpl->setContent($ret);
175 }
176 }
177 }
178 }
179
183 public function setAdditional(array $a_additional): void
184 {
185 $this->additional = $a_additional;
186 }
187
188 public function getAdditional(): array
189 {
190 return $this->additional;
191 }
192
196 public function setPermaLink(
197 int $a_obj_id,
198 string $a_type
199 ): void {
200 $this->perma_link = array("obj_id" => $a_obj_id, "type" => $a_type);
201 }
202
203
204 //
205 // CREATE/EDIT
206 //
207
208 protected function setSettingsSubTabs(string $a_active): void
209 {
210 // #17455
211 $this->lng->loadLanguageModule($this->getType());
212
213 // general properties
214 $this->tabs_gui->addSubTab(
215 "properties",
216 $this->lng->txt($this->getType() . "_properties"),
217 $this->ctrl->getLinkTarget($this, 'edit')
218 );
219
220 $this->tabs_gui->addSubTab(
221 "style",
222 $this->lng->txt("obj_sty"),
223 $this->ctrl->getLinkTargetByClass("ilobjectcontentstylesettingsgui", "")
224 );
225
226 $this->tabs_gui->activateSubTab($a_active);
227 }
228
229 protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
230 {
231 $this->setSettingsSubTabs("properties");
232
233
234 // profile picture
235 $ppic = new ilCheckboxInputGUI($this->lng->txt("prtf_profile_picture"), "ppic");
236 $a_form->addItem($ppic);
237
238 $prfa_set = new ilSetting("prfa");
239
240 $section = new ilFormSectionHeaderGUI();
241 $section->setTitle($this->lng->txt('obj_features'));
242 $a_form->addItem($section);
243
244 // comments
245 $comments = new ilCheckboxInputGUI($this->lng->txt("prtf_public_comments"), "comments");
246 $a_form->addItem($comments);
247
248 /* #15000
249 $bg_color = new ilColorPickerInputGUI($this->lng->txt("prtf_background_color"), "bg_color");
250 $a_form->addItem($bg_color);
251
252 $font_color = new ilColorPickerInputGUI($this->lng->txt("prtf_font_color"), "font_color");
253 $a_form->addItem($font_color);
254 */
255 }
256
257 protected function getEditFormCustomValues(array &$a_values): void
258 {
259 $a_values["comments"] = $this->object->hasPublicComments();
260 $a_values["ppic"] = $this->object->hasProfilePicture();
261 /*
262 $a_values["bg_color"] = $this->object->getBackgroundColor();
263 $a_values["font_color"] = $this->object->getFontColor();
264 */
265 }
266
267 protected function updateCustom(ilPropertyFormGUI $form): void
268 {
269 $this->object->setPublicComments($form->getInput("comments"));
270 $this->object->setProfilePicture($form->getInput("ppic"));
271 $prfa_set = new ilSetting("prfa");
272 }
273
274
275 //
276 // PAGES
277 //
278
279 abstract protected function getPageInstance(
280 ?int $a_page_id = null,
281 ?int $a_portfolio_id = null
283
284 abstract protected function getPageGUIInstance(int $a_page_id): ilPortfolioPageGUI;
285
286 abstract public function getPageGUIClassName(): string;
287
291 public function view(): void
292 {
293 $ilToolbar = $this->toolbar;
294 $ilSetting = $this->settings;
296
297 if (!$this->checkPermissionBool("write")) {
298 $this->ctrl->redirect($this, "infoScreen");
299 }
300
301 $this->tabs_gui->activateTab("pages");
302
303 $pages = ilPortfolioPage::getAllPortfolioPages($this->getObject()->getId());
304
305 $this->gui->button(
306 $this->lng->txt("prtf_add_page"),
307 $this->ctrl->getLinkTarget($this, "addPage")
308 )->toToolbar(true);
309
310
311 // #16571
312 $modal_html = "";
313 if ($this->getType() === "prtf" && count($pages) > 0) {
314 $ilToolbar->addSeparator();
315
316 $ui = $this->ui;
317
318 if ($this->object->isCommentsExportPossible()) {
319 $this->lng->loadLanguageModule("note");
320 $comment_export_helper = new \ILIAS\Notes\Export\ExportHelperGUI();
321 $comment_modal = $comment_export_helper->getCommentIncludeModalDialog(
322 $this->lng->txt("export_html"),
323 $this->lng->txt("note_html_export_include_comments"),
324 $this->ctrl->getLinkTarget($this, "export"),
325 $this->ctrl->getLinkTarget($this, "exportWithComments")
326 );
327 $button = $ui->factory()->button()->standard($this->lng->txt("export_html"), '')
328 ->withOnClick($comment_modal->getShowSignal());
329 $ilToolbar->addComponent($button);
330 $modal_html = $ui->renderer()->render($comment_modal);
331 } else {
332 $this->gui->button(
333 $this->lng->txt("export_html"),
334 $this->ctrl->getLinkTarget($this, "export")
335 )->toToolbar();
336 }
337
338 $print_view = $this->getPrintView();
339 $modal_elements = $print_view->getModalElements($this->ctrl->getLinkTarget(
340 $this,
341 "printSelection"
342 ));
343 $modal_html .= $ui->renderer()->render($modal_elements->modal);
344 $ilToolbar->addComponent($modal_elements->button);
345 }
346
347 $table = new ilPortfolioPageTableGUI($this, "view");
348
349
350 $this->tpl->setContent($table->getHTML() . $modal_html);
351 }
352
353 public function getPrintView(): \ILIAS\Export\PrintProcessGUI
354 {
355 $obj_ids = $this->port_request->getObjIds();
356 $signature = $this->port_request->getSignature();
357 $declaration = $this->port_request->getIncludeDeclaration();
358 if (count($obj_ids) === 0) {
359 $obj_ids = null;
360 }
362 $port = $this->object;
364 $this->lng,
365 $this->ctrl,
366 $port,
367 $signature,
368 $obj_ids,
369 $declaration
370 );
371 $provider = $provider->withDeclarationOfAuthorship(
373 $this->user
374 );
375 return new \ILIAS\Export\PrintProcessGUI(
376 $provider,
377 $this->http,
378 $this->ui,
379 $this->lng
380 );
381 }
382
386 protected function addPage(): void
387 {
388 $ilHelp = $this->help;
389
390 $this->tabs_gui->clearTargets();
391 $this->tabs_gui->setBackTarget(
392 $this->lng->txt("back"),
393 $this->ctrl->getLinkTarget($this, "view")
394 );
395
396 $ilHelp->setScreenIdComponent("prtf");
397 $ilHelp->setScreenId("add_page");
398
399
400 $form = $this->initPageForm("create");
401 $this->tpl->setContent($form->getHTML());
402 }
403
407 public function initPageForm(string $a_mode = "create"): ilPropertyFormGUI
408 {
409 $form = new ilPropertyFormGUI();
410 $form->setFormAction($this->ctrl->getFormAction($this));
411
412 // title
413 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
414 $ti->setMaxLength(200);
415 $ti->setRequired(true);
416 $form->addItem($ti);
417
418 // save and cancel commands
419 if ($a_mode === "create") {
421 if ($templates) {
422 $use_template = new ilRadioGroupInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
423 $use_template->setRequired(true);
424 $form->addItem($use_template);
425
426 $opt = new ilRadioOption($this->lng->txt("none"), 0);
427 $use_template->addOption($opt);
428
429 foreach ($templates as $templ) {
430 $templ->readObject();
431
432 $opt = new ilRadioOption($templ->getTitle() . $templ->getPreview(), $templ->getId());
433 $use_template->addOption($opt);
434 }
435 }
436
437 $form->setTitle($this->lng->txt("prtf_add_page") . ": " .
438 $this->object->getTitle());
439 $form->addCommandButton("savePage", $this->lng->txt("save"));
440 $form->addCommandButton("view", $this->lng->txt("cancel"));
441 }
442
443 return $form;
444 }
445
449 public function savePage(): void
450 {
451 $form = $this->initPageForm("create");
452 if ($form->checkInput() && $this->checkPermissionBool("write")) {
453 $page = $this->getPageInstance();
454 $page->setType(ilPortfolioPage::TYPE_PAGE);
455 $page->setTitle($form->getInput("title"));
456
457 // use template as basis
458 $layout_id = $form->getInput("tmpl");
459 if ($layout_id) {
460 $layout_obj = new ilPageLayout($layout_id);
461 $page->setXMLContent($layout_obj->copyXmlContent(false));
462 }
463
464 $page->create();
465
466 $this->tpl->setOnScreenMessage('success', $this->lng->txt("prtf_page_created"), true);
467 $this->ctrl->redirect($this, "view");
468 }
469
470 $this->tabs_gui->clearTargets();
471 $this->tabs_gui->setBackTarget(
472 $this->lng->txt("back"),
473 $this->ctrl->getLinkTarget($this, "view")
474 );
475
476 $form->setValuesByPost();
477 $this->tpl->setContent($form->getHTML());
478 }
479
483 public function savePortfolioPagesOrdering(): void
484 {
485 if (!$this->checkPermissionBool("write")) {
486 return;
487 }
488
489 $title_changes = array();
490
491 $order = $this->port_request->getOrder();
492 $titles = $this->port_request->getTitles();
493 if (count($order) > 0) {
494 foreach ($order as $k => $v) {
495 $page = $this->getPageInstance(ilUtil::stripSlashes($k));
496 if ($titles[$k] ?? "") {
497 $new_title = $titles[$k] ?? "";
498 if ($page->getTitle() != $new_title) {
499 $title_changes[$page->getId()] = array("old" => $page->getTitle(), "new" => $new_title);
500 $page->setTitle($new_title);
501 }
502 }
503 $page->setOrderNr(ilUtil::stripSlashes($v));
504 $page->update();
505 }
506 ilPortfolioPage::fixOrdering($this->object->getId());
507 }
508
509 $this->object->fixLinksOnTitleChange($title_changes);
510
511 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
512 $this->ctrl->redirect($this, "view");
513 }
514
515 public function confirmPortfolioPageDeletion(): void
516 {
517 $prtf_pages = $this->port_request->getPortfolioPageIds();
518
519 if (count($prtf_pages) === 0) {
520 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
521 $this->ctrl->redirect($this, "view");
522 } else {
523 $this->tabs_gui->activateTab("pages");
524
525 $cgui = new ilConfirmationGUI();
526 $cgui->setFormAction($this->ctrl->getFormAction($this));
527 $cgui->setHeaderText($this->lng->txt("prtf_sure_delete_portfolio_pages"));
528 $cgui->setCancel($this->lng->txt("cancel"), "view");
529 $cgui->setConfirm($this->lng->txt("delete"), "deletePortfolioPages");
530
531 foreach ($prtf_pages as $id) {
532 $page = $this->getPageInstance($id);
533 if ($page->getPortfolioId() !== $this->object->getId()) {
534 continue;
535 }
536
537 $title = $page->getTitle();
538 $cgui->addItem("prtf_pages[]", $id, $title);
539 }
540
541 $this->tpl->setContent($cgui->getHTML());
542 }
543 }
544
545 public function deletePortfolioPages(): void
546 {
547 if (!$this->checkPermissionBool("write")) {
548 return;
549 }
550
551 $page_ids = $this->port_request->getPortfolioPageIds();
552 foreach ($page_ids as $id) {
553 $page = $this->getPageInstance($id);
554 $page->delete();
555 }
556 $this->tpl->setOnScreenMessage('success', $this->lng->txt("prtf_portfolio_page_deleted"), true);
557 $this->ctrl->redirect($this, "view");
558 }
559
563 public function preview(
564 bool $a_return = false,
565 $a_content = false,
566 bool $a_show_notes = true
567 ): string {
568 $ilSetting = $this->settings;
569 $ilUser = $this->user;
570 $portfolio_id = $this->object->getId();
571 $user_id = $this->object->getOwner();
572
573 $content = "";
574
575 $this->tabs_gui->clearTargets();
576
577 $pages = ilPortfolioPage::getAllPortfolioPages($portfolio_id);
578 $current_page = $this->getCurrentPage();
579
580 // #13788 - keep page after login
581 if ($this->user_id === ANONYMOUS_USER_ID &&
582 $this->getType() === "prtf") {
583 $this->tpl->setLoginTargetPar("prtf_" . $this->object->getId() . "_" . $current_page);
584 }
585
586 $back_caption = "";
587
588 // public profile
589 if ($this->requested_back_url != "") {
590 $back = $this->requested_back_url;
591 } elseif (strtolower($this->port_request->getBaseClass()) !== strtolower(PublicProfileGUI::class) &&
592 $this->user_id && $this->user_id !== ANONYMOUS_USER_ID) {
593 if (!$this->checkPermissionBool("write")) {
594 // shared
595 if ($this->getType() === "prtf") {
596 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", $this->object->getOwner());
597 $back = $this->ctrl->getLinkTargetByClass(array("ildashboardgui", "ilportfoliorepositorygui"), "showOther");
598 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", "");
599 }
600 // listgui / parent container
601 else {
602 // #12819
603 $tree = $this->tree;
604 $parent_id = $tree->getParentId($this->node_id);
605 $back = ilLink::_getStaticLink($parent_id);
606 }
607 }
608 // owner
609 else {
610 $back = $this->ctrl->getLinkTarget($this, "view");
611 if ($this->getType() === "prtf") {
612 $back_caption = $this->lng->txt("prtf_back_to_portfolio_owner");
613 } else {
614 // #19316
615 $this->lng->loadLanguageModule("prtt");
616 $back_caption = $this->lng->txt("prtt_edit");
617 }
618 }
619 }
620
621 // render tabs
622 if (count($pages) > 1) {
623 foreach ($pages as $p) {
624 $this->ctrl->setParameter($this, "user_page", $p["id"]);
625 $this->tabs_gui->addTab(
626 "user_page_" . $p["id"],
627 $p["title"],
628 $this->ctrl->getLinkTarget($this, "preview")
629 );
630 }
631
632 $this->tabs_gui->activateTab("user_page_" . $current_page);
633 }
634
635 $this->ctrl->setParameter($this, "user_page", $current_page);
636
637
638 // blog posting comments are handled within the blog
639 // note: notes must be handled before the $this->ctrl->getHTML below, since
640 // this messes up the path since ILIAS 8
641 $notes = "";
642 if ($a_show_notes && $this->object->hasPublicComments() && $current_page) {
643 $comment_gui = $this->getCommentGUI();
644 $next_class = $this->ctrl->getNextClass($this);
645 if ($next_class === "ilcommentgui") {
646 $notes = $this->ctrl->forwardCommand($comment_gui);
647 } else {
648 $notes = $comment_gui->getListHTML();
649 }
650 }
651
652 if (!$a_content) {
653 // #18291
654 if ($current_page) {
655 // get current page content
656 $page_gui = $this->getPageGUIInstance($current_page);
657 $page_gui->setEmbedded(true);
658
659 $content = $this->ctrl->getHTML($page_gui);
660 }
661 } else {
662 $content = $a_content;
663 }
664
665 if ($a_return && $this->checkPermissionBool("write")) {
666 return $content;
667 }
668
669
670 if (count($this->perma_link) === 0) {
671 if ($this->getType() === "prtf") {
672 $this->tpl->setPermanentLink($this->getType(), $this->object->getId(), "_" . $current_page);
673 } else {
674 $this->tpl->setPermanentLink($this->getType(), $this->object->getRefId());
675 }
676 } else {
677 $this->tpl->setPermanentLink($this->perma_link["type"] ?? "", $this->perma_link["obj_id"] ?? 0);
678 }
679
680 // #18208 - see ilPortfolioTemplatePageGUI::getPageContentUserId()
681 if ($this->getType() === "prtt" && !$this->checkPermissionBool("write")) {
682 $user_id = $ilUser->getId();
683 }
684
686 $obj = $this->object;
687 self::renderFullscreenHeader($obj, $this->tpl, $user_id);
688
689 // #13564
690 $this->ctrl->setParameter($this, "user_page", "");
691 //$this->tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
692 $this->ctrl->setParameter($this, "user_page", $this->page_id);
693
694 // blog pages do their own (page) style handling
695 $content = '<div id="ilCOPageContent" class="ilc_page_cont_PageContainer">' .
696 '<div class="ilc_page_Page">' .
697 $content .
698 '</div></div>';
699
700 $this->setContentStyleSheet($this->tpl);
701
702 $this->showEditButton($current_page);
703
704 // #10717
705 $this->tpl->setContent($content .
706 '<div class="ilClearFloat">' . $notes . '</div>');
707 return "";
708 }
709
710 protected function getCurrentPage(): ?int
711 {
712 $pages = ilPortfolioPage::getAllPortfolioPages($this->object->getId());
713 $current_page = (int) $this->requested_user_page;
714
715 // validate current page
716 if ($pages && $current_page) {
717 $found = false;
718 foreach ($pages as $page) {
719 if ((int) $page["id"] === $current_page) {
720 $found = true;
721 break;
722 }
723 }
724 if (!$found) {
725 $current_page = null;
726 }
727 }
728
729 // display first page of portfolio if none given
730 if (!$current_page && $pages) {
731 $current_page = $pages;
732 $current_page = array_shift($current_page);
733 $current_page = (int) $current_page["id"];
734 }
735 return $current_page;
736 }
737
738 protected function getCommentGUI(): ilCommentGUI
739 {
740 $gui = $this->notes->gui()->getCommentsGUI(
741 $this->object->getId(),
742 $this->getCurrentPage(),
743 "pfpg"
744 );
745 $gui->setRepositoryMode(false);
746 $gui->enablePublicNotesDeletion(($this->user_id === $this->object->getOwner()) &&
747 $this->settings->get("comments_del_tutor", '1'));
748 return $gui;
749 }
750
751 protected function showEditButton(
752 int $page_id
753 ): void {
754 $page_class = ($this->getType() === "prtt")
755 ? "ilPortfolioTemplatePageGUI"
756 : "ilportfoliopagegui";
757 $button = null;
758 if ($this->checkPermissionBool("write") &&
759 ($page_id === 0 || ilPortfolioPage::lookupType($page_id) === ilPortfolioPage::TYPE_PAGE)) {
760 if ($this->getType() === "prtt") {
761 $button = $this->ui->factory()->button()->standard(
762 $this->lng->txt("prtt_edit"),
763 $this->ctrl->getLinkTargetByClass(["ilobjportfoliotemplategui"], "view")
764 );
765 } else {
766 $button = $this->ui->factory()->button()->standard(
767 $this->lng->txt("prtf_edit_portfolio"),
768 $this->ctrl->getLinkTargetByClass([
769 ilDashboardGUI::class,
770 ilPortfolioRepositoryGUI::class,
771 ilObjPortfolioGUI::class
772 ], "view")
773 );
774 }
775 $this->toolbar->addComponent($button);
776 $button = null;
777 }
778 if ($page_id > 0 && ilPortfolioPage::lookupType($page_id) === ilPortfolioPage::TYPE_PAGE) {
779 $this->ctrl->setParameterByClass($page_class, "ppage", $page_id);
780 $button = $this->ui->factory()->button()->standard(
781 $this->lng->txt("edit_page"),
782 $this->ctrl->getLinkTargetByClass($page_class, "edit")
783 );
784 if ($this->checkPermissionBool("write")) {
785 $this->toolbar->addComponent($button);
786 }
787 $button = null;
788 }
789 if ($button && $this->checkPermissionBool("write")) {
790 $this->tpl->setHeaderActionMenu($this->ui->renderer()->render($button));
791 }
792 }
793
794 public static function renderFullscreenHeader(
795 ilObjPortfolioBase $a_portfolio,
797 int $a_user_id,
798 bool $a_export = false
799 ): void {
800 global $DIC;
801
802 $ilUser = $DIC->user();
803
804 if (!$a_export) {
806 $a_portfolio->getType(),
807 ($a_portfolio->getType() === "prtt")
808 ? $a_portfolio->getRefId()
809 : $a_portfolio->getId(),
810 $a_portfolio->getId(),
811 $ilUser->getId()
812 );
813 }
814
815 $name = ilObjUser::_lookupName($a_user_id);
816 $name = $name["lastname"] . ", " . (($t = $name["title"]) ? $t . " " : "") . $name["firstname"];
817
818 $prfa_set = new ilSetting("prfa");
819
820 // profile picture
821 $ppic = null;
822 if ($a_portfolio->hasProfilePicture()) {
823 $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
824 if ($a_export) {
825 $ppic = basename($ppic);
826 }
827 }
828
829 $a_tpl->resetHeaderBlock(false);
830 // $a_tpl->setBackgroundColor($a_portfolio->getBackgroundColor());
831 // @todo fix this
832 $a_tpl->setTitleIcon((string) $ppic);
833 $a_tpl->setTitle($a_portfolio->getTitle());
834 // $a_tpl->setTitleColor($a_portfolio->getFontColor());
835 $a_tpl->setDescription($name);
836
837 // to get rid of locator in portfolio template preview
838 $a_tpl->setVariable("LOCATOR", "");
839
840 // :TODO: obsolete?
841 // $a_tpl->setBodyClass("std ilExternal ilPortfolio");
842 }
843
844 public function export(
845 bool $a_with_comments = false
846 ): void {
847 $port_export = new \ILIAS\Portfolio\Export\PortfolioHtmlExport($this);
848 $port_export->includeComments($a_with_comments);
849 $port_export->exportHtml();
850 $port_export->deliver($this->object->getTitle() . ".zip", true);
851 }
852
853 public function exportWithComments(): void
854 {
855 $this->export(true);
856 }
857
861 public function copyPageForm(
862 ?ilPropertyFormGUI $a_form = null
863 ): void {
864 $prtf_pages = $this->port_request->getPortfolioPageIds();
865
866 if (count($prtf_pages) === 0) {
867 $this->tpl->setOnScreenMessage('info', $this->lng->txt("no_checkbox"), true);
868 $this->ctrl->redirect($this, "view");
869 } else {
870 $this->tabs_gui->activateTab("pages");
871
872 if (!$a_form) {
873 $a_form = $this->initCopyPageForm();
874 }
875
876 foreach ($prtf_pages as $page_id) {
877 $item = new ilHiddenInputGUI("prtf_pages[]");
878 $item->setValue($page_id);
879 $a_form->addItem($item);
880 }
881
882 $this->tpl->setContent($a_form->getHTML());
883 }
884 }
885
886 public function copyPage(): void
887 {
888 $form = $this->initCopyPageForm();
889 if ($form->checkInput()) {
890 // existing
891 if ($form->getInput("target") === "old") {
892 $portfolio_id = $form->getInput("prtf");
893 }
894 // new
895 else {
896 $portfolio = new ilObjPortfolio();
897 $portfolio->setTitle($form->getInput("title"));
898 $portfolio->create();
899 $portfolio_id = $portfolio->getId();
900 }
901
902 // copy page(s)
903 $page_ids = $this->port_request->getPortfolioPageIds();
904 foreach ($page_ids as $page_id) {
905 $source = $this->getPageInstance($page_id);
906 $target = $this->getPageInstance(null, $portfolio_id);
907 $target->setXMLContent($source->copyXmlContent(true)); // copy mobs
908 $target->setType($source->getType());
909 $target->setTitle($source->getTitle());
910 $target->create();
911 }
912
913 $this->tpl->setOnScreenMessage('success', $this->lng->txt("prtf_pages_copied"), true);
914 $this->ctrl->redirect($this, "view");
915 }
916
917 $form->setValuesByPost();
918 $this->copyPageForm($form);
919 }
920
921 abstract protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form): void;
922
924 {
925 $form = new ilPropertyFormGUI();
926 $form->setFormAction($this->ctrl->getFormAction($this));
927 $form->setTitle($this->lng->txt("prtf_copy_page"));
928
929 $this->initCopyPageFormOptions($form);
930
931 $form->addCommandButton("copyPage", $this->lng->txt("save"));
932 $form->addCommandButton("view", $this->lng->txt("cancel"));
933
934 return $form;
935 }
936
937
941
942 public function setContentStyleSheet(
943 ?ilGlobalTemplateInterface $a_tpl = null
944 ): void {
945 $tpl = $this->tpl;
946
947 if ($a_tpl) {
948 $ctpl = $a_tpl;
949 } else {
950 $ctpl = $tpl;
951 }
952
953 $this->content_style_gui->addCss(
954 $ctpl,
955 $this->object->getRefId(),
956 $this->object->getId()
957 );
958 }
959}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
GUI class for public user profile presentation.
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...
This class represents a section header in a property form.
Help GUI class.
This class represents a hidden form property in a property form.
setRepositoryMode(bool $a_value)
Portfolio view gui base class.
ILIAS Style Content GUIService $content_style_gui
ILIAS Style Content Object ObjectFacade $content_style_domain
initCopyPageFormOptions(ilPropertyFormGUI $a_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.
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?)
ILIAS Portfolio InternalGUIService $gui
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)
savePortfolioPagesOrdering()
Save ordering of portfolio pages.
initPageForm(string $a_mode="create")
Init portfolio page form.
export(bool $a_with_comments=false)
copyPageForm(?ilPropertyFormGUI $a_form=null)
Select target portfolio for page(s) copy.
addLocatorItems()
Functions to be overwritten.
setContentStyleSheet(?ilGlobalTemplateInterface $a_tpl=null)
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 _lookupName(int $a_user_id)
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false)
New implementation of ilObjectGUI.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
ilLocatorGUI $locator
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...
Portfolio page 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...
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-...
This class represents a property in a property form.
This class represents an option in a radio group.
ILIAS Setting Class.
This class represents a text property in a property form.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
const ANONYMOUS_USER_ID
Definition: constants.php:27
setDescription(string $a_descr)
Sets description below title in standard template.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
resetHeaderBlock(bool $a_reset_header_action=true)
Reset all header properties: title, icon, description, alerts, action menu.
$provider
Definition: ltitoken.php:80
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:31
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26
$comments