ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAchievementsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected ilCtrl $ctrl;
28 protected ilLanguage $lng;
29 protected ilTabsGUI $tabs;
31
32 public function __construct()
33 {
34 global $DIC;
35 $this->ctrl = $DIC->ctrl();
36 $this->achievements = new ilAchievements();
37 $this->lng = $DIC->language();
38 $this->tabs = $DIC->tabs();
39 $this->main_tpl = $DIC->ui()->mainTemplate();
40 }
41
42 public function executeCommand(): void
43 {
47
48 $lng->loadLanguageModule('lhist');
49
50 $next_class = $ctrl->getNextClass($this);
51 $cmd = $ctrl->getCmd('show');
52
53
54 switch ($next_class) {
55 case strtolower(ilLearningHistoryGUI::class):
56 $main_tpl->setTitle($lng->txt('lhist_learning_history'));
57 $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_lhist.svg'));
58 $lhistgui = new ilLearningHistoryGUI();
59 $ctrl->forwardCommand($lhistgui);
60 $this->main_tpl->printToStdout();
61 break;
62
63 case strtolower(ilLPPersonalGUI::class):
64 $lng->loadLanguageModule("trac");
65 $main_tpl->setTitle($lng->txt("personal_learning_progress_view_title"));
66 $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_trac.svg'));
67 $main_tpl->setDescription($lng->txt("personal_learning_progress_view_description"));
68 $plp_gui = new ilLPPersonalGUI();
69 $ctrl->forwardCommand($plp_gui);
70 $this->main_tpl->printToStdout();
71 break;
72
73 case strtolower(ilPersonalSkillsGUI::class):
74 $main_tpl->setTitle($lng->txt('skills'));
75 $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_skmg.svg'));
76 $skgui = new ilPersonalSkillsGUI();
77 $ctrl->forwardCommand($skgui);
78 $this->main_tpl->printToStdout();
79 break;
80
81 case strtolower(ilBadgeProfileGUI::class):
82 $main_tpl->setTitle($lng->txt('obj_bdga'));
83 $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_bdga.svg'));
84 $bgui = new ilBadgeProfileGUI();
85 $ctrl->forwardCommand($bgui);
86 $this->main_tpl->printToStdout();
87 break;
88
89 case strtolower(ilUserCertificateGUI::class):
90 $main_tpl->setTitle($lng->txt('obj_cert'));
91 $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_cert.svg'));
92 $cgui = new ilUserCertificateGUI();
93 $ctrl->forwardCommand($cgui);
94 $this->main_tpl->printToStdout();
95 break;
96
97 default:
98 if ($cmd == 'show') {
99 $this->$cmd();
100 }
101 $this->main_tpl->printToStdout();
102 break;
103 }
104 }
105
106 protected function show(): void
107 {
109
110 $gui_classes = $this->getGUIClasses();
111 $first_service = current($this->achievements->getActiveServices());
112 if ($first_service) {
113 $ctrl->redirectByClass([ilDashboardGUI::class, ilAchievementsGUI::class, $gui_classes[$first_service]]);
114 }
115 }
116
117 protected function setTabs(string $activate): void
118 {
120 $links = $this->getLinks();
121
122 foreach ($this->achievements->getActiveServices() as $s) {
123 $tabs->addTab('achieve_' . $s, $links[$s]['txt'], $links[$s]['link']);
124 }
125 $tabs->activateTab('achieve_' . $activate);
126 }
127
131 protected function getLinks(): array
132 {
135
136 $lng->loadLanguageModule('lhist');
137 $gui_classes = $this->getGUIClasses();
138
139 $links = [
141 'txt' => $lng->txt('lhist_learning_history')
142 ],
144 'txt' => $lng->txt('skills')
145 ],
147 'txt' => $lng->txt('learning_progress')
148 ],
150 'txt' => $lng->txt('obj_bdga')
151 ],
153 'txt' => $lng->txt('obj_cert')
154 ]
155 ];
156
157 foreach ($links as $k => $v) {
158 $links[$k]['link'] = $ctrl->getLinkTargetByClass([ilDashboardGUI::class, ilAchievementsGUI::class, $gui_classes[$k]]);
159 }
160
161 return $links;
162 }
163
167 protected function getGUIClasses(): array
168 {
169 return [
170 ilAchievements::SERV_LEARNING_HISTORY => strtolower(ilLearningHistoryGUI::class),
171 ilAchievements::SERV_COMPETENCES => strtolower(ilPersonalSkillsGUI::class),
172 ilAchievements::SERV_LEARNING_PROGRESS => strtolower(ilLearningProgressGUI::class),
173 ilAchievements::SERV_BADGES => strtolower(ilBadgeProfileGUI::class),
174 ilAchievements::SERV_CERTIFICATES => strtolower(ilUserCertificateGUI::class)
175 ];
176 }
177}
@ilCtrl_Calls ilAchievementsGUI: ilPersonalSkillsGUI, ilBadgeProfileGUI, ilLearningHistoryGUI,...
ilGlobalTemplateInterface $main_tpl
Class ilCtrl provides processing control methods.
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
getNextClass($a_gui_class=null)
@inheritDoc
forwardCommand(object $a_gui_object)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
@ilCtrl_IsCalledBy ilLPPersonalGUI: ilDashboardGUI
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Learning history main GUI class.
Personal skills GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
activateTab(string $a_id)
@ilCtrl_IsCalledBy ilUserCertificateGUI: ilAchievementsGUI
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setDescription(string $a_descr)
Sets description below title in standard template.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
global $DIC
Definition: shib_login.php:26