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