ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjPortfolioBaseGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('./Services/Object/classes/class.ilObject2GUI.php');
5include_once('./Modules/Portfolio/classes/class.ilObjPortfolio.php');
6include_once('./Modules/Portfolio/classes/class.ilPortfolioPage.php');
7
16abstract class ilObjPortfolioBaseGUI extends ilObject2GUI
17{
21 protected $help;
22
26 protected $main_menu;
27
28 protected $user_id; // [int]
29 protected $additional = array();
30 protected $perma_link; // [string]
31 protected $page_id; // [int]
32 protected $page_mode; // [string] preview|edit
33
38
43
47 protected $requested_back_url = "";
48
49 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $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->main_menu = $DIC["ilMainMenu"];
60 $this->tpl = $DIC["tpl"];
61 $ilUser = $DIC->user();
62
63 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
64
65 $this->user_id = $ilUser->getId();
66
67 $this->lng->loadLanguageModule("prtf");
68 $this->lng->loadLanguageModule("user");
69 $this->lng->loadLanguageModule("obj");
70
71 $this->requested_ppage = (int) $_REQUEST["ppage"];
72 $this->requested_user_page = (int) $_REQUEST["user_page"];
73
74 // temp sanitization, should be done smarter in the future
75 $back = str_replace("&amp;", ":::", $_REQUEST["back_url"]);
76 $back = preg_replace(
77 "/[^a-zA-Z0-9_\.\?=:\s]/",
78 "",
79 $back
80 );
81 $this->requested_back_url = str_replace(":::", "&amp;", $back);
82
83 $this->ctrl->setParameterbyClass("ilobjportfoliogui", "back_url", rawurlencode($this->requested_back_url));
84 }
85
86 protected function addLocatorItems()
87 {
88 $ilLocator = $this->locator;
89
90 if ($this->object) {
91 $ilLocator->addItem(
92 strip_tags($this->object->getTitle()),
93 $this->ctrl->getLinkTarget($this, "view")
94 );
95 }
96
97 if ($this->page_id) {
98 $page = $this->getPageInstance($this->page_id);
99 $title = $page->getTitle();
100 if ($page->getType() == ilPortfolioPage::TYPE_BLOG) {
102 }
103 $this->ctrl->setParameterByClass($this->getPageGUIClassName(), "ppage", $this->page_id);
104 $ilLocator->addItem(
105 $title,
106 $this->ctrl->getLinkTargetByClass($this->getPageGUIClassName(), "edit")
107 );
108 }
109 }
110
111 protected function determinePageCall()
112 {
113 // edit
114 if ($this->requested_ppage > 0) {
115 if (!$this->checkPermissionBool("write")) {
116 $this->ctrl->redirect($this, "view");
117 }
118
119 $this->page_id = $this->requested_ppage;
120 $this->page_mode = "edit";
121 $this->ctrl->setParameter($this, "ppage", $this->page_id);
122 return true;
123 }
124 // preview
125 else {
126 $this->page_id = $this->requested_user_page;
127 $this->page_mode = "preview";
128 $this->ctrl->setParameter($this, "user_page", $this->page_id);
129 return false;
130 }
131 }
132
133 protected function handlePageCall($a_cmd)
134 {
135 $this->tabs_gui->clearTargets();
136 $this->tabs_gui->setBackTarget(
137 $this->lng->txt("back"),
138 $this->ctrl->getLinkTarget($this, "view")
139 );
140
141 if (!$this->page_id) {
142 $this->ctrl->redirect($this, "view");
143 }
144
145 $page_gui = $this->getPageGUIInstance($this->page_id);
146
147 // needed for editor
149 $this->object->getStyleSheetId(),
150 $this->getType()
151 ));
152
153 $ret = $this->ctrl->forwardCommand($page_gui);
154
155 if ($ret != "" && $ret !== true) {
156 // preview (fullscreen)
157 if ($this->page_mode == "preview") {
158 // embedded call which did not generate any output (e.g. calendar month navigation)
160 // suppress (portfolio) notes for blog postings
161 $this->preview(false, $ret, ($a_cmd != "previewEmbedded"));
162 } else {
163 $this->preview(false);
164 }
165 }
166 // edit
167 else {
168 $this->setContentStyleSheet();
169 if (is_string($ret)) {
170 $this->tpl->setContent($ret);
171 }
172 }
173 }
174 }
175
181 public function setAdditional($a_additional)
182 {
183 $this->additional = $a_additional;
184 }
185
191 public function getAdditional()
192 {
193 return $this->additional;
194 }
195
202 public function setPermaLink($a_obj_id, $a_type)
203 {
204 $this->perma_link = array("obj_id" => $a_obj_id, "type" => $a_type);
205 }
206
207
208 //
209 // CREATE/EDIT
210 //
211
212 protected function setSettingsSubTabs($a_active)
213 {
214 // #17455
215 $this->lng->loadLanguageModule($this->getType());
216
217 // general properties
218 $this->tabs_gui->addSubTab(
219 "properties",
220 $this->lng->txt($this->getType() . "_properties"),
221 $this->ctrl->getLinkTarget($this, 'edit')
222 );
223
224 $this->tabs_gui->addSubTab(
225 "style",
226 $this->lng->txt("obj_sty"),
227 $this->ctrl->getLinkTarget($this, 'editStyleProperties')
228 );
229
230 $this->tabs_gui->activateSubTab($a_active);
231 }
232
233 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
234 {
235 $this->setSettingsSubTabs("properties");
236
237
238 // profile picture
239 $ppic = new ilCheckboxInputGUI($this->lng->txt("prtf_profile_picture"), "ppic");
240 $a_form->addItem($ppic);
241
242 $prfa_set = new ilSetting("prfa");
243 if ($prfa_set->get("banner")) {
244 include_once "Services/Form/classes/class.ilFileInputGUI.php";
246
247 $dimensions = " (" . $prfa_set->get("banner_width") . "x" .
248 $prfa_set->get("banner_height") . ")";
249
250 $img = new ilImageFileInputGUI($this->lng->txt("prtf_banner") . $dimensions, "banner");
251 $a_form->addItem($img);
252
253 // show existing file
254 $file = $this->object->getImageFullPath(true);
255 if ($file) {
256 $img->setImage($file);
257 }
258 }
259
261 $section->setTitle($this->lng->txt('obj_features'));
262 $a_form->addItem($section);
263
264 // comments
265 $comments = new ilCheckboxInputGUI($this->lng->txt("prtf_public_comments"), "comments");
266 $a_form->addItem($comments);
267
268 /* #15000
269 $bg_color = new ilColorPickerInputGUI($this->lng->txt("prtf_background_color"), "bg_color");
270 $a_form->addItem($bg_color);
271
272 $font_color = new ilColorPickerInputGUI($this->lng->txt("prtf_font_color"), "font_color");
273 $a_form->addItem($font_color);
274 */
275 }
276
277 protected function getEditFormCustomValues(array &$a_values)
278 {
279 $a_values["comments"] = $this->object->hasPublicComments();
280 $a_values["ppic"] = $this->object->hasProfilePicture();
281 /*
282 $a_values["bg_color"] = $this->object->getBackgroundColor();
283 $a_values["font_color"] = $this->object->getFontColor();
284 */
285 }
286
287 public function updateCustom(ilPropertyFormGUI $a_form)
288 {
289 $this->object->setPublicComments($a_form->getInput("comments"));
290 $this->object->setProfilePicture($a_form->getInput("ppic"));
291 /*
292 $this->object->setBackgroundColor($a_form->getInput("bg_color"));
293 $this->object->setFontcolor($a_form->getInput("font_color"));
294 */
295
296 $prfa_set = new ilSetting("prfa");
297
298 if ($_FILES["banner"]["tmp_name"]) {
299 $this->object->uploadImage($_FILES["banner"]);
300 } elseif ($prfa_set->get('banner') and $a_form->getItemByPostVar("banner")->getDeletionFlag()) {
301 $this->object->deleteImage();
302 }
303 }
304
305
306 //
307 // PAGES
308 //
309
310 abstract protected function getPageInstance($a_page_id = null, $a_portfolio_id = null);
311
312 abstract protected function getPageGUIInstance($a_page_id);
313
314 abstract public function getPageGUIClassName();
315
319 public function view()
320 {
321 $ilToolbar = $this->toolbar;
324
325 if (!$this->checkPermissionBool("write")) {
326 $this->ctrl->redirect($this, "infoScreen");
327 }
328
329 $this->tabs_gui->activateTab("pages");
330
331 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
332
333 $button = ilLinkButton::getInstance();
334 $button->setCaption("prtf_add_page");
335 $button->setUrl($this->ctrl->getLinkTarget($this, "addPage"));
336 $ilToolbar->addStickyItem($button);
337
338 if (!$ilSetting->get('disable_wsp_blogs')) {
339 $button = ilLinkButton::getInstance();
340 $button->setCaption("prtf_add_blog");
341 $button->setUrl($this->ctrl->getLinkTarget($this, "addBlog"));
342 $ilToolbar->addStickyItem($button);
343 }
344
345
346 // #16571
347 if ($this->getType() == "prtf") {
348 $ilToolbar->addSeparator();
349
350 $button = ilLinkButton::getInstance();
351 $button->setCaption("export_html");
352 $button->setUrl($this->ctrl->getLinkTarget($this, "export"));
353 $ilToolbar->addButtonInstance($button);
354
355 $button = ilLinkButton::getInstance();
356 $button->setCaption("prtf_pdf");
357 $button->setUrl($this->ctrl->getLinkTarget($this, "exportPDFSelection"));
358 $ilToolbar->addButtonInstance($button);
359 }
360
361 include_once "Modules/Portfolio/classes/class.ilPortfolioPageTableGUI.php";
362 $table = new ilPortfolioPageTableGUI($this, "view");
363
364 // exercise portfolio?
365 include_once "Modules/Portfolio/classes/class.ilPortfolioExerciseGUI.php";
366 $message = ilPortfolioExerciseGUI::checkExercise($this->user_id, $this->object->getId(), $table->dataExists());
367
368 $this->tpl->setContent($message . $table->getHTML());
369 }
370
374 protected function addPage()
375 {
376 $ilHelp = $this->help;
377
378 $this->tabs_gui->clearTargets();
379 $this->tabs_gui->setBackTarget(
380 $this->lng->txt("back"),
381 $this->ctrl->getLinkTarget($this, "view")
382 );
383
384 $ilHelp->setScreenIdComponent("prtf");
385 $ilHelp->setScreenId("add_page");
386
387
388 $form = $this->initPageForm("create");
389 $this->tpl->setContent($form->getHTML());
390 }
391
398 public function initPageForm($a_mode = "create")
399 {
400 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
401 $form = new ilPropertyFormGUI();
402 $form->setFormAction($this->ctrl->getFormAction($this));
403
404 // title
405 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
406 $ti->setMaxLength(200);
407 $ti->setRequired(true);
408 $form->addItem($ti);
409
410 // save and cancel commands
411 if ($a_mode == "create") {
412 include_once "Services/COPage/Layout/classes/class.ilPageLayout.php";
414 if ($templates) {
415 $use_template = new ilRadioGroupInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
416 $use_template->setRequired(true);
417 $form->addItem($use_template);
418
419 $opt = new ilRadioOption($this->lng->txt("none"), 0);
420 $use_template->addOption($opt);
421
422 foreach ($templates as $templ) {
423 $templ->readObject();
424
425 $opt = new ilRadioOption($templ->getTitle() . $templ->getPreview(), $templ->getId());
426 $use_template->addOption($opt);
427 }
428 }
429
430 $form->setTitle($this->lng->txt("prtf_add_page") . ": " .
431 $this->object->getTitle());
432 $form->addCommandButton("savePage", $this->lng->txt("save"));
433 $form->addCommandButton("view", $this->lng->txt("cancel"));
434 } else {
435 /* edit is done directly in table gui
436 $form->setTitle($this->lng->txt("prtf_edit_page"));
437 $form->addCommandButton("updatePage", $this->lng->txt("save"));
438 $form->addCommandButton("view", $this->lng->txt("cancel"));
439 */
440 }
441
442 return $form;
443 }
444
448 public function savePage()
449 {
450 $form = $this->initPageForm("create");
451 if ($form->checkInput() && $this->checkPermissionBool("write")) {
452 include_once("Modules/Portfolio/classes/class.ilPortfolioPage.php");
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 include_once("./Services/COPage/Layout/classes/class.ilPageLayout.php");
461 $layout_obj = new ilPageLayout($layout_id);
462 $page->setXMLContent($layout_obj->getXMLContent());
463 }
464
465 $page->create();
466
467 ilUtil::sendSuccess($this->lng->txt("prtf_page_created"), true);
468 $this->ctrl->redirect($this, "view");
469 }
470
471 $this->tabs_gui->clearTargets();
472 $this->tabs_gui->setBackTarget(
473 $this->lng->txt("back"),
474 $this->ctrl->getLinkTarget($this, "view")
475 );
476
477 $form->setValuesByPost();
478 $this->tpl->setContent($form->getHtml());
479 }
480
484 protected function addBlog()
485 {
486 $ilHelp = $this->help;
487
488 $this->tabs_gui->clearTargets();
489 $this->tabs_gui->setBackTarget(
490 $this->lng->txt("back"),
491 $this->ctrl->getLinkTarget($this, "view")
492 );
493
494 $ilHelp->setScreenIdComponent("prtf");
495 $ilHelp->setScreenId("add_blog");
496
497 $form = $this->initBlogForm();
498 $this->tpl->setContent($form->getHTML());
499 }
500
501 abstract protected function initBlogForm();
502
503 abstract protected function saveBlog();
504
509 {
510 if (!$this->checkPermissionBool("write")) {
511 return;
512 }
513
514 $title_changes = array();
515
516 if (is_array($_POST["order"])) {
517 foreach ($_POST["order"] as $k => $v) {
518 $page = $this->getPageInstance(ilUtil::stripSlashes($k));
519 if ($_POST["title"][$k]) {
520 $new_title = trim(ilUtil::stripSlashes($_POST["title"][$k]));
521 if ($page->getTitle() != $new_title) {
522 $title_changes[$page->getId()] = array("old" => $page->getTitle(), "new" => $new_title);
523 $page->setTitle($new_title);
524 }
525 }
526 $page->setOrderNr(ilUtil::stripSlashes($v));
527 $page->update();
528 }
529 ilPortfolioPage::fixOrdering($this->object->getId());
530 }
531
532 $this->object->fixLinksOnTitleChange($title_changes);
533
534 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
535 $this->ctrl->redirect($this, "view");
536 }
537
542 {
543 $prtf_pages = $_REQUEST["prtf_pages"];
544
545 if (!is_array($prtf_pages) || count($prtf_pages) == 0) {
546 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
547 $this->ctrl->redirect($this, "view");
548 } else {
549 $this->tabs_gui->activateTab("pages");
550
551 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
552 $cgui = new ilConfirmationGUI();
553 $cgui->setFormAction($this->ctrl->getFormAction($this));
554 $cgui->setHeaderText($this->lng->txt("prtf_sure_delete_portfolio_pages"));
555 $cgui->setCancel($this->lng->txt("cancel"), "view");
556 $cgui->setConfirm($this->lng->txt("delete"), "deletePortfolioPages");
557
558 foreach ($prtf_pages as $id) {
559 $page = $this->getPageInstance((int) $id);
560 if ($page->getPortfolioId() != $this->object->getId()) {
561 continue;
562 }
563
564 $title = $page->getTitle();
565 if ($page->getType() == ilPortfolioPage::TYPE_BLOG) {
566 $title = $this->lng->txt("obj_blog") . ": " . ilObject::_lookupTitle((int) $title);
567 }
568 $cgui->addItem("prtf_pages[]", $id, $title);
569 }
570
571 $this->tpl->setContent($cgui->getHTML());
572 }
573 }
574
578 public function deletePortfolioPages()
579 {
580 if (!$this->checkPermissionBool("write")) {
581 return;
582 }
583
584 if (is_array($_POST["prtf_pages"])) {
585 foreach ($_POST["prtf_pages"] as $id) {
586 $page = $this->getPageInstance($id);
587 $page->delete();
588 }
589 }
590 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_page_deleted"), true);
591 $this->ctrl->redirect($this, "view");
592 }
593
597 public function preview($a_return = false, $a_content = false, $a_show_notes = true)
598 {
601
602 $portfolio_id = $this->object->getId();
603 $user_id = $this->object->getOwner();
604
605 $this->tabs_gui->clearTargets();
606
607 $pages = ilPortfolioPage::getAllPortfolioPages($portfolio_id);
608 $current_page = $this->requested_user_page;
609
610 // validate current page
611 if ($pages && $current_page) {
612 $found = false;
613 foreach ($pages as $page) {
614 if ($page["id"] == $current_page) {
615 $found = true;
616 break;
617 }
618 }
619 if (!$found) {
620 $current_page = null;
621 }
622 }
623
624 // display first page of portfolio if none given
625 if (!$current_page && $pages) {
626 $current_page = $pages;
627 $current_page = array_shift($current_page);
628 $current_page = $current_page["id"];
629 }
630
631 // #13788 - keep page after login
632 if ($this->user_id == ANONYMOUS_USER_ID &&
633 $this->getType() == "prtf") {
634 $this->tpl->setLoginTargetPar("prtf_" . $this->object->getId() . "_" . $current_page);
635 }
636
637 $back_caption = "";
638
639 // public profile
640 if ($this->requested_back_url != "") {
642 } elseif ($_GET["baseClass"] != "ilPublicUserProfileGUI" &&
643 $this->user_id && $this->user_id != ANONYMOUS_USER_ID) {
644 if (!$this->checkPermissionBool("write")) {
645 // shared
646 if ($this->getType() == "prtf") {
647 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", $this->object->getOwner());
648 $back = $this->ctrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilportfoliorepositorygui"), "showOther");
649 $this->ctrl->setParameterByClass("ilportfoliorepositorygui", "shr_id", "");
650 }
651 // listgui / parent container
652 else {
653 // #12819
655 $parent_id = $tree->getParentId($this->node_id);
656 include_once "Services/Link/classes/class.ilLink.php";
658 }
659 }
660 // owner
661 else {
662 $back = $this->ctrl->getLinkTarget($this, "view");
663 if ($this->getType() == "prtf") {
664 $back_caption = $this->lng->txt("prtf_back_to_portfolio_owner");
665 } else {
666 // #19316
667 $this->lng->loadLanguageModule("prtt");
668 $back_caption = $this->lng->txt("prtt_edit");
669 }
670 }
671 }
672
673 $ilMainMenu = $this->main_menu;
674 $ilMainMenu->setMode(ilMainMenuGUI::MODE_TOPBAR_ONLY);
675 if ($back) {
676 // might already be set in ilPublicUserProfileGUI
677 $ilMainMenu->setTopBarBack($back, $back_caption);
678 }
679
680 // render tabs
681 $current_blog = null;
682 if (count($pages) > 1) {
683 foreach ($pages as $p) {
684 if ($p["type"] == ilPortfolioPage::TYPE_BLOG) {
685 // needed for blog comments (see below)
686 if ($p["id"] == $current_page) {
687 $current_blog = (int) $p["title"];
688 }
689 include_once "Modules/Blog/classes/class.ilObjBlog.php";
690 $p["title"] = ilObjBlog::_lookupTitle($p["title"]);
691 }
692
693 $this->ctrl->setParameter($this, "user_page", $p["id"]);
694 $this->tabs_gui->addTab(
695 "user_page_" . $p["id"],
696 $p["title"],
697 $this->ctrl->getLinkTarget($this, "preview")
698 );
699 }
700
701 $this->tabs_gui->activateTab("user_page_" . $current_page);
702 }
703
704 $this->ctrl->setParameter($this, "user_page", $current_page);
705
706 if (!$a_content) {
707 // #18291
708 if ($current_page) {
709 // get current page content
710 $page_gui = $this->getPageGUIInstance($current_page);
711 $page_gui->setEmbedded(true);
712
713 $content = $this->ctrl->getHTML($page_gui);
714 }
715 } else {
716 $content = $a_content;
717 }
718
719 if ($a_return && $this->checkPermissionBool("write")) {
720 return $content;
721 }
722
723 // blog posting comments are handled within the blog
724 $notes = "";
725 if ($a_show_notes && $this->object->hasPublicComments() && !$current_blog && $current_page) {
726 include_once("./Services/Notes/classes/class.ilNoteGUI.php");
727 $note_gui = new ilNoteGUI($portfolio_id, $current_page, "pfpg");
728 $note_gui->setRepositoryMode(false);
729 $note_gui->enablePublicNotes(true);
730 $note_gui->enablePrivateNotes(false);
731
732 $note_gui->enablePublicNotesDeletion(($this->user_id == $user_id) &&
733 $ilSetting->get("comments_del_tutor", 1));
734
735 $next_class = $this->ctrl->getNextClass($this);
736 if ($next_class == "ilnotegui") {
737 $notes = $this->ctrl->forwardCommand($note_gui);
738 } else {
739 $notes = $note_gui->getNotesHTML();
740 }
741 }
742
743 if ($this->perma_link === null) {
744 if ($this->getType() == "prtf") {
745 $this->tpl->setPermanentLink($this->getType(), $this->object->getId(), "_" . $current_page);
746 } else {
747 $this->tpl->setPermanentLink($this->getType(), $this->object->getRefId());
748 }
749 } else {
750 $this->tpl->setPermanentLink($this->perma_link["type"], $this->perma_link["obj_id"]);
751 }
752
753 // #18208 - see ilPortfolioTemplatePageGUI::getPageContentUserId()
754 if ($this->getType() == "prtt" && !$this->checkPermissionBool("write")) {
755 $user_id = $ilUser->getId();
756 }
757
758 self::renderFullscreenHeader($this->object, $this->tpl, $user_id);
759
760 // #13564
761 $this->ctrl->setParameter($this, "user_page", "");
762 $this->tpl->setTitleUrl($this->ctrl->getLinkTarget($this, "preview"));
763 $this->ctrl->setParameter($this, "user_page", $this->page_id);
764
765 // blog pages do their own (page) style handling
766 if (!$current_blog) {
767 $content = '<div id="ilCOPageContent" class="ilc_page_cont_PageContainer">' .
768 '<div class="ilc_page_Page">' .
769 $content .
770 '</div></div>';
771
772 $this->setContentStyleSheet($this->tpl);
773 }
774
775 // #10717
776 $this->tpl->setContent($content .
777 '<div class="ilClearFloat">' . $notes . '</div>');
778 }
779
787 public static function renderFullscreenHeader($a_portfolio, $a_tpl, $a_user_id, $a_export = false)
788 {
789 global $DIC;
790
791 $ilUser = $DIC->user();
792
793 if (!$a_export) {
794 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
796 $a_portfolio->getType(),
797 ($a_portfolio->getType() == "prtt")
798 ? $a_portfolio->getRefId()
799 : $a_portfolio->getId(),
800 $a_portfolio->getId(),
801 $ilUser->getId()
802 );
803 }
804
805 $name = ilObjUser::_lookupName($a_user_id);
806 $name = $name["lastname"] . ", " . ($t = $name["title"] ? $t . " " : "") . $name["firstname"];
807
808 // show banner?
809 $banner = $banner_width = $banner_height = false;
810 $prfa_set = new ilSetting("prfa");
811 if ($prfa_set->get("banner")) {
812 require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
813 $banner = ilWACSignedPath::signFile($a_portfolio->getImageFullPath());
814 $banner_width = $prfa_set->get("banner_width");
815 $banner_height = $prfa_set->get("banner_height");
816 if ($a_export) {
817 $banner = basename($banner);
818 }
819 }
820
821 // profile picture
822 $ppic = null;
823 if ($a_portfolio->hasProfilePicture()) {
824 $ppic = ilObjUser::_getPersonalPicturePath($a_user_id, "xsmall", true, true);
825 if ($a_export) {
826 $ppic = basename($ppic);
827 }
828 }
829
830 $a_tpl->resetHeaderBlock(false);
831 // $a_tpl->setBackgroundColor($a_portfolio->getBackgroundColor());
832 $a_tpl->setBanner($banner, $banner_width, $banner_height, $a_export);
833 $a_tpl->setTitleIcon($ppic);
834 $a_tpl->setTitle($a_portfolio->getTitle());
835 // $a_tpl->setTitleColor($a_portfolio->getFontColor());
836 $a_tpl->setDescription($name);
837
838 // to get rid of locator in portfolio template preview
839 $a_tpl->setVariable("LOCATOR", "");
840
841 // :TODO: obsolete?
842 // $a_tpl->setBodyClass("std ilExternal ilPortfolio");
843 }
844
845 public function export()
846 {
847 include_once "Modules/Portfolio/classes/class.ilPortfolioHTMLExport.php";
848 $export = new ilPortfolioHTMLExport($this, $this->object);
849 $zip = $export->buildExportFile();
850
851 ilUtil::deliverFile($zip, $this->object->getTitle() . ".zip", '', false, true);
852 }
853
854
858 public function copyPageForm($a_form = null)
859 {
860 $prtf_pages = $_REQUEST["prtf_pages"];
861
862 if (!is_array($prtf_pages) || count($prtf_pages) == 0) {
863 ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
864 $this->ctrl->redirect($this, "view");
865 } else {
866 $this->tabs_gui->activateTab("pages");
867
868 if (!$a_form) {
869 $a_form = $this->initCopyPageForm();
870 }
871
872 foreach ($prtf_pages as $page_id) {
873 $item = new ilHiddenInputGUI("prtf_pages[]");
874 $item->setValue((int) $page_id);
875 $a_form->addItem($item);
876 }
877
878 $this->tpl->setContent($a_form->getHTML());
879 }
880 }
881
882 public function copyPage()
883 {
884 $form = $this->initCopyPageForm();
885 if ($form->checkInput()) {
886 // existing
887 if ($form->getInput("target") == "old") {
888 $portfolio_id = $form->getInput("prtf");
889 }
890 // new
891 else {
892 $portfolio = new ilObjPortfolio();
893 $portfolio->setTitle($form->getInput("title"));
894 $portfolio->create();
895 $portfolio_id = $portfolio->getId();
896 }
897
898 // copy page(s)
899 foreach ($_POST["prtf_pages"] 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 ilUtil::sendSuccess($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);
917
918 public function initCopyPageForm()
919 {
920 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
921 $form = new ilPropertyFormGUI();
922 $form->setFormAction($this->ctrl->getFormAction($this));
923 $form->setTitle($this->lng->txt("prtf_copy_page"));
924
926
927 $form->addCommandButton("copyPage", $this->lng->txt("save"));
928 $form->addCommandButton("view", $this->lng->txt("cancel"));
929
930 return $form;
931 }
932
933
937
938 public function setContentStyleSheet($a_tpl = null)
939 {
941
942 if ($a_tpl != null) {
943 $ctpl = $a_tpl;
944 } else {
945 $ctpl = $tpl;
946 }
947
948 $ctpl->setCurrentBlock("ContentStyle");
949 $ctpl->setVariable(
950 "LOCATION_CONTENT_STYLESHEET",
951 ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
952 );
953 $ctpl->parseCurrentBlock();
954 }
955
956 public function editStyleProperties()
957 {
958 $this->checkPermission("write");
959
960 $this->tabs_gui->activateTab("settings");
961 $this->setSettingsSubTabs("style");
962
964 $this->tpl->setContent($form->getHTML());
965 }
966
967 public function initStylePropertiesForm()
968 {
970
971 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
972 $this->lng->loadLanguageModule("style");
973
974 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
975 $form = new ilPropertyFormGUI();
976
977 $fixed_style = $ilSetting->get("fixed_content_style_id");
978 $style_id = $this->object->getStyleSheetId();
979
980 if ($fixed_style > 0) {
981 $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
982 $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
983 $this->lng->txt("global_fixed") . ")");
984 $form->addItem($st);
985 } else {
987 true,
988 false,
989 $_GET["ref_id"]
990 );
991
992 $st_styles[0] = $this->lng->txt("default");
993 ksort($st_styles);
994
995 if ($style_id > 0) {
996 // individual style
997 if (!ilObjStyleSheet::_lookupStandard($style_id)) {
998 $st = new ilNonEditableValueGUI($this->lng->txt("style_current_style"));
999 $st->setValue(ilObject::_lookupTitle($style_id));
1000 $form->addItem($st);
1001
1002 // delete command
1003 $form->addCommandButton("editStyle", $this->lng->txt("style_edit_style"));
1004 $form->addCommandButton("deleteStyle", $this->lng->txt("style_delete_style"));
1005 }
1006 }
1007
1008 if ($style_id <= 0 || ilObjStyleSheet::_lookupStandard($style_id)) {
1009 $style_sel = new ilSelectInputGUI(
1010 $this->lng->txt("style_current_style"),
1011 "style_id"
1012 );
1013 $style_sel->setOptions($st_styles);
1014 $style_sel->setValue($style_id);
1015 $form->addItem($style_sel);
1016
1017 $form->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
1018 $form->addCommandButton("createStyle", $this->lng->txt("sty_create_ind_style"));
1019 }
1020 }
1021
1022 $form->setTitle($this->lng->txt($this->getType() . "_style"));
1023 $form->setFormAction($this->ctrl->getFormAction($this));
1024
1025 return $form;
1026 }
1027
1028 public function createStyle()
1029 {
1030 $this->ctrl->redirectByClass("ilobjstylesheetgui", "create");
1031 }
1032
1033 public function editStyle()
1034 {
1035 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
1036 }
1037
1038 public function deleteStyle()
1039 {
1040 $this->ctrl->redirectByClass("ilobjstylesheetgui", "delete");
1041 }
1042
1043 public function saveStyleSettings()
1044 {
1046
1047 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1048 if ($ilSetting->get("fixed_content_style_id") <= 0 &&
1049 (ilObjStyleSheet::_lookupStandard($this->object->getStyleSheetId())
1050 || $this->object->getStyleSheetId() == 0)) {
1051 $this->object->setStyleSheetId(ilUtil::stripSlashes($_POST["style_id"]));
1052 $this->object->update();
1053
1054 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1055 }
1056 $this->ctrl->redirect($this, "editStyleProperties");
1057 }
1058}
user()
Definition: user.php:4
$section
Definition: Utf8Test.php:83
$source
Definition: linkback.php:22
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
This class represents a checkbox property in a property form.
Confirmation screen class.
static setPersonalWorkspaceQuotaCheck($a_value)
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
This class represents an image file property in a property form.
static getInstance()
Factory.
This class represents a non editable value in a property form.
Notes GUI class.
Portfolio view gui base class.
initPageForm($a_mode="create")
Init portfolio page form.
setPermaLink($a_obj_id, $a_type)
Set custom perma link (used in public profile?)
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
addBlog()
Show portfolio blog page creation form.
addPage()
Show portfolio page creation form.
view()
Show list of portfolio pages.
savePage()
Create new portfolio page.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
getAdditional()
Get Additonal Information.
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
confirmPortfolioPageDeletion()
Confirm portfolio deletion.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
copyPageForm($a_form=null)
Select target portfolio for page(s) copy.
deletePortfolioPages()
Delete portfolio pages.
getPageInstance($a_page_id=null, $a_portfolio_id=null)
savePortfolioPagesOrdering()
Save ordering of portfolio pages.
addLocatorItems()
Functions to be overwritten.
static renderFullscreenHeader($a_portfolio, $a_tpl, $a_user_id, $a_export=false)
Render banner, user name.
setAdditional($a_additional)
Set Additonal Information (used in public profile?)
preview($a_return=false, $a_content=false, $a_show_notes=true)
Show user page.
getPageGUIInstance($a_page_id)
static _lookupStandard($a_id)
Lookup standard flag.
static _getStandardStyles( $a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static getContentStylePath($a_style_id, $add_random=true)
get content style path
static _lookupName($a_user_id)
lookup user name
New implementation of ilObjectGUI.
getType()
Functions that must be overwritten.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
static _lookupTitle($a_id)
lookup object title
static _lookupTitle($a_id)
lookup object title
Class ilPageLayout.
static activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
static checkExercise($a_user_id, $a_obj_id, $a_add_submit=false, $as_array=false)
Portfolio HTML exporter class.
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
static fixOrdering($a_portfolio_id)
Fix ordering.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
ILIAS Setting Class.
This class represents a text property in a property form.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static signFile($path_to_file)
if(!array_key_exists('StateId', $_REQUEST)) $id
catch(Exception $e) $message
$target
Definition: test.php:19
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$a_content
Definition: workflow.php:93
$a_type
Definition: workflow.php:92