1<?php 2 3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5/** 6 * Menu / Tabs renderer 7 * 8 * @author killing@leifos.de 9 */ 10class ilLMMenuRendererGUI 11{ 12 /** 13 * @var ilAccessHandler 14 */ 15 protected $access; 16 17 /** 18 * @var ilObjUser 19 */ 20 protected $user; 21 22 /** 23 * @var int 24 */ 25 protected $current_page; 26 27 /** 28 * @var ilObjLearningModule 29 */ 30 protected $lm; 31 32 /** 33 * @var bool 34 */ 35 protected $offline; 36 37 /** 38 * @var ilCtrl 39 */ 40 protected $ctrl; 41 42 43 /** 44 * @var string 45 */ 46 protected $lang; 47 48 /** 49 * @var string 50 */ 51 protected $active_tab; 52 53 /** 54 * @var string 55 */ 56 protected $export_format; 57 58 /** 59 * @var ilTabsGUI 60 */ 61 protected $tabs; 62 63 /** 64 * @var ilLMMenuEditor 65 */ 66 protected $menu_editor; 67 68 /** 69 * Constructor 70 */ 71 public function __construct( 72 ilTabsGUI $tabs, 73 int $current_page, 74 string $active_tab, 75 string $export_format, 76 bool $export_all, 77 ilObjLearningModule $lm, 78 bool $offline, 79 ilLMMenuEditor $menu_editor, 80 string $lang, 81 ilCtrl $ctrl, 82 ilAccessHandler $access, 83 ilObjUser $user, 84 ilLanguage $lng 85 ) { 86 $this->active_tab = $active_tab; 87 $this->export_format = $export_format; 88 $this->export_all = $export_all; 89 $this->tabs = $tabs; 90 $this->menu_editor = $menu_editor; 91 $this->lng = $lng; 92 93 $this->access = $access; 94 $this->user = $user; 95 $this->ctrl = $ctrl; 96 $this->lang = $lang; 97 $this->current_page = $current_page; 98 $this->lm = $lm; 99 $this->offline = $offline; 100 101 $this->requested_obj_id = (int) $_GET["obj_id"]; 102 $this->requested_ref_id = (int) $_GET["ref_id"]; 103 } 104 105 /** 106 * Render 107 * 108 * @return string 109 */ 110 public function render() 111 { 112 $ilCtrl = $this->ctrl; 113 $ilUser = $this->user; 114 $ilAccess = $this->access; 115 $ilTabs = $this->tabs; 116 117 $addcmd = "addTarget"; 118 $getcmd = "getHTML"; 119 120 //$ilHelp->setScreenIdComponent("lm"); 121 122 $active[$this->active_tab] = true; 123 124 if (!$this->lm->isActiveLMMenu()) { 125 return ""; 126 } 127 128 $tabs_gui = $ilTabs; 129 130 // workaround for preventing tooltips in export 131 if ($this->offline) { 132 $tabs_gui->setSetupMode(true); 133 } 134 135 // Determine whether the view of a learning resource should 136 // be shown in the frameset of ilias, or in a separate window. 137 //$showViewInFrameset = true; 138 139 140 // content 141 if (!$this->offline && $ilAccess->checkAccess("read", "", $this->requested_ref_id)) { 142 $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id); 143 $tabs_gui->$addcmd( 144 "content", 145 $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"), 146 "", 147 "", 148 "", 149 $active["content"] 150 ); 151 /* 152 if ($active["content"]) 153 { 154 $ilHelp->setScreenId("content"); 155 $ilHelp->setSubScreenId("content"); 156 }*/ 157 } elseif ($this->offline) { 158 $tabs_gui->setForcePresentationOfSingleTab(true); 159 } 160 161 // table of contents 162 /* 163 if($this->lm->isActiveTOC() && $ilAccess->checkAccess("read", "", $this->requested_ref_id)) 164 { 165 if (!$this->offline) 166 { 167 $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id); 168 $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showTableOfContents"); 169 } 170 else 171 { 172 if ($this->export_all) 173 { 174 $link = "./table_of_contents_".$this->lang.".html"; 175 } 176 else 177 { 178 $link = "./table_of_contents.html"; 179 } 180 } 181 $tabs_gui->$addcmd("cont_toc", $link, 182 "", "", "", $active["toc"]); 183 }*/ 184 185 // print view 186 if ($this->lm->isActivePrintView() && $ilAccess->checkAccess("read", "", $this->requested_ref_id)) { 187 if (!$this->offline) { // has to be implemented for offline mode 188 $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id); 189 $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showPrintViewSelection"); 190 $tabs_gui->$addcmd( 191 "cont_print_view", 192 $link, 193 "", 194 "", 195 "", 196 $active["print"] 197 ); 198 } 199 } 200 201 // download 202 if ($ilUser->getId() == ANONYMOUS_USER_ID) { 203 $is_public = $this->lm->isActiveDownloadsPublic(); 204 } else { 205 $is_public = true; 206 } 207 208 if ($this->lm->isActiveDownloads() && !$this->offline && $is_public && 209 $ilAccess->checkAccess("read", "", $this->requested_ref_id)) { 210 $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id); 211 $link = $ilCtrl->getLinkTargetByClass("illmpresentationgui", "showDownloadList"); 212 $tabs_gui->$addcmd( 213 "download", 214 $link, 215 "", 216 "", 217 "", 218 $active["download"] 219 ); 220 } 221 222 // info button 223 if ($this->export_format != "scorm" && !$this->offline) { 224 if (!$this->offline) { 225 $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id); 226 $link = $this->ctrl->getLinkTargetByClass( 227 array("illmpresentationgui", "ilinfoscreengui"), 228 "showSummary" 229 ); 230 } else { 231 $link = "./info.html"; 232 } 233 234 $tabs_gui->$addcmd( 235 'info_short', 236 $link, 237 "", 238 "", 239 "", 240 $active["info"] 241 ); 242 } 243 244 if (!$this->offline && 245 $ilAccess->checkAccess("read", "", $this->requested_ref_id) && // #14075 246 ilLearningProgressAccess::checkAccess($this->requested_ref_id)) { 247 $olp = ilObjectLP::getInstance($this->lm->getId()); 248 if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL) { 249 $tabs_gui->$addcmd( 250 "learning_progress", 251 $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "editManual"), 252 "", 253 "", 254 "", 255 $active["learning_progress"] 256 ); 257 } elseif ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) { 258 $tabs_gui->$addcmd( 259 "learning_progress", 260 $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "showtlt"), 261 "", 262 "", 263 "", 264 $active["learning_progress"] 265 ); 266 } 267 } 268 269 // get user defined menu entries 270 $entries = $this->menu_editor->getMenuEntries(true); 271 if (count($entries) > 0 && $ilAccess->checkAccess("read", "", $this->requested_ref_id)) { 272 foreach ($entries as $entry) { 273 // build goto-link for internal resources 274 if ($entry["type"] == "intern") { 275 $entry["link"] = ILIAS_HTTP_PATH . "/goto.php?target=" . $entry["link"]; 276 } 277 278 // add http:// prefix if not exist 279 if (!strstr($entry["link"], '://') && !strstr($entry["link"], 'mailto:')) { 280 $entry["link"] = "http://" . $entry["link"]; 281 } 282 283 if (!strstr($entry["link"], 'mailto:')) { 284 $entry["link"] = ilUtil::appendUrlParameterString($entry["link"], "ref_id=" . 285 $this->requested_ref_id . "&structure_id=" . $this->requested_obj_id); 286 } 287 $tabs_gui->$addcmd( 288 $entry["title"], 289 $entry["link"], 290 "", 291 "", 292 "_blank", 293 "", 294 true 295 ); 296 } 297 } 298 299 // edit learning module 300 if (!$this->offline) { 301 if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) { 302 if ($this->current_page <= 0) { 303 $link = $this->ctrl->getLinkTargetByClass(["ilLMEditorGUI", "ilobjlearningmodulegui"], "chapters"); 304 } else { 305 $link = ILIAS_HTTP_PATH . "/ilias.php?baseClass=ilLMEditorGUI&ref_id=" . $this->requested_ref_id . 306 "&obj_id=" . $this->current_page . "&to_page=1"; 307 } 308 $tabs_gui->addNonTabbedLink( 309 "edit_page", 310 $this->lng->txt("lm_editing_view"), 311 $link 312 ); 313 } 314 } 315 316 // user interface hook [uihk] 317 /* 318 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk"); 319 $plugin_html = false; 320 foreach ($pl_names as $pl) 321 { 322 $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl); 323 $gui_class = $ui_plugin->getUIClassInstance(); 324 $resp = $gui_class->modifyGUI("Modules/LearningModule", "lm_menu_tabs", 325 array("lm_menu_tabs" => $tabs_gui)); 326 }*/ 327 328 return $tabs_gui->$getcmd(); 329 } 330} 331