ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilScorm2004Export Class Reference

Export class for SCORM 2004 object. More...

+ Collaboration diagram for ilScorm2004Export:

Public Member Functions

 __construct (&$a_cont_obj, $a_mode="SCORM 2004 3rd")
 Constructor 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 ()
 

Protected Attributes

 $log
 

Private Attributes

 $err
 
 $db
 
 $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.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor public.

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

References $DIC, $ilDB, $ilErr, $ilSetting, $settings, array, date, getExportDirectory(), getExportFileName(), getExportSubDirectory(), settings(), and time.

37  {
38  global $DIC;
39 
40  $this->settings = $DIC->settings();
41  $this->log = $DIC["ilLog"];
42  $ilErr = $DIC["ilErr"];
43  $ilDB = $DIC->database();
44  $ilSetting = $DIC->settings();
45 
46  $this->export_types = array("SCORM 2004 3rd","SCORM 2004 4th","SCORM 1.2","HTML","ISO","PDF",
47  "HTMLOne");
48 
49  if (!in_array($a_mode, $this->export_types)) {
50  die("Unsupported format");
51  }
52 
53  $this->cont_obj = $a_cont_obj;
54 
55  $this->err = $ilErr;
56  $this->db = $ilDB;
57  $this->mode = $a_mode;
58 
59  $settings = $ilSetting->getAll();
60 
61  $this->inst_id = IL_INST_ID;
62 
63  switch ($this->cont_obj->getType()) {
64  case 'sahs':
65  $this->module_id = $this->cont_obj->getId();
66  $this->cont_obj_id = $this->cont_obj->getId();
67  break;
68  case 'sco':
69  $this->module_id = $this->cont_obj->slm_id;
70  $this->cont_obj_id = $this->cont_obj->getId();
71  break;
72  }
73 
74  $this->date = time();
75 
76  $this->export_dir = $this->getExportDirectory();
77  $this->subdir = $this->getExportSubDirectory();
78  $this->filename = $this->getExportFileName();
79  }
global $ilErr
Definition: raiseError.php:16
global $DIC
Definition: saml.php:7
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
global $ilSetting
Definition: privfeed.php:17
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportFile()

ilScorm2004Export::buildExportFile ( )

build export file (complete zip file)

public

Returns

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

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

141  {
142  switch ($this->mode) {
143  case "SCORM 2004 3rd":
144  return $this->buildExportFileSCORM("2004 3rd");
145  case "SCORM 2004 4th":
146  return $this->buildExportFileSCORM("2004 4th");
147  case "SCORM 1.2":
148  return $this->buildExportFileSCORM("12");
149  case "HTML":
150  return $this->buildExportFileHTML();
151  case "HTMLOne":
152  return $this->buildExportFileHTMLOne();
153  case "ISO":
154  return $this->buildExportFileISO();
155  case "PDF":
156  return $this->buildExportFilePDF();
157  }
158  }
buildExportFileHTML()
build xml export file
buildExportFileHTMLOne()
build xml export file
buildExportFileSCORM($ver)
build xml export file
+ Here is the call graph for this function:

◆ buildExportFileHTML()

ilScorm2004Export::buildExportFileHTML ( )

build xml export file

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

References $export_dir, createExportDirectory(), date, ilUtil\delDir(), ilMathJax\getInstance(), ilUtil\makeDir(), ilMathJax\PURPOSE_EXPORT, and ilUtil\zip().

Referenced by buildExportFile().

202  {
203  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
204 
205  // init the mathjax rendering for HTML export
206  include_once './Services/MathJax/classes/class.ilMathJax.php';
208 
209  // create directories
210  $this->createExportDirectory();
211  ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
212 
213  // get Log File
214  $expDir = $this->export_dir;
215  include_once './Services/Logging/classes/class.ilLog.php';
216  $expLog = new ilLog($expDir, "export.log");
217  $expLog->delete();
218  $expLog->setLogFormat("");
219  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
220 
221  // get xml content
222  $this->cont_obj->exportHTML($this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog);
223 
224  // zip the file
225  ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip", true);
226 
227  ilUtil::delDir($this->export_dir . "/" . $this->subdir);
228 
229  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
230 
231  return $this->export_dir . "/" . $this->subdir . ".zip";
232  }
logging
Definition: class.ilLog.php:18
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
const PURPOSE_EXPORT
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getInstance()
Singleton: get instance.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ 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 237 of file class.ilSCORM2004Export.php.

References $export_dir, createExportDirectory(), date, ilUtil\delDir(), ilMathJax\getInstance(), ilUtil\makeDir(), ilMathJax\PURPOSE_EXPORT, and ilUtil\zip().

Referenced by buildExportFile().

238  {
239  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
240 
241  // init the mathjax rendering for HTML export
242  include_once './Services/MathJax/classes/class.ilMathJax.php';
244 
245  // create directories
246  $this->createExportDirectory();
247  ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
248 
249  // get Log File
250  $expDir = $this->export_dir;
251  include_once './Services/Logging/classes/class.ilLog.php';
252  $expLog = new ilLog($expDir, "export.log");
253  $expLog->delete();
254  $expLog->setLogFormat("");
255  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
256 
257  // get xml content
258  $this->cont_obj->exportHTMLOne($this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog);
259 
260  // zip the file
261  ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip", true);
262 
263  ilUtil::delDir($this->export_dir . "/" . $this->subdir);
264 
265  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
266 
267  return $this->export_dir . "/" . $this->subdir . ".zip";
268  }
logging
Definition: class.ilLog.php:18
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
const PURPOSE_EXPORT
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getInstance()
Singleton: get instance.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildExportFileISO()

ilScorm2004Export::buildExportFileISO ( )

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

References $export_dir, $result, createExportDirectory(), ilUtil\CreateIsoFromFolder(), date, ilUtil\delDir(), ilMathJax\getInstance(), ilUtil\makeDir(), and ilMathJax\PURPOSE_EXPORT.

Referenced by buildExportFile().

271  {
272  $result = "";
273 
274  // init the mathjax rendering for HTML export
275  include_once './Services/MathJax/classes/class.ilMathJax.php';
277 
278  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
279 
280  // create directories
281  $this->createExportDirectory();
282  ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
283 
284  // get Log File
285  $expDir = $this->export_dir;
286  include_once './Services/Logging/classes/class.ilLog.php';
287  $expLog = new ilLog($expDir, "export.log");
288  $expLog->delete();
289  $expLog->setLogFormat("");
290  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
291 
292  // get xml content
293 
294  $this->cont_obj->exportHTML($this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog);
295 
296  // zip the file
297  if (ilUtil::CreateIsoFromFolder($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".iso")) {
298  $result = $this->export_dir . "/" . $this->subdir . ".iso";
299  }
300 
301  ilUtil::delDir($this->export_dir . "/" . $this->subdir);
302 
303  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
304 
305  return $result;
306  }
$result
logging
Definition: class.ilLog.php:18
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static CreateIsoFromFolder($a_dir, $a_file)
const PURPOSE_EXPORT
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getInstance()
Singleton: get instance.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildExportFilePDF()

ilScorm2004Export::buildExportFilePDF ( )

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

References $export_dir, $ilLog, $log, createExportDirectory(), date, ilUtil\delDir(), ilRpcClientFactory\factory(), ilMathJax\getInstance(), ilUtil\makeDir(), ilMathJax\PURPOSE_DEFERRED_PDF, ilMathJax\PURPOSE_PDF, ilMathJax\RENDER_PNG_AS_FO_FILE, and ilUtil\sendFailure().

Referenced by buildExportFile().

309  {
310 
311  // don't render mathjax before fo code is generated
312  include_once './Services/MathJax/classes/class.ilMathJax.php';
314 
315  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
316 
317  // create directories
318  $this->createExportDirectory();
319  ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
320 
321  // get Log File
322  $expDir = $this->export_dir;
323  include_once './Services/Logging/classes/class.ilLog.php';
324  $expLog = new ilLog($expDir, "export.log");
325  $expLog->delete();
326  $expLog->setLogFormat("");
327  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
328 
329  $fo_string = $this->cont_obj->exportPDF($this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog);
330 
331  // now render mathjax for pdf generation
332  $fo_string = ilMathJax::getInstance()
333  ->init(ilMathJax::PURPOSE_PDF)
334  ->setRendering(ilMathJax::RENDER_PNG_AS_FO_FILE)
335  ->insertLatexImages($fo_string);
336 
337 
338  fputs(fopen($this->export_dir . "/" . $this->subdir . '/temp.fo', 'w+'), $fo_string);
339 
340  $ilLog = $this->log;
341  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
342  try {
343  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($fo_string);
344  //ilUtil::deliverData($pdf_base64->scalar,'learning_progress.pdf','application/pdf');
345  fputs(fopen($this->export_dir . '/' . $this->subdir . '.pdf', 'w+'), $pdf_base64->scalar);
346  } catch (Exception $e) {
347  ilUtil::sendFailure($e->getMessage(), true);
348  return false;
349  }
350 
351  ilUtil::delDir($this->export_dir . "/" . $this->subdir);
352 
353  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
354 
355  return $this->export_dir . "/" . $this->subdir . ".pdf";
356  }
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
const PURPOSE_PDF
logging
Definition: class.ilLog.php:18
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const RENDER_PNG_AS_FO_FILE
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getInstance()
Singleton: get instance.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
const PURPOSE_DEFERRED_PDF
+ 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 163 of file class.ilSCORM2004Export.php.

References $export_dir, createExportDirectory(), date, ilUtil\delDir(), ilMathJax\getInstance(), ilUtil\makeDir(), ilMathJax\PURPOSE_EXPORT, and ilUtil\zip().

Referenced by buildExportFile().

164  {
165 
166  // init the mathjax rendering for HTML export
167  include_once './Services/MathJax/classes/class.ilMathJax.php';
169 
170  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
171 
172  // create directories
173  $this->createExportDirectory();
174  ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
175 
176  // get Log File
177  $expDir = $this->export_dir;
178  include_once './Services/Logging/classes/class.ilLog.php';
179  $expLog = new ilLog($expDir, "export.log");
180  $expLog->delete();
181  $expLog->setLogFormat("");
182  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
183 
184  // get xml content
185 
186  $this->cont_obj->exportScorm($this->inst_id, $this->export_dir . "/" . $this->subdir, $ver, $expLog);
187 
188  // zip the file
189  ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip", true);
190 
191  ilUtil::delDir($this->export_dir . "/" . $this->subdir);
192 
193  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
194 
195  return $this->export_dir . "/" . $this->subdir . ".zip";
196  }
logging
Definition: class.ilLog.php:18
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
const PURPOSE_EXPORT
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getInstance()
Singleton: get instance.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createExportDirectory()

ilScorm2004Export::createExportDirectory ( )

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

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

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

359  {
360  $ilErr = $this->err;
361 
362  $lm_data_dir = ilUtil::getDataDir() . "/lm_data";
363  if (!is_writable($lm_data_dir)) {
364  $ilErr->raiseError("Content object Data Directory (" . $lm_data_dir . ") not writeable.", $ilErr->FATAL);
365  }
366  // create learning module directory (data_dir/lm_data/lm_<id>)
367  $lm_dir = $lm_data_dir . "/lm_" . $this->module_id;
368  ilUtil::makeDir($lm_dir);
369  if (!@is_dir($lm_dir)) {
370  $ilErr->raiseError("Creation of Learning Module Directory failed.", $ilErr->FATAL);
371  }
372 
373  //$export_dir = $lm_dir."/export_".$this->mode;
374  ilUtil::makeDir($this->export_dir);
375 
376  if (!@is_dir($this->export_dir)) {
377  $ilErr->raiseError("Creation of Export Directory failed.", $ilErr->FATAL);
378  }
379  }
global $ilErr
Definition: raiseError.php:16
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getDataDir()
get data directory (outside webspace)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportDirectory()

ilScorm2004Export::getExportDirectory ( )

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

References getExportDirectoryForType().

Referenced by __construct().

82  {
83  return $this->getExportDirectoryForType($this->mode);
84  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportDirectoryForType()

ilScorm2004Export::getExportDirectoryForType (   $type)

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

References $ret, $type, and ilUtil\getDataDir().

Referenced by getExportDirectory().

87  {
88  $ret = ilUtil::getDataDir() . "/lm_data" . "/lm_" . $this->module_id . "/export_";
89  switch ($type) {
90  case "ISO":
91  return $ret . "_iso";
92  case "PDF":
93  return $ret . "_pdf";
94  case "SCORM 2004 3rd":
95  return $ret . "_scorm2004";
96  case "SCORM 2004 4th":
97  return $ret . "_scorm2004_4th";
98  case "HTML":
99  return $ret . "_html";
100  case "HTMLOne":
101  return $ret . "_html_one";
102  case "SCORM 1.2":
103  return $ret . "_scorm12";
104  }
105  }
$type
static getDataDir()
get data directory (outside webspace)
$ret
Definition: parser.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportFileName()

ilScorm2004Export::getExportFileName ( )

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

Referenced by __construct().

113  {
114  switch ($this->mode) {
115  case "ISO":
116  return $this->subdir . ".iso";
117  case "PDF":
118  return $this->subdir . ".pdf";
119  default:
120  return $this->subdir . ".zip";
121  }
122  }
+ Here is the caller graph for this function:

◆ getExportSubDirectory()

ilScorm2004Export::getExportSubDirectory ( )

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

References $cont_obj_id, and date.

Referenced by __construct().

108  {
109  return $this->date . "__" . $this->inst_id . "__" . $this->cont_obj->getType() . "_" . $this->cont_obj_id;
110  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
+ Here is the caller graph for this function:

◆ getInstId()

ilScorm2004Export::getInstId ( )

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

References $inst_id.

130  {
131  return $this->inst_id;
132  }

◆ getSupportedExportTypes()

ilScorm2004Export::getSupportedExportTypes ( )

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

References $export_types.

125  {
126  return $this->export_types;
127  }

Field Documentation

◆ $cont_obj

ilScorm2004Export::$cont_obj
private

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

◆ $cont_obj_id

ilScorm2004Export::$cont_obj_id
private

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

Referenced by getExportSubDirectory().

◆ $date

ilScorm2004Export::$date
private

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

◆ $db

ilScorm2004Export::$db
private

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

◆ $err

ilScorm2004Export::$err
private

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

Referenced by createExportDirectory().

◆ $export_dir

ilScorm2004Export::$export_dir
private

◆ $export_types

ilScorm2004Export::$export_types
private

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

Referenced by getSupportedExportTypes().

◆ $filename

ilScorm2004Export::$filename
private

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

◆ $inst_id

ilScorm2004Export::$inst_id
private

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

Referenced by getInstId().

◆ $log

ilScorm2004Export::$log
protected

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

Referenced by buildExportFilePDF().

◆ $mode

ilScorm2004Export::$mode
private

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

◆ $module_id

ilScorm2004Export::$module_id
private

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

Referenced by createExportDirectory().

◆ $settings

ilScorm2004Export::$settings
private

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

Referenced by __construct().

◆ $subdir

ilScorm2004Export::$subdir
private

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


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