ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjPortfolioGUI.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('./Modules/Portfolio/classes/class.ilObjPortfolioBaseGUI.php');
5
19{
23 protected $help;
24
25 protected $ws_access; // [ilWorkspaceAccessHandler]
26
30 protected $ui;
31
36
37 public function __construct($a_id = 0)
38 {
39 global $DIC;
40
41 $this->lng = $DIC->language();
42 $this->help = $DIC["ilHelp"];
43 $this->settings = $DIC->settings();
44 $this->access = $DIC->access();
45 $this->user = $DIC->user();
46 $this->ctrl = $DIC->ctrl();
47 $this->ui = $DIC->ui();
48
49 parent::__construct($a_id, self::PORTFOLIO_OBJECT_ID, 0);
50 $this->declaration_authorship = new ilPortfolioDeclarationOfAuthorship();
51
52 $this->ctrl->saveParameter($this, "exc_back_ref_id");
53 }
54
55 public function getType()
56 {
57 return "prtf";
58 }
59
60 protected function checkPermissionBool($a_perm, $a_cmd = "", $a_type = "", $a_node_id = null)
61 {
62 if ($a_perm == "create") {
63 return true;
64 }
65 if (!$a_node_id) {
66 $a_node_id = $this->obj_id;
67 }
68 return $this->access_handler->checkAccess($a_perm, "", $a_node_id);
69 }
70
71 public function executeCommand()
72 {
74
75 $this->checkPermission("read");
76
78
79 $next_class = $this->ctrl->getNextClass($this);
80 $cmd = $this->ctrl->getCmd("view");
81
82 /*
83 if($_REQUEST["ecal"])
84 {
85 $cmd = "preview";
86 $next_class = "";
87 }
88 */
89
90 switch ($next_class) {
91 case "ilworkspaceaccessgui":
92 if ($this->checkPermissionBool("write")) {
93 $this->setTabs();
94 $this->tabs_gui->activateTab("share");
95
96 if ($this->access_handler->getPermissions($this->object->getId()) &&
97 !$this->object->isOnline()) {
98 //ilUtil::sendInfo($lng->txt("prtf_shared_offline_info"));
99 }
100
101 $this->tpl->setPermanentLink("prtf", $this->object->getId());
102
103 include_once('./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php');
104 $wspacc = new ilWorkspaceAccessGUI($this->object->getId(), $this->access_handler, true);
105 $wspacc->setBlockingMessage($this->getOfflineMessage());
106 $this->ctrl->forwardCommand($wspacc);
107 }
108 break;
109
110 case 'ilportfoliopagegui':
111 if ($this->determinePageCall()) {
112 // only in edit mode
113 $this->addLocator();
114
115 include_once "Services/Form/classes/class.ilFileInputGUI.php";
117 }
118 $this->handlePageCall($cmd);
119 break;
120
121 case "ilnotegui":
122 $this->preview();
123 break;
124
125 case "ilobjstylesheetgui":
126 include_once("./Services/Style/Content/classes/class.ilObjStyleSheetGUI.php");
127 $this->ctrl->setReturn($this, "editStyleProperties");
128 $style_gui = new ilObjStyleSheetGUI("", $this->object->getStyleSheetId(), false, false);
129 $style_gui->omitLocator();
130 if ($cmd == "create" || $_GET["new_type"] == "sty") {
131 $style_gui->setCreationMode(true);
132 }
133
134 if ($cmd == "confirmedDelete") {
135 $this->object->setStyleSheetId(0);
136 $this->object->update();
137 }
138
139 $ret = $this->ctrl->forwardCommand($style_gui);
140
141 if ($cmd == "save" || $cmd == "copyStyle" || $cmd == "importStyle") {
142 $style_id = $ret;
143 $this->object->setStyleSheetId($style_id);
144 $this->object->update();
145 $this->ctrl->redirectByClass("ilobjstylesheetgui", "edit");
146 }
147 break;
148
149 case "ilportfolioexercisegui":
150 $this->ctrl->setReturn($this, "view");
151 include_once "Modules/Portfolio/classes/class.ilPortfolioExerciseGUI.php";
152 $gui = new ilPortfolioExerciseGUI($this->user_id, $this->object->getId());
153 $this->ctrl->forwardCommand($gui);
154 break;
155
156 default:
157
158 if ($cmd != "preview") {
159 $this->addLocator();
160 $this->setTabs();
161 }
162 $this->$cmd();
163 break;
164 }
165
166 return true;
167 }
168
169 protected function setTabs()
170 {
171 $ilHelp = $this->help;
172
173 $ilHelp->setScreenIdComponent("prtf");
174
175 if ($this->checkPermissionBool("write")) {
176 $this->tabs_gui->addTab(
177 "pages",
178 $this->lng->txt("content"),
179 $this->ctrl->getLinkTarget($this, "view")
180 );
181
182 $this->tabs_gui->addTab(
183 "settings",
184 $this->lng->txt("settings"),
185 $this->ctrl->getLinkTarget($this, "edit")
186 );
187
188 $this->tabs_gui->addNonTabbedLink(
189 "preview",
190 $this->lng->txt("user_profile_preview"),
191 $this->ctrl->getLinkTarget($this, "preview")
192 );
193
194 $this->lng->loadLanguageModule("wsp");
195 $this->tabs_gui->addTab(
196 "share",
197 $this->lng->txt("wsp_permissions"),
198 $this->ctrl->getLinkTargetByClass("ilworkspaceaccessgui", "share")
199 );
200 }
201 }
202
203 protected function addLocator()
204 {
205 if (!$this->creation_mode) {
206 $this->ctrl->setParameter($this, "prt_id", $this->object->getId());
207 }
208
209 parent::addLocatorItems();
210
211 $this->tpl->setLocator();
212 }
213
214 protected function setTitleAndDescription()
215 {
216 // parent::setTitleAndDescription();
217
218 $title = $this->lng->txt("portfolio");
219 if ($this->object) {
220 $title .= ": " . $this->object->getTitle();
221 }
222 $this->tpl->setTitle($title);
223 $this->tpl->setTitleIcon(
224 ilUtil::getImagePath("icon_prtf.svg"),
225 $this->lng->txt("portfolio")
226 );
227
228 if ($this->object &&
229 !$this->object->isOnline()) {
230 $this->tpl->setAlertProperties(array(
231 array("alert" => true,
232 "property" => $this->lng->txt("status"),
233 "value" => $this->lng->txt("offline"))
234 ));
235 }
236 }
237
238
239 //
240 // CREATE/EDIT
241 //
242
248 public function create()
249 {
252
253 $new_type = $_REQUEST["new_type"];
254
255 // add new object to custom parent container
256 $this->ctrl->saveParameter($this, "crtptrefid");
257 // use forced callback after object creation
258 $this->ctrl->saveParameter($this, "crtcb");
259
260 if (!$this->checkPermissionBool("create", "", $new_type)) {
261 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
262 } else {
263 $this->lng->loadLanguageModule($new_type);
264 $this->ctrl->setParameter($this, "new_type", $new_type);
265
266 $forms = $this->initCreationForms($new_type);
267
268 // copy form validation error: do not show other creation forms
269 if ($_GET["cpfl"] && isset($forms[self::CFORM_CLONE])) {
270 $forms = array(self::CFORM_CLONE => $forms[self::CFORM_CLONE]);
271 }
272 $tpl->setContent($this->getCreateInfoMessage() . $this->getCreationFormsHTML($forms));
273 }
274 }
275
282 protected function getCreateInfoMessage()
283 {
284 global $DIC;
285
288 $ui = $DIC->ui();
289 $ilSetting = $DIC->settings();
290
291 $message = "";
292 // page type: blog
293 if (!$ilSetting->get('disable_wsp_blogs')) {
294 $options = array();
295 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
296 $tree = new ilWorkspaceTree($this->user_id);
297 $root = $tree->readRootId();
298 if ($root) {
299 $root = $tree->getNodeData($root);
300 foreach ($tree->getSubTree($root) as $node) {
301 if ($node["type"] == "blog") {
302 $options[$node["obj_id"]] = $node["title"];
303 }
304 }
305 asort($options);
306 }
307 if (!sizeof($options)) {
308
309 // #18147
310 $this->lng->loadLanguageModule('pd');
311 $url = $this->ctrl->getLinkTargetByClass("ilpersonaldesktopgui", "jumpToWorkspace");
312 $text = $this->lng->txt("pd_personal_workspace");
313
314 $text = sprintf($this->lng->txt("prtf_no_blogs_info"), $text);
315
316 $mbox = $ui->factory()->messageBox()->info($text)
317 ->withLinks([$ui->factory()->link()->standard(
318 $this->lng->txt("pd_personal_workspace"),
319 $url
320 )]);
321
322 $message = $ui->renderer()->render($mbox);
323 }
324 }
325 return $message;
326 }
327
328
329 protected function initCreationForms($a_new_type)
330 {
331 return array(self::CFORM_NEW => $this->initCreateForm($a_new_type));
332 }
333
334 protected function initCreateForm($a_new_type)
335 {
337
338 $this->ctrl->setParameter($this, "new_type", $this->getType());
339
340 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
341 $form = new ilPropertyFormGUI();
342 $form->setFormAction($this->ctrl->getFormAction($this));
343
344 // title
345 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
346 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
347 $ti->setMaxLength(ilObject::TITLE_LENGTH);
348 $ti->setRequired(true);
349 $form->addItem($ti);
350
351 /* description
352 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
353 $ta->setCols(40);
354 $ta->setRows(2);
355 $form->addItem($ta);
356 */
357
358 $main = new ilRadioGroupInputGUI($this->lng->txt("prtf_creation_mode"), "mode");
359 $main->setValue("mode_scratch");
360 $form->addItem($main);
361
362 $opt_scratch = new ilRadioOption($this->lng->txt("prtf_creation_mode_scratch"), "mode_scratch");
363 $main->addOption($opt_scratch);
364
365
366 // 1st page
367
368 $type = new ilRadioGroupInputGUI($this->lng->txt("prtf_first_page_title"), "ptype");
369 $type->setRequired(true);
370 $opt_scratch->addSubItem($type);
371
372 $type_page = new ilRadioOption($this->lng->txt("page"), "page");
373 $type->addOption($type_page);
374
375 // page type: page
376 $tf = new ilTextInputGUI($this->lng->txt("title"), "fpage");
377 $tf->setMaxLength(128);
378 $tf->setSize(40);
379 $tf->setRequired(true);
380 $type_page->addSubItem($tf);
381
382 // page templates
383 include_once "Services/COPage/Layout/classes/class.ilPageLayout.php";
385 if ($templates) {
386 $options = array(0 => $this->lng->txt("none"));
387 foreach ($templates as $templ) {
388 $templ->readObject();
389 $options[$templ->getId()] = $templ->getTitle();
390 }
391
392 $use_template = new ilSelectInputGUI($this->lng->txt("prtf_use_page_layout"), "tmpl");
393 $use_template->setRequired(true);
394 $use_template->setOptions($options);
395 $type_page->addSubItem($use_template);
396 }
397
398 // page type: blog
399 if (!$ilSetting->get('disable_wsp_blogs')) {
400 $options = array();
401 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
402 $tree = new ilWorkspaceTree($this->user_id);
403 $root = $tree->readRootId();
404 if ($root) {
405 $root = $tree->getNodeData($root);
406 foreach ($tree->getSubTree($root) as $node) {
407 if ($node["type"] == "blog") {
408 $options[$node["obj_id"]] = $node["title"];
409 }
410 }
411 asort($options);
412 }
413 if (sizeof($options)) {
414 $type_blog = new ilRadioOption($this->lng->txt("obj_blog"), "blog");
415 $type->addOption($type_blog);
416
417 $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), "blog");
418 $obj->setRequired(true);
419 $obj->setOptions(array("" => $this->lng->txt("please_select")) + $options);
420 $type_blog->addSubItem($obj);
421 } else {
422 $type->setValue("page");
423 }
424 }
425
426
427 // portfolio templates
428
429 $opt_tmpl = new ilRadioOption($this->lng->txt("prtf_creation_mode_template"), "mode_tmpl");
430 $main->addOption($opt_tmpl);
431
432 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
434 if (!sizeof($templates)) {
435 $opt_tmpl->setDisabled(true);
436 } else {
437 $tmpl = new ilSelectInputGUI($this->lng->txt("obj_prtt"), "prtt");
438 $tmpl->setRequired(true);
439 $tmpl->setOptions(array("" => $this->lng->txt("please_select")) + $templates);
440 $opt_tmpl->addSubItem($tmpl);
441
442 // incoming from repository
443 if ((int) $_REQUEST["prtt_pre"]) {
444 $tmpl->setValue((int) $_REQUEST["prtt_pre"]);
445 $main->setValue("mode_tmpl");
446 }
447 }
448
449
450 $form->setTitle($this->lng->txt("prtf_create_portfolio"));
451 $form->addCommandButton("save", $this->lng->txt("create"));
452 $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
453
454 return $form;
455 }
456
457 public function save()
458 {
459 $form = $this->initCreateForm("prtf");
460 if ($form->checkInput()) {
461 // trigger portfolio template "import" process
462 if ($form->getInput("mode") == "mode_tmpl") {
463 $_REQUEST["pt"] = $form->getInput("title");
464 $_REQUEST["prtt_pre"] = (int) $_REQUEST["prtt"];
465 return $this->createFromTemplateDirect($form->getInput("title"));
466 //return $this->createPortfolioFromTemplate();
467 }
468 }
469
470 return parent::save();
471 }
472
473 protected function afterSave(ilObject $a_new_object)
474 {
475 // create 1st page / blog
476 include_once("Modules/Portfolio/classes/class.ilPortfolioPage.php");
477 $page = $this->getPageInstance(null, $a_new_object->getId());
478 if ($_POST["ptype"] == "page") {
479 $page->setType(ilPortfolioPage::TYPE_PAGE);
480 $page->setTitle($_POST["fpage"]);
481
482 // use template as basis
483 $layout_id = $_POST["tmpl"];
484 if ($layout_id) {
485 include_once("./Services/COPage/Layout/classes/class.ilPageLayout.php");
486 $layout_obj = new ilPageLayout($layout_id);
487 $page->setXMLContent($layout_obj->getXMLContent());
488 }
489 } else {
490 $page->setType(ilPortfolioPage::TYPE_BLOG);
491 $page->setTitle($_POST["blog"]);
492 }
493 $page->create();
494
495 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
496 $this->ctrl->setParameter($this, "prt_id", $a_new_object->getId());
497 $this->ctrl->redirect($this, "view");
498 }
499
500 protected function toRepository()
501 {
502 $ilAccess = $this->access;
503
504 // return to exercise (portfolio assignment)
505 $exc_ref_id = (int) $_REQUEST["exc_id"];
506 if ($exc_ref_id &&
507 $ilAccess->checkAccess("read", "", $exc_ref_id)) {
508 include_once "Services/Link/classes/class.ilLink.php";
509 ilUtil::redirect(ilLink::_getLink($exc_ref_id, "exc"));
510 }
511
512 $this->ctrl->redirectByClass("ilportfoliorepositorygui", "show");
513 }
514
515 protected function initEditForm()
516 {
517 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
518 $form = new ilPropertyFormGUI();
519 $form->setFormAction($this->ctrl->getFormAction($this));
520
521 // title
522 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
523 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
524 $ti->setMaxLength(ilObject::TITLE_LENGTH);
525 $ti->setRequired(true);
526 $ti->setValue($this->object->getTitle());
527 $form->addItem($ti);
528
529 /* description
530 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
531 $ta->setCols(40);
532 $ta->setRows(2);
533 $ta->setValue($this->object->getDescription());
534 $form->addItem($ta);
535 */
536
537 // :TODO: online
538 $online = new ilCheckboxInputGUI($this->lng->txt("online"), "online");
539 $online->setChecked($this->object->isOnline());
540 $form->addItem($online);
541
543
544 $form->setTitle($this->lng->txt("prtf_edit_portfolio"));
545 $form->addCommandButton("update", $this->lng->txt("save"));
546 $form->addCommandButton("view", $this->lng->txt("cancel"));
547
548 return $form;
549 }
550
551 protected function getEditFormCustomValues(array &$a_values)
552 {
553 $a_values["online"] = $this->object->isOnline();
554
555 parent::getEditFormCustomValues($a_values);
556 }
557
558 public function updateCustom(ilPropertyFormGUI $a_form)
559 {
560 $this->object->setOnline($a_form->getInput("online"));
561
562 // if portfolio is not online, it cannot be default
563 if (!$a_form->getInput("online")) {
564 ilObjPortfolio::setUserDefault($this->user_id, 0);
565 }
566
567 parent::updateCustom($a_form);
568 }
569
570
571 //
572 // PAGES
573 //
574
582 protected function getPageInstance($a_page_id = null, $a_portfolio_id = null)
583 {
584 // #11531
585 if (!$a_portfolio_id && $this->object) {
586 $a_portfolio_id = $this->object->getId();
587 }
588 include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
589 $page = new ilPortfolioPage($a_page_id);
590 $page->setPortfolioId($a_portfolio_id);
591 return $page;
592 }
593
600 protected function getPageGUIInstance($a_page_id)
601 {
602 include_once("Modules/Portfolio/classes/class.ilPortfolioPageGUI.php");
603 $page_gui = new ilPortfolioPageGUI(
604 $this->object->getId(),
605 $a_page_id,
606 0,
607 $this->object->hasPublicComments()
608 );
609 $page_gui->setAdditional($this->getAdditional());
610 return $page_gui;
611 }
612
613 public function getPageGUIClassName()
614 {
615 return "ilportfoliopagegui";
616 }
617
618 protected function initCopyPageFormOptions(ilPropertyFormGUI $a_form)
619 {
620 $a_tgt = new ilRadioGroupInputGUI($this->lng->txt("target"), "target");
621 $a_tgt->setRequired(true);
622 $a_form->addItem($a_tgt);
623
624 $old = new ilRadioOption($this->lng->txt("prtf_existing_portfolio"), "old");
625 $a_tgt->addOption($old);
626
627 $options = array();
628 $all = ilObjPortfolio::getPortfoliosOfUser($this->user_id);
629 foreach ($all as $item) {
630 $options[$item["id"]] = $item["title"];
631 }
632 $prtf = new ilSelectInputGUI($this->lng->txt("portfolio"), "prtf");
633 $prtf->setRequired(true);
634 $prtf->setOptions($options);
635 $old->addSubItem($prtf);
636
637 $new = new ilRadioOption($this->lng->txt("prtf_new_portfolio"), "new");
638 $a_tgt->addOption($new);
639
640 $tf = new ilTextInputGUI($this->lng->txt("title"), "title");
641 $tf->setMaxLength(128);
642 $tf->setSize(40);
643 $tf->setRequired(true);
644 $new->addSubItem($tf);
645 }
646
647
648 //
649 // BLOG
650 //
651
658 public function initBlogForm()
659 {
660 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
661 $form = new ilPropertyFormGUI();
662 $form->setFormAction($this->ctrl->getFormAction($this));
663
664 $options = array();
665 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
666 $tree = new ilWorkspaceTree($this->user_id);
667 $root = $tree->readRootId();
668 if ($root) {
669 $root = $tree->getNodeData($root);
670 foreach ($tree->getSubTree($root, true, "blog") as $node) {
671 $options[$node["obj_id"]] = $node["title"];
672 }
673 asort($options);
674 }
675
676 // add blog
677 $radg = new ilRadioGroupInputGUI($this->lng->txt("obj_blog"), "creation_mode");
678 $radg->setInfo($this->lng->txt(""));
679 $radg->setValue("new");
680 $radg->setInfo($this->lng->txt(""));
681
682 $op1 = new ilRadioOption($this->lng->txt("prtf_add_new_blog"), "new", $this->lng->txt("prtf_add_new_blog_info"));
683 $radg->addOption($op1);
684 $form->addItem($radg);
685
686 // Blog title
687 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
688 $ti->setRequired(true);
689 $op1->addSubItem($ti);
690
691
692 if (sizeof($options)) {
693 $op2 = new ilRadioOption($this->lng->txt("prtf_add_existing_blog"), "existing");
694 $radg->addOption($op2);
695
696 $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), "blog");
697 $obj->setOptions($options);
698 $op2->addSubItem($obj);
699 }
700
701 $form->setTitle($this->lng->txt("prtf_add_blog") . ": " .
702 $this->object->getTitle());
703 $form->addCommandButton("saveBlog", $this->lng->txt("save"));
704 $form->addCommandButton("view", $this->lng->txt("cancel"));
705
706 return $form;
707 }
708
712 public function saveBlog()
713 {
714 global $DIC;
715
716 $ilUser = $DIC->user();
717
718 $form = $this->initBlogForm();
719 if ($form->checkInput() && $this->checkPermissionBool("write")) {
720 if ($form->getInput("creation_mode") == "existing") {
721 $page = $this->getPageInstance();
722 $page->setType(ilPortfolioPage::TYPE_BLOG);
723 $page->setTitle($form->getInput("blog"));
724 $page->create();
725 } else {
726 $blog = new ilObjBlog();
727 $blog->setTitle($form->getInput("title"));
728 $blog->create();
729
730 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
731 $tree = new ilWorkspaceTree($ilUser->getId());
732
733 // @todo: see also e.g. ilExSubmissionObjectGUI->getOverviewContentBlog, this needs refactoring, consumer should not
734 // be responsibel to handle this
735 if (!$tree->getRootId()) {
736 $tree->createTreeForUser($ilUser->getId());
737 }
738
739 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
741 $node_id = $tree->insertObject($tree->readRootId(), $blog->getId());
742 $access_handler->setPermissions($tree->readRootId(), $node_id);
743
744 $page = $this->getPageInstance();
745 $page->setType(ilPortfolioPage::TYPE_BLOG);
746 $page->setTitle($blog->getId());
747 $page->create();
748 }
749
750 ilUtil::sendSuccess($this->lng->txt("prtf_blog_page_created"), true);
751 $this->ctrl->redirect($this, "view");
752 }
753
754 $this->tabs_gui->clearTargets();
755 $this->tabs_gui->setBackTarget(
756 $this->lng->txt("back"),
757 $this->ctrl->getLinkTarget($this, "view")
758 );
759
760 $form->setValuesByPost();
761 $this->tpl->setContent($form->getHtml());
762 }
763
764
765 //
766 // CREATE FROM TEMPLATE
767 //
768
769 protected function createPortfolioFromTemplate(ilPropertyFormGUI $a_form = null)
770 {
771 $title = trim($_REQUEST["pt"]);
772 $prtt_id = (int) $_REQUEST["prtt"];
773
774 // valid template?
775 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
777 if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
778 $this->toRepository();
779 }
780 unset($templates);
781
782 $this->ctrl->setParameter($this, "prtt", $prtt_id);
783
784 if (!$a_form) {
785 $a_form = $this->initCreatePortfolioFromTemplateForm($prtt_id, $title);
786 }
787 if ($a_form) {
788 $this->tpl->setContent($a_form->getHTML());
789 } else {
791 }
792 }
793
794 protected function initCreatePortfolioFromTemplateForm($a_prtt_id, $a_title)
795 {
798
799 if ((int) $_REQUEST["exc_id"]) {
800 $this->ctrl->setParameter($this, "exc_id", (int) $_REQUEST["exc_id"]);
801 $this->ctrl->setParameter($this, "ass_id", (int) $_REQUEST["ass_id"]);
802 }
803
804 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
805 $form = new ilPropertyFormGUI();
806 $form->setFormAction($this->ctrl->getFormAction($this));
807
808 $tmpl = new ilNonEditableValueGUI($this->lng->txt("obj_prtt"));
809 $tmpl->setValue(ilObject::_lookupTitle($a_prtt_id));
810 $form->addItem($tmpl);
811
812 $title = new ilNonEditableValueGUI($this->lng->txt("title"), "pt");
813 $title->setValue($a_title);
814 $form->addItem($title);
815
816 // gather user blogs
817 if (!$ilSetting->get('disable_wsp_blogs')) {
818 $blog_options = array();
819 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
820 $tree = new ilWorkspaceTree($this->user_id);
821 $root = $tree->readRootId();
822 if ($root) {
823 $root = $tree->getNodeData($root);
824 foreach ($tree->getSubTree($root, true, "blog") as $node) {
825 $blog_options[$node["obj_id"]] = $node["title"];
826 }
827 asort($blog_options);
828 }
829 }
830
831 $has_form_content = false;
832
833 include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
835 $quota_sum = 0;
836
837 include_once "Services/Skill/classes/class.ilPersonalSkill.php";
838 $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId()));
839 $skill_ids = array();
840
841 include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
842 foreach (ilPortfolioTemplatePage::getAllPortfolioPages($a_prtt_id) as $page) {
843 switch ($page["type"]) {
845 // skills
846 $source_page = new ilPortfolioTemplatePage($page["id"]);
847 $source_page->buildDom(true);
848 $skill_ids = $this->getSkillsToPortfolioAssignment($pskills, $skill_ids, $source_page);
849
850 if ($check_quota) {
851 $quota_sum += $source_page->getPageDiskSize();
852 }
853 if (sizeof($skill_ids)) {
854 $has_form_content = true;
855 }
856 break;
857
859 if (!$ilSetting->get('disable_wsp_blogs')) {
860 $has_form_content = true;
861
862 $field_id = "blog_" . $page["id"];
863
864 $blog = new ilRadioGroupInputGUI($this->lng->txt("obj_blog") . ": " .
865 $page["title"], $field_id);
866 $blog->setRequired(true);
867 $blog->setValue("blog_create");
868 $form->addItem($blog);
869
870 $new_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_create"), "blog_create");
871 $blog->addOption($new_blog);
872
873 $title = new ilTextInputGUI($this->lng->txt("title"), $field_id . "_create_title");
874 $title->setRequired(true);
875 $new_blog->addSubItem($title);
876
877 if (sizeof($blog_options)) {
878 $reuse_blog = new ilRadioOption($this->lng->txt("prtf_template_import_blog_reuse"), "blog_resuse");
879 $blog->addOption($reuse_blog);
880
881 $obj = new ilSelectInputGUI($this->lng->txt("obj_blog"), $field_id . "_reuse_blog");
882 $obj->setRequired(true);
883 $obj->setOptions(array("" => $this->lng->txt("please_select")) + $blog_options);
884 $reuse_blog->addSubItem($obj);
885 }
886
887 $blog->addOption(new ilRadioOption($this->lng->txt("prtf_template_import_blog_ignore"), "blog_ignore"));
888 }
889 break;
890 }
891 }
892
893 if ($skill_ids) {
894 include_once "Services/Skill/classes/class.ilSkillTreeNode.php";
895 $skills = new ilCheckboxGroupInputGUI($this->lng->txt("skills"), "skill_ids");
896 $skills->setInfo($this->lng->txt("prtf_template_import_new_skills"));
897 $skills->setValue($skill_ids);
898 foreach ($skill_ids as $skill_id) {
899 $skills->addOption(new ilCheckboxOption(ilSkillTreeNode::_lookupTitle($skill_id), $skill_id));
900 }
901 $form->addItem($skills);
902 }
903
904 if ($quota_sum) {
905 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
906 if (!ilDiskQuotaHandler::isUploadPossible($quota_sum)) {
907 ilUtil::sendFailure($this->lng->txt("prtf_template_import_quota_failure"), true);
908 $this->ctrl->redirect($this, "create");
909 }
910 }
911
912 // no dialog needed, go ahead
913 if (!$has_form_content) {
914 return;
915 }
916
917 $form->setTitle($this->lng->txt("prtf_creation_mode") . ": " . $this->lng->txt("prtf_creation_mode_template"));
918 $form->addCommandButton("createPortfolioFromTemplateProcess", $this->lng->txt("continue"));
919 $form->addCommandButton("toRepository", $this->lng->txt("cancel"));
920
921 return $form;
922 }
923
924 protected function createPortfolioFromTemplateProcess($a_process_form = true)
925 {
928 $ilAccess = $this->access;
929
930 $title = trim($_REQUEST["pt"]);
931 $prtt_id = (int) $_REQUEST["prtt"];
932
933 // valid template?
934 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
936 if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
937 $this->toRepository();
938 }
939 unset($templates);
940
941 // build page recipe (aka import form values)
942 $recipe = null;
943 if ($a_process_form) {
944 $this->ctrl->setParameter($this, "prtt", $prtt_id);
945
947 if ($form->checkInput()) {
948 include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
949 foreach (ilPortfolioTemplatePage::getAllPortfolioPages($prtt_id) as $page) {
950 switch ($page["type"]) {
952 if (!$ilSetting->get('disable_wsp_blogs')) {
953 $field_id = "blog_" . $page["id"];
954 switch ($form->getInput($field_id)) {
955 case "blog_create":
956 $recipe[$page["id"]] = array("blog", "create",
957 trim($form->getInput($field_id . "_create_title")));
958 break;
959
960 case "blog_resuse":
961 $recipe[$page["id"]] = array("blog", "reuse",
962 (int) $form->getInput($field_id . "_reuse_blog"));
963 break;
964
965 case "blog_ignore":
966 $recipe[$page["id"]] = array("blog", "ignore");
967 break;
968 }
969 }
970 break;
971 }
972 }
973
974 $recipe["skills"] = (array) $form->getInput("skill_ids");
975 } else {
976 $form->setValuesByPost();
977 return $this->createPortfolioFromTemplate($form);
978 }
979 }
980
981 $source = new ilObjPortfolioTemplate($prtt_id, false);
982
983 // create portfolio
984 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
985 $target = new ilObjPortfolio();
986 $target->setTitle($title);
987 $target->create();
988 $target_id = $target->getId();
989
990 $source->clonePagesAndSettings($source, $target, $recipe);
991
992 // link portfolio to exercise assignment
994
995 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created_from_template"), true);
996 $this->ctrl->setParameter($this, "prt_id", $target_id);
997 $this->ctrl->redirect($this, "preview");
998 }
999
1003 protected function createFromTemplateDirect($title = "")
1004 {
1005 $prtt_id = (int) $_REQUEST["prtt_pre"];
1006 if ($title == "") {
1007 $title = ilObject::_lookupTitle($prtt_id);
1008 }
1009
1010 // valid template?
1011 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
1013 if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
1014 $this->toRepository();
1015 }
1016 unset($templates);
1017
1018 $source = new ilObjPortfolioTemplate($prtt_id, false);
1019
1020 // create portfolio
1021 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
1022 $target = new ilObjPortfolio();
1023 $target->setTitle($title);
1024 $target->create();
1025 $target_id = $target->getId();
1026
1027 $source->clonePagesAndSettings($source, $target, null, true);
1028
1029 // link portfolio to exercise assignment
1030 //$this->linkPortfolioToAssignment($target_id);
1031
1032 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created_from_template"), true);
1033 $this->ctrl->setParameter($this, "prt_id", $target_id);
1034 $this->ctrl->redirect($this, "preview");
1035 }
1036
1037
1038 public static function _goto($a_target)
1039 {
1041 global $DIC;
1042
1043 $ctrl = $DIC->ctrl();
1044
1045 $id = explode("_", $a_target);
1046
1047 $_GET["baseClass"] = "ilsharedresourceGUI";
1048 $ctrl->setParameterByClass("ilobjportfoliogui", "prt_id", $id[0]);
1049 if (sizeof($id) == 2) {
1050 $ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $id[1]);
1051 }
1052 $ctrl->redirectByClass(["ilsharedresourceGUI", "ilobjportfoliogui"], "preview");
1053 }
1054
1056 {
1059
1060 include_once "Modules/Portfolio/classes/class.ilObjPortfolioTemplate.php";
1061 include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
1062 include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
1063
1064 $title = trim($_REQUEST["pt"]);
1065 $prtt_id = (int) $_REQUEST["prtt"];
1066
1067 // get assignment template
1068 $ass_template_id = 0;
1069 if ((int) $_REQUEST["ass_id"] > 0) {
1070 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
1071 $ass = new ilExAssignment((int) $_REQUEST["ass_id"]);
1072 $ass_template_id = ilObject::_lookupObjectId($ass->getPortfolioTemplateId());
1073 }
1074
1075 if ($prtt_id > 0) {
1077 if (!sizeof($templates) || !in_array($prtt_id, $templates)) {
1078 if ($ass_template_id != $prtt_id) {
1079 $this->toRepository();
1080 }
1081 }
1082
1083 //quota manipulation
1084 include_once "Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
1086 $quota_sum = 0;
1087
1088 //skills manipulation
1089 include_once "Services/Skill/classes/class.ilPersonalSkill.php";
1090 $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId()));
1091 $skill_ids = array();
1092
1093 $recipe = array();
1094 foreach (ilPortfolioTemplatePage::getAllPortfolioPages($prtt_id) as $page) {
1095 switch ($page["type"]) {
1097 if (!$ilSetting->get('disable_wsp_blogs')) {
1098 $recipe[$page["id"]] = array("blog", "create", $page['title']);
1099 }
1100 break;
1102 $source_page = new ilPortfolioTemplatePage($page["id"]);
1103 $source_page->buildDom(true);
1104 if ($check_quota) {
1105 $quota_sum += $source_page->getPageDiskSize();
1106 }
1107 $skill_ids = $this->getSkillsToPortfolioAssignment($pskills, $skill_ids, $source_page);
1108 break;
1109 }
1110 }
1111
1112 if ($quota_sum) {
1113 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1114 if (!ilDiskQuotaHandler::isUploadPossible($quota_sum)) {
1115 ilUtil::sendFailure($this->lng->txt("prtf_template_import_quota_failure"), true);
1116 $this->ctrl->redirect($this, "create");
1117 }
1118 }
1119
1120 if ($skill_ids) {
1121 $recipe["skills"] = $skill_ids;
1122 }
1123 }
1124
1125 // create portfolio
1126 $target = new ilObjPortfolio();
1127 $target->setTitle($title);
1128 $target->create();
1129 $target_id = $target->getId();
1130
1131 if ($prtt_id) {
1132 $source = new ilObjPortfolioTemplate($prtt_id, false);
1133 $source->clonePagesAndSettings($source, $target, $recipe);
1134 }
1135
1136 // link portfolio to exercise assignment
1138
1139 $this->ctrl->setParameter($this, "prt_id", $target_id);
1140 if ($prtt_id) {
1141 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created_from_template"), true);
1142 $this->ctrl->redirect($this, "preview");
1143 } else {
1144 ilUtil::sendSuccess($this->lng->txt("prtf_portfolio_created"), true);
1145 $this->ctrl->redirect($this, "view");
1146 }
1147 }
1148
1149 public function linkPortfolioToAssignment($a_target_id)
1150 {
1151 $ilAccess = $this->access;
1153
1154 $exc_ref_id = (int) $_REQUEST["exc_id"];
1155 $ass_id = (int) $_REQUEST["ass_id"];
1156
1157 if ($exc_ref_id &&
1158 $ass_id &&
1159 $ilAccess->checkAccess("read", "", $exc_ref_id)) {
1160 include_once "Modules/Exercise/classes/class.ilObjExercise.php";
1161 include_once "Modules/Exercise/classes/class.ilExAssignment.php";
1162 $exc = new ilObjExercise($exc_ref_id);
1163 $ass = new ilExAssignment($ass_id);
1164 if ($ass->getExerciseId() == $exc->getId() &&
1165 $ass->getType() == ilExAssignment::TYPE_PORTFOLIO) {
1166 // #16205
1167 include_once "Modules/Exercise/classes/class.ilExSubmission.php";
1168 $sub = new ilExSubmission($ass, $ilUser->getId());
1169 $sub->addResourceObject($a_target_id);
1170 }
1171 }
1172 }
1173
1180 public function getSkillsToPortfolioAssignment($a_pskills, $a_skill_ids, $a_source_page)
1181 {
1182 $dom = $a_source_page->getDom();
1183 if ($dom instanceof php4DOMDocument) {
1184 $dom = $dom->myDOMDocument;
1185 }
1186 $xpath = new DOMXPath($dom);
1187 $nodes = $xpath->query("//PageContent/Skills");
1188 foreach ($nodes as $node) {
1189 $skill_id = $node->getAttribute("Id");
1190 if (!in_array($skill_id, $a_pskills)) {
1191 $a_skill_ids[] = $skill_id;
1192 }
1193 }
1194 unset($nodes);
1195 unset($xpath);
1196 unset($dom);
1197
1198 return $a_skill_ids;
1199 }
1200
1206 public function exportPDFSelection()
1207 {
1208 global $DIC;
1209
1210 $tpl = $DIC["tpl"];
1211
1212 $form = $this->initPDFSelectionForm();
1213
1214 $tpl->setContent($form->getHTML());
1215 }
1216
1220 public function initPDFSelectionForm()
1221 {
1222 global $DIC;
1223
1224 $lng = $this->lng;
1226
1227 $tabs = $DIC->tabs();
1228
1229 $tabs->clearTargets();
1230 $tabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, "view"));
1231
1232 $pages = ilPortfolioPage::getAllPortfolioPages($this->object->getId());
1233
1234
1235 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1236 $form = new ilPropertyFormGUI();
1237
1238 // because of PDF export
1239 $form->setPreventDoubleSubmission(false);
1240
1241 // declaration of authorship
1242 if ($this->declaration_authorship->getForUser($this->user) != "") {
1243 $cb = new ilCheckboxInputGUI($this->lng->txt("prtf_decl_authorship"), "decl_author");
1244 $cb->setInfo($this->declaration_authorship->getForUser($this->user));
1245 $form->addItem($cb);
1246 }
1247
1248 // signature
1249 $cb = new ilCheckboxInputGUI($this->lng->txt("prtf_signature"), "signature");
1250 $cb->setInfo($this->lng->txt("prtf_signature_info"));
1251 $form->addItem($cb);
1252
1253
1254 // selection type
1255 $radg = new ilRadioGroupInputGUI($lng->txt("prtf_print_selection"), "sel_type");
1256 $radg->setValue("all_pages");
1257 $op2 = new ilRadioOption($lng->txt("prtf_all_pages"), "all_pages");
1258 $radg->addOption($op2);
1259 $op3 = new ilRadioOption($lng->txt("prtf_selected_pages"), "selection");
1260 $radg->addOption($op3);
1261
1262 include_once("./Services/Form/classes/class.ilNestedListInputGUI.php");
1263 $nl = new ilNestedListInputGUI("", "obj_id");
1264 $op3->addSubItem($nl);
1265
1266 foreach ($pages as $p) {
1267 if ($p["type"] != ilPortfolioPage::TYPE_BLOG) {
1268 $nl->addListNode(
1269 $p["id"],
1270 $p["title"],
1271 0,
1272 false,
1273 false,
1274 ilUtil::getImagePath("icon_pg.svg"),
1275 $lng->txt("page")
1276 );
1277 } else {
1278 $nl->addListNode(
1279 $p["id"],
1280 $lng->txt("obj_blog") . ": " . ilObject::_lookupTitle($p["title"]),
1281 0,
1282 false,
1283 false,
1284 ilUtil::getImagePath("icon_blog.svg"),
1285 $lng->txt("obj_blog")
1286 );
1287 $pages2 = ilBlogPosting::getAllPostings($p["title"]);
1288 foreach ($pages2 as $p2) {
1289 $nl->addListNode(
1290 "b" . $p2["id"],
1291 $p2["title"],
1292 $p["id"],
1293 false,
1294 false,
1295 ilUtil::getImagePath("icon_pg.svg"),
1296 $lng->txt("page")
1297 );
1298 }
1299 }
1300 }
1301
1302 $form->addItem($radg);
1303
1304 $form->addCommandButton("exportPDF", $lng->txt("prtf_pdf"));
1305 if (DEVMODE == "1") {
1306 $form->addCommandButton("exportPDFDev", $lng->txt("prtf_pdf") . " (DEV)");
1307 }
1308
1309 $form->setTitle($lng->txt("prtf_print_options"));
1310 $form->setFormAction($ilCtrl->getFormAction($this, "exportPDF"));
1311
1312 return $form;
1313 }
1314
1318 public function exportPDFDev()
1319 {
1320 $this->exportPDF(true);
1321 }
1322
1327 public function exportPDF($a_dev_mode = false)
1328 {
1329 require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
1331
1332 // prepare generation before contents are processed (for mathjax)
1333 ilPDFGeneratorUtils::prepareGenerationRequest("Portfolio", "ContentExport");
1334
1335 $html = $this->printView(true);
1336
1337 // :TODO: fixing css dummy parameters
1338 $html = preg_replace("/\?dummy\=[0-9]+/", "", $html);
1339 $html = preg_replace("/\?vers\=[0-9A-Za-z\-]+/", "", $html);
1340
1341 $html = preg_replace("/src=\"\\.\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $html);
1342 $html = preg_replace("/href=\"\\.\\//ims", "href=\"" . ILIAS_HTTP_PATH . "/", $html);
1343
1344
1345 if ($a_dev_mode) {
1346 echo $html;
1347 exit;
1348 }
1349
1350 //$html = str_replace("&amp;", "&", $html);
1351
1352 $pdf_factory = new ilHtmlToPdfTransformerFactory();
1353 $pdf_factory->deliverPDFFromHTMLString($html, "portfolio.pdf", ilHtmlToPdfTransformerFactory::PDF_OUTPUT_DOWNLOAD, "Portfolio", "ContentExport");
1354 }
1355
1356 public function printView($a_pdf_export = false)
1357 {
1358 global $tpl;
1359
1360 $lng = $this->lng;
1361
1362 $pages = ilPortfolioPage::getAllPortfolioPages($this->object->getId());
1363
1364
1365 $tpl = new ilTemplate("tpl.main.html", true, true);
1366
1367 $tpl->setBodyClass("ilPrtfPdfBody");
1368
1369 $tpl->setCurrentBlock("AdditionalStyle");
1370 $tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET", ilUtil::getStyleSheetLocation("filesystem"));
1371 $tpl->parseCurrentBlock();
1372
1373 $tpl->setCurrentBlock("ContentStyle");
1374 $tpl->setVariable(
1375 "LOCATION_CONTENT_STYLESHEET",
1376 ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId(), false)
1377 );
1378 $tpl->parseCurrentBlock();
1379
1380 $tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
1381 //$this->setContentStyleSheet($tpl);
1382
1383 // syntax style
1384 $tpl->setCurrentBlock("SyntaxStyle");
1385 $tpl->setVariable(
1386 "LOCATION_SYNTAX_STYLESHEET",
1388 );
1389 $tpl->parseCurrentBlock();
1390
1391
1392 include_once("./Modules/Portfolio/classes/class.ilPortfolioPageGUI.php");
1393
1394 $page_content = "";
1395
1396 // cover page
1397 $cover_tpl = new ilTemplate("tpl.prtf_cover.html", true, true, "Modules/Portfolio");
1398 foreach ($pages as $page) {
1399 if ($page["type"] != ilPortfolioPage::TYPE_BLOG) {
1400 if ($_POST["sel_type"] == "selection" && (!is_array($_POST["obj_id"]) || !in_array($page["id"], $_POST["obj_id"]))) {
1401 continue;
1402 }
1403 $cover_tpl->setCurrentBlock("content_item");
1404 $cover_tpl->setVariable("ITEM_TITLE", $page["title"]);
1405 $cover_tpl->parseCurrentBlock();
1406 } else {
1407 $cover_tpl->setCurrentBlock("content_item");
1408 $cover_tpl->setVariable("ITEM_TITLE", $lng->txt("obj_blog") . ": " . ilObject::_lookupTitle($page["title"]));
1409 $cover_tpl->parseCurrentBlock();
1410 }
1411 }
1412
1413 if ($_POST["signature"]) {
1414 $cover_tpl->setCurrentBlock("signature");
1415 $cover_tpl->setVariable("TXT_SIGNATURE", $lng->txt("prtf_signature_date"));
1416 $cover_tpl->parseCurrentBlock();
1417 }
1418
1419 if ($_POST["decl_author"]) {
1420 $cover_tpl->setCurrentBlock("decl_author");
1421 $cover_tpl->setVariable(
1422 "TXT_DECL_AUTHOR",
1423 nl2br($this->declaration_authorship->getForUser($this->user))
1424 );
1425 $cover_tpl->parseCurrentBlock();
1426 }
1427
1428 $cover_tpl->setVariable("PORTFOLIO_TITLE", $this->object->getTitle());
1429 $cover_tpl->setVariable("PORTFOLIO_ICON", ilUtil::getImagePath("icon_prtf.svg"));
1430
1431 $cover_tpl->setVariable("TXT_AUTHOR", $lng->txt("prtf_author"));
1432 $cover_tpl->setVariable("TXT_LINK", $lng->txt("prtf_link"));
1433 $cover_tpl->setVariable("TXT_DATE", $lng->txt("prtf_date_of_print"));
1434
1435 $author = ilObjUser::_lookupName($this->object->getOwner());
1436 $author_str = $author["firstname"] . " " . $author["lastname"];
1437 $cover_tpl->setVariable("AUTHOR", $author_str);
1438
1439 include_once('./Services/Link/classes/class.ilLink.php');
1440 $href = ilLink::_getStaticLink($this->object->getId(), "prtf");
1441 $cover_tpl->setVariable("LINK", $href);
1442
1444 $date_str = ilDatePresentation::formatDate(new ilDate(date("Y-m-d"), IL_CAL_DATE));
1445 $cover_tpl->setVariable("DATE", $date_str);
1446
1447 $page_content .= $cover_tpl->get();
1448 $page_content .= '<p style="page-break-after:always;"></p>';
1449
1450 $page_head_tpl = new ilTemplate("tpl.prtf_page_head.html", true, true, "Modules/Portfolio");
1451 $page_head_tpl->setVariable("AUTHOR", $author_str);
1452 $page_head_tpl->setVariable("DATE", $date_str);
1453 $page_head_str = $page_head_tpl->get();
1454
1455 foreach ($pages as $page) {
1456 if ($page["type"] != ilPortfolioPage::TYPE_BLOG) {
1457 if ($_POST["sel_type"] == "selection" && (!is_array($_POST["obj_id"]) || !in_array($page["id"], $_POST["obj_id"]))) {
1458 continue;
1459 }
1460
1461 $page_gui = new ilPortfolioPageGUI($this->object->getId(), $page["id"]);
1462 $page_gui->setOutputMode("print");
1463 $page_gui->setPresentationTitle($page["title"]);
1464 $html = $this->ctrl->getHTML($page_gui);
1465 $page_content .= $page_head_str . $html;
1466
1467 if ($a_pdf_export) {
1468 $page_content .= '<p style="page-break-after:always;"></p>';
1469 }
1470 } else {
1471 $pages2 = ilBlogPosting::getAllPostings($page["title"]);
1472 foreach ($pages2 as $p2) {
1473 if ($_POST["sel_type"] == "selection" && (!is_array($_POST["obj_id"]) || !in_array("b" . $p2["id"], $_POST["obj_id"]))) {
1474 continue;
1475 }
1476 $page_gui = new ilBlogPostingGUI(0, null, $p2["id"]);
1477 $page_gui->setFileDownloadLink("#");
1478 $page_gui->setFullscreenLink("#");
1479 $page_gui->setSourcecodeDownloadScript("#");
1480 $page_gui->setOutputMode("print");
1481 $page_content .= $page_head_str . $page_gui->showPage(ilObject::_lookupTitle($page["title"]) . ": " . $page_gui->getBlogPosting()->getTitle());
1482
1483 if ($a_pdf_export) {
1484 $page_content .= '<p style="page-break-after:always;"></p>';
1485 }
1486 }
1487 }
1488 }
1489
1490 $page_content = '<div class="ilInvisibleBorder">' . $page_content . '</div>';
1491
1492 if (!$a_pdf_export) {
1493 $page_content .= '<script type="text/javascript" language="javascript1.2">
1494 <!--
1495 il.Util.addOnLoad(function () {
1496 il.Util.print();
1497 });
1498 //-->
1499 </script>';
1500 }
1501
1502 $tpl->setVariable("CONTENT", $page_content);
1503
1504 if (!$a_pdf_export) {
1505 $tpl->show(false);
1506 exit;
1507 } else {
1508 $tpl->fillJavaScriptFiles();
1509 $ret = $tpl->get("DEFAULT", false, false, false, true, false, false);
1510 return $ret;
1511 }
1512 }
1513
1519 protected function getOfflineMessage()
1520 {
1521 $ui = $this->ui;
1522 $lng = $this->lng;
1524
1525 if (!$this->object->isOnline()) {
1526 $f = $ui->factory();
1527 $renderer = $ui->renderer();
1528
1529 $buttons = [$f->button()->standard(
1530 $lng->txt("prtf_set_online"),
1531 $ctrl->getLinkTarget($this, "setOnlineAndShare")
1532 )];
1533
1534 return $renderer->render($f->messageBox()->info($lng->txt("prtf_no_offline_share_info"))
1535 ->withButtons($buttons));
1536 }
1537 return "";
1538 }
1539
1543 protected function setOnlineAndShare()
1544 {
1546 $lng = $this->lng;
1547
1548 if (ilObjPortfolio::_lookupOwner($this->object->getId()) == $this->user_id) {
1549 $this->object->setOnline(true);
1550 $this->object->update();
1551 ilUtil::sendSuccess($lng->txt("prtf_has_been_set_online"), true);
1552 }
1553 $ilCtrl->redirectByClass("ilworkspaceaccessgui", "");
1554 }
1555}
user()
Definition: user.php:4
$source
Definition: linkback.php:22
exit
Definition: backend.php:16
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
Class ilBlogPosting GUI class.
static getAllPostings($a_blog_id, $a_limit=1000, $a_offset=0)
Get all postings of blog.
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
Class for single dates.
static isUploadPossible($a_additional_size=null)
Exercise assignment.
Exercise submission //TODO: This class has to much static methods related to delivered "files".
static setPersonalWorkspaceQuotaCheck($a_value)
Class ilHtmlToPdfTransformerFactory.
This class represents a (nested) list of checkboxes (could be extended for radio items,...
This class represents a non editable value in a property form.
Class ilObjBlog.
Class ilObjExercise.
Portfolio view gui base class.
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
getAdditional()
Get Additonal Information.
preview($a_return=false, $a_content=false, $a_show_notes=true)
Show user page.
Portfolio view gui class.
setOnlineAndShare()
Set online and switch to share screen.
getType()
Functions that must be overwritten.
getSkillsToPortfolioAssignment($a_pskills, $a_skill_ids, $a_source_page)
getOfflineMessage()
Get offline message for sharing tab.
initEditForm()
Init object edit form.
exportPDFSelection()
Export PDF selection.
executeCommand()
execute command
getPageGUIInstance($a_page_id)
Get portfolio template page gui instance.
exportPDF($a_dev_mode=false)
create()
create new object form
saveBlog()
Create new portfolio blog page.
initCreateForm($a_new_type)
Init object creation form.
getPageInstance($a_page_id=null, $a_portfolio_id=null)
Get portfolio template page instance.
getCreateInfoMessage()
Get cereat info message.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
printView($a_pdf_export=false)
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
setTitleAndDescription()
called by prepare output
createPortfolioFromTemplate(ilPropertyFormGUI $a_form=null)
createFromTemplateDirect($title="")
Create portfolio template direct.
createPortfolioFromTemplateProcess($a_process_form=true)
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
initCopyPageFormOptions(ilPropertyFormGUI $a_form)
setTabs()
create tabs (repository/workspace switch)
initBlogForm()
Init blog page form.
initPDFSelectionForm()
Init print view selection form.
initCreationForms($a_new_type)
Init creation froms.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
initCreatePortfolioFromTemplateForm($a_prtt_id, $a_title)
linkPortfolioToAssignment($a_target_id)
static getAvailablePortfolioTemplates($a_permission="read")
static setUserDefault($a_user_id, $a_portfolio_id=null)
Set the user default portfolio.
static getPortfoliosOfUser($a_user_id)
Get views of user.
Class ilObjStyleSheetGUI.
static getContentPrintStyle()
get content print style
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true)
get content style path
static _lookupName($a_user_id)
lookup user name
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
static _lookupOwner($a_id)
lookup object owner
getCreationFormsHTML(array $a_forms)
Get HTML for creation forms (accordion)
Class ilObject Basic functions for all objects.
const TITLE_LENGTH
max length of object title
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
getId()
get object id @access public
static prepareGenerationRequest($service, $purpose)
Prepare the content processing for a PDF generation request This function should be called as in a re...
Class ilPageLayout.
static activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
static getSelectedUserSkills($a_user_id)
Get personal selected user skills.
Class ilPortfolioExerciseGUI.
Portfolio page gui class.
Page for user portfolio.
static getAllPortfolioPages($a_portfolio_id)
Get pages of portfolio.
Page for portfolio template.
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.
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.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
Access handler for personal workspace.
Tree handler for personal workspace.
if(!empty($this->data['faventry'])) $tabs
Definition: disco.tpl.php:124
$html
Definition: example_001.php:87
if(!array_key_exists('StateId', $_REQUEST)) $id
$target_id
Definition: goto.php:49
global $ilCtrl
Definition: ilias.php:18
catch(Exception $e) $message
$target
Definition: test.php:19
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
$type
$url
if(isset($_POST['submit'])) $form
$root
Definition: sabredav.php:45
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$text
Definition: errorreport.php:18