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