ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilLMMenuRendererGUI.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  protected ilLanguage $lng;
27  protected bool $export_all;
28  protected int $requested_ref_id;
29  protected int $requested_obj_id;
31  protected ilObjUser $user;
32  protected int $current_page;
34  protected bool $offline;
35  protected ilCtrl $ctrl;
36  protected string $lang;
37  protected string $active_tab;
38  protected string $export_format;
39  protected ilTabsGUI $tabs;
44  protected \ILIAS\UI\Factory $ui_factory;
46 
47  public function __construct(
48  \ilLMPresentationService $lm_pres_service,
49  ilTabsGUI $tabs,
50  ilToolbarGUI $toolbar,
51  int $current_page,
52  string $active_tab,
53  string $export_format,
54  bool $export_all,
56  bool $offline,
57  ilLMMenuEditor $menu_editor,
58  string $lang,
59  ilCtrl $ctrl,
60  ilAccessHandler $access,
61  ilObjUser $user,
62  ilLanguage $lng,
63  ilGlobalTemplateInterface $main_tpl,
64  Closure $additional_content_collector
65  ) {
67  global $DIC;
68 
69  $this->ui_factory = $DIC->ui()->factory();
70  $this->active_tab = $active_tab;
71  $this->export_format = $export_format;
72  $this->export_all = $export_all;
73  $this->tabs = $tabs;
74  $this->menu_editor = $menu_editor;
75  $this->lng = $lng;
76  $this->lm_pres_service = $lm_pres_service;
77  $this->toolbar = $toolbar;
78  $this->main_tpl = $main_tpl;
79  $this->additional_content_collector = $additional_content_collector;
80  $this->access = $access;
81  $this->user = $user;
82  $this->ctrl = $ctrl;
83  $this->lang = $lang;
84  $this->current_page = $current_page;
85  $this->lm = $lm;
86  $this->offline = $offline;
87  $request = $lm_pres_service->getRequest();
88  $this->requested_obj_id = $request->getObjId();
89  $this->requested_ref_id = $request->getRefId();
90  $this->lng->loadLanguageModule("lm");
91  }
92 
93  public function render(): string
94  {
95  $ilCtrl = $this->ctrl;
96  $ilAccess = $this->access;
97  $ilTabs = $this->tabs;
98  $actions = [];
99 
100  $getcmd = "getHTML";
101 
102  $content_active = ($this->active_tab === "content");
103 
104  if (!$this->lm->isActiveLMMenu()) {
105  return "";
106  }
107 
108  $tabs_gui = $ilTabs;
109 
110  // workaround for preventing tooltips in export
111  if ($this->offline) {
112  $tabs_gui->setSetupMode(true);
113  }
114 
115  // content
116  if (!$this->offline && $ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
117  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id);
118  if (!$content_active) {
119  $this->toolbar->addStickyItem(
120  $this->ui_factory->button()->standard($this->lng->txt("content"), $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"))
121  );
122  }
123  } elseif ($this->offline) {
124  $tabs_gui->setForcePresentationOfSingleTab(true);
125  }
126 
127  if (!$content_active) {
128  return "";
129  }
130 
131  // info button
132  if ($this->lm->isInfoEnabled()) {
133  if (!$this->offline) {
134  $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id);
135  $link = $this->ctrl->getLinkTargetByClass(
136  array("illmpresentationgui", "ilinfoscreengui"),
137  "showSummary"
138  );
139  /*
140  $this->toolbar->addComponent(
141  $this->ui_factory->button()->standard($this->lng->txt("info_short"), $link)
142  );*/
143  $actions[] =
144  $this->ui_factory->button()->shy($this->lng->txt("info_short"), $link);
145  }
146  }
147  if (!$this->offline &&
148  $ilAccess->checkAccess("read", "", $this->requested_ref_id) && // #14075
149  ilLearningProgressAccess::checkAccess($this->requested_ref_id)) {
150  $olp = ilObjectLP::getInstance($this->lm->getId());
151  if ($olp->getCurrentMode() !== ilLPObjSettings::LP_MODE_COLLECTION_MANUAL) {
152  $this->toolbar->addComponent(
153  $this->ui_factory->button()->standard(
154  $this->lng->txt("learning_progress"),
155  $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "")
156  )
157  );
158  } else {
159  $this->toolbar->addComponent(
160  $this->ui_factory->button()->standard(
161  $this->lng->txt("learning_progress"),
162  $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "editManual")
163  )
164  );
165  } /* elseif ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
166  $this->toolbar->addComponent(
167  $this->ui_factory->button()->standard(
168  $this->lng->txt("learning_progress"),
169  $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "showtlt")
170  )
171  );
172  }*/
173  }
174 
175  // default entries (appearing in lsq and native mode)
176  $menu = new \ILIAS\LearningModule\Menu\ilLMMenuGUI($this->lm_pres_service);
177  foreach ($menu->getEntries() as $entry) {
178  if (is_object($entry["signal"])) {
179  if ($this->lm_pres_service->getPresentationStatus()->getEmbedMode()) {
180  $this->toolbar->addComponent(
181  $this->ui_factory->button()->standard($entry["label"], '')
182  ->withOnClick($entry["signal"])
183  );
184  } else {
185  $actions[] = $this->ui_factory->button()->shy($entry["label"], '')
186  ->withOnClick($entry["signal"]);
187  }
188  }
189  if (is_object($entry["modal"])) {
190  ($this->additional_content_collector)($entry["modal"]);
191  }
192  if ($entry["on_load"] != "") {
193  $this->main_tpl->addOnLoadCode($entry["on_load"]);
194  }
195  }
196 
197  // edit learning module
198  if (!$this->offline) {
199  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
200 
201  if ($this->current_page > 0) {
202  $actions[] = $this->ui_factory->button()->shy(
203  $this->lng->txt("edit_page"),
204  ILIAS_HTTP_PATH . "/ilias.php?baseClass=ilLMEditorGUI&ref_id=" . $this->requested_ref_id .
205  "&obj_id=" . $this->current_page . "&to_page=1"
206  );
207  }
208  $actions[] = $this->ui_factory->button()->shy(
209  $this->lng->txt("lm_edit_chapters"),
210  $this->ctrl->getLinkTargetByClass(["ilLMEditorGUI", "ilobjlearningmodulegui"], "chapters")
211  );
212  $actions[] = $this->ui_factory->button()->shy(
213  $this->lng->txt("lm_edit_lm_settings"),
214  $this->ctrl->getLinkTargetByClass(["ilLMEditorGUI", "ilobjlearningmodulegui"], "properties")
215  );
216  }
217  }
218  if (count($actions) > 0) {
219  $this->toolbar->addStickyItem(
220  $this->ui_factory->dropdown()->standard($actions)
221  );
222  }
223 
224  return $tabs_gui->$getcmd();
225  }
226 }
ilGlobalTemplateInterface $main_tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
global $DIC
Definition: shib_login.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSetupMode(bool $a_val)
__construct(Container $dic, ilPlugin $plugin)
ilLMPresentationService $lm_pres_service
static getInstance(int $obj_id)
Main service init and factory.