ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPortfolioPageGUI.php
Go to the documentation of this file.
1<?php
2
20
29{
30 public const EMBEDDED_NO_OUTPUT = -99;
31 protected bool $enable_comments;
32 protected int $portfolio_id;
33 protected \ILIAS\Portfolio\StandardGUIRequest $port_request;
34
35 protected bool $embedded = false;
37 protected ilTree $tree;
38 protected array $js_onload_code = array();
39 protected array $additional = array();
40 protected array $export_material = array("js" => array(), "images" => array(), "files" => array());
41 protected static int $initialized = 0;
42 protected static bool $calender_initialized = false;
43 protected int $requested_ppage;
44 protected \ILIAS\UI\Factory $ui_fac;
45 protected \ILIAS\UI\Renderer $ui_ren;
46
47 public function __construct(
48 int $a_portfolio_id,
49 int $a_id = 0,
50 int $a_old_nr = 0,
51 bool $a_enable_comments = true
52 ) {
53 global $DIC;
54
55 $this->tpl = $DIC["tpl"];
56 $this->ctrl = $DIC->ctrl();
57 $this->user = $DIC->user();
58 $this->obj_definition = $DIC["objDefinition"];
59 $this->access = $DIC->access();
60 $this->tree = $DIC->repositoryTree();
61 $this->lng = $DIC->language();
62 $tpl = $DIC["tpl"];
63 $this->port_request = $DIC->portfolio()
64 ->internal()
65 ->gui()
66 ->standardRequest();
67 $this->ui_fac = $DIC->ui()->factory();
68 $this->ui_ren = $DIC->ui()->renderer();
69
70 $this->portfolio_id = $a_portfolio_id;
71 $this->enable_comments = $a_enable_comments;
72
73 parent::__construct($this->getParentType(), $a_id, $a_old_nr);
74 $this->getPageObject()->setPortfolioId($this->portfolio_id);
75
76 // content style
77
78 $tpl->setCurrentBlock("SyntaxStyle");
80 "LOCATION_SYNTAX_STYLESHEET",
82 );
84
85 $tpl->setCurrentBlock("ContentStyle");
87 "LOCATION_CONTENT_STYLESHEET",
89 );
91
92 $this->requested_ppage = $this->port_request->getPortfolioPageId();
93 }
94
95 public function getParentType(): string
96 {
97 return "prtf";
98 }
99
100 protected function getPageContentUserId(int $a_user_id): int
101 {
102 // user id from content-xml
103 return $a_user_id;
104 }
105
106 protected function getPortfolioPage(): ilPortfolioPage
107 {
109 $page = $this->getPageObject();
110 return $page;
111 }
112
113 public function executeCommand(): string
114 {
115 $ilCtrl = $this->ctrl;
116 $ilUser = $this->user;
117
118 $next_class = $this->ctrl->getNextClass($this);
119 $cmd = $this->ctrl->getCmd();
120
121 switch ($next_class) {
122 case "ilcalendarmonthgui":
123 $this->ctrl->saveParameter($this, "chuid");
124 // booking action
125 if ($cmd && $cmd !== "preview") {
127 if ($categories->getMode() === 0) {
128 $chuid = $this->port_request->getConsultationHourUserId();
129 if ($chuid > 0) {
130 $categories->setCHUserId($chuid);
131 }
132 $categories->initialize(ilCalendarCategories::MODE_PORTFOLIO_CONSULTATION, 0, true);
133 }
134
135 $req_seed = $this->port_request->getCalendarSeed();
136 if ($req_seed !== "") {
137 $seed = new ilDate($req_seed, IL_CAL_DATE);
138 } else {
139 $seed = new ilDate(time(), IL_CAL_UNIX);
140 }
141
142 $month_gui = new ilCalendarMonthGUI($seed);
143 return (string) $ilCtrl->forwardCommand($month_gui);
144 }
145
146 // calendar month navigation
147 //$ilCtrl->setParameter($this, "cmd", "preview");
148 return (string) self::EMBEDDED_NO_OUTPUT;
149 default:
150 $this->setPresentationTitle($this->getPageObject()->getTitle());
151 return (string) parent::executeCommand();
152 }
153 }
154
155 public function showPage(): string
156 {
157 $ilUser = $this->user;
158
159 if (!$this->getPageObject()) {
160 return "";
161 }
162
163 $this->setTemplateOutput(false);
164 // $this->setPresentationTitle($this->getPageObject()->getTitle());
165 return parent::showPage();
166 }
167
168 public function getTabs(string $a_activate = ""): void
169 {
170 if (!$this->embedded) {
171 parent::getTabs($a_activate);
172 }
173 }
174
178 public function setEmbedded(bool $a_value): void
179 {
180 $this->embedded = $a_value;
181 }
182
186 public function setAdditional(array $a_additional): void
187 {
188 $this->additional = $a_additional;
189 }
190
194 public function getAdditional(): array
195 {
196 return $this->additional;
197 }
198
199 public function getJsOnloadCode(): array
200 {
202 }
203
204 public function postOutputProcessing(string $a_output): string
205 {
206 $parts = array(
207 "Profile" => array("0-9", "a-z", "0-9a-z_;\W"), // user, mode, fields
208 "Verification" => array("0-9", "a-z", "0-9"), // user, type, id
209 "Blog" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
210 "BlogTeaser" => array("0-9", "0-9", "0-9;\W"), // user, blog id, posting ids
211 "Skills" => array("0-9", "0-9"), // user, skill id
212 "SkillsTeaser" => array("0-9", "0-9"), // user, skill id
213 "ConsultationHours" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
214 "ConsultationHoursTeaser" => array("0-9", "a-z", "0-9;\W"), // user, mode, group ids
215 "MyCourses" => array("0-9", "a-z*"), // user, sort
216 "MyCoursesTeaser" => array("0-9", "a-z*") // user, sort
217 );
218
219 foreach ($parts as $type => $def) {
220 // #15732 - allow optional parts
221 $def_parts = array();
222 foreach ($def as $part) {
223 $is_opt = (substr($part, -1) === "*");
224 if (!$is_opt) {
225 $def_parts[] = "#";
226 $end_marker = "+";
227 } else {
228 $def_parts[] = "#*";
229 $end_marker = "*";
230 $part = substr($part, 0, -1);
231 }
232 $def_parts[] = "([" . $part . "]" . $end_marker . ")";
233 }
234 $def = implode("", $def_parts);
235
236 if (preg_match_all(
237 "/" . $this->pl_start . $type . $def . $this->pl_end . "/",
238 $a_output,
239 $blocks
240 )) {
241 foreach ($blocks[0] as $idx => $block) {
242 switch ($type) {
243 case "Profile":
244 case "Blog":
245 case "BlogTeaser":
246 case "Skills":
247 case "SkillsTeaser":
248 case "ConsultationHours":
249 case "ConsultationHoursTeaser":
250 case "MyCourses":
251 case "MyCoursesTeaser":
252 $subs = null;
253 if (trim(($blocks[3][$idx] ?? ""))) {
254 foreach (explode(";", $blocks[3][$idx]) as $sub) {
255 if (trim($sub)) {
256 $subs[] = trim($sub);
257 }
258 }
259 }
260 $snippet = $this->{"render" . $type}(
261 $blocks[1][$idx],
262 $blocks[2][$idx],
263 $subs
264 );
265 break;
266
267 default:
268 $snippet = $this->{"render" . $type}(
269 $blocks[1][$idx],
270 $blocks[2][$idx],
271 $blocks[3][$idx]
272 );
273 break;
274 }
275
276 $snippet = $this->renderPageElement($type, $snippet);
277 $a_output = str_replace($block, $snippet, $a_output);
278 }
279 }
280 }
281
282 $a_output = $this->makePlaceHoldersClickable($a_output);
283
284 return $a_output;
285 }
286
287 protected function renderPageElement(
288 string $a_type,
289 string $a_html
290 ): string {
291 return trim($a_html);
292 }
293
294 protected function renderTeaser(
295 string $a_type,
296 string $a_title,
297 string $a_options = ""
298 ): string {
299 $options = "";
300 if ($a_options) {
301 $options = '<div class="il_Footer">' . $this->lng->txt("prtf_page_element_teaser_settings") .
302 ": " . $a_options . '</div>';
303 }
304
305 return '<div style="margin:5px" class="ilBox"><h3>' . $a_title . '</h3>' .
306 '<div class="il_Description_no_margin">' . $this->lng->txt("prtf_page_element_teaser_" . $a_type) . '</div>' .
307 $options . '</div>';
308 }
309
310 protected function renderProfile(
311 int $a_user_id,
312 string $a_type,
313 ?array $a_fields = null
314 ): string {
315 $ilCtrl = $this->ctrl;
316
317 $user_id = $this->getPageContentUserId($a_user_id);
318
319 $pub_profile = new PublicProfileGUI($user_id);
320 $pub_profile->setEmbedded(true, ($this->getOutputMode() === "offline"));
321
322 // full circle: additional was set in the original public user profile call
323 $pub_profile->setAdditional($this->getAdditional());
324
325 if ($a_type === "manual" && is_array($a_fields) && count($a_fields) > 0) {
326 $prefs = array();
327 foreach ($a_fields as $field) {
328 $field = trim($field);
329 if ($field) {
330 $prefs["public_" . $field] = "y";
331 }
332 }
333
334 $pub_profile->setCustomPrefs($prefs);
335 }
336
337 if ($this->getOutputMode() !== "offline") {
338 return $ilCtrl->getHTML($pub_profile);
339 }
340
341 return $pub_profile->getEmbeddable();
342 }
343
347 protected function renderVerification(
348 int $a_user_id,
349 string $a_type,
350 int $a_id
351 ): string {
352 $objDefinition = $this->obj_definition;
353
354 $outputMode = $this->getOutputMode();
355
356 // not used
357 // $user_id = $this->getPageContentUserId($a_user_id);
358 if ($a_type === 'crta' && $outputMode === 'offline') {
359 $fileService = new ilPortfolioCertificateFileService();
360
361 $certificatePdfFile = $fileService->createCertificateFilePath($a_user_id, $a_id);
362 $this->export_material["files"][] = $certificatePdfFile;
363
364 $url = 'files/' . basename($certificatePdfFile);
365
366 $userCertificateRepository = new ilUserCertificateRepository();
367
368 return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
369 }
370
371 if ($a_type === 'crta' && $outputMode === 'print') {
372 $userCertificateRepository = new ilUserCertificateRepository();
373 $url = $this->getPagePermaLink();
374
375 return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
376 }
377
378 if ($a_type === 'crta') {
379 $this->ctrl->setParameter($this, "dlid", $a_id);
380 $url = $this->ctrl->getLinkTarget($this, "dl" . $a_type);
381 $this->ctrl->setParameter($this, "dlid", "");
382
383 $userCertificateRepository = new ilUserCertificateRepository();
384
385 return $this->createPersistentCertificateUrl($a_id, $userCertificateRepository, $url);
386 }
387
388 if (!ilObject::_exists($a_id)) {
389 return $this->lng->txt('deleted');
390 }
391
392 $class = "ilObj" . $objDefinition->getClassName($a_type) . "GUI";
393 $verification = new $class($a_id, ilObject2GUI::WORKSPACE_OBJECT_ID);
394
395 if ($outputMode === "print") {
396 $url = $this->getPagePermaLink();
397 } elseif ($outputMode !== "offline") {
398 // direct download link
399 $this->ctrl->setParameter($this, "dlid", $a_id);
400 $url = $this->ctrl->getLinkTarget($this, "dl" . $a_type);
401 $this->ctrl->setParameter($this, "dlid", "");
402 } else {
403 $file = $verification->getObject()->getFilePath();
404 $url = "files/" . basename($file);
405
406 $this->export_material["files"][] = $file;
407 }
408
409 return $verification->render(true, $url);
410 }
411
412 protected function dltstv(): void
413 {
414 $id = $this->port_request->getVerificationId();
415 if ($id) {
417 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
418 }
419 }
420
421 protected function dlexcv(): void
422 {
423 $id = $this->port_request->getVerificationId();
424 if ($id) {
426 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
427 }
428 }
429
430 protected function dlcrsv(): void
431 {
432 $id = $this->port_request->getVerificationId();
433 if ($id) {
435 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
436 }
437 }
438
439 protected function dlcmxv(): void
440 {
441 $id = $this->port_request->getVerificationId();
442 if ($id) {
444 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
445 }
446 }
447
448 protected function dlltiv(): void
449 {
450 $id = $this->port_request->getVerificationId();
451 if ($id) {
453 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
454 }
455 }
456
457 protected function dlscov(): void
458 {
459 $id = $this->port_request->getVerificationId();
460 if ($id) {
462 $verification->downloadFromPortfolioPage($this->getPortfolioPage());
463 }
464 }
465
466 protected function dlcrta(): void
467 {
468 $objectId = $this->port_request->getVerificationId();
469 if ($objectId) {
471 $object->downloadFromPortfolioPage($this->getPortfolioPage(), $objectId, $this->user->getId());
472 }
473 }
474
475 protected function renderBlogTeaser(
476 int $a_user_id,
477 int $a_blog_id,
478 ?array $a_posting_ids = null
479 ): string {
480 // not used
481 // $user_id = $this->getPageContentUserId($a_user_id);
482
483 $postings = "";
484 if ($a_posting_ids) {
485 $postings = array("<ul>");
486 foreach ($a_posting_ids as $post) {
488 $postings[] = "<li>" . $post->getTitle() . " - " .
489 ilDatePresentation::formatDate($post->getCreated()) . "</li>";
490 }
491 $postings[] = "</ul>";
492 $postings = implode("\n", $postings);
493 }
494
495 return $this->renderTeaser("blog", $this->lng->txt("obj_blog") . ' "' .
496 ilObject::_lookupTitle($a_blog_id) . '"', $postings);
497 }
498
499 protected function renderSkills(
500 int $a_user_id,
501 int $a_skills_id
502 ): string {
503 if ($this->getOutputMode() === "preview") {
504 return $this->renderSkillsTeaser($a_user_id, $a_skills_id);
505 }
506
507 $user_id = $this->getPageContentUserId($a_user_id);
508
509 $gui = new ilPersonalSkillsGUI();
510 if ($this->getOutputMode() === "offline") {
511 $gui->setOfflineMode("./files/");
512 }
513 return $gui->getSkillHTML($a_skills_id, $user_id);
514 }
515
516 protected function renderSkillsTeaser(
517 int $a_user_id,
518 int $a_skills_id
519 ): string {
520 // not used
521 // $user_id = $this->getPageContentUserId($a_user_id);
522
523 return $this->renderTeaser("skills", $this->lng->txt("skills") . ' "' .
524 ilSkillTreeNode::_lookupTitle($a_skills_id) . '"');
525 }
526
528 int $a_user_id,
529 string $a_mode,
530 ?array $a_group_ids = null
531 ): string {
532 // not used
533 // $user_id = $this->getPageContentUserId($a_user_id);
534 if ($a_mode === "auto") {
535 $mode = $this->lng->txt("cont_cach_mode_automatic");
536 $groups = null;
537 }
538 // begin-abandon ch_groups
539 /*
540 else {
541 $mode = $this->lng->txt("cont_cach_mode_manual");
542
543 $groups = array();
544 foreach ($a_group_ids as $grp_id) {
545 $groups[] = ilConsultationHourGroups::lookupTitle($grp_id);
546 }
547 $groups = " (" . implode(", ", $groups) . ")";
548 }
549 */
550 // end-abandon ch_groups
551
552 $this->lng->loadLanguageModule("dateplaner");
553 return $this->renderTeaser(
554 "consultation_hours",
555 $this->lng->txt("app_consultation_hours"),
556 $mode . $groups
557 );
558 }
559
560 protected function renderConsultationHours(
561 int $a_user_id,
562 string $a_mode,
563 ?array $a_group_ids = null
564 ): string {
565 $ilUser = $this->user;
566 if ($this->getOutputMode() === "preview") {
567 return $this->renderConsultationHoursTeaser($a_user_id, $a_mode, $a_group_ids);
568 }
569
570 if ($this->getOutputMode() === "offline") {
571 return "";
572 }
573
574 if ($this->getOutputMode() === "print") {
575 return "";
576 }
577
578 $user_id = $this->getPageContentUserId($a_user_id);
579
580 // only if not owner
581 $bkid = 0;
582 if ($ilUser->getId() !== $user_id) {
583 $bkid = $user_id;
584 }
585 $this->ctrl->setParameter($this, "chuid", $user_id);
586
587 if ($a_mode !== "manual") {
588 $a_group_ids = null;
589 }
591 if (!self::$calender_initialized) {
594 0,
595 true
596 );
597 self::$calender_initialized = true;
598 }
599
600 $seed = $this->port_request->getCalendarSeed();
601 if ($seed === "") {
602 $seed = new ilDate(time(), IL_CAL_UNIX);
603 } else {
604 $seed = new ilDate($seed, IL_CAL_DATE);
605 }
606
607 $month_gui = new ilCalendarMonthGUI($seed);
608 if ($bkid > 0) {
609 $month_gui->setBkId($bkid);
610 }
611 $month_gui->setConsulationHoursUserId($user_id);
612
613 // custom schedule filter: handle booking group ids
615 $month_gui->addScheduleFilter($filter);
616
617 $this->tpl->addCss(ilUtil::getStyleSheetLocation('filesystem', 'delos.css'));
618
619 $this->lng->loadLanguageModule("dateplaner");
620 return '<h3>' . $this->lng->txt("app_consultation_hours") . '</h3>' .
621 $this->ctrl->getHTML($month_gui);
622 }
623
624 protected function isMyCoursesActive(): bool
625 {
626 $prfa_set = new ilSetting("prfa");
627 return (bool) $prfa_set->get("mycrs", true);
628 }
629
630 protected function renderMyCoursesTeaser(
631 int $a_user_id,
632 $a_default_sorting
633 ): string {
634 // not used
635 // $user_id = $this->getPageContentUserId($a_user_id);
636
637 $title = $this->isMyCoursesActive()
638 ? "my_courses"
639 : "my_courses_inactive";
640
641 return $this->renderTeaser(
642 $title,
643 $this->lng->txt("prtf_page_element_my_courses_title")
644 );
645 }
646
647 protected function renderMyCourses(
648 int $a_user_id,
649 string $a_default_sorting
650 ): string {
651 $ilAccess = $this->access;
652 $ilUser = $this->user;
653 $ilCtrl = $this->ctrl;
654
655 if ($this->getOutputMode() === "preview") {
656 return $this->renderMyCoursesTeaser($a_user_id, $a_default_sorting);
657 }
658
659 if (!$this->isMyCoursesActive()) {
660 return "";
661 }
662
663 $img_path = null;
665
666 $user_id = $this->getPageContentUserId($a_user_id);
667
668 // sorting pref
669 $req_sorting = $this->port_request->getCourseSorting();
670 if (in_array($req_sorting, array("alpha", "loc"))) {
671 $ilUser->writePref("prtf_mcrs_sort", $req_sorting);
672 }
673 $sorting = $ilUser->getPref("prtf_mcrs_sort");
674 if (!$sorting) {
675 $sorting = $a_default_sorting;
676 }
677
678 $data = $this->getCoursesOfUser($user_id, ($sorting === "loc"));
679 if (count($data)) {
680 if ($sorting !== "loc") {
681 $data = ilArrayUtil::sortArray($data, "title", "ASC");
682 } else {
683 $data = ilArrayUtil::sortArray($data, "path_sort", "ASC");
684 }
685
686 $tpl = new ilTemplate("tpl.pc_my_courses.html", true, true, "components/ILIAS/Portfolio");
687 $tpl->setVariable("TITLE", $this->lng->txt("prtf_page_element_my_courses_title"));
688 $tpl->setVariable("INFO", $this->lng->txt("prtf_page_element_my_courses_info")); // #14464
689
690 $this->lng->loadLanguageModule("trac");
691 $this->lng->loadLanguageModule("crs");
692
693 // sorting
694 if ($this->getOutputMode() !== "print") {
695 $options = array(
696 "alpha" => $this->lng->txt("cont_mycourses_sortorder_alphabetical"),
697 "loc" => $this->lng->txt("cont_mycourses_sortorder_location")
698 );
699 $tpl->setVariable(
700 "SORT_SELECT",
702 $sorting,
703 "srt",
704 $options,
705 false,
706 true,
707 0,
708 "",
709 ["onchange" => "form.submit()"]
710 )
711 );
712 $tpl->setVariable("SORT_FORM", $this->getCourseSortAction($ilCtrl));
713 }
714
715 $old_path = null;
716
717 foreach ($data as $course) {
718 if (($sorting === "loc") && $course["path"] != $old_path) {
719 $tpl->setCurrentBlock("path_bl");
720 $tpl->setVariable("PATH", $course["path"]);
721 $tpl->parseCurrentBlock();
722
723 $old_path = $course["path"];
724 }
725
726 if (isset($course["lp_status"])) {
727 $lp_icon_rendered = $lp_icons->renderIconForStatus($course["lp_status"]);
728
729 $tpl->setCurrentBlock("lp_bl");
730 $tpl->setVariable("LP_ICON", $lp_icon_rendered);
731 $tpl->parseCurrentBlock();
732 }
733
734 $do_links = false;
735 if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
736 $do_links = $ilAccess->checkAccessOfUser($ilUser->getId(), "read", "", $course["ref_id"], "crs") ||
737 ($ilAccess->checkAccessOfUser($ilUser->getId(), "visible", "", $course["ref_id"], "crs") &&
738 $ilAccess->checkAccessOfUser($ilUser->getId(), "join", "", $course["ref_id"], "crs"));
739 }
740
741 if (isset($course["objectives"])) {
742 $loc_settings = ilLOSettings::getInstanceByObjId($course["obj_id"]);
743 $has_initial_test = (bool) $loc_settings->getInitialTest();
744
745 foreach ($course["objectives"] as $objtv) {
746 if ($do_links) {
747 $params = array("oobj" => $objtv["id"]);
748 $url = ilLink::_getLink($course["ref_id"], "crs", $params);
749
750 // #15510
751 $url .= "#objtv_acc_" . $objtv["id"];
752
753 if ($this->getOutputMode() !== "print") {
754 $tpl->touchBlock("objective_dnone");
755 }
756
757 $tpl->setCurrentBlock("objective_link_bl");
758
759 $objtv_link = $this->ui_fac->link()->standard(
760 $objtv["title"],
761 $url
762 );
763 if (trim($objtv["desc"] ?? "") !== "") {
764 $desc = nl2br($objtv["desc"]);
765 $objtv_link = $objtv_link->withHelpTopics(...$this->ui_fac->helpTopics($desc));
766 }
767
768 $tpl->setVariable("OBJECTIVE_LINK", $this->ui_ren->render($objtv_link));
769 } else {
770 $tpl->setCurrentBlock("objective_nolink_bl");
771 $tpl->setVariable("OBJECTIVE_NOLINK_TITLE", $objtv["title"]);
772 }
773 $tpl->parseCurrentBlock();
774
775 $objtv_icon = ilObject::_getIcon($objtv["id"], 'big', "lobj");
776 if ($img_path) {
777 $objtv_icon = $img_path . basename($objtv_icon);
778 }
779
780 $tpl->setCurrentBlock("objective_bl");
781 $tpl->setVariable("OBJTV_ICON_URL", $objtv_icon);
782 $tpl->setVariable("OBJTV_ICON_ALT", $this->lng->txt("crs_objectives"));
783
784 if (isset($objtv["type"])) {
785 $tpl->setVariable(
786 "LP_OBJTV_PROGRESS",
788 $has_initial_test,
789 $objtv["id"],
790 $objtv,
791 true,
792 false,
793 self::$initialized
794 )
795 );
796 }
797
798 $tpl->parseCurrentBlock();
799 }
800
801 $tpl->setCurrentBlock("objectives_bl");
802 $tpl->setVariable("OBJTV_LIST_CRS_ID", $course["obj_id"]);
803 $tpl->parseCurrentBlock();
804 }
805
806 // always check against current user
807 if ($do_links) {
808 $tpl->setCurrentBlock("course_link_bl");
809 $tpl->setVariable("COURSE_LINK_TITLE", $course["title"]);
810 $tpl->setVariable("COURSE_LINK_URL", ilLink::_getLink($course["ref_id"]));
811 } else {
812 $tpl->setCurrentBlock("course_nolink_bl");
813 $tpl->setVariable("COURSE_NOLINK_TITLE", $course["title"]);
814 }
815 $tpl->parseCurrentBlock();
816
817 $crs_icon = ilObject::_getIcon($course["obj_id"], 'small', 'crs');
818 if ($img_path) {
819 $crs_icon = $img_path . basename($crs_icon);
820 }
821
822 $tpl->setCurrentBlock("course_bl");
823
824 if (isset($course["objectives"])) {
825 $tpl->setVariable("TOGGLE_CLASS", "ilPCMyCoursesToggle");
826 } else {
827 $tpl->setVariable("NO_TOGGLE", ' style="visibility:hidden;"');
828 }
829
830 $tpl->setVariable("CRS_ICON_URL", $crs_icon);
831 $tpl->setVariable("CRS_ICON_ALT", $this->lng->txt("obj_crs"));
832 $tpl->parseCurrentBlock();
833 }
834
835 // #15508
836 if (!self::$initialized) {
837 $GLOBALS["tpl"]->addJavaScript("assets/js/ilPortfolio.js");
838 $GLOBALS["tpl"]->addOnLoadCode("ilPortfolio.init()");
839 }
840 self::$initialized++;
841
842 return $tpl->get();
843 }
844 return "";
845 }
846
850 protected function getCourseSortAction(ilCtrl $ctrl): string
851 {
852 return $ctrl->getFormActionByClass("ilobjportfoliogui", "preview");
853 }
854
855 protected function getCoursesOfUser(
856 int $a_user_id,
857 bool $a_add_path = false
858 ): array {
859 $tree = $this->tree;
860
861 // see ilPDSelectedItemsBlockGUI
862
863 $items = ilParticipants::_getMembershipByType($a_user_id, ['crs']);
864
865 $repo_title = $tree->getNodeData(ROOT_FOLDER_ID);
866 $repo_title = $repo_title["title"];
867 if ($repo_title == "ILIAS") {
868 $repo_title = $this->lng->txt("repository");
869 }
870
871 $references = $lp_obj_refs = array();
872 foreach ($items as $obj_id) {
874 if (is_array($ref_id) && count($ref_id)) {
875 $ref_id = array_pop($ref_id);
876 if (!$tree->isDeleted($ref_id)) {
877 $visible = false;
878 $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
879 if ($active && $visible) {
880 $references[$ref_id] = array(
881 'ref_id' => $ref_id,
882 'obj_id' => $obj_id,
883 'title' => ilObject::_lookupTitle($obj_id)
884 );
885
886 if ($a_add_path) {
887 $path = array();
888 foreach ($tree->getPathFull($ref_id) as $item) {
889 $path[] = $item["title"];
890 }
891 // top level comes first
892 if (count($path) === 2) {
893 $path[0] = 0;
894 } else {
895 $path[0] = 1;
896 }
897 $references[$ref_id]["path_sort"] = implode("__", $path);
898 array_shift($path);
899 array_pop($path);
900 if (!count($path)) {
901 array_unshift($path, $repo_title);
902 }
903 $references[$ref_id]["path"] = implode(" &rsaquo; ", $path);
904 }
905
906 $lp_obj_refs[$obj_id] = $ref_id;
907 }
908 }
909 }
910 }
911
912 // get lp data for valid courses
913
914 if (count($lp_obj_refs)) {
915 // listing the objectives should NOT depend on any LP status / setting
916 foreach ($lp_obj_refs as $obj_id => $ref_id) {
917 // only if set in DB (default mode is not relevant
919 $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id);
920 }
921 }
922
923 // LP must be active, personal and not anonymized
927 // see ilLPProgressTableGUI
928 $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
929 foreach ($lp_data as $item) {
930 $ref_id = $item["ref_ids"];
931 $references[$ref_id]["lp_status"] = $item["status"];
932 }
933 }
934 }
935
936 return $references;
937 }
938
939 protected function parseObjectives(
940 int $a_obj_id,
941 int $a_user_id
942 ): array {
943 $res = array();
944
945 // we need the collection for the correct order
947 $coll_objtv = $coll_objtv->getItems();
948 if ($coll_objtv) {
949 // #13373
950 $lo_results = $this->parseLOUserResults($a_obj_id, $a_user_id);
951
952 $lo_ass = ilLOTestAssignments::getInstance($a_obj_id);
953
954 $tmp = array();
955
956 foreach ($coll_objtv as $objective_id) {
958 $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
959
960 $tmp[$objective_id] = array(
961 "id" => $objective_id,
962 "title" => $title["title"],
963 "desc" => $title["description"],
964 "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL),
965 "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED)
966 );
967
968 if (array_key_exists($objective_id, $lo_results)) {
969 $lo_result = $lo_results[$objective_id];
970 $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
971 $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"] ?? null;
972 $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"] ?? null;
973 $tmp[$objective_id]["status"] = $lo_result["status"] ?? null;
974 $tmp[$objective_id]["type"] = $lo_result["type"] ?? null;
975 $tmp[$objective_id]["initial"] = $lo_result["initial"] ?? null;
976 }
977 }
978
979 // order
980 foreach ($coll_objtv as $objtv_id) {
981 $res[] = $tmp[$objtv_id];
982 }
983 }
984
985 return $res;
986 }
987
988 // see ilContainerObjectiveGUI::parseLOUserResults()
989 protected function parseLOUserResults(
990 int $a_course_obj_id,
991 int $a_user_id
992 ): array {
993 $res = array();
994 $initial_status = "";
995
996 $lur = new ilLOUserResults($a_course_obj_id, $a_user_id);
997 foreach ($lur->getCourseResultsForUserPresentation() as $objective_id => $types) {
998 // show either initial or qualified for objective
999 if (isset($types[ilLOUserResults::TYPE_INITIAL])) {
1000 $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
1001 }
1002
1003 // qualified test has priority
1004 if (isset($types[ilLOUserResults::TYPE_QUALIFIED])) {
1005 $result = $types[ilLOUserResults::TYPE_QUALIFIED];
1006 $result["type"] = ilLOUserResults::TYPE_QUALIFIED;
1007 $result["initial"] = $types[ilLOUserResults::TYPE_INITIAL] ?? null;
1008 } else {
1009 $result = $types[ilLOUserResults::TYPE_INITIAL];
1010 $result["type"] = ilLOUserResults::TYPE_INITIAL;
1011 }
1012
1013 $result["initial_status"] = $initial_status;
1014
1015 $res[$objective_id] = $result;
1016 }
1017
1018 return $res;
1019 }
1020
1021 public function getExportMaterial(): array
1022 {
1023 return $this->export_material;
1024 }
1025
1026 public function makePlaceHoldersClickable(string $a_html): string
1027 {
1028 $ilCtrl = $this->ctrl;
1029 $lng = $this->lng;
1030 $ilUser = $this->user;
1031
1032 $end = 0;
1033 $start = strpos($a_html, "{{{{{PlaceHolder#");
1034 if (is_int($start)) {
1035 $end = strpos($a_html, "}}}}}", $start);
1036 }
1037 while ($end > 0) {
1038 $param = substr($a_html, $start + 17, $end - $start - 17);
1039 $param = explode("#", $param);
1040
1041 $html = $param[2];
1042 switch ($param[2]) {
1043 case "Text":
1044 $html = $lng->txt("cont_text_placeh");
1045 break;
1046
1047 case "Media":
1048 $html = $lng->txt("cont_media_placeh");
1049 break;
1050
1051 case "Question":
1052 $html = $lng->txt("cont_question_placeh");
1053 break;
1054
1055 case "Verification":
1056 $html = $lng->txt("cont_verification_placeh");
1057 break;
1058 }
1059
1060 // only if not owner
1061 if ($ilUser->getId() === ilObjPortfolio::_lookupOwner($this->portfolio_id)
1062 && $this->getOutputMode() === "presentation") {
1063 switch ($param[2]) {
1064 case "Text":
1065 $ilCtrl->setParameterByClass("ilportfoliopagegui", "prt_id", $this->port_request->getPortfolioId());
1066 $ilCtrl->setParameterByClass("ilportfoliopagegui", "ppage", $this->getId());
1067 $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_pc_id", $param[0]);
1068 $ilCtrl->setParameterByClass("ilportfoliopagegui", "pl_hier_id", $param[1]);
1069 $href = $ilCtrl->getLinkTargetByClass("ilportfoliopagegui", "insertJSAtPlaceholder");
1070 $html = "<a href='" . $href . "'>" . $html . "</a>";
1071 break;
1072
1073 case "Media":
1074 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "prt_id", $this->port_request->getPortfolioId());
1075 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "ppage", $this->getId());
1076 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_pc_id", $param[0]);
1077 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "pl_hier_id", $param[1]);
1078 $ilCtrl->setParameterByClass("ilpcmediaobjectgui", "subCmd", "insertNew");
1079 $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilpcmediaobjectgui"), "insert");
1080 $html = "<a href='" . $href . "'>" . $html . "</a>";
1081 break;
1082
1083 /* see #34170, may need a different change, keep code to monitor
1084 case "Verification":
1085 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "prt_id", $this->port_request->getPortfolioId());
1086 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "ppage", $this->getId());
1087 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "pl_pc_id", $param[0]);
1088 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "pl_hier_id", $param[1]);
1089 $ilCtrl->setParameterByClass("ilPCVerificationGUI", "subCmd", "insertNew");
1090 $href = $ilCtrl->getLinkTargetByClass(array("ilPortfolioPageGUI", "ilPageEditorGUI", "ilPCPlaceHolderGUI", "ilPCVerificationGUI"), "insert");
1091 $html = "<a href='" . $href . "'>" . $html . "</a>";
1092 break;
1093 */
1094 }
1095 }
1096
1097 $h2 = substr($a_html, 0, $start) .
1098 $html .
1099 substr($a_html, $end + 5);
1100 $a_html = $h2;
1101
1102 $start = strpos($a_html, "{{{{{PlaceHolder#", $start + 5);
1103 $end = 0;
1104 if (is_int($start)) {
1105 $end = strpos($a_html, "}}}}}", $start);
1106 }
1107 }
1108 return $a_html;
1109 }
1110
1111 public function getViewPageLink(): string
1112 {
1113 global $DIC;
1114
1115 $ctrl = $DIC->ctrl();
1116
1117 $ctrl->setParameterByClass("ilobjportfoliogui", "user_page", $this->requested_ppage);
1118 return $ctrl->getLinkTargetByClass("ilobjportfoliogui", "preview");
1119 }
1120
1121 public function getViewPageText(): string
1122 {
1123 return $this->lng->txt("preview");
1124 }
1125
1126 public function getPagePermaLink(): string
1127 {
1129 return ilLink::_getStaticLink($pid, "prtf", true, "_" . $this->getId());
1130 }
1131
1133 int $a_id,
1134 ilUserCertificateRepository $userCertificateRepository,
1135 string $url
1136 ): string {
1137 try {
1138 $presentation = $userCertificateRepository->fetchActiveCertificateForPresentation($this->user->getId(), $a_id);
1139 } catch (Exception $e) {
1140 return "";
1141 }
1142 $caption = $this->lng->txt('certificate') . ': ';
1143 $caption .= $this->lng->txt($presentation->getUserCertificate()->getObjType()) . ' ';
1144 $caption .= '"' . $presentation->getObjectTitle() . '"';
1145
1146 return '<div><a href="' . $url . '">' . $caption . '</a></div>';
1147 }
1148
1149 public function getCommentsHTMLExport(): string
1150 {
1151 $notes_gui = new ilCommentGUI(
1152 $this->portfolio_id,
1153 $this->getPageObject()->getId(),
1154 "pfpg"
1155 );
1156 $notes_gui->enablePublicNotes(true);
1157 $notes_gui->setRepositoryMode(false);
1158 $notes_gui->setExportMode();
1159 return $notes_gui->getListHTML();
1160 }
1161
1162 public function finishEditing(): void
1163 {
1164 $this->ctrl->redirectByClass("ilObjPortfolioGUI", "view");
1165 }
1166}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
GUI class for public user profile presentation.
const IL_CAL_DATE
const IL_CAL_UNIX
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
Class ilBlogPosting.
static _getInstance($a_usr_id=0)
get singleton instance
Calendar schedule filter for consultation hour bookings.
static buildObjectiveProgressBar(bool $a_has_initial_test, int $a_objective_id, array $a_lo_result, bool $a_list_mode=false, bool $a_sub=false, ?string $a_tt_suffix=null)
Render progressbar(s) for given objective and result data.
static lookupObjectiveTitle(int $a_objective_id, bool $a_add_description=false)
Class ilCtrl provides processing control methods.
getFormActionByClass( $a_class, ?string $a_fallback_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
Class for single dates.
static getInstanceByObjId(int $a_obj_id)
static getInstance(int $a_container_id)
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
static _isActivated(int $a_obj_id, ?bool &$a_visible_flag=null, bool $a_mind_member_view=true)
GUI class for course verification.
static _lookupViewMode(int $a_id)
GUI class for exercise verification.
GUI class for scorm verification.
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
GUI class for test verification.
parses the objects.xml it handles the xml-description of all ilias objects
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupOwner(int $obj_id)
Lookup owner user ID for object ID.
static _getAllReferences(int $id)
get all reference ids for object ID
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupTitle(int $obj_id)
Class ilPageObjectGUI.
setPresentationTitle(string $a_title="")
setTemplateOutput(bool $a_output=true)
ilGlobalTemplateInterface $tpl
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
Personal skills GUI class.
Portfolio page gui class.
getTabs(string $a_activate="")
renderConsultationHoursTeaser(int $a_user_id, string $a_mode, ?array $a_group_ids=null)
renderVerification(int $a_user_id, string $a_type, int $a_id)
getCourseSortAction(ilCtrl $ctrl)
Get course sort action.
__construct(int $a_portfolio_id, int $a_id=0, int $a_old_nr=0, bool $a_enable_comments=true)
renderProfile(int $a_user_id, string $a_type, ?array $a_fields=null)
postOutputProcessing(string $a_output)
Finalizing output processing.
renderMyCoursesTeaser(int $a_user_id, $a_default_sorting)
renderPageElement(string $a_type, string $a_html)
ilObjectDefinition $obj_definition
renderTeaser(string $a_type, string $a_title, string $a_options="")
renderMyCourses(int $a_user_id, string $a_default_sorting)
makePlaceHoldersClickable(string $a_html)
getCoursesOfUser(int $a_user_id, bool $a_add_path=false)
getPageContentUserId(int $a_user_id)
getAdditional()
Get Additonal Information.
setEmbedded(bool $a_value)
Set embedded mode: will suppress tabs.
setAdditional(array $a_additional)
Set Additonal Information.
renderSkillsTeaser(int $a_user_id, int $a_skills_id)
renderConsultationHours(int $a_user_id, string $a_mode, ?array $a_group_ids=null)
showPage()
display content of page
renderBlogTeaser(int $a_user_id, int $a_blog_id, ?array $a_posting_ids=null)
renderSkills(int $a_user_id, int $a_skills_id)
parseLOUserResults(int $a_course_obj_id, int $a_user_id)
ILIAS Portfolio StandardGUIRequest $port_request
createPersistentCertificateUrl(int $a_id, ilUserCertificateRepository $userCertificateRepository, string $url)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static findPortfolioForPage(int $a_page_id)
Get portfolio id of page id.
ILIAS Setting Class.
A node in the skill tree.
special template class to simplify handling of ITX/PEAR
static getObjectsStatusForUser(int $a_user_id, array $obj_refs)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
isDeleted(int $a_node_id)
This is a wrapper for isSaved() with a more useful name.
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
const ANONYMOUS_USER_ID
Definition: constants.php:27
const ROOT_FOLDER_ID
Definition: constants.php:32
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
$ref_id
Definition: ltiauth.php:66
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
$path
Definition: ltiservices.php:30
$res
Definition: ltiservices.php:69
$post
Definition: ltitoken.php:46
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
try
handle Lrs Init
Definition: xapiproxy.php:86
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68
$GLOBALS["DIC"]
Definition: wac.php:54
$param
Definition: xapitoken.php:46