ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilAchievementsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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  {
44  $ctrl = $this->ctrl;
45  $main_tpl = $this->main_tpl;
46  $lng = $this->lng;
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(ilLearningProgressGUI::class):
56  $main_tpl->setTitle($lng->txt('learning_progress'));
57  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_trac.svg'));
59  $ctrl->forwardCommand($new_gui);
60  break;
61 
62  case strtolower(ilLearningHistoryGUI::class):
63  $main_tpl->setTitle($lng->txt('lhist_learning_history'));
64  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_lhist.svg'));
65  $lhistgui = new ilLearningHistoryGUI();
66  $ctrl->forwardCommand($lhistgui);
67  $this->main_tpl->printToStdout();
68  break;
69 
70  case strtolower(ilPersonalSkillsGUI::class):
71  $main_tpl->setTitle($lng->txt('skills'));
72  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_skmg.svg'));
73  $skgui = new ilPersonalSkillsGUI();
74  $ctrl->forwardCommand($skgui);
75  $this->main_tpl->printToStdout();
76  break;
77 
78  case strtolower(ilBadgeProfileGUI::class):
79  $main_tpl->setTitle($lng->txt('obj_bdga'));
80  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_bdga.svg'));
81  $bgui = new ilBadgeProfileGUI();
82  $ctrl->forwardCommand($bgui);
83  $this->main_tpl->printToStdout();
84  break;
85 
86  case strtolower(ilUserCertificateGUI::class):
87  $main_tpl->setTitle($lng->txt('obj_cert'));
88  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_cert.svg'));
89  $cgui = new ilUserCertificateGUI();
90  $ctrl->forwardCommand($cgui);
91  $this->main_tpl->printToStdout();
92  break;
93 
94  default:
95  if ($cmd == 'show') {
96  $this->$cmd();
97  }
98  $this->main_tpl->printToStdout();
99  break;
100  }
101  }
102 
103  protected function show(): void
104  {
105  $ctrl = $this->ctrl;
106 
107  $gui_classes = $this->getGUIClasses();
108  $first_service = current($this->achievements->getActiveServices());
109  if ($first_service) {
110  $ctrl->redirectByClass([ilDashboardGUI::class, ilAchievementsGUI::class, $gui_classes[$first_service]]);
111  }
112  }
113 
114  protected function setTabs(string $activate): void
115  {
116  $tabs = $this->tabs;
117  $links = $this->getLinks();
118 
119  foreach ($this->achievements->getActiveServices() as $s) {
120  $tabs->addTab('achieve_' . $s, $links[$s]['txt'], $links[$s]['link']);
121  }
122  $tabs->activateTab('achieve_' . $activate);
123  }
124 
128  protected function getLinks(): array
129  {
130  $ctrl = $this->ctrl;
131  $lng = $this->lng;
132 
133  $lng->loadLanguageModule('lhist');
134  $gui_classes = $this->getGUIClasses();
135 
136  $links = [
138  'txt' => $lng->txt('lhist_learning_history')
139  ],
141  'txt' => $lng->txt('skills')
142  ],
144  'txt' => $lng->txt('learning_progress')
145  ],
147  'txt' => $lng->txt('obj_bdga')
148  ],
150  'txt' => $lng->txt('obj_cert')
151  ]
152  ];
153 
154  foreach ($links as $k => $v) {
155  $links[$k]['link'] = $ctrl->getLinkTargetByClass([ilDashboardGUI::class, ilAchievementsGUI::class, $gui_classes[$k]]);
156  }
157 
158  return $links;
159  }
160 
164  protected function getGUIClasses(): array
165  {
166  return [
167  ilAchievements::SERV_LEARNING_HISTORY => strtolower(ilLearningHistoryGUI::class),
168  ilAchievements::SERV_COMPETENCES => strtolower(ilPersonalSkillsGUI::class),
169  ilAchievements::SERV_LEARNING_PROGRESS => strtolower(ilLearningProgressGUI::class),
170  ilAchievements::SERV_BADGES => strtolower(ilBadgeProfileGUI::class),
171  ilAchievements::SERV_CERTIFICATES => strtolower(ilUserCertificateGUI::class)
172  ];
173  }
174 }
ilUserCertificateGUI: ilAchievementsGUI
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
getCmd(string $fallback_command=null)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
loadLanguageModule(string $a_module)
Load language module.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
forwardCommand(object $a_gui_object)
global $DIC
Definition: feed.php:28
Personal skills GUI class.
ilGlobalTemplateInterface $main_tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getNextClass($a_gui_class=null)
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
Class ilBadgeProfileGUI.
activateTab(string $a_id)
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.