ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilScorm2004Export Class Reference

Export class for SCORM 2004 object. More...

+ Collaboration diagram for ilScorm2004Export:

Public Member Functions

 ilScorm2004Export (&$a_cont_obj, $a_mode="SCORM 2004 3rd")
 Constructor @access public. More...
 
 getExportDirectory ()
 
 getExportDirectoryForType ($type)
 
 getExportSubDirectory ()
 
 getExportFileName ()
 
 getSupportedExportTypes ()
 
 getInstId ()
 
 buildExportFile ()
 build export file (complete zip file) More...
 
 buildExportFileSCORM ($ver)
 build xml export file More...
 
 buildExportFileHTML ()
 build xml export file More...
 
 buildExportFileHTMLOne ()
 build xml export file More...
 
 buildExportFileISO ()
 
 buildExportFilePDF ()
 
 createExportDirectory ()
 

Private Attributes

 $err
 
 $db
 
 $ilias
 
 $cont_obj
 
 $cont_obj_id
 
 $inst_id
 
 $mode
 
 $export_types
 
 $module_id
 
 $date
 
 $settings
 
 $export_dir
 
 $subdir
 
 $filename
 

Detailed Description

Export class for SCORM 2004 object.

Definition at line 10 of file class.ilSCORM2004Export.php.

Member Function Documentation

◆ buildExportFile()

ilScorm2004Export::buildExportFile ( )

build export file (complete zip file)

@access public

Returns

Definition at line 134 of file class.ilSCORM2004Export.php.

135 {
136 switch ($this->mode)
137 {
138 case "SCORM 2004 3rd":
139 return $this->buildExportFileSCORM("2004 3rd");
140 case "SCORM 2004 4th":
141 return $this->buildExportFileSCORM("2004 4th");
142 case "SCORM 1.2":
143 return $this->buildExportFileSCORM("12");
144 case "HTML":
145 return $this->buildExportFileHTML();
146 case "HTMLOne":
147 return $this->buildExportFileHTMLOne();
148 case "ISO":
149 return $this->buildExportFileISO();
150 case "PDF":
151 return $this->buildExportFilePDF();
152 }
153 }
buildExportFileHTMLOne()
build xml export file
buildExportFileHTML()
build xml export file
buildExportFileSCORM($ver)
build xml export file

References buildExportFileHTML(), buildExportFileHTMLOne(), buildExportFileISO(), buildExportFilePDF(), and buildExportFileSCORM().

+ Here is the call graph for this function:

◆ buildExportFileHTML()

ilScorm2004Export::buildExportFileHTML ( )

build xml export file

Definition at line 200 of file class.ilSCORM2004Export.php.

201 {
202 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
203
204 // create directories
205 $this->createExportDirectory();
206 ilUtil::makeDir($this->export_dir."/".$this->subdir);
207
208 // get Log File
209 $expDir = $this->export_dir;
210 include_once './Services/Logging/classes/class.ilLog.php';
211 $expLog = new ilLog($expDir, "export.log");
212 $expLog->delete();
213 $expLog->setLogFormat("");
214 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
215
216 // get xml content
217 $this->cont_obj->exportHTML($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
218
219 // zip the file
220 ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip", true);
221
222 ilUtil::delDir($this->export_dir."/".$this->subdir);
223
224 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
225
226 return $this->export_dir."/".$this->subdir.".zip";
227 }
logging
Definition: class.ilLog.php:19
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static zip($a_dir, $a_file, $compress_content=false)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References $export_dir, createExportDirectory(), ilUtil\delDir(), ilUtil\makeDir(), and ilUtil\zip().

Referenced by buildExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildExportFileHTMLOne()

ilScorm2004Export::buildExportFileHTMLOne ( )

build xml export file

Definition at line 232 of file class.ilSCORM2004Export.php.

233 {
234 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
235
236 // create directories
237 $this->createExportDirectory();
238 ilUtil::makeDir($this->export_dir."/".$this->subdir);
239
240 // get Log File
241 $expDir = $this->export_dir;
242 include_once './Services/Logging/classes/class.ilLog.php';
243 $expLog = new ilLog($expDir, "export.log");
244 $expLog->delete();
245 $expLog->setLogFormat("");
246 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
247
248 // get xml content
249 $this->cont_obj->exportHTMLOne($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
250
251 // zip the file
252 ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip", true);
253
254 ilUtil::delDir($this->export_dir."/".$this->subdir);
255
256 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
257
258 return $this->export_dir."/".$this->subdir.".zip";
259 }

References $export_dir, createExportDirectory(), ilUtil\delDir(), ilUtil\makeDir(), and ilUtil\zip().

Referenced by buildExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildExportFileISO()

ilScorm2004Export::buildExportFileISO ( )

Definition at line 261 of file class.ilSCORM2004Export.php.

262 {
263 global $ilBench;
264 $result = "";
265 $ilBench->start("ContentObjectExport", "buildExportFile");
266
267 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
268
269 // create directories
270 $this->createExportDirectory();
271 ilUtil::makeDir($this->export_dir."/".$this->subdir);
272
273 // get Log File
274 $expDir = $this->export_dir;
275 include_once './Services/Logging/classes/class.ilLog.php';
276 $expLog = new ilLog($expDir, "export.log");
277 $expLog->delete();
278 $expLog->setLogFormat("");
279 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
280
281 // get xml content
282
283 $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
284 $this->cont_obj->exportHTML($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
285 $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
286
287 // zip the file
288 $ilBench->start("ContentObjectExport", "buildExportFile_zipFile");
289 if(ilUtil::CreateIsoFromFolder($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".iso"))
290 {
291 $result = $this->export_dir."/".$this->subdir.".iso";
292 }
293 $ilBench->stop("ContentObjectExport", "buildExportFile_zipFile");
294
295 ilUtil::delDir($this->export_dir."/".$this->subdir);
296
297 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
298 $ilBench->stop("ContentObjectExport", "buildExportFile");
299
300 return $result;
301 }
$result
static CreateIsoFromFolder($a_dir, $a_file)
global $ilBench
Definition: ilias.php:18

References $export_dir, $ilBench, $result, createExportDirectory(), ilUtil\CreateIsoFromFolder(), ilUtil\delDir(), and ilUtil\makeDir().

Referenced by buildExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildExportFilePDF()

ilScorm2004Export::buildExportFilePDF ( )

Definition at line 303 of file class.ilSCORM2004Export.php.

304 {
305 global $ilBench;
306 /*include_once('./Services/WebServices/RPC/classes/class.ilRPCServerSettings.php');
307 $pp = ilRPCServerSettings::getInstance();
308 if(!$pp->isEnabled()||!$pp->pingServer())
309 {
310 $this->ilias->raiseError("Xml Rpc Server is not running. Check Administration/Webservices/Java-Server settings", $this->ilias->error_obj->MESSAGE);
311 return;
312 }*/
313
314 $ilBench->start("ContentObjectExport", "buildExportFile");
315
316 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
317
318 // create directories
319 $this->createExportDirectory();
320 ilUtil::makeDir($this->export_dir."/".$this->subdir);
321
322 // get Log File
323 $expDir = $this->export_dir;
324 include_once './Services/Logging/classes/class.ilLog.php';
325 $expLog = new ilLog($expDir, "export.log");
326 $expLog->delete();
327 $expLog->setLogFormat("");
328 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
329
330 $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
331 $fo_string = $this->cont_obj->exportPDF($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
332
333 $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
334
335 $ilBench->start("ContentObjectExport", "buildExportFile_pdfFile");
336 fputs(fopen($this->export_dir."/".$this->subdir.'/temp.fo','w+'),$fo_string);
337
338 global $ilLog;
339 include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
340 try
341 {
342 $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($fo_string);
343 //ilUtil::deliverData($pdf_base64->scalar,'learning_progress.pdf','application/pdf');
344 fputs(fopen($this->export_dir.'/'.$this->subdir.'.pdf','w+'),$pdf_base64->scalar);
345 }
347 {
348 ilUtil::sendFailure($e->getMessage(),true);
349 return false;
350 }
351 catch(Exception $e)
352 {
353 ilUtil::sendFailure($e->getMessage(),true);
354 return false;
355 }
356 $ilBench->stop("ContentObjectExport", "buildExportFile_pdfFile");
357
358 ilUtil::delDir($this->export_dir."/".$this->subdir);
359
360 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
361 $ilBench->stop("ContentObjectExport", "buildExportFile");
362
363 return $this->export_dir."/".$this->subdir.".pdf";
364 }
static factory($a_package)
Create an XML_RPC2 client instance.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $export_dir, $ilBench, $ilLog, createExportDirectory(), ilUtil\delDir(), ilRpcClientFactory\factory(), ilUtil\makeDir(), and ilUtil\sendFailure().

Referenced by buildExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildExportFileSCORM()

ilScorm2004Export::buildExportFileSCORM (   $ver)

build xml export file

Definition at line 158 of file class.ilSCORM2004Export.php.

159 {
160 global $ilBench;
161
162 $ilBench->start("ContentObjectExport", "buildExportFile");
163
164 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
165
166 // create directories
167 $this->createExportDirectory();
168 ilUtil::makeDir($this->export_dir."/".$this->subdir);
169
170 // get Log File
171 $expDir = $this->export_dir;
172 include_once './Services/Logging/classes/class.ilLog.php';
173 $expLog = new ilLog($expDir, "export.log");
174 $expLog->delete();
175 $expLog->setLogFormat("");
176 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
177
178 // get xml content
179
180 $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
181 $this->cont_obj->exportScorm($this->inst_id, $this->export_dir."/".$this->subdir, $ver, $expLog);
182 $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
183
184 // zip the file
185 $ilBench->start("ContentObjectExport", "buildExportFile_zipFile");
186 ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip", true);
187 $ilBench->stop("ContentObjectExport", "buildExportFile_zipFile");
188
189 ilUtil::delDir($this->export_dir."/".$this->subdir);
190
191 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
192 $ilBench->stop("ContentObjectExport", "buildExportFile");
193
194 return $this->export_dir."/".$this->subdir.".zip";
195 }

References $export_dir, $ilBench, createExportDirectory(), ilUtil\delDir(), ilUtil\makeDir(), and ilUtil\zip().

Referenced by buildExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createExportDirectory()

ilScorm2004Export::createExportDirectory ( )

Definition at line 366 of file class.ilSCORM2004Export.php.

367 {
368 $lm_data_dir = ilUtil::getDataDir()."/lm_data";
369 if(!is_writable($lm_data_dir))
370 {
371 $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir.") not writeable.",$this->ilias->error_obj->FATAL);
372 }
373 // create learning module directory (data_dir/lm_data/lm_<id>)
374 $lm_dir = $lm_data_dir."/lm_".$this->module_id;
375 ilUtil::makeDir($lm_dir);
376 if(!@is_dir($lm_dir))
377 {
378 $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
379 }
380
381 //$export_dir = $lm_dir."/export_".$this->mode;
382 ilUtil::makeDir($this->export_dir);
383
384 if(!@is_dir($this->export_dir))
385 {
386 $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
387 }
388 }
static getDataDir()
get data directory (outside webspace)
redirection script todo: (a better solution should control the processing via a xml file)

References $module_id, ilUtil\getDataDir(), and ilUtil\makeDir().

Referenced by buildExportFileHTML(), buildExportFileHTMLOne(), buildExportFileISO(), buildExportFilePDF(), and buildExportFileSCORM().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportDirectory()

ilScorm2004Export::getExportDirectory ( )

Definition at line 72 of file class.ilSCORM2004Export.php.

73 {
74 return $this->getExportDirectoryForType($this->mode);
75 }

References getExportDirectoryForType().

Referenced by ilScorm2004Export().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportDirectoryForType()

ilScorm2004Export::getExportDirectoryForType (   $type)

Definition at line 77 of file class.ilSCORM2004Export.php.

78 {
79 $ret = ilUtil::getDataDir()."/lm_data"."/lm_".$this->module_id."/export_";
80 switch($type)
81 {
82 case "ISO":
83 return $ret."_iso";
84 case "PDF":
85 return $ret."_pdf";
86 case "SCORM 2004 3rd":
87 return $ret."_scorm2004";
88 case "SCORM 2004 4th":
89 return $ret."_scorm2004_4th";
90 case "HTML":
91 return $ret."_html";
92 case "HTMLOne":
93 return $ret."_html_one";
94 case "SCORM 1.2":
95 return $ret."_scorm12";
96 }
97
98 }

References $ret, and ilUtil\getDataDir().

Referenced by getExportDirectory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportFileName()

ilScorm2004Export::getExportFileName ( )

Definition at line 105 of file class.ilSCORM2004Export.php.

106 {
107 switch($this->mode)
108 {
109 case "ISO":
110 return $this->subdir.".iso";
111 case "PDF":
112 return $this->subdir.".pdf";
113 default:
114 return $this->subdir.".zip";
115 }
116 }

Referenced by ilScorm2004Export().

+ Here is the caller graph for this function:

◆ getExportSubDirectory()

ilScorm2004Export::getExportSubDirectory ( )

Definition at line 100 of file class.ilSCORM2004Export.php.

101 {
102 return $this->date."__".$this->inst_id."__".$this->cont_obj->getType()."_".$this->cont_obj_id;
103 }

References $cont_obj_id.

Referenced by ilScorm2004Export().

+ Here is the caller graph for this function:

◆ getInstId()

ilScorm2004Export::getInstId ( )

Definition at line 123 of file class.ilSCORM2004Export.php.

124 {
125 return $this->inst_id;
126 }

References $inst_id.

◆ getSupportedExportTypes()

ilScorm2004Export::getSupportedExportTypes ( )

Definition at line 118 of file class.ilSCORM2004Export.php.

References $export_types.

◆ ilScorm2004Export()

ilScorm2004Export::ilScorm2004Export ( $a_cont_obj,
  $a_mode = "SCORM 2004 3rd" 
)

Constructor @access public.

Definition at line 32 of file class.ilSCORM2004Export.php.

33 {
34 global $ilErr, $ilDB, $ilias;
35
36 $this->export_types = array("SCORM 2004 3rd","SCORM 2004 4th","SCORM 1.2","HTML","ISO","PDF",
37 "HTMLOne");
38
39 if(!in_array($a_mode,$this->export_types))
40 die("Unsupported format");
41
42 $this->cont_obj =& $a_cont_obj;
43
44 $this->err =& $ilErr;
45 $this->ilias =& $ilias;
46 $this->db =& $ilDB;
47 $this->mode = $a_mode;
48
49 $settings = $this->ilias->getAllSettings();
50
51 $this->inst_id = IL_INST_ID;
52
53 switch ($this->cont_obj->getType())
54 {
55 case 'sahs':
56 $this->module_id = $this->cont_obj->getId();
57 $this->cont_obj_id = $this->cont_obj->getId();
58 break;
59 case 'sco':
60 $this->module_id = $this->cont_obj->slm_id;
61 $this->cont_obj_id = $this->cont_obj->getId();
62 break;
63 }
64
65 $this->date = time();
66
67 $this->export_dir = $this->getExportDirectory();
68 $this->subdir = $this->getExportSubDirectory();
69 $this->filename = $this->getExportFileName();
70 }
global $ilDB

References $ilDB, $ilErr, $ilias, $settings, getExportDirectory(), getExportFileName(), and getExportSubDirectory().

+ Here is the call graph for this function:

Field Documentation

◆ $cont_obj

ilScorm2004Export::$cont_obj
private

Definition at line 15 of file class.ilSCORM2004Export.php.

◆ $cont_obj_id

ilScorm2004Export::$cont_obj_id
private

Definition at line 16 of file class.ilSCORM2004Export.php.

Referenced by getExportSubDirectory().

◆ $date

ilScorm2004Export::$date
private

Definition at line 22 of file class.ilSCORM2004Export.php.

◆ $db

ilScorm2004Export::$db
private

Definition at line 13 of file class.ilSCORM2004Export.php.

◆ $err

ilScorm2004Export::$err
private

Definition at line 12 of file class.ilSCORM2004Export.php.

◆ $export_dir

ilScorm2004Export::$export_dir
private

◆ $export_types

ilScorm2004Export::$export_types
private

Definition at line 19 of file class.ilSCORM2004Export.php.

Referenced by getSupportedExportTypes().

◆ $filename

ilScorm2004Export::$filename
private

Definition at line 26 of file class.ilSCORM2004Export.php.

◆ $ilias

ilScorm2004Export::$ilias
private

Definition at line 14 of file class.ilSCORM2004Export.php.

Referenced by ilScorm2004Export().

◆ $inst_id

ilScorm2004Export::$inst_id
private

Definition at line 17 of file class.ilSCORM2004Export.php.

Referenced by getInstId().

◆ $mode

ilScorm2004Export::$mode
private

Definition at line 18 of file class.ilSCORM2004Export.php.

◆ $module_id

ilScorm2004Export::$module_id
private

Definition at line 20 of file class.ilSCORM2004Export.php.

Referenced by createExportDirectory().

◆ $settings

ilScorm2004Export::$settings
private

Definition at line 23 of file class.ilSCORM2004Export.php.

Referenced by ilScorm2004Export().

◆ $subdir

ilScorm2004Export::$subdir
private

Definition at line 25 of file class.ilSCORM2004Export.php.


The documentation for this class was generated from the following file: