ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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  include_once './Services/Skill/classes/class.ilPersonalSkillsGUI.php';
90  $skgui = new ilPersonalSkillsGUI();
91  $ctrl->forwardCommand($skgui);
92  $this->main_tpl->printToStdout();
93  break;
94 
95  case 'ilbadgeprofilegui':
96  $main_tpl->setTitle($lng->txt("obj_bdga"));
97  $main_tpl->setTitleIcon(ilUtil::getImagePath("icon_bdga.svg"));
98  include_once './Services/Badge/classes/class.ilBadgeProfileGUI.php';
99  $bgui = new ilBadgeProfileGUI();
100  $ctrl->forwardCommand($bgui);
101  $this->main_tpl->printToStdout();
102  break;
103 
104  case 'ilusercertificategui':
105  $main_tpl->setTitle($lng->txt("obj_cert"));
106  $main_tpl->setTitleIcon(ilUtil::getImagePath("icon_cert.svg"));
107  $cgui = new ilUserCertificateGUI();
108  $ctrl->forwardCommand($cgui);
109  $this->main_tpl->printToStdout();
110  break;
111 
112  default:
113  if (in_array($cmd, array("show"))) {
114  $this->$cmd();
115  }
116  $this->main_tpl->printToStdout();
117  break;
118  }
119  }
120 
124  protected function show()
125  {
126  $ctrl = $this->ctrl;
127 
128  $gui_classes = $this->getGUIClasses();
129  $first_service = current($this->achievements->getActiveServices());
130  if ($first_service) {
131  $ctrl->redirectByClass(["ildashboardgui", "ilachievementsgui", $gui_classes[$first_service]]);
132  }
133  }
134 
138  protected function setTabs($activate)
139  {
140  $tabs = $this->tabs;
141  $links = $this->getLinks();
142 
143  foreach ($this->achievements->getActiveServices() as $s) {
144  $tabs->addTab("achieve_" . $s, $links[$s]["txt"], $links[$s]["link"]);
145  }
146  $tabs->activateTab("achieve_" . $activate);
147  }
148 
155  protected function getLinks()
156  {
157  $ctrl = $this->ctrl;
158  $lng = $this->lng;
159 
160  $lng->loadLanguageModule("lhist");
161  $gui_classes = $this->getGUIClasses();
162 
163  $links = [
165  "txt" => $lng->txt("lhist_learning_history")
166  ],
168  "txt" => $lng->txt("skills")
169  ],
171  "txt" => $lng->txt("learning_progress")
172  ],
174  "txt" => $lng->txt('obj_bdga')
175  ],
177  "txt" => $lng->txt("obj_cert")
178  ]
179  ];
180 
181  foreach ($links as $k => $v) {
182  $links[$k]["link"] = $ctrl->getLinkTargetByClass(["ildashboardgui", "ilachievementsgui", $gui_classes[$k]]);
183  }
184 
185  return $links;
186  }
187 
194  protected function getGUIClasses()
195  {
196  $gui_classes = [
197  ilAchievements::SERV_LEARNING_HISTORY => "ilLearningHistoryGUI",
198  ilAchievements::SERV_COMPETENCES => "ilpersonalskillsgui",
199  ilAchievements::SERV_LEARNING_PROGRESS => "illearningprogressgui",
200  ilAchievements::SERV_BADGES => "ilbadgeprofilegui",
201  ilAchievements::SERV_CERTIFICATES => "ilusercertificategui"
202  ];
203 
204  return $gui_classes;
205  }
206 }
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.
Class ilBadgeProfileGUI.
$DIC
Definition: xapitoken.php:46
Class ilObjUserTrackingGUI.