ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPortfolioPageGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
15{
19 protected $obj_definition;
20
24 protected $tree;
25
26 const EMBEDDED_NO_OUTPUT = -99;
27
28 protected $js_onload_code = array();
29 protected $additional = array();
30 protected $export_material = array("js" => array(), "images" => array(), "files" => array());
31
32 protected static $initialized = 0;
33
38
42 public function __construct($a_portfolio_id, $a_id = 0, $a_old_nr = 0, $a_enable_comments = true)
43 {
44 global $DIC;
45
46 $this->tpl = $DIC["tpl"];
47 $this->ctrl = $DIC->ctrl();
48 $this->user = $DIC->user();
49 $this->obj_definition = $DIC["objDefinition"];
50 $this->access = $DIC->access();
51 $this->tree = $DIC->repositoryTree();
52 $this->lng = $DIC->language();
53 $tpl = $DIC["tpl"];
54
55 $this->portfolio_id = (int) $a_portfolio_id;
56 $this->enable_comments = (bool) $a_enable_comments;
57
58 parent::__construct($this->getParentType(), $a_id, $a_old_nr);
59 $this->getPageObject()->setPortfolioId($this->portfolio_id);
60
61 // content style
62
63 $tpl->setCurrentBlock("SyntaxStyle");
64 $tpl->setVariable(
65 "LOCATION_SYNTAX_STYLESHEET",
67 );
68 $tpl->parseCurrentBlock();
69
70 $tpl->setCurrentBlock("ContentStyle");
71 $tpl->setVariable(
72 "LOCATION_CONTENT_STYLESHEET",
74 );
75 $tpl->setVariable(
76 "LOCATION_ADDITIONAL_STYLESHEET",
78 );
79 $tpl->parseCurrentBlock();
80
81 $this->requested_ppage = (int) $_GET["ppage"];
82 }
83
84 public function getParentType()
85 {
86 return "prtf";
87 }
88
89 protected function getPageContentUserId($a_user_id)
90 {
91 // user id from content-xml
92 return $a_user_id;
93 }
94
98 public function executeCommand()
99 {
100 $ilCtrl = $this->ctrl;
102
103 $next_class = $this->ctrl->getNextClass($this);
104 $cmd = $this->ctrl->getCmd();
105
106 switch ($next_class) {
107 case "ilobjbloggui":
108 // #12879 - we need the wsp-id for the keywords
109 $wsp_tree = new ilWorkspaceTree($ilUser->getId());
110 $blog_obj_id = (int) $this->getPageObject()->getTitle();
111 $blog_node_id = $wsp_tree->lookupNodeId($blog_obj_id);
112
113 $blog_gui = new ilObjBlogGUI($blog_node_id, ilObjBlogGUI::WORKSPACE_NODE_ID);
114 $blog_gui->disableNotes(!$this->enable_comments);
115 $blog_gui->prtf_embed = true; // disables prepareOutput()/getStandardTemplate() in blog
116 return $ilCtrl->forwardCommand($blog_gui);
117
118 case "ilcalendarmonthgui":
119
120
121 // booking action
122 if ($cmd && $cmd != "preview") {
124 if ($categories->getMode() == 0) {
125 if ($_GET['chuid']) {
126 $categories->setCHUserId((int) $_GET['chuid']);
127 }
128 $categories->initialize(ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION, null, true);
129 }
130
131 if ($_GET['seed']) {
132 $seed = new ilDate((string) $_GET['seed'], IL_CAL_DATE);
133 } else {
134 $seed = new ilDate(time(), IL_CAL_UNIX);
135 }
136
137 $month_gui = new ilCalendarMonthGUI($seed);
138 return $ilCtrl->forwardCommand($month_gui);
139 }
140 // calendar month navigation
141 else {
142 $ilCtrl->setParameter($this, "cmd", "preview");
144 }
145
146 // no break
147 case "ilpageobjectgui":
148 die("Deprecated. ilPortfolioPage gui forwarding to ilpageobject");
149 return;
150
151 default:
152 $this->setPresentationTitle($this->getPageObject()->getTitle());
153 return parent::executeCommand();
154 }
155 }
156
162 public function showPage()
163 {
165
166 if (!$this->getPageObject()) {
167 return;
168 }
169
170 switch ($this->getPageObject()->getType()) {
172 return $this->renderBlog($ilUser->getId(), (int) $this->getPageObject()->getTitle());
173
174 default:
175 $this->setTemplateOutput(false);
176 // $this->setPresentationTitle($this->getPageObject()->getTitle());
177 $output = parent::showPage();
178
179 return $output;
180 }
181 }
182
189 public function getTabs($a_activate = "")
190 {
191 if (!$this->embedded) {
192 parent::getTabs($a_activate);
193 }
194 }
195
201 public function setEmbedded($a_value)
202 {
203 $this->embedded = (bool) $a_value;
204 }
205
211 public function setAdditional($a_additional)
212 {
213 $this->additional = $a_additional;
214 }
215
221 public function getAdditional()
222 {
223 return $this->additional;
224 }
225
226 public function getJsOnloadCode()
227 {
229 }
230
231 public function postOutputProcessing($a_output)
232 {
233 $parts = array(
234 "Profile" => array("0-9", "a-z", "0-9a-z_;\W"), // user, mode, fields
235 "Verification" => array("0-9", "a-z", "0-9"), // user, type, id
236 "Blog" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
237 "BlogTeaser" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
238 "Skills" => array("0-9", "0-9"), // user, skill id
239 "SkillsTeaser" => array("0-9", "0-9"), // user, skill id
240 "ConsultationHours" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
241 "ConsultationHoursTeaser" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
242 "MyCourses" => array("0-9", "a-z*"), // user, sort
243 "MyCoursesTeaser" => array("0-9", "a-z*") // user, sort
244 );
245
246 foreach ($parts as $type => $def) {
247 // #15732 - allow optional parts
248 $def_parts = array();
249 foreach ($def as $part) {
250 $is_opt = (substr($part, -1) == "*");
251 if (!$is_opt) {
252 $def_parts[] = "#";
253 $end_marker = "+";
254 } else {
255 $def_parts[] = "#*";
256 $end_marker = "*";
257 $part = substr($part, 0, -1);
258 }
259 $def_parts[] = "([" . $part . "]" . $end_marker . ")";
260 }
261 $def = implode("", $def_parts);
262
263 if (preg_match_all(
264 "/" . $this->pl_start . $type . $def . $this->pl_end . "/",
265 $a_output,
266 $blocks
267 )) {
268 foreach ($blocks[0] as $idx => $block) {
269 switch ($type) {
270 case "Profile":
271 case "Blog":
272 case "BlogTeaser":
273 case "Skills":
274 case "SkillsTeaser":
275 case "ConsultationHours":
276 case "ConsultationHoursTeaser":
277 case "MyCourses":
278 case "MyCoursesTeaser":
279 $subs = null;
280 if (trim($blocks[3][$idx])) {
281 foreach (explode(";", $blocks[3][$idx]) as $sub) {
282 if (trim($sub)) {
283 $subs[] = trim($sub);
284 }
285 }
286 }
287 $snippet = $this->{"render" . $type}(
288 $blocks[1][$idx],
289 $blocks[2][$idx],
290 $subs
291 );
292 break;
293
294 default:
295 $snippet = $this->{"render" . $type}(
296 $blocks[1][$idx],
297 $blocks[2][$idx],
298 $blocks[3][$idx]
299 );
300 break;
301 }
302
303 $snippet = $this->renderPageElement($type, $snippet);
304 $a_output = str_replace($block, $snippet, $a_output);
305 }
306 }
307 }
308
309 $a_output = $this->makePlaceHoldersClickable($a_output);
310
311 return $a_output;
312 }
313
314 protected function renderPageElement($a_type, $a_html)
315 {
316 return trim($a_html);
317 }
318
319 protected function renderTeaser($a_type, $a_title, $a_options = null)
320 {
321 $options = "";
322 if ($a_options) {
323 $options = '<div class="il_Footer">' . $this->lng->txt("prtf_page_element_teaser_settings") .
324 ": " . $a_options . '</div>';
325 }
326
327 return '<div style="margin:5px" class="ilBox"><h3>' . $a_title . '</h3>' .
328 '<div class="il_Description_no_margin">' . $this->lng->txt("prtf_page_element_teaser_" . $a_type) . '</div>' .
329 $options . '</div>';
330 }
331
332 protected function renderProfile($a_user_id, $a_type, array $a_fields = null)
333 {
334 $ilCtrl = $this->ctrl;
335
336 $user_id = $this->getPageContentUserId($a_user_id);
337 /*
338 if($this->getOutputMode() == "offline")
339 {
340 // profile picture is done in ilPortfolioHTMLExport
341
342 $this->export_material["js"][] = "http://maps.google.com/maps/api/js?sensor=false";
343 $this->export_material["js"][] = "./Services/Maps/js/ServiceGoogleMaps.js";
344 $this->export_material["js"][] = "./Services/Maps/js/OpenLayers.js";
345 $this->export_material["js"][] = "./Services/Maps/js/ServiceOpenLayers.js";
346 }*/
347
348 $pub_profile = new ilPublicUserProfileGUI($user_id);
349 $pub_profile->setEmbedded(true, ($this->getOutputMode() == "offline"));
350
351 // full circle: additional was set in the original public user profile call
352 $pub_profile->setAdditional($this->getAdditional());
353
354 if ($a_type == "manual" && is_array($a_fields) && count($a_fields) > 0) {
355 $prefs = array();
356 foreach ($a_fields as $field) {
357 $field = trim($field);
358 if ($field) {
359 $prefs["public_" . $field] = "y";
360 }
361 }
362
363 $pub_profile->setCustomPrefs($prefs);
364 }
365
366 if ($this->getOutputMode() != "offline") {
367 return $ilCtrl->getHTML($pub_profile);
368 } else {
369 return $pub_profile->getEmbeddable();
370 }
371 }
372
380 protected function renderVerification($a_user_id, $a_type, $a_id)
381 {
382 $objDefinition = $this->obj_definition;
383
384 $outputMode = $this->getOutputMode();
385
386 // not used
387 // $user_id = $this->getPageContentUserId($a_user_id);
388 if ($a_type === 'crta' && $outputMode === 'offline') {
389 $fileService = new ilPortfolioCertificateFileService();
390
391 $certificatePdfFile = $fileService->createCertificateFilePath($a_user_id, $a_id);
392 $this->export_material["files"][] = $certificatePdfFile;
393
394 $url = 'files/' . basename($certificatePdfFile);
395
396 $userCertificateRepository = new ilUserCertificateRepository();
397
398 return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
399 } elseif ($a_type === 'crta' && $outputMode === 'print') {
400 $userCertificateRepository = new ilUserCertificateRepository();
401 $url = $this->getPagePermaLink();
402
403 return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
404 } elseif ($a_type === 'crta') {
405 $this->ctrl->setParameter($this, "dlid", $a_id);
406 $url = $this->ctrl->getLinkTarget($this, "dl" . $a_type);
407 $this->ctrl->setParameter($this, "dlid", "");
408
409 $userCertificateRepository = new ilUserCertificateRepository();
410
411 return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
412 }
413
414 if (!ilObject::_exists($a_id)) {
415 return $this->lng->txt('deleted');
416 }
417
418 $class = "ilObj" . $objDefinition->getClassName($a_type) . "GUI";
419 $verification = new $class($a_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
420
421 if ($outputMode == "print") {
422 $url = $this->getPagePermaLink();
423 } elseif ($outputMode != "offline") {
424 // direct download link
425 $this->ctrl->setParameter($this, "dlid", $a_id);
426 $url = $this->ctrl->getLinkTarget($this, "dl" . $a_type);
427 $this->ctrl->setParameter($this, "dlid", "");
428 } else {
429 $file = $verification->object->getFilePath();
430 $url = "files/" . basename($file);
431
432 $this->export_material["files"][] = $file;
433 }
434
435 return $verification->render(true, $url);
436 }
437
438 protected function dltstv()
439 {
440 $id = $_GET["dlid"];
441 if ($id) {
443 $verification->downloadFromPortfolioPage($this->getPageObject());
444 }
445 }
446
447 protected function dlexcv()
448 {
449 $id = $_GET["dlid"];
450 if ($id) {
452 $verification->downloadFromPortfolioPage($this->getPageObject());
453 }
454 }
455
456 protected function dlcrsv()
457 {
458 $id = $_GET["dlid"];
459 if ($id) {
461 $verification->downloadFromPortfolioPage($this->getPageObject());
462 }
463 }
464
465 protected function dlcmxv()
466 {
467 $id = $_GET["dlid"];
468 if ($id) {
470 $verification->downloadFromPortfolioPage($this->getPageObject());
471 }
472 }
473
474 protected function dlltiv()
475 {
476 $id = $_GET["dlid"];
477 if ($id) {
479 $verification->downloadFromPortfolioPage($this->getPageObject());
480 }
481 }
482
483 protected function dlscov()
484 {
485 $id = $_GET["dlid"];
486 if ($id) {
488 $verification->downloadFromPortfolioPage($this->getPageObject());
489 }
490 }
491
492 protected function dlcrta()
493 {
494 $objectId = $_GET["dlid"];
495 if ($objectId) {
497 $object->downloadFromPortfolioPage($this->getPageObject(), $objectId, $this->user->getId());
498 }
499 }
500
501 protected function renderBlog($a_user_id, $a_blog_id, array $a_posting_ids = null)
502 {
503 $ilCtrl = $this->ctrl;
504
505 // not used
506 // $user_id = $this->getPageContentUserId($a_user_id);
507
508 // full blog (separate tab/page)
509 if (!$a_posting_ids) {
510 if (ilObject::_lookupType($a_blog_id) != "blog") {
511 return;
512 }
513 $blog = new ilObjBlogGUI($a_blog_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
514 $blog->disableNotes(!$this->enable_comments);
515 $blog->setContentStyleSheet();
516
517 if ($this->getOutputMode() != "offline") {
518 return $ilCtrl->getHTML($blog);
519 } else {
520 }
521 }
522 // embedded postings
523 else {
524 $html = array();
525
526 $html[] = ilObjBlog::_lookupTitle($a_blog_id);
527
528 foreach ($a_posting_ids as $post) {
529 $page = new ilBlogPostingGUI(0, null, $post);
530 if ($this->getOutputMode() != "offline") {
531 $page->setOutputMode(ilPageObjectGUI::PREVIEW);
532 } else {
533 $page->setOutputMode("offline");
534 }
535 $html[] = $page->showPage();
536 }
537
538 return implode("\n", $html);
539 }
540 }
541
542 protected function renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids = null)
543 {
544 // not used
545 // $user_id = $this->getPageContentUserId($a_user_id);
546
547 $postings = "";
548 if ($a_posting_ids) {
549 $postings = array("<ul>");
550 foreach ($a_posting_ids as $post) {
551 $post = new ilBlogPosting($post);
552 $postings[] = "<li>" . $post->getTitle() . " - " .
553 ilDatePresentation::formatDate($post->getCreated()) . "</li>";
554 }
555 $postings[] = "</ul>";
556 $postings = implode("\n", $postings);
557 }
558
559 return $this->renderTeaser("blog", $this->lng->txt("obj_blog") . ' "' .
560 ilObject::_lookupTitle($a_blog_id) . '"', $postings);
561 }
562
563 protected function renderSkills($a_user_id, $a_skills_id)
564 {
565 if ($this->getOutputMode() == "preview") {
566 return $this->renderSkillsTeaser($a_user_id, $a_skills_id);
567 }
568
569 $user_id = $this->getPageContentUserId($a_user_id);
570
571 $gui = new ilPersonalSkillsGUI();
572 if ($this->getOutputMode() == "offline") {
573 $gui->setOfflineMode("./files/");
574 }
575 $html = $gui->getSkillHTML($a_skills_id, $user_id);
576
577 return $html;
578 }
579
580 protected function renderSkillsTeaser($a_user_id, $a_skills_id)
581 {
582 // not used
583 // $user_id = $this->getPageContentUserId($a_user_id);
584
585 return $this->renderTeaser("skills", $this->lng->txt("skills") . ' "' .
586 ilSkillTreeNode::_lookupTitle($a_skills_id) . '"');
587 }
588
589 protected function renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
590 {
591 // not used
592 // $user_id = $this->getPageContentUserId($a_user_id);
593
594 if ($a_mode == "auto") {
595 $mode = $this->lng->txt("cont_cach_mode_automatic");
596 $groups = null;
597 } else {
598 $mode = $this->lng->txt("cont_cach_mode_manual");
599
600 $groups = array();
601 foreach ($a_group_ids as $grp_id) {
602 $groups[] = ilConsultationHourGroups::lookupTitle($grp_id);
603 }
604 $groups = " (" . implode(", ", $groups) . ")";
605 }
606
607 $this->lng->loadLanguageModule("dateplaner");
608 return $this->renderTeaser(
609 "consultation_hours",
610 $this->lng->txt("app_consultation_hours"),
611 $mode . $groups
612 );
613 }
614
615 protected function renderConsultationHours($a_user_id, $a_mode, $a_group_ids)
616 {
618
619 if ($this->getOutputMode() == "preview") {
620 return $this->renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids);
621 }
622
623 if ($this->getOutputMode() == "offline") {
624 return;
625 }
626
627 if ($this->getOutputMode() == "print") {
628 return;
629 }
630
631 $user_id = $this->getPageContentUserId($a_user_id);
632
633 // only if not owner
634 if ($ilUser->getId() != $user_id) {
635 $_GET["bkid"] = $user_id;
636 }
637
638 if ($a_mode != "manual") {
639 $a_group_ids = null;
640 }
641
642 ilCalendarCategories::_getInstance()->setCHUserId($user_id);
644
645 if (!$_REQUEST["seed"]) {
646 $seed = new ilDate(time(), IL_CAL_UNIX);
647 } else {
648 $seed = new ilDate($_REQUEST["seed"], IL_CAL_DATE);
649 }
650
651 $month_gui = new ilCalendarMonthGUI($seed);
652 $month_gui->setConsulationHoursUserId($user_id);
653
654 // custom schedule filter: handle booking group ids
655 $filter = new ilCalendarScheduleFilterBookings($user_id, $a_group_ids);
656 $month_gui->addScheduleFilter($filter);
657
658 $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem', 'delos.css', 'Services/Calendar'));
659
660 $this->lng->loadLanguageModule("dateplaner");
661 return '<h3>' . $this->lng->txt("app_consultation_hours") . '</h3>' .
662 $this->ctrl->getHTML($month_gui);
663 }
664
665 protected function isMyCoursesActive()
666 {
667 $prfa_set = new ilSetting("prfa");
668 return (bool) $prfa_set->get("mycrs", true);
669 }
670
671 protected function renderMyCoursesTeaser($a_user_id, $a_default_sorting)
672 {
673 // not used
674 // $user_id = $this->getPageContentUserId($a_user_id);
675
676 $title = $this->isMyCoursesActive()
677 ? "my_courses"
678 : "my_courses_inactive";
679
680 return $this->renderTeaser(
681 $title,
682 $this->lng->txt("prtf_page_element_my_courses_title")
683 );
684 }
685
686 protected function renderMyCourses($a_user_id, $a_default_sorting)
687 {
688 $ilAccess = $this->access;
690 $ilCtrl = $this->ctrl;
691
692 if ($this->getOutputMode() == "preview") {
693 return $this->renderMyCoursesTeaser($a_user_id, $a_default_sorting);
694 }
695
696 if (!$this->isMyCoursesActive()) {
697 return;
698 }
699
700 $img_path = null;
702
703 $user_id = $this->getPageContentUserId($a_user_id);
704
705 // sorting pref
706 if ($_POST["srt"] &&
707 in_array($_POST["srt"], array("alpha", "loc"))) {
708 $ilUser->writePref("prtf_mcrs_sort", $_POST["srt"]);
709 }
710 $sorting = $ilUser->getPref("prtf_mcrs_sort");
711 if (!$sorting) {
712 $sorting = $a_default_sorting;
713 }
714
715 $data = $this->getCoursesOfUser($user_id, ($sorting == "loc"));
716 if (sizeof($data)) {
717 if ($sorting != "loc") {
718 $data = ilUtil::sortArray($data, "title", "ASC");
719 } else {
720 $data = ilUtil::sortArray($data, "path_sort", "ASC");
721 }
722
723 $tpl = new ilTemplate("tpl.pc_my_courses.html", true, true, "Modules/Portfolio");
724 $tpl->setVariable("TITLE", $this->lng->txt("prtf_page_element_my_courses_title"));
725 $tpl->setVariable("INFO", $this->lng->txt("prtf_page_element_my_courses_info")); // #14464
726
727 $this->lng->loadLanguageModule("trac");
728 $this->lng->loadLanguageModule("crs");
729
730 // sorting
731 if ($this->getOutputMode() != "print") {
732 $options = array(
733 "alpha" => $this->lng->txt("cont_mycourses_sortorder_alphabetical"),
734 "loc" => $this->lng->txt("cont_mycourses_sortorder_location")
735 );
736 $tpl->setVariable("SORT_SELECT", ilUtil::formSelect(
737 $sorting,
738 "srt",
739 $options,
740 false,
741 true,
742 0,
743 "",
744 array("onchange" => "form.submit()")
745 ));
746 $tpl->setVariable("SORT_FORM", $this->getCourseSortAction($ilCtrl));
747 }
748
749 $old_path = null;
750
751 foreach ($data as $course) {
752 if ($sorting == "loc") {
753 if ($course["path"] != $old_path) {
754 $tpl->setCurrentBlock("path_bl");
755 $tpl->setVariable("PATH", $course["path"]);
756 $tpl->parseCurrentBlock();
757
758 $old_path = $course["path"];
759 }
760 }
761
762 if (isset($course["lp_status"])) {
763 $lp_icon_rendered = $lp_icons->renderIconForStatus($course["lp_status"]);
764
765 $tpl->setCurrentBlock("lp_bl");
766 $tpl->setVariable("LP_ICON", $lp_icon_rendered);
767 $tpl->parseCurrentBlock();
768 }
769
770 $do_links = false;
771 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
772 $do_links = $ilAccess->checkAccessOfUser($ilUser->getId(), "read", "", $course["ref_id"], "crs") ||
773 ($ilAccess->checkAccessOfUser($ilUser->getId(), "visible", "", $course["ref_id"], "crs") &&
774 $ilAccess->checkAccessOfUser($ilUser->getId(), "join", "", $course["ref_id"], "crs"));
775 }
776
777 if (isset($course["objectives"])) {
778 $loc_settings = ilLOSettings::getInstanceByObjId($course["obj_id"]);
779 $has_initial_test = (bool) $loc_settings->getInitialTest();
780
781 foreach ($course["objectives"] as $objtv) {
782 if ($do_links) {
783 $params = array("oobj" => $objtv["id"]);
784 $url = ilLink::_getLink($course["ref_id"], "crs", $params);
785
786 // #15510
787 $url .= "#objtv_acc_" . $objtv["id"];
788
789 if ($this->getOutputMode() != "print") {
790 $tpl->touchBlock("objective_dnone");
791 }
792
793 $tpl->setCurrentBlock("objective_link_bl");
794
795 if (trim($objtv["desc"])) {
796 $desc = nl2br($objtv["desc"]);
797 $tt_id = "objtvtt_" . $objtv["id"] . "_" . ((int) self::$initialized);
798
799 ilTooltipGUI::addTooltip($tt_id, $desc, "", "bottom center", "top center", false);
800
801 $tpl->setVariable("OBJECTIVE_LINK_ID", $tt_id);
802 }
803
804 $tpl->setVariable("OBJECTIVE_LINK_URL", $url);
805 $tpl->setVariable("OBJECTIVE_LINK_TITLE", $objtv["title"]);
806 $tpl->parseCurrentBlock();
807 } else {
808 $tpl->setCurrentBlock("objective_nolink_bl");
809 $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
810 $tpl->parseCurrentBlock();
811 }
812
813 $objtv_icon = ilUtil::getTypeIconPath("lobj", $objtv["id"]);
814 if ($img_path) {
815 $objtv_icon = $img_path . basename($objtv_icon);
816 }
817
818 $tpl->setCurrentBlock("objective_bl");
819 $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
820 $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
821
822 if ($objtv["type"]) {
823 $tpl->setVariable(
824 "LP_OBJTV_PROGRESS",
825 ilContainerObjectiveGUI::buildObjectiveProgressBar($has_initial_test, $objtv["id"], $objtv, true, false, (int) self::$initialized)
826 );
827 }
828
829 $tpl->parseCurrentBlock();
830 }
831
832 $tpl->setCurrentBlock("objectives_bl");
833 $tpl->setVariable("OBJTV_LIST_CRS_ID", $course["obj_id"]);
834 $tpl->parseCurrentBlock();
835 }
836
837 // always check against current user
838 if ($do_links) {
839 $tpl->setCurrentBlock("course_link_bl");
840 $tpl->setVariable("COURSE_LINK_TITLE", $course["title"]);
841 $tpl->setVariable("COURSE_LINK_URL", ilLink::_getLink($course["ref_id"]));
842 $tpl->parseCurrentBlock();
843 } else {
844 $tpl->setCurrentBlock("course_nolink_bl");
845 $tpl->setVariable("COURSE_NOLINK_TITLE", $course["title"]);
846 $tpl->parseCurrentBlock();
847 }
848
849 $crs_icon = ilUtil::getTypeIconPath("crs", $course["obj_id"]);
850 if ($img_path) {
851 $crs_icon = $img_path . basename($crs_icon);
852 }
853
854 $tpl->setCurrentBlock("course_bl");
855
856 if (isset($course["objectives"])) {
857 $tpl->setVariable("TOGGLE_CLASS", "ilPCMyCoursesToggle");
858 } else {
859 $tpl->setVariable("NO_TOGGLE", ' style="visibility:hidden;"');
860 }
861
862 $tpl->setVariable("CRS_ICON_URL", $crs_icon);
863 $tpl->setVariable("CRS_ICON_ALT", $this->lng->txt("obj_crs"));
864 $tpl->parseCurrentBlock();
865 }
866
867 // #15508
868 if (!self::$initialized) {
869 $GLOBALS["tpl"]->addJavaScript("Modules/Portfolio/js/ilPortfolio.js");
870 $GLOBALS["tpl"]->addOnLoadCode("ilPortfolio.init()");
871 }
872 self::$initialized++;
873
874 return $tpl->get();
875 }
876 }
877
884 protected function getCourseSortAction($ctrl)
885 {
886 return $ctrl->getFormActionByClass("ilobjportfoliogui", "preview");
887 }
888
889
890 protected function getCoursesOfUser($a_user_id, $a_add_path = false)
891 {
893
894 // see ilPDSelectedItemsBlockGUI
895
896 $items = ilParticipants::_getMembershipByType($a_user_id, 'crs');
897
898 $repo_title = $tree->getNodeData(ROOT_FOLDER_ID);
899 $repo_title = $repo_title["title"];
900 if ($repo_title == "ILIAS") {
901 $repo_title = $this->lng->txt("repository");
902 }
903
904 $references = $lp_obj_refs = array();
905 foreach ($items as $obj_id) {
906 $ref_id = ilObject::_getAllReferences($obj_id);
907 if (is_array($ref_id) && count($ref_id)) {
908 $ref_id = array_pop($ref_id);
909 if (!$tree->isDeleted($ref_id)) {
910 $visible = false;
911 $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
912 if ($active && $visible) {
913 $references[$ref_id] = array(
914 'ref_id' => $ref_id,
915 'obj_id' => $obj_id,
916 'title' => ilObject::_lookupTitle($obj_id)
917 );
918
919 if ($a_add_path) {
920 $path = array();
921 foreach ($tree->getPathFull($ref_id) as $item) {
922 $path[] = $item["title"];
923 }
924 // top level comes first
925 if (sizeof($path) == 2) {
926 $path[0] = 0;
927 } else {
928 $path[0] = 1;
929 }
930 $references[$ref_id]["path_sort"] = implode("__", $path);
931 array_shift($path);
932 array_pop($path);
933 if (!sizeof($path)) {
934 array_unshift($path, $repo_title);
935 }
936 $references[$ref_id]["path"] = implode(" &rsaquo; ", $path);
937 }
938
939 $lp_obj_refs[$obj_id] = $ref_id;
940 }
941 }
942 }
943 }
944
945 // get lp data for valid courses
946
947 if (sizeof($lp_obj_refs)) {
948 // listing the objectives should NOT depend on any LP status / setting
949 foreach ($lp_obj_refs as $obj_id => $ref_id) {
950 // only if set in DB (default mode is not relevant
952 $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id);
953 }
954 }
955
956 // LP must be active, personal and not anonymized
960 // see ilLPProgressTableGUI
961 $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
962 foreach ($lp_data as $item) {
963 $ref_id = $item["ref_ids"];
964 $references[$ref_id]["lp_status"] = $item["status"];
965 }
966 }
967 }
968
969 return $references;
970 }
971
972 protected function parseObjectives($a_obj_id, $a_user_id)
973 {
974 $res = array();
975
976 // we need the collection for the correct order
978 $coll_objtv = $coll_objtv->getItems();
979 if ($coll_objtv) {
980 // #13373
981 $lo_results = $this->parseLOUserResults($a_obj_id, $a_user_id);
982
983 $lo_ass = ilLOTestAssignments::getInstance($a_obj_id);
984
985 $tmp = array();
986
987 foreach ($coll_objtv as $objective_id) {
988 $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
989
990 $tmp[$objective_id] = array(
991 "id" => $objective_id,
992 "title" => $title["title"],
993 "desc" => $title["description"],
994 "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL),
995 "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED)
996 );
997
998 if (array_key_exists($objective_id, $lo_results)) {
999 $lo_result = $lo_results[$objective_id];
1000 $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
1001 $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"];
1002 $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"];
1003 $tmp[$objective_id]["status"] = $lo_result["status"];
1004 $tmp[$objective_id]["type"] = $lo_result["type"];
1005 $tmp[$objective_id]["initial"] = $lo_result["initial"];
1006 }
1007 }
1008
1009 // order
1010 foreach ($coll_objtv as $objtv_id) {
1011 $res[] = $tmp[$objtv_id];
1012 }
1013 }
1014
1015 return $res;
1016 }
1017
1018 // see ilContainerObjectiveGUI::parseLOUserResults()
1019 protected function parseLOUserResults($a_course_obj_id, $a_user_id)
1020 {
1021 $res = array();
1022
1023 $lur = new ilLOUserResults($a_course_obj_id, $a_user_id);
1024 foreach ($lur->getCourseResultsForUserPresentation() as $objective_id => $types) {
1025 // show either initial or qualified for objective
1026 if (isset($types[ilLOUserResults::TYPE_INITIAL])) {
1027 $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
1028 }
1029
1030 // qualified test has priority
1031 if (isset($types[ilLOUserResults::TYPE_QUALIFIED])) {
1034 $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL];
1035 } else {
1038 }
1039
1040 $result["initial_status"] = $initial_status;
1041
1042 $res[$objective_id] = $result;
1043 }
1044
1045 return $res;
1046 }
1047
1048 public function getExportMaterial()
1049 {
1051 }
1052
1059 public function makePlaceHoldersClickable($a_html)
1060 {
1061 $ilCtrl = $this->ctrl;
1062 $lng = $this->lng;
1064
1065 $c_pos = 0;
1066 $start = strpos($a_html, "{{{{{PlaceHolder#");
1067 if (is_int($start)) {
1068 $end = strpos($a_html, "}}}}}", $start);
1069 }
1070 $i = 1;
1071 while ($end > 0) {
1072 $param = substr($a_html, $start + 17, $end - $start - 17);
1073 $param = explode("#", $param);
1074
1075 $html = $param[2];
1076 switch ($param[2]) {
1077 case "Text":
1078 $html = $lng->txt("cont_text_placeh");
1079 break;
1080
1081 case "Media":
1082 $html = $lng->txt("cont_media_placeh");
1083 break;
1084
1085 case "Question":
1086 $html = $lng->txt("cont_question_placeh");
1087 break;
1088
1089 case "Verification":
1090 $html = $lng->txt("cont_verification_placeh");
1091 break;
1092 }
1093
1094 // only if not owner
1095 if ($ilUser->getId() == ilObjPortfolio::_lookupOwner($this->portfolio_id)
1096 && $this->getOutputMode() == "presentation") {
1097 switch ($param[2]) {
1098 case "Text":
1099 $ilCtrl->setParameterByClass("ilportfoliopagegui", "prt_id", $_GET["prt_id"]);
1100 $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->getId());
1101 $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_pc_id", $param[0]);
1102 $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_hier_id", $param[1]);
1103 $href = $ilCtrl->getLinkTargetByClass("ilportfoliopagegui", "insertJSAtPlaceholder");
1104 $html = "<a href='" . $href . "'>" . $html . "</a>";
1105 break;
1106
1107 case "Media":
1108 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "prt_id", $_GET["prt_id"]);
1109 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "ppage", $this->getId());
1110 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_pc_id", $param[0]);
1111 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_hier_id", $param[1]);
1112 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "insertNew");
1113 $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilpcmediaobjectgui"), "insert");
1114 $html = "<a href='" . $href . "'>" . $html . "</a>";
1115 break;
1116
1117 case "Verification":
1118 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "prt_id", $_GET["prt_id"]);
1119 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "ppage", $this->getId());
1120 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "pl_pc_id", $param[0]);
1121 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "pl_hier_id", $param[1]);
1122 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "subCmd", "insertNew");
1123 $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilPCVerificationGUI"), "insert");
1124 $html = "<a href='" . $href . "'>" . $html . "</a>";
1125 break;
1126 }
1127 }
1128
1129 $h2 = substr($a_html, 0, $start) .
1130 $html .
1131 substr($a_html, $end + 5);
1132 $a_html = $h2;
1133 $i++;
1134
1135 $start = strpos($a_html, "{{{{{PlaceHolder#", $start + 5);
1136 $end = 0;
1137 if (is_int($start)) {
1138 $end = strpos($a_html, "}}}}}", $start);
1139 }
1140 }
1141 return $a_html;
1142 }
1143
1150 public function getViewPageLink()
1151 {
1152 global $DIC;
1153
1154 $ctrl = $DIC->ctrl();
1155
1156 $ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $this->requested_ppage);
1157 return $ctrl->getLinkTargetByClass("ilobjportfoliogui", "preview");
1158 }
1159
1166 public function getViewPageText()
1167 {
1168 return $this->lng->txt("preview");
1169 }
1170
1177 public function getPagePermaLink()
1178 {
1180 $href = ilLink::_getStaticLink($pid, "prtf", true, "_" . $this->getId());
1181 return $href;
1182 }
1183
1190 private function createPersistentCertificateUrl($a_id, $userCertificateRepository, $url) : string
1191 {
1192 $presentation = $userCertificateRepository->fetchActiveCertificateForPresentation($this->user->getId(), $a_id);
1193 $caption = $this->lng->txt('certificate') . ': ';
1194 $caption .= $this->lng->txt($presentation->getUserCertificate()->getObjType()) . ' ';
1195 $caption .= '"' . $presentation->getObjectTitle() . '"';
1196
1197 return '<div><a href="' . $url . '">' . $caption . '</a></div>';
1198 }
1199
1203 public function getCommentsHTMLExport()
1204 {
1205 $notes_gui = new ilNoteGUI(
1206 $this->portfolio_id,
1207 $this->getPageObject()->getId(),
1208 "pfpg"
1209 );
1210 $notes_gui->enablePublicNotes(true);
1211 $notes_gui->setRepositoryMode(false);
1212 $notes_gui->setExportMode();
1213 return $notes_gui->getNotesHTML();
1214 }
1215
1216 public function finishEditing()
1217 {
1218 $this->ctrl->redirectByClass("ilObjPortfolioGUI", "view");
1219 }
1220}
$result
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CRS_VIEW_OBJECTIVE
const IL_CAL_DATE
const IL_CAL_UNIX
Class ilBlogPosting GUI class.
Class ilBlogPosting.
static _getInstance($a_usr_id=0)
get singleton instance
Calendar schedule filter for consultation hour bookings.
static lookupTitle($a_group_id)
Lookup group title.
static buildObjectiveProgressBar($a_has_initial_test, $a_objective_id, array $a_lo_result, $a_list_mode=false, $a_sub=false, $a_tt_suffix=null)
Render progressbar(s) for given objective and result data.
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
Class for single dates.
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
Notes GUI class.
Class ilObjBlogGUI.
static _isActivated($a_obj_id, &$a_visible_flag=null, $a_mind_member_view=true)
Is activated?
GUI class for course verification.
static _lookupViewMode($a_id)
lookup view mode of container
GUI class for exercise verification.
GUI class for scorm verification.
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
GUI class for test verification.
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static _lookupOwner($a_id)
lookup object owner
static _lookupTitle($a_id)
lookup object title
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilPageObjectGUI.
setPresentationTitle($a_title="")
getPageObject()
Get Page Object.
setTemplateOutput($a_output=true)
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
Personal skills GUI class.
Portfolio page gui class.
setEmbedded($a_value)
Set embedded mode: will suppress tabs.
executeCommand()
execute command
getCoursesOfUser($a_user_id, $a_add_path=false)
parseLOUserResults($a_course_obj_id, $a_user_id)
getCourseSortAction($ctrl)
Get course sort action.
renderTeaser($a_type, $a_title, $a_options=null)
getParentType()
Get parent type.
renderPageElement($a_type, $a_html)
renderProfile($a_user_id, $a_type, array $a_fields=null)
renderConsultationHours($a_user_id, $a_mode, $a_group_ids)
getPagePermaLink()
Get page perma link.
getViewPageText()
Get view page link.
renderSkillsTeaser($a_user_id, $a_skills_id)
getTabs($a_activate="")
Set all tabs.
renderBlog($a_user_id, $a_blog_id, array $a_posting_ids=null)
renderBlogTeaser($a_user_id, $a_blog_id, array $a_posting_ids=null)
renderVerification($a_user_id, $a_type, $a_id)
postOutputProcessing($a_output)
Finalizing output processing.
getAdditional()
Get Additonal Information.
createPersistentCertificateUrl($a_id, $userCertificateRepository, $url)
renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids)
__construct($a_portfolio_id, $a_id=0, $a_old_nr=0, $a_enable_comments=true)
Constructor.
parseObjectives($a_obj_id, $a_user_id)
renderMyCoursesTeaser($a_user_id, $a_default_sorting)
getViewPageLink()
Get view page link.
renderMyCourses($a_user_id, $a_default_sorting)
renderSkills($a_user_id, $a_skills_id)
makePlaceHoldersClickable($a_html)
Modify page content after xsl.
setAdditional($a_additional)
Set Additonal Information.
static findPortfolioForPage($a_page_id)
Get portfolio id of page id.
GUI class for public user profile presentation.
ILIAS Setting Class.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
special template class to simplify handling of ITX/PEAR
static addTooltip( $a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Adds a tooltip to an HTML element.
static getObjectsStatusForUser($a_user_id, array $obj_refs)
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
Tree handler for personal workspace.
const ANONYMOUS_USER_ID
Definition: constants.php:25
const ROOT_FOLDER_ID
Definition: constants.php:30
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$url
foreach($_POST as $key=> $value) $res
$data
Definition: storeScorm.php:23
$param
Definition: xapitoken.php:29