ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public function __construct()
39  {
40  global $DIC;
41  $this->ctrl = $DIC->ctrl();
42  $this->achievements = new ilAchievements();
43  $this->lng = $DIC->language();
44  $this->tabs = $DIC->tabs();
45  $this->main_tpl = $DIC->ui()->mainTemplate();
46  }
47 
52  public function executeCommand()
53  {
55  $main_tpl = $this->main_tpl;
56  $lng = $this->lng;
57 
58  $next_class = $ctrl->getNextClass($this);
59  $cmd = $ctrl->getCmd("show");
60 
61  $main_tpl->setTitle($lng->txt("pd_achievements"));
62  $main_tpl->setTitleIcon(ilUtil::getImagePath("icon_lhist.svg")); // needs a final decision
63 
64  switch ($next_class) {
65  case "illearningprogressgui":
67  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
69  $ctrl->forwardCommand($new_gui);
70  break;
71 
72  case 'illearninghistorygui':
74  $lhistgui = new ilLearningHistoryGUI();
75  $ctrl->forwardCommand($lhistgui);
76  $this->main_tpl->show();
77  break;
78 
79  case 'ilpersonalskillsgui':
81  include_once './Services/Skill/classes/class.ilPersonalSkillsGUI.php';
82  $skgui = new ilPersonalSkillsGUI();
83  $ctrl->forwardCommand($skgui);
84  $this->main_tpl->show();
85  break;
86 
87  case 'ilbadgeprofilegui':
89  include_once './Services/Badge/classes/class.ilBadgeProfileGUI.php';
90  $bgui = new ilBadgeProfileGUI();
91  $ctrl->forwardCommand($bgui);
92  $this->main_tpl->show();
93  break;
94 
95  case 'ilusercertificategui':
97  $cgui = new ilUserCertificateGUI();
98  $ctrl->forwardCommand($cgui);
99  $this->main_tpl->show();
100  break;
101 
102  default:
103  if (in_array($cmd, array("show"))) {
104  $this->$cmd();
105  }
106  $this->main_tpl->show();
107  break;
108  }
109  }
110 
114  protected function show()
115  {
116  $ctrl = $this->ctrl;
117 
118  $gui_classes = $this->getGUIClasses();
119  $first_service = current($this->achievements->getActiveServices());
120  if ($first_service) {
121  $ctrl->redirectByClass(["ilpersonaldesktopgui", "ilachievementsgui", $gui_classes[$first_service]]);
122  }
123  }
124 
128  protected function setTabs($activate)
129  {
130  $tabs = $this->tabs;
131  $links = $this->getLinks();
132 
133  foreach ($this->achievements->getActiveServices() as $s) {
134  $tabs->addTab("achieve_" . $s, $links[$s]["txt"], $links[$s]["link"]);
135  }
136  $tabs->activateTab("achieve_" . $activate);
137  }
138 
145  protected function getLinks()
146  {
147  $ctrl = $this->ctrl;
148  $lng = $this->lng;
149 
150  $lng->loadLanguageModule("lhist");
151  $gui_classes = $this->getGUIClasses();
152 
153  $links = [
155  "txt" => $lng->txt("lhist_learning_history")
156  ],
158  "txt" => $lng->txt("skills")
159  ],
161  "txt" => $lng->txt("learning_progress")
162  ],
164  "txt" => $lng->txt('obj_bdga')
165  ],
167  "txt" => $lng->txt("obj_cert")
168  ]
169  ];
170 
171  foreach ($links as $k => $v) {
172  $links[$k]["link"] = $ctrl->getLinkTargetByClass(["ilpersonaldesktopgui", "ilachievementsgui", $gui_classes[$k]]);
173  }
174 
175  return $links;
176  }
177 
184  protected function getGUIClasses()
185  {
186  $gui_classes = [
187  ilAchievements::SERV_LEARNING_HISTORY => "ilLearningHistoryGUI",
188  ilAchievements::SERV_COMPETENCES => "ilpersonalskillsgui",
189  ilAchievements::SERV_LEARNING_PROGRESS => "illearningprogressgui",
190  ilAchievements::SERV_BADGES => "ilbadgeprofilegui",
191  ilAchievements::SERV_CERTIFICATES => "ilusercertificategui"
192  ];
193 
194  return $gui_classes;
195  }
196 }
show()
Show (redirects to first active service)
global $DIC
Definition: saml.php:7
getGUIClasses()
Get GUI class.
Learning history main GUI class.
executeCommand()
Execute command.
$s
Definition: pwgen.php:45
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.
$links
Class ilObjUserTrackingGUI.