ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLMMenuRendererGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
15  protected $access;
16 
20  protected $user;
21 
25  protected $current_page;
26 
30  protected $lm;
31 
35  protected $offline;
36 
40  protected $ctrl;
41 
42 
46  protected $lang;
47 
51  protected $active_tab;
52 
56  protected $export_format;
57 
61  protected $tabs;
62 
66  protected $toolbar;
67 
71  protected $menu_editor;
72 
76  protected $lm_pres_service;
77 
81  protected $main_tpl;
82 
86  protected $ui_factory;
87 
92 
96  public function __construct(
100  int $current_page,
101  string $active_tab,
102  string $export_format,
103  bool $export_all,
105  bool $offline,
107  string $lang,
108  ilCtrl $ctrl,
112  $main_tpl,
114  ) {
116  global $DIC;
117 
118  $this->ui_factory = $DIC->ui()->factory();
119  $this->active_tab = $active_tab;
120  $this->export_format = $export_format;
121  $this->export_all = $export_all;
122  $this->tabs = $tabs;
123  $this->menu_editor = $menu_editor;
124  $this->lng = $lng;
125  $this->lm_pres_service = $lm_pres_service;
126  $this->toolbar = $toolbar;
127  $this->main_tpl = $main_tpl;
128 
129  $this->additional_content_collector = $additional_content_collector;
130 
131  $this->access = $access;
132  $this->user = $user;
133  $this->ctrl = $ctrl;
134  $this->lang = $lang;
135  $this->current_page = $current_page;
136  $this->lm = $lm;
137  $this->offline = $offline;
138 
139  $this->requested_obj_id = (int) $_GET["obj_id"];
140  $this->requested_ref_id = (int) $_GET["ref_id"];
141  }
142 
148  public function render()
149  {
150  $ilCtrl = $this->ctrl;
151  $ilAccess = $this->access;
152  $ilTabs = $this->tabs;
153 
154  $getcmd = "getHTML";
155 
156  $active[$this->active_tab] = true;
157 
158  if (!$this->lm->isActiveLMMenu()) {
159  return "";
160  }
161 
162  $tabs_gui = $ilTabs;
163 
164  // workaround for preventing tooltips in export
165  if ($this->offline) {
166  $tabs_gui->setSetupMode(true);
167  }
168 
169  // content
170  if (!$this->offline && $ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
171  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id);
172  if (!$active["content"]) {
173  $this->toolbar->addComponent(
174  $this->ui_factory->button()->standard($this->lng->txt("content"), $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"))
175  );
176  }
177  } elseif ($this->offline) {
178  $tabs_gui->setForcePresentationOfSingleTab(true);
179  }
180 
181  if (!$active["content"]) {
182  return;
183  }
184 
185  // info button
186  if ($this->export_format != "scorm" && !$this->offline) {
187  if (!$this->offline) {
188  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id);
189  $link = $this->ctrl->getLinkTargetByClass(
190  array("illmpresentationgui", "ilinfoscreengui"),
191  "showSummary"
192  );
193  } else {
194  $link = "./info.html";
195  }
196  $this->toolbar->addComponent(
197  $this->ui_factory->button()->standard($this->lng->txt("info_short"), $link)
198  );
199  }
200 
201  if (!$this->offline &&
202  $ilAccess->checkAccess("read", "", $this->requested_ref_id) && // #14075
203  ilLearningProgressAccess::checkAccess($this->requested_ref_id)) {
204 
205  $olp = ilObjectLP::getInstance($this->lm->getId());
206 
207  if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL) {
208  $this->toolbar->addComponent(
209  $this->ui_factory->button()->standard($this->lng->txt("learning_progress"),
210  $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "editManual"))
211  );
212 
213  } elseif ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
214  $this->toolbar->addComponent(
215  $this->ui_factory->button()->standard($this->lng->txt("learning_progress"),
216  $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "showtlt")
217  ));
218  }
219  }
220 
221  // default entries (appearing in lsq and native mode)
222  $menu = new \ILIAS\LearningModule\Menu\ilLMMenuGUI($this->lm_pres_service);
223  foreach ($menu->getEntries() as $entry) {
224  if (is_object($entry["signal"])) {
225  $this->toolbar->addComponent(
226  $this->ui_factory->button()->standard($entry["label"], '')
227  ->withOnClick($entry["signal"]));
228  }
229  if (is_object($entry["modal"])) {
230  ($this->additional_content_collector)($entry["modal"]);
231  }
232  if ($entry["on_load"] != "") {
233  $this->main_tpl->addOnLoadCode($entry["on_load"]);
234  }
235  }
236 
237  // edit learning module
238  if (!$this->offline) {
239  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
240  if ($this->current_page <= 0) {
241  $link = $this->ctrl->getLinkTargetByClass(["ilLMEditorGUI", "ilobjlearningmodulegui"], "chapters");
242  } else {
243  $link = ILIAS_HTTP_PATH . "/ilias.php?baseClass=ilLMEditorGUI&ref_id=" . $this->requested_ref_id .
244  "&obj_id=" . $this->current_page . "&to_page=1";
245  }
246  $this->toolbar->addComponent(
247  $this->ui_factory->button()->standard($this->lng->txt("edit_page"),
248  $link
249  ));
250 
251  }
252  }
253 
254  return $tabs_gui->$getcmd();
255  }
256 }
This class provides processing control methods.
Class ilObjLearningModule.
Tabs GUI.
$_GET["client_id"]
Menu / Tabs renderer.
user()
Definition: user.php:4
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
$lng
global $DIC
Definition: goto.php:24
class for editing lm menu
__construct(Container $dic, ilPlugin $plugin)
static getInstance($a_obj_id)
Main service init and factory.