ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 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)

public

Returns

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

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

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  }
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 199 of file class.ilSCORM2004Export.php.

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

Referenced by buildExportFile().

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

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

Referenced by buildExportFile().

231  {
232  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
233 
234  // create directories
235  $this->createExportDirectory();
236  ilUtil::makeDir($this->export_dir."/".$this->subdir);
237 
238  // get Log File
239  $expDir = $this->export_dir;
240  $expLog = new ilLog($expDir, "export.log");
241  $expLog->delete();
242  $expLog->setLogFormat("");
243  $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
244 
245  // get xml content
246  $this->cont_obj->exportHTMLOne($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
247 
248  // zip the file
249  ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip", true);
250 
251  ilUtil::delDir($this->export_dir."/".$this->subdir);
252 
253  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
254 
255  return $this->export_dir."/".$this->subdir.".zip";
256  }
logging
Definition: class.ilLog.php:18
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
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 258 of file class.ilSCORM2004Export.php.

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

Referenced by buildExportFile().

259  {
260  global $ilBench;
261  $result = "";
262  $ilBench->start("ContentObjectExport", "buildExportFile");
263 
264  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
265 
266  // create directories
267  $this->createExportDirectory();
268  ilUtil::makeDir($this->export_dir."/".$this->subdir);
269 
270  // get Log File
271  $expDir = $this->export_dir;
272  $expLog = new ilLog($expDir, "export.log");
273  $expLog->delete();
274  $expLog->setLogFormat("");
275  $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
276 
277  // get xml content
278 
279  $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
280  $this->cont_obj->exportHTML($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
281  $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
282 
283  // zip the file
284  $ilBench->start("ContentObjectExport", "buildExportFile_zipFile");
285  if(ilUtil::CreateIsoFromFolder($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".iso"))
286  {
287  $result = $this->export_dir."/".$this->subdir.".iso";
288  }
289  $ilBench->stop("ContentObjectExport", "buildExportFile_zipFile");
290 
291  ilUtil::delDir($this->export_dir."/".$this->subdir);
292 
293  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
294  $ilBench->stop("ContentObjectExport", "buildExportFile");
295 
296  return $result;
297  }
$result
logging
Definition: class.ilLog.php:18
static CreateIsoFromFolder($a_dir, $a_file)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
global $ilBench
Definition: ilias.php:18
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 299 of file class.ilSCORM2004Export.php.

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

Referenced by buildExportFile().

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

◆ buildExportFileSCORM()

ilScorm2004Export::buildExportFileSCORM (   $ver)

build xml export file

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

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

Referenced by buildExportFile().

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  $expLog = new ilLog($expDir, "export.log");
173  $expLog->delete();
174  $expLog->setLogFormat("");
175  $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
176 
177  // get xml content
178 
179  $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
180  $this->cont_obj->exportScorm($this->inst_id, $this->export_dir."/".$this->subdir, $ver, $expLog);
181  $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
182 
183  // zip the file
184  $ilBench->start("ContentObjectExport", "buildExportFile_zipFile");
185  ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip", true);
186  $ilBench->stop("ContentObjectExport", "buildExportFile_zipFile");
187 
188  ilUtil::delDir($this->export_dir."/".$this->subdir);
189 
190  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
191  $ilBench->stop("ContentObjectExport", "buildExportFile");
192 
193  return $this->export_dir."/".$this->subdir.".zip";
194  }
logging
Definition: class.ilLog.php:18
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
global $ilBench
Definition: ilias.php:18
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 361 of file class.ilSCORM2004Export.php.

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

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

362  {
363  $lm_data_dir = ilUtil::getDataDir()."/lm_data";
364  if(!is_writable($lm_data_dir))
365  {
366  $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir.") not writeable.",$this->ilias->error_obj->FATAL);
367  }
368  // create learning module directory (data_dir/lm_data/lm_<id>)
369  $lm_dir = $lm_data_dir."/lm_".$this->module_id;
370  ilUtil::makeDir($lm_dir);
371  if(!@is_dir($lm_dir))
372  {
373  $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
374  }
375 
376  //$export_dir = $lm_dir."/export_".$this->mode;
377  ilUtil::makeDir($this->export_dir);
378 
379  if(!@is_dir($this->export_dir))
380  {
381  $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
382  }
383  }
redirection script todo: (a better solution should control the processing via a xml file) ...
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 72 of file class.ilSCORM2004Export.php.

References getExportDirectoryForType().

Referenced by ilScorm2004Export().

73  {
74  return $this->getExportDirectoryForType($this->mode);
75  }
+ 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.

References $ret, and ilUtil\getDataDir().

Referenced by getExportDirectory().

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  }
static getDataDir()
get data directory (outside webspace)
+ 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.

Referenced by ilScorm2004Export().

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  }
+ Here is the caller graph for this function:

◆ getExportSubDirectory()

ilScorm2004Export::getExportSubDirectory ( )

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

References $cont_obj_id.

Referenced by ilScorm2004Export().

101  {
102  return $this->date."__".$this->inst_id."__".$this->cont_obj->getType()."_".$this->cont_obj_id;
103  }
+ Here is the caller graph for this function:

◆ getInstId()

ilScorm2004Export::getInstId ( )

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

References $inst_id.

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

◆ getSupportedExportTypes()

ilScorm2004Export::getSupportedExportTypes ( )

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

References $export_types.

119  {
120  return $this->export_types;
121  }

◆ ilScorm2004Export()

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

Constructor public.

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

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

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  }
redirection script todo: (a better solution should control the processing via a xml file) ...
global $ilDB
+ 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: