ILIAS  release_8 Revision v8.24
class.ilSAHSEditGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
33{
34 private \ILIAS\HTTP\Wrapper\WrapperFactory $wrapper;
35 private \ILIAS\Refinery\Factory $refinery;
37 protected ilLanguage $lng;
38 protected ilCtrl $ctrl;
39 protected int $refId;
40
44 protected $slm_gui;
45
49 public function __construct()
50 {
51 global $DIC;
52 $this->tpl = $DIC['tpl'];
53 $this->lng = $DIC->language();
54 $this->ctrl = $DIC->ctrl();
55 $this->wrapper = $DIC->http()->wrapper();
56 $this->refinery = $DIC->refinery();
57 $this->refId = $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
58
59 $this->ctrl->saveParameter($this, "ref_id");
60 }
61
65 public function executeCommand(): void
66 {
67 global $DIC;
68
69 $DIC->globalScreen()->tool()->context()->claim()->repository();
70
71 $lng = $DIC->language();
72 $ilAccess = $DIC->access();
73 $ilNavigationHistory = $DIC['ilNavigationHistory'];
74 $ilCtrl = $DIC->ctrl();
75 $ilErr = $DIC["ilErr"];
76 $ilLog = ilLoggerFactory::getLogger('sahs');
77 $ilLog->debug("bc:" . $DIC->http()->wrapper()->query()->retrieve('baseClass', $DIC->refinery()->kindlyTo()->string()) . "; nc:" . $this->ctrl->getNextClass($this) . "; cmd:" . $this->ctrl->getCmd());
78
79 $lng->loadLanguageModule("content");
80
81 // permission
82 if (!$ilAccess->checkAccess("write", "", $this->refId)) {
83 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->MESSAGE);
84 }
85
86 // add entry to navigation history
87 $ilNavigationHistory->addItem(
88 $this->refId,
89 "ilias.php?baseClass=ilSAHSEditGUI&ref_id=" . $this->refId,
90 "lm"
91 );
92
93 $next_class = $this->ctrl->getNextClass($this);
94 $cmd = $this->ctrl->getCmd();
95
96 $obj_id = ilObject::_lookupObjectId($this->refId);
98
99 switch ($type) {
100
101 case "scorm":
102 $this->slm_gui = new ilObjSCORMLearningModuleGUI([], $this->refId, true, false);
103 break;
104
105 case "scorm2004":
106 $this->slm_gui = new ilObjSCORM2004LearningModuleGUI([], $this->refId, true, false);
107 break;
108
109 }
110
111 if ($next_class == "") {
112 switch ($type) {
113
114 case "scorm2004":
115 $this->ctrl->setCmdClass("ilobjscorm2004learningmodulegui");
116 break;
117
118 case "scorm":
119 $this->ctrl->setCmdClass("ilobjscormlearningmodulegui");
120 break;
121 }
122 $next_class = $this->ctrl->getNextClass($this);
123 }
124
125 switch ($next_class) {
126 case "ilobjscormlearningmodulegui":
127 case "ilobjscorm2004learningmodulegui":
128 $ret = $this->ctrl->forwardCommand($this->slm_gui);
129 break;
130
131 case "ilexportgui":
132 $obj_id = ilObject::_lookupObjectId($this->refId);
133 if ($cmd === "create_xml") {
134 $exporter = new ilScormAiccExporter();
135 $xml = $exporter->getXmlRepresentation("sahs", "5.1.0", (string) $obj_id);
136 } elseif ($cmd === "download") {
137 $file = $this->wrapper->query()->retrieve('file', $this->refinery->kindlyTo()->string());
138 $ftmp = explode(":", $file);
139 $fileName = (string) $ftmp[1];
140 $exportDir = ilExport::_getExportDirectory($obj_id);
141 ilFileDelivery::deliverFileLegacy($exportDir . "/" . $fileName, $fileName, "zip");
142 } elseif ($cmd === "confirmDeletion") {
143 $exportDir = ilExport::_getExportDirectory($obj_id);
144 // $files = $_POST['file'];
145 $files = $this->wrapper->post()->retrieve('file', $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()));
146 foreach ($files as $file) {
147 $file = explode(":", $file);
148 $file[1] = basename($file[1]);
149 $exp_file = $exportDir . "/" . str_replace("..", "", $file[1]);
150 if (@is_file($exp_file)) {
151 unlink($exp_file);
152 }
153 }
154 }
155 $this->ctrl->setCmd("export");
156 ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&cmd=export&ref_id=" . $this->refId);
157 break;
158
159
160 default:
161 die("ilSAHSEdit: Class $next_class not found.");
162 }
163
164 $this->tpl->printToStdout();
165 }
166}
Class ilCtrl provides processing control methods.
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object.
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getLogger(string $a_component_id)
Get component logger.
static _lookupSubType(int $a_obj_id)
lookup subtype id (scorm, )
Class ilObjSCORMLearningModuleGUI.
static _lookupObjectId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalPageTemplate $tpl
ILIAS HTTP Wrapper WrapperFactory $wrapper
ILIAS Refinery Factory $refinery
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static redirect(string $a_script)
global $DIC
Definition: feed.php:28
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
$xml
Definition: metadata.php:351
$type
$ilErr
Definition: raiseError.php:17