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