ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilContObjectExport Class Reference

Export class for content objects. More...

+ Collaboration diagram for ilContObjectExport:

Public Member Functions

 __construct (&$a_cont_obj, $a_mode="xml", $a_lang="")
 Constructor @access public. More...
 
 getInstId ()
 
 buildExportFile ($a_mode="")
 build export file (complete zip file) More...
 
 buildExportFileXML ($a_mode="")
 build xml export file More...
 
 buildExportFilePDF ()
 build pdf offline file More...
 
 buildExportFileHTML ()
 build html package More...
 
 buildExportFileSCORM ()
 build scorm package More...
 

Data Fields

 $err
 
 $db
 
 $cont_obj
 
 $inst_id
 
 $mode
 

Detailed Description

Export class for content objects.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Databay AG ay@da.nosp@m.taba.nosp@m.y.de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilContObjectExport::__construct ( $a_cont_obj,
  $a_mode = "xml",
  $a_lang = "" 
)

Constructor @access public.

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

28 {
29 global $DIC;
30
31 $ilErr = $DIC["ilErr"];
32 $ilDB = $DIC->database();
33
34 $this->cont_obj = $a_cont_obj;
35
36 $this->err = $ilErr;
37 $this->db = $ilDB;
38 $this->mode = $a_mode;
39 $this->lang = $a_lang;
40
41 $this->inst_id = IL_INST_ID;
42
43 $date = time();
44 switch ($this->mode) {
45 case "html":
46 if ($this->lang == "") {
47 $this->export_dir = $this->cont_obj->getExportDirectory("html");
48 } else {
49 $this->export_dir = $this->cont_obj->getExportDirectory("html_" . $this->lang);
50 }
51 $this->subdir = $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
52 $this->filename = $this->subdir . ".zip";
53 break;
54
55 case "scorm":
56 $this->export_dir = $this->cont_obj->getExportDirectory("scorm");
57 $this->subdir = $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
58 $this->filename = $this->subdir . ".zip";
59 break;
60
61 case "pdf":
62 $this->export_dir = $this->cont_obj->getOfflineDirectory();
63 $this->subdir = $date . "__" . $this->inst_id . "__" .
64 $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
65 $this->filename = $this->subdir . ".fo";
66 break;
67
68 default:
69 $this->export_dir = $this->cont_obj->getExportDirectory();
70 $this->subdir = $date . "__" . $this->inst_id . "__" .
71 $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
72 $this->filename = $this->subdir . ".xml";
73 break;
74 }
75 }
$ilErr
Definition: raiseError.php:18
global $ilDB
$DIC
Definition: xapitoken.php:46

References $DIC, $ilDB, and $ilErr.

Member Function Documentation

◆ buildExportFile()

ilContObjectExport::buildExportFile (   $a_mode = "")

build export file (complete zip file)

@access public

Returns

Definition at line 88 of file class.ilContObjectExport.php.

89 {
90 switch ($this->mode) {
91 case "html":
92 $this->buildExportFileHTML();
93 break;
94
95 case "scorm":
96 $this->buildExportFileSCORM();
97 break;
98
99 case "pdf":
100 $this->buildExportFilePDF();
101 break;
102
103 default:
104 return $this->buildExportFileXML($a_mode);
105 break;
106 }
107 }
buildExportFileXML($a_mode="")
build xml export file
buildExportFilePDF()
build pdf offline file
buildExportFileSCORM()
build scorm package
buildExportFileHTML()
build html package

References buildExportFileHTML(), buildExportFilePDF(), buildExportFileSCORM(), and buildExportFileXML().

+ Here is the call graph for this function:

◆ buildExportFileHTML()

ilContObjectExport::buildExportFileHTML ( )

build html package

Definition at line 213 of file class.ilContObjectExport.php.

214 {
215 // create directories
216 if ($this->lang == "") {
217 $this->cont_obj->createExportDirectory("html");
218 } else {
219 $this->cont_obj->createExportDirectory("html_" . $this->lang);
220 }
221
222
223 // get html content
224 $exp = new \ILIAS\LearningModule\Export\LMHtmlExport(
225 $this->cont_obj,
226 $this->export_dir,
227 $this->subdir,
228 "html",
229 $this->lang
230 );
231 $exp->exportHTML(true);
232 }

Referenced by buildExportFile().

+ Here is the caller graph for this function:

◆ buildExportFilePDF()

ilContObjectExport::buildExportFilePDF ( )

build pdf offline file

Definition at line 205 of file class.ilContObjectExport.php.

206 {
207 die("deprecated.");
208 }

Referenced by buildExportFile().

+ Here is the caller graph for this function:

◆ buildExportFileSCORM()

ilContObjectExport::buildExportFileSCORM ( )

build scorm package

Definition at line 237 of file class.ilContObjectExport.php.

238 {
239 // create directories
240 $this->cont_obj->createExportDirectory("scorm");
241
242 $target_dir = $this->export_dir . "/" . $this->subdir;
243
244 ilUtil::delDir($target_dir);
245 ilUtil::makeDir($target_dir);
246
247 // export everything to html
248// $this->exportHTML($a_target_dir . "/res", $log, false, "scorm");
249 // get html content
250 $exp = new \ILIAS\LearningModule\Export\LMHtmlExport(
251 $this->cont_obj,
252 $target_dir,
253 "res",
254 "scorm",
255 $this->lang
256 );
257 $exp->exportHTML(false);
258
259 // build manifest file
260 $man_builder = new ilLMContObjectManifestBuilder($this->cont_obj);
261 $man_builder->buildManifest();
262 $man_builder->dump($target_dir);
263
264 // copy scorm 1.2 schema definitions
265 copy("Modules/LearningModule/scorm_xsd/adlcp_rootv1p2.xsd", $target_dir . "/adlcp_rootv1p2.xsd");
266 copy("Modules/LearningModule/scorm_xsd/imscp_rootv1p1p2.xsd", $target_dir . "/imscp_rootv1p1p2.xsd");
267 copy("Modules/LearningModule/scorm_xsd/imsmd_rootv1p2p1.xsd", $target_dir . "/imsmd_rootv1p2p1.xsd");
268 copy("Modules/LearningModule/scorm_xsd/ims_xml.xsd", $target_dir . "/ims_xml.xsd");
269
270 // zip it all
271 $date = time();
272 $zip_file = $target_dir . "/" . $date . "__" . IL_INST_ID . "__" .
273 $this->cont_obj->getType() . "_" . $this->cont_obj->getId() . ".zip";
274 //echo "zip-".$a_target_dir."-to-".$zip_file;
275 ilUtil::zip(array($target_dir . "/res",
276 $target_dir . "/imsmanifest.xml",
277 $target_dir . "/adlcp_rootv1p2.xsd",
278 $target_dir . "/imscp_rootv1p1p2.xsd",
279 $target_dir . "/ims_xml.xsd",
280 $target_dir . "/imsmd_rootv1p2p1.xsd"), $zip_file);
281
282 $dest_file = $this->cont_obj->getExportDirectory("scorm") . "/" . $date . "__" . IL_INST_ID . "__" .
283 $this->cont_obj->getType() . "_" . $this->cont_obj->getId() . ".zip";
284
285 rename($zip_file, $dest_file);
286 ilUtil::delDir($target_dir);
287
288 // get html content
289// $this->cont_obj->exportSCORM($this->export_dir . "/" . $this->subdir, $expLog);
290 }
Content Object (ILIAS native learning module / digilib book) Manifest export class.
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)
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 ...

References 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:

◆ buildExportFileXML()

ilContObjectExport::buildExportFileXML (   $a_mode = "")

build xml export file

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

113 {
114 if (in_array($a_mode, array("master", "masternomedia"))) {
115 $exp = new ilExport();
116 $conf = $exp->getConfig("Modules/LearningModule");
117 $conf->setMasterLanguageOnly(true, ($a_mode == "master"));
118 $exp->exportObject($this->cont_obj->getType(), $this->cont_obj->getId(), "5.1.0");
119 return;
120 }
121
122 $this->xml = new ilXmlWriter;
123
124 // set dtd definition
125 $this->xml->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
126
127 // set generated comment
128 $this->xml->xmlSetGenCmt("Export of ILIAS Content Module " .
129 $this->cont_obj->getId() . " of installation " . $this->inst . ".");
130
131 // set xml header
132 $this->xml->xmlHeader();
133
134 // create directories
135 $this->cont_obj->createExportDirectory();
136 ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
137 ilUtil::makeDir($this->export_dir . "/" . $this->subdir . "/objects");
138
139 // get Log File
140 $expDir = $this->cont_obj->getExportDirectory();
141 $expLog = new ilLog($expDir, "export.log");
142 $expLog->delete();
143 $expLog->setLogFormat("");
144 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
145
146 // get xml content
147 $this->cont_obj->exportXML(
148 $this->xml,
149 $this->inst_id,
150 $this->export_dir . "/" . $this->subdir,
151 $expLog
152 );
153
154 // export style
155 if ($this->cont_obj->getStyleSheetId() > 0) {
156 $style_obj = new ilObjStyleSheet($this->cont_obj->getStyleSheetId(), false);
157 //$style_obj->exportXML($this->export_dir."/".$this->subdir);
158 $style_obj->setExportSubDir("style");
159 $style_file = $style_obj->export();
160 if (is_file($style_file)) {
161 copy($style_file, $this->export_dir . "/" . $this->subdir . "/style.zip");
162 }
163 }
164
165 // dump xml document to screen (only for debugging reasons)
166 /*
167 echo "<PRE>";
168 echo htmlentities($this->xml->xmlDumpMem($format));
169 echo "</PRE>";
170 */
171
172 // dump xml document to file
173 $this->xml->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->filename, false);
174
175 // help export (workaround to use ref id here)
176 if (ilObjContentObject::isOnlineHelpModule((int) $_GET["ref_id"])) {
177 $exp = new ilExport();
178 $exp->exportEntity(
179 "help",
180 $this->cont_obj->getId(),
181 "4.3.0",
182 "Services/Help",
183 "OnlineHelp",
184 $this->export_dir . "/" . $this->subdir
185 );
186 }
187
188 // zip the file
190 $this->export_dir . "/" . $this->subdir,
191 $this->export_dir . "/" . $this->subdir . ".zip"
192 );
193
194 // destroy writer object
195 $this->xml->_XmlWriter;
196
197 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
198
199 return $this->export_dir . "/" . $this->subdir . ".zip";
200 }
$_GET["client_id"]
logging
Definition: class.ilLog.php:19
static isOnlineHelpModule($a_id, $a_as_obj_id=false)
Is module an online module.
Class ilObjStyleSheet.
XML writer class.
xmlSetDtdDef($dtdDef)
Sets dtd definition.

References $_GET, ilObjContentObject\isOnlineHelpModule(), ilUtil\makeDir(), ilXmlWriter\xmlSetDtdDef(), and ilUtil\zip().

Referenced by buildExportFile().

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

◆ getInstId()

ilContObjectExport::getInstId ( )

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

References $inst_id.

Field Documentation

◆ $cont_obj

ilContObjectExport::$cont_obj

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

◆ $db

ilContObjectExport::$db

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

◆ $err

ilContObjectExport::$err

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

◆ $inst_id

ilContObjectExport::$inst_id

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

Referenced by getInstId().

◆ $mode

ilContObjectExport::$mode

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


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