1<?php 2 3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5 6/** 7* User Interface class for file based learning modules (HTML) 8* 9* @author Alex Killing <alex.killing@gmx.de> 10* 11* $Id$ 12* 13* @ilCtrl_Calls ilObjFileBasedLMGUI: ilFileSystemGUI, ilObjectMetaDataGUI, ilPermissionGUI, ilLearningProgressGUI, ilInfoScreenGUI 14* @ilCtrl_Calls ilObjFileBasedLMGUI: ilCommonActionDispatcherGUI 15* @ilCtrl_Calls ilObjFileBasedLMGUI: ilExportGUI 16* @ingroup ModulesHTMLLearningModule 17*/ 18 19require_once("./Services/Object/classes/class.ilObjectGUI.php"); 20require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php"); 21require_once("./Services/Table/classes/class.ilTableGUI.php"); 22require_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php"); 23 24class ilObjFileBasedLMGUI extends ilObjectGUI 25{ 26 /** 27 * @var ilTabsGUI 28 */ 29 protected $tabs; 30 31 /** 32 * @var ilRbacSystem 33 */ 34 protected $rbacsystem; 35 36 /** 37 * @var ilErrorHandling 38 */ 39 protected $error; 40 41 /** 42 * @var ilHelpGUI 43 */ 44 protected $help; 45 46 public $output_prepared; 47 48 /** 49 * Constructor 50 * 51 * @access public 52 */ 53 public function __construct($a_data, $a_id = 0, $a_call_by_reference = true, $a_prepare_output = true) 54 { 55 global $DIC; 56 57 $this->lng = $DIC->language(); 58 $this->user = $DIC->user(); 59 $this->locator = $DIC["ilLocator"]; 60 $this->tabs = $DIC->tabs(); 61 $this->rbacsystem = $DIC->rbac()->system(); 62 $this->tree = $DIC->repositoryTree(); 63 $this->tpl = $DIC["tpl"]; 64 $this->access = $DIC->access(); 65 $this->error = $DIC["ilErr"]; 66 $this->toolbar = $DIC->toolbar(); 67 $this->help = $DIC["ilHelp"]; 68 $lng = $DIC->language(); 69 $ilCtrl = $DIC->ctrl(); 70 71 $this->ctrl = $ilCtrl; 72 $this->ctrl->saveParameter($this, array("ref_id")); 73 74 $this->type = "htlm"; 75 $lng->loadLanguageModule("content"); 76 $lng->loadLanguageModule("obj"); 77 78 parent::__construct($a_data, $a_id, $a_call_by_reference, false); 79 //$this->actions = $this->objDefinition->getActions("mep"); 80 $this->output_prepared = $a_prepare_output; 81 } 82 83 /** 84 * execute command 85 */ 86 public function executeCommand() 87 { 88 $ilUser = $this->user; 89 $ilLocator = $this->locator; 90 $ilTabs = $this->tabs; 91 92 $next_class = $this->ctrl->getNextClass($this); 93 $cmd = $this->ctrl->getCmd(); 94 95 if (strtolower($_GET["baseClass"]) == "iladministrationgui" || 96 $this->getCreationMode() == true) { 97 $this->prepareOutput(); 98 } else { 99 if (!in_array($cmd, array("", "framset")) || $next_class != "") { 100 $this->getTemplate(); 101 $this->setLocator(); 102 $this->setTabs(); 103 } 104 } 105 106 switch ($next_class) { 107 case 'ilobjectmetadatagui': 108 $this->checkPermission("write"); 109 $ilTabs->activateTab('id_meta_data'); 110 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php"; 111 $md_gui = new ilObjectMetaDataGUI($this->object); 112 $this->ctrl->forwardCommand($md_gui); 113 break; 114 115 case "ilfilesystemgui": 116 $this->checkPermission("write"); 117 $ilTabs->activateTab('id_list_files'); 118 $fs_gui = new ilFileSystemGUI($this->object->getDataDirectory()); 119 $fs_gui->activateLabels(true, $this->lng->txt("cont_purpose")); 120 $fs_gui->setUseUploadDirectory(true); 121 $fs_gui->setTableId("htlmfs" . $this->object->getId()); 122 if ($this->object->getStartFile() != "") { 123 $fs_gui->labelFile( 124 $this->object->getStartFile(), 125 $this->lng->txt("cont_startfile") 126 ); 127 } 128 $fs_gui->addCommand($this, "setStartFile", $this->lng->txt("cont_set_start_file")); 129 130 $this->ctrl->forwardCommand($fs_gui); 131 132 // try to set start file automatically 133 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php"); 134 if (!ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId())) { 135 $do_update = false; 136 137 $pcommand = $fs_gui->getLastPerformedCommand(); 138 if (is_array($pcommand)) { 139 $valid = array("index.htm", "index.html", "start.htm", "start.html"); 140 if ($pcommand["cmd"] == "create_file") { 141 $file = strtolower(basename($pcommand["name"])); 142 if (in_array($file, $valid)) { 143 $this->object->setStartFile($pcommand["name"]); 144 $do_update = $pcommand["name"]; 145 } 146 } elseif ($pcommand["cmd"] == "unzip_file") { 147 $zip_file = strtolower(basename($pcommand["name"])); 148 $suffix = strrpos($zip_file, "."); 149 if ($suffix) { 150 $zip_file = substr($zip_file, 0, $suffix); 151 } 152 foreach ($pcommand["added"] as $file) { 153 $chk_file = null; 154 if (stristr($file, ".htm")) { 155 $chk_file = strtolower(basename($file)); 156 $suffix = strrpos($chk_file, "."); 157 if ($suffix) { 158 $chk_file = substr($chk_file, 0, $suffix); 159 } 160 } 161 if (in_array(basename($file), $valid) || 162 ($zip_file && $chk_file && $chk_file == $zip_file)) { 163 $this->object->setStartFile($file); 164 $do_update = $file; 165 break; 166 } 167 } 168 } 169 } 170 171 if ($do_update) { 172 ilUtil::sendInfo(sprintf($this->lng->txt("cont_start_file_set_to"), $do_update), true); 173 174 $this->object->update(); 175 $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles"); 176 } 177 } 178 break; 179 180 case "ilinfoscreengui": 181 $ret = $this->outputInfoScreen(); 182 break; 183 184 case "illearningprogressgui": 185 $ilTabs->activateTab('id_learning_progress'); 186 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php'; 187 $new_gui = new ilLearningProgressGUI( 188 ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, 189 $this->object->getRefId(), 190 $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId() 191 ); 192 $this->ctrl->forwardCommand($new_gui); 193 break; 194 195 case 'ilpermissiongui': 196 $ilTabs->activateTab('id_permissions'); 197 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php"); 198 $perm_gui = new ilPermissionGUI($this); 199 $ret = $this->ctrl->forwardCommand($perm_gui); 200 break; 201 202 case "ilexportgui": 203 $ilTabs->activateTab("export"); 204 include_once("./Services/Export/classes/class.ilExportGUI.php"); 205 $exp_gui = new ilExportGUI($this); 206 $exp_gui->addFormat("xml"); 207 $exp_gui->addFormat("html", "", $this, "exportHTML"); 208 $ret = $this->ctrl->forwardCommand($exp_gui); 209// $this->tpl->show(); 210 break; 211 212 case "ilcommonactiondispatchergui": 213 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php"); 214 $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall(); 215 $this->ctrl->forwardCommand($gui); 216 break; 217 218 default: 219 $cmd = $this->ctrl->getCmd("frameset"); 220 if (strtolower($_GET["baseClass"]) == "iladministrationgui" || 221 $this->getCreationMode() == true) { 222 $cmd .= "Object"; 223 } 224 $ret = $this->$cmd(); 225 break; 226 } 227 228 $this->addHeaderAction(); 229 } 230 231 protected function initCreationForms($a_new_type) 232 { 233 $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type), 234 self::CFORM_IMPORT => $this->initImportForm($a_new_type)); 235 236 return $forms; 237 } 238 239 /** 240 * cancel action and go back to previous page 241 * @access public 242 * 243 */ 244 final public function cancelCreationObject($in_rep = false) 245 { 246 $ilCtrl = $this->ctrl; 247 248 $ilCtrl->redirectByClass("ilrepositorygui", "frameset"); 249 } 250 251 /** 252 * edit properties of object (admin form) 253 * 254 * @access public 255 */ 256 public function properties() 257 { 258 $rbacsystem = $this->rbacsystem; 259 $tree = $this->tree; 260 $tpl = $this->tpl; 261 $ilTabs = $this->tabs; 262 263 $ilTabs->activateTab("id_settings"); 264 265 $this->initSettingsForm(); 266 $this->getSettingsFormValues(); 267 $tpl->setContent($this->form->getHTML()); 268 } 269 270 /** 271 * Init settings form. 272 */ 273 public function initSettingsForm() 274 { 275 $obj_service = $this->getObjectService(); 276 $lng = $this->lng; 277 $ilCtrl = $this->ctrl; 278 $ilAccess = $this->access; 279 280 include_once("Services/Form/classes/class.ilPropertyFormGUI.php"); 281 $this->form = new ilPropertyFormGUI(); 282 283 // title 284 $ti = new ilTextInputGUI($this->lng->txt("title"), "title"); 285 $ti->setSize(min(40, ilObject::TITLE_LENGTH)); 286 $ti->setMaxLength(ilObject::TITLE_LENGTH); 287 $ti->setRequired(true); 288 $this->form->addItem($ti); 289 290 // description 291 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc"); 292 $ta->setCols(40); 293 $ta->setRows(2); 294 $this->form->addItem($ta); 295 296 // online 297 $cb = new ilCheckboxInputGUI($lng->txt("cont_online"), "cobj_online"); 298 $cb->setOptionTitle($lng->txt("")); 299 $cb->setValue("y"); 300 $this->form->addItem($cb); 301 302 // startfile 303 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php"); 304 $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId()); 305 306 $ne = new ilNonEditableValueGUI($lng->txt("cont_startfile"), ""); 307 if ($startfile != "") { 308 $ne->setValue(basename($startfile)); 309 } else { 310 $ne->setValue(basename($this->lng->txt("no_start_file"))); 311 } 312 $this->form->addItem($ne); 313 314 $pres = new ilFormSectionHeaderGUI(); 315 $pres->setTitle($this->lng->txt('obj_presentation')); 316 $this->form->addItem($pres); 317 318 // tile image 319 $obj_service->commonSettings()->legacyForm($this->form, $this->object)->addTileImage(); 320 321 $this->form->addCommandButton("saveProperties", $lng->txt("save")); 322 $this->form->addCommandButton("toFilesystem", $lng->txt("cont_set_start_file")); 323 324 $this->form->setTitle($lng->txt("cont_lm_properties")); 325 $this->form->setFormAction($ilCtrl->getFormAction($this, "saveProperties")); 326 } 327 328 /** 329 * Get current values for settings from 330 */ 331 public function getSettingsFormValues() 332 { 333 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php"); 334 $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId()); 335 336 $values = array(); 337 $values['cobj_online'] = !$this->object->getOfflineStatus(); 338 if ($startfile != "") { 339 $startfile = basename($startfile); 340 } else { 341 $startfile = $this->lng->txt("no_start_file"); 342 } 343 344 $values["startfile"] = $startfile; 345 $values["title"] = $this->object->getTitle(); 346 $values["desc"] = $this->object->getLongDescription(); 347 //$values["lic"] = $this->object->getShowLicense(); 348 349 $this->form->setValuesByArray($values); 350 } 351 352 /** 353 * Set start file 354 * 355 * @param 356 * @return 357 */ 358 public function toFilesystem() 359 { 360 $ilCtrl = $this->ctrl; 361 362 $ilCtrl->redirectByClass("ilfilesystemgui", "listFiles"); 363 } 364 365 /** 366 * Save properties form 367 */ 368 public function saveProperties() 369 { 370 $tpl = $this->tpl; 371 $ilAccess = $this->access; 372 $ilTabs = $this->tabs; 373 $obj_service = $this->getObjectService(); 374 375 $this->initSettingsForm(""); 376 if ($this->form->checkInput()) { 377 $this->object->setTitle($this->form->getInput("title")); 378 $this->object->setDescription($this->form->getInput("desc")); 379 $this->object->setOfflineStatus(!(bool) $_POST['cobj_online']); 380 381 $this->object->update(); 382 383 // tile image 384 $obj_service->commonSettings()->legacyForm($this->form, $this->object)->saveTileImage(); 385 386 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true); 387 $this->ctrl->redirect($this, "properties"); 388 } 389 390 $ilTabs->activateTab("id_settings"); 391 $this->form->setValuesByPost(); 392 $tpl->setContent($this->form->getHtml()); 393 } 394 395 /** 396 * edit properties of object (admin form) 397 * 398 * @access public 399 */ 400 public function editObject() 401 { 402 $rbacsystem = $this->rbacsystem; 403 $ilErr = $this->error; 404 405 if (!$rbacsystem->checkAccess("visible,write", $this->object->getRefId())) { 406 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE); 407 } 408 } 409 410 /** 411 * edit properties of object (module form) 412 */ 413 public function edit() 414 { 415 $this->prepareOutput(); 416 $this->editObject(); 417 } 418 419 /** 420 * cancel editing 421 */ 422 public function cancel() 423 { 424 //$this->setReturnLocation("cancel","fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"]); 425 $this->cancelObject(); 426 } 427 428 /** 429 * save object 430 * @access public 431 */ 432 public function afterSave(ilObject $newObj) 433 { 434 if (!$newObj->getStartFile()) { 435 // try to set start file automatically 436 $files = array(); 437 include_once "Services/Utilities/classes/class.ilFileUtils.php"; 438 ilFileUtils::recursive_dirscan($newObj->getDataDirectory(), $files); 439 if (is_array($files["file"])) { 440 $zip_file = null; 441 if (stristr($newObj->getTitle(), ".zip")) { 442 $zip_file = strtolower($newObj->getTitle()); 443 $suffix = strrpos($zip_file, "."); 444 if ($suffix) { 445 $zip_file = substr($zip_file, 0, $suffix); 446 } 447 } 448 $valid = array("index.htm", "index.html", "start.htm", "start.html"); 449 foreach ($files["file"] as $idx => $file) { 450 $chk_file = null; 451 if (stristr($file, ".htm")) { 452 $chk_file = strtolower($file); 453 $suffix = strrpos($chk_file, "."); 454 if ($suffix) { 455 $chk_file = substr($chk_file, 0, $suffix); 456 } 457 } 458 if (in_array($file, $valid) || 459 ($chk_file && $zip_file && $chk_file == $zip_file)) { 460 $newObj->setStartFile(str_replace($newObj->getDataDirectory() . "/", "", $files["path"][$idx]) . $file); 461 $newObj->update(); 462 break; 463 } 464 } 465 } 466 } 467 468 // always send a message 469 ilUtil::sendSuccess($this->lng->txt("object_added"), true); 470 $this->object = $newObj; 471 $this->redirectAfterCreation(); 472 } 473 474 475 /** 476 * update properties 477 */ 478 public function update() 479 { 480 //$this->setReturnLocation("update", "fblm_edit.php?cmd=listFiles&ref_id=".$_GET["ref_id"]. 481 // "&obj_id=".$_GET["obj_id"]); 482 $this->updateObject(); 483 } 484 485 486 public function setStartFile($a_file) 487 { 488 $this->object->setStartFile($a_file); 489 $this->object->update(); 490 $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles"); 491 } 492 493 /** 494 * permission form 495 */ 496 public function perm() 497 { 498 $this->setFormAction("permSave", "fblm_edit.php?cmd=permSave&ref_id=" . $_GET["ref_id"] . 499 "&obj_id=" . $_GET["obj_id"]); 500 $this->setFormAction("addRole", "fblm_edit.php?ref_id=" . $_GET["ref_id"] . 501 "&obj_id=" . $_GET["obj_id"] . "&cmd=addRole"); 502 $this->permObject(); 503 } 504 505 506 /** 507 * Frameset -> Output list of files 508 */ 509 public function frameset() 510 { 511 $ilCtrl = $this->ctrl; 512 513 $ilCtrl->setCmdClass("ilfilesystemgui"); 514 $ilCtrl->setCmd("listFiles"); 515 return $this->executeCommand(); 516 } 517 518 /** 519 * output main header (title and locator) 520 */ 521 public function getTemplate() 522 { 523 $lng = $this->lng; 524 525 $this->tpl->loadStandardTemplate(); 526 } 527 528 public function showLearningModule() 529 { 530 $ilUser = $this->user; 531 532 // #9483 533 if ($ilUser->getId() != ANONYMOUS_USER_ID) { 534 include_once "Services/Tracking/classes/class.ilLearningProgress.php"; 535 ilLearningProgress::_tracProgress( 536 $ilUser->getId(), 537 $this->object->getId(), 538 $this->object->getRefId(), 539 "htlm" 540 ); 541 } 542 543 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php"); 544 require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php'); 545 546 $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId()); 547 ilWACSignedPath::signFolderOfStartFile($startfile); 548 if ($startfile != "") { 549 ilUtil::redirect($startfile); 550 } 551 } 552 553 // InfoScreen methods 554 /** 555 * this one is called from the info button in the repository 556 * not very nice to set cmdClass/Cmd manually, if everything 557 * works through ilCtrl in the future this may be changed 558 */ 559 public function infoScreen() 560 { 561 $this->ctrl->setCmd("showSummary"); 562 $this->ctrl->setCmdClass("ilinfoscreengui"); 563 $this->outputInfoScreen(); 564 } 565 566 /** 567 * info screen call from inside learning module 568 */ 569 public function showInfoScreen() 570 { 571 $this->outputInfoScreen(true); 572 } 573 574 /** 575 * info screen 576 */ 577 public function outputInfoScreen($a_standard_locator = true) 578 { 579 $ilToolbar = $this->toolbar; 580 $ilAccess = $this->access; 581 $ilTabs = $this->tabs; 582 583 $ilTabs->activateTab('id_info'); 584 585 $this->lng->loadLanguageModule("meta"); 586 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php"); 587 588 $info = new ilInfoScreenGUI($this); 589 $info->enablePrivateNotes(); 590 $info->enableLearningProgress(); 591 592 $info->enableNews(); 593 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) { 594 $info->enableNewsEditing(); 595 596 $news_set = new ilSetting("news"); 597 $enable_internal_rss = $news_set->get("enable_rss_for_internal"); 598 if ($enable_internal_rss) { 599 $info->setBlockProperty("news", "settings", true); 600 } 601 } 602 603 // add read / back button 604 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"])) { 605 // #15127 606 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php"; 607 $button = ilLinkButton::getInstance(); 608 $button->setCaption("view"); 609 $button->setPrimary(true); 610 $button->setUrl("ilias.php?baseClass=ilHTLMPresentationGUI&ref_id=" . $this->object->getRefID()); 611 $button->setTarget("ilContObj" . $this->object->getId()); 612 $ilToolbar->addButtonInstance($button); 613 } 614 615 // show standard meta data section 616 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType()); 617 618 // forward the command 619 $this->ctrl->forwardCommand($info); 620 } 621 622 623 624 /** 625 * output tabs 626 */ 627 public function setTabs() 628 { 629 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm.svg")); 630 631 $this->getTabs(); 632 $this->tpl->setTitle($this->object->getTitle()); 633 } 634 635 /** 636 * adds tabs to tab gui object 637 */ 638 public function getTabs() 639 { 640 $ilUser = $this->user; 641 $ilAccess = $this->access; 642 $ilTabs = $this->tabs; 643 $lng = $this->lng; 644 $ilHelp = $this->help; 645 646 $ilHelp->setScreenIdComponent("htlm"); 647 648 if ($ilAccess->checkAccess('write', '', $this->ref_id)) { 649 $ilTabs->addTab( 650 "id_list_files", 651 $lng->txt("cont_list_files"), 652 $this->ctrl->getLinkTargetByClass("ilfilesystemgui", "listFiles") 653 ); 654 } 655 656 if ($ilAccess->checkAccess('visible', '', $this->ref_id)) { 657 $ilTabs->addTab( 658 "id_info", 659 $lng->txt("info_short"), 660 $this->ctrl->getLinkTargetByClass(array("ilobjfilebasedlmgui", "ilinfoscreengui"), "showSummary") 661 ); 662 } 663 664 if ($ilAccess->checkAccess('write', '', $this->ref_id)) { 665 $ilTabs->addTab( 666 "id_settings", 667 $lng->txt("settings"), 668 $this->ctrl->getLinkTarget($this, "properties") 669 ); 670 } 671 672 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php'; 673 if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) { 674 $ilTabs->addTab( 675 "id_learning_progress", 676 $lng->txt("learning_progress"), 677 $this->ctrl->getLinkTargetByClass(array('ilobjfilebasedlmgui','illearningprogressgui'), '') 678 ); 679 } 680 681 if ($ilAccess->checkAccess('write', '', $this->ref_id)) { 682 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php"; 683 $mdgui = new ilObjectMetaDataGUI($this->object); 684 $mdtab = $mdgui->getTab(); 685 if ($mdtab) { 686 $ilTabs->addTab( 687 "id_meta_data", 688 $lng->txt("meta_data"), 689 $mdtab 690 ); 691 } 692 } 693 694 695 // export 696 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) { 697 $ilTabs->addTab( 698 "export", 699 $lng->txt("export"), 700 $this->ctrl->getLinkTargetByClass("ilexportgui", "") 701 ); 702 } 703 704 if ($ilAccess->checkAccess('edit_permission', '', $this->object->getRefId())) { 705 $ilTabs->addTab( 706 "id_permissions", 707 $lng->txt("perm_settings"), 708 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm") 709 ); 710 } 711 712 require_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php"); 713 $startfile = ilObjFileBasedLMAccess::_determineStartUrl($this->object->getId()); 714 if ($ilAccess->checkAccess('read', '', $this->ref_id)) { 715 if ($startfile != "") { 716 $ilTabs->addNonTabbedLink( 717 "presentation_view", 718 $this->lng->txt("glo_presentation_view"), 719 "ilias.php?baseClass=ilHTLMPresentationGUI&ref_id=" . $this->object->getRefID(), 720 "_blank" 721 ); 722 } 723 } 724 } 725 726 /** 727 * redirect script 728 * 729 * @param string $a_target 730 */ 731 public static function _goto($a_target) 732 { 733 global $DIC; 734 735 $rbacsystem = $DIC->rbac()->system(); 736 $ilErr = $DIC["ilErr"]; 737 $lng = $DIC->language(); 738 $ilAccess = $DIC->access(); 739 740 if ($ilAccess->checkAccess("read", "", $a_target) || 741 $ilAccess->checkAccess("visible", "", $a_target)) { 742 ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen"); 743 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) { 744 ilUtil::sendFailure(sprintf( 745 $lng->txt("msg_no_perm_read_item"), 746 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target)) 747 ), true); 748 ilObjectGUI::_gotoRepositoryRoot(); 749 } 750 751 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL); 752 } 753 754 public function addLocatorItems() 755 { 756 $ilLocator = $this->locator; 757 758 if (is_object($this->object)) { 759 $ilLocator->addItem( 760 $this->object->getTitle(), 761 $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"), 762 "", 763 $_GET["ref_id"] 764 ); 765 } 766 } 767 768 769 /** 770 * Import file 771 * 772 * @param 773 * @return 774 */ 775 public function importFileObject($parent_id = null, $a_catch_errors = true) 776 { 777 try { 778 return parent::importFileObject(); 779 } catch (ilManifestFileNotFoundImportException $e) { 780 // since there is no manifest xml we assume that this is an HTML export file 781 $this->createFromDirectory($e->getTmpDir()); 782 } 783 } 784 785 /** 786 * Create new object from a html zip file 787 * 788 * @param 789 * @return 790 */ 791 public function createFromDirectory($a_dir) 792 { 793 $ilErr = $this->error; 794 795 if (!$this->checkPermissionBool("create", "", "htlm") || $a_dir == "") { 796 $ilErr->raiseError($this->lng->txt("no_create_permission")); 797 } 798 799 // create instance 800 $newObj = new ilObjFileBasedLM(); 801 $filename = ilUtil::stripSlashes($_FILES["importfile"]["name"]); 802 $newObj->setTitle($filename); 803 $newObj->setDescription(""); 804 $newObj->create(); 805 $newObj->populateByDirectoy($a_dir, $filename); 806 $this->putObjectInTree($newObj); 807 808 $this->afterSave($newObj); 809 } 810 811 812 813 814 //// 815 //// Export to HTML 816 //// 817 818 819 /** 820 * create html package 821 */ 822 public function exportHTML() 823 { 824 $inst_id = IL_INST_ID; 825 826 include_once("./Services/Export/classes/class.ilExport.php"); 827 828 ilExport::_createExportDirectory( 829 $this->object->getId(), 830 "html", 831 $this->object->getType() 832 ); 833 $export_dir = ilExport::_getExportDirectory( 834 $this->object->getId(), 835 "html", 836 $this->object->getType() 837 ); 838 839 $subdir = $this->object->getType() . "_" . $this->object->getId(); 840 $filename = $this->subdir . ".zip"; 841 842 $target_dir = $export_dir . "/" . $subdir; 843 844 ilUtil::delDir($target_dir); 845 ilUtil::makeDir($target_dir); 846 847 $source_dir = $this->object->getDataDirectory(); 848 849 ilUtil::rCopy($source_dir, $target_dir); 850 851 // zip it all 852 $date = time(); 853 $zip_file = $export_dir . "/" . $date . "__" . IL_INST_ID . "__" . 854 $this->object->getType() . "_" . $this->object->getId() . ".zip"; 855 ilUtil::zip($target_dir, $zip_file); 856 857 ilUtil::delDir($target_dir); 858 } 859 860 /** 861 * @inheritdoc 862 */ 863 public function redirectAfterCreation() 864 { 865 $ctrl = $this->ctrl; 866 $ctrl->setParameterByClass("ilObjFileBasedLMGUI", "ref_id", $this->object->getRefId()); 867 $ctrl->redirectByClass(["ilrepositorygui", "ilObjFileBasedLMGUI"], "properties"); 868 } 869} 870