ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAchievementsGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
14 {
18  protected $ctrl;
19 
23  protected $achievements;
24 
28  protected $lng;
29 
33  protected $tabs;
34 
38  private $main_tpl;
39 
43  public function __construct()
44  {
45  global $DIC;
46  $this->ctrl = $DIC->ctrl();
47  $this->achievements = new ilAchievements();
48  $this->lng = $DIC->language();
49  $this->tabs = $DIC->tabs();
50  $this->main_tpl = $DIC->ui()->mainTemplate();
51  }
52 
57  public function executeCommand()
58  {
61  $lng = $this->lng;
62 
63  $lng->loadLanguageModule("lhist");
64 
65  $next_class = $ctrl->getNextClass($this);
66  $cmd = $ctrl->getCmd("show");
67 
68 
69  switch ($next_class) {
70  case "illearningprogressgui":
71  $main_tpl->setTitle($lng->txt("learning_progress"));
72  $main_tpl->setTitleIcon(ilUtil::getImagePath("icon_trac.svg"));
73  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
75  $ctrl->forwardCommand($new_gui);
76  break;
77 
78  case 'illearninghistorygui':
79  $main_tpl->setTitle($lng->txt("lhist_learning_history"));
80  $main_tpl->setTitleIcon(ilUtil::getImagePath("icon_lhist.svg"));
81  $lhistgui = new ilLearningHistoryGUI();
82  $ctrl->forwardCommand($lhistgui);
83  $this->main_tpl->printToStdout();
84  break;
85 
86  case 'ilpersonalskillsgui':
87  $main_tpl->setTitle($lng->txt("skills"));
88  $main_tpl->setTitleIcon(ilUtil::getImagePath("icon_skmg.svg"));
89  $skgui = new ilPersonalSkillsGUI();
90  $ctrl->forwardCommand($skgui);
91  $this->main_tpl->printToStdout();
92  break;
93 
94  case 'ilbadgeprofilegui':
95  $main_tpl->setTitle($lng->txt("obj_bdga"));
96  $main_tpl->setTitleIcon(ilUtil::getImagePath("icon_bdga.svg"));
97  include_once './Services/Badge/classes/class.ilBadgeProfileGUI.php';
98  $bgui = new ilBadgeProfileGUI();
99  $ctrl->forwardCommand($bgui);
100  $this->main_tpl->printToStdout();
101  break;
102 
103  case 'ilusercertificategui':
104  $main_tpl->setTitle($lng->txt("obj_cert"));
105  $main_tpl->setTitleIcon(ilUtil::getImagePath("icon_cert.svg"));
106  $cgui = new ilUserCertificateGUI();
107  $ctrl->forwardCommand($cgui);
108  $this->main_tpl->printToStdout();
109  break;
110 
111  default:
112  if (in_array($cmd, array("show"))) {
113  $this->$cmd();
114  }
115  $this->main_tpl->printToStdout();
116  break;
117  }
118  }
119 
123  protected function show()
124  {
125  $ctrl = $this->ctrl;
126 
127  $gui_classes = $this->getGUIClasses();
128  $first_service = current($this->achievements->getActiveServices());
129  if ($first_service) {
130  $ctrl->redirectByClass(["ildashboardgui", "ilachievementsgui", $gui_classes[$first_service]]);
131  }
132  }
133 
137  protected function setTabs($activate)
138  {
139  $tabs = $this->tabs;
140  $links = $this->getLinks();
141 
142  foreach ($this->achievements->getActiveServices() as $s) {
143  $tabs->addTab("achieve_" . $s, $links[$s]["txt"], $links[$s]["link"]);
144  }
145  $tabs->activateTab("achieve_" . $activate);
146  }
147 
154  protected function getLinks()
155  {
156  $ctrl = $this->ctrl;
157  $lng = $this->lng;
158 
159  $lng->loadLanguageModule("lhist");
160  $gui_classes = $this->getGUIClasses();
161 
162  $links = [
164  "txt" => $lng->txt("lhist_learning_history")
165  ],
167  "txt" => $lng->txt("skills")
168  ],
170  "txt" => $lng->txt("learning_progress")
171  ],
173  "txt" => $lng->txt('obj_bdga')
174  ],
176  "txt" => $lng->txt("obj_cert")
177  ]
178  ];
179 
180  foreach ($links as $k => $v) {
181  $links[$k]["link"] = $ctrl->getLinkTargetByClass(["ildashboardgui", "ilachievementsgui", $gui_classes[$k]]);
182  }
183 
184  return $links;
185  }
186 
193  protected function getGUIClasses()
194  {
195  $gui_classes = [
196  ilAchievements::SERV_LEARNING_HISTORY => "ilLearningHistoryGUI",
197  ilAchievements::SERV_COMPETENCES => "ilpersonalskillsgui",
198  ilAchievements::SERV_LEARNING_PROGRESS => "illearningprogressgui",
199  ilAchievements::SERV_BADGES => "ilbadgeprofilegui",
200  ilAchievements::SERV_CERTIFICATES => "ilusercertificategui"
201  ];
202 
203  return $gui_classes;
204  }
205 }
show()
Show (redirects to first active service)
getGUIClasses()
Get GUI class.
executeCommand()
Execute command.
Personal skills GUI class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Maybe a separate service in the future.
setTabs($activate)
Set tabs.
global $DIC
Definition: goto.php:24
Class ilBadgeProfileGUI.
Class ilObjUserTrackingGUI.