ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilContObjectExport.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
5
17{
18 var $err; // error object
19 var $db; // database object
20 var $ilias; // ilias object
21 var $cont_obj; // content object (learning module | digilib book)
22 var $inst_id; // installation id
23 var $mode;
24
29 function ilContObjectExport(&$a_cont_obj, $a_mode = "xml", $a_lang = "")
30 {
31 global $ilErr, $ilDB, $ilias;
32
33 $this->cont_obj = $a_cont_obj;
34
35 $this->err = $ilErr;
36 $this->db = $ilDB;
37 $this->mode = $a_mode;
38 $this->lang = $a_lang;
39
40 $this->inst_id = IL_INST_ID;
41
42 $date = time();
43 switch($this->mode)
44 {
45 case "html":
46 if ($this->lang == "")
47 {
48 $this->export_dir = $this->cont_obj->getExportDirectory("html");
49 }
50 else
51 {
52 $this->export_dir = $this->cont_obj->getExportDirectory("html_".$this->lang);
53 }
54 $this->subdir = $this->cont_obj->getType()."_".$this->cont_obj->getId();
55 $this->filename = $this->subdir.".zip";
56 break;
57
58 case "scorm":
59 $this->export_dir = $this->cont_obj->getExportDirectory("scorm");
60 $this->subdir = $this->cont_obj->getType()."_".$this->cont_obj->getId();
61 $this->filename = $this->subdir.".zip";
62 break;
63
64 case "pdf":
65 $this->export_dir = $this->cont_obj->getOfflineDirectory();
66 $this->subdir = $date."__".$this->inst_id."__".
67 $this->cont_obj->getType()."_".$this->cont_obj->getId();
68 $this->filename = $this->subdir.".fo";
69 break;
70
71 default:
72 $this->export_dir = $this->cont_obj->getExportDirectory();
73 $this->subdir = $date."__".$this->inst_id."__".
74 $this->cont_obj->getType()."_".$this->cont_obj->getId();
75 $this->filename = $this->subdir.".xml";
76 break;
77 }
78 }
79
80 function getInstId()
81 {
82 return $this->inst_id;
83 }
84
91 function buildExportFile($a_master_only = false)
92 {
93 switch ($this->mode)
94 {
95 case "html":
96 $this->buildExportFileHTML();
97 break;
98
99 case "scorm":
100 $this->buildExportFileSCORM();
101 break;
102
103 case "pdf":
104 $this->buildExportFilePDF();
105 break;
106
107 default:
108 return $this->buildExportFileXML($a_master_only);
109 break;
110 }
111 }
112
116 function buildExportFileXML($a_master_only = false)
117 {
118 global $ilBench;
119
120 if ($a_master_only)
121 {
122 include_once("./Services/Export/classes/class.ilExport.php");
123 $exp = new ilExport();
124 $conf = $exp->getConfig("Modules/LearningModule");
125 $conf->setMasterLanguageOnly(true);
126 $exp->exportObject($this->cont_obj->getType(),$this->cont_obj->getId(), "5.1.0");
127 return;
128 }
129
130 $ilBench->start("ContentObjectExport", "buildExportFile");
131
132 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
133
134 $this->xml = new ilXmlWriter;
135
136 // set dtd definition
137 $this->xml->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
138
139 // set generated comment
140 $this->xml->xmlSetGenCmt("Export of ILIAS Content Module ".
141 $this->cont_obj->getId()." of installation ".$this->inst.".");
142
143 // set xml header
144 $this->xml->xmlHeader();
145
146 // create directories
147 $this->cont_obj->createExportDirectory();
148 ilUtil::makeDir($this->export_dir."/".$this->subdir);
149 ilUtil::makeDir($this->export_dir."/".$this->subdir."/objects");
150
151 // get Log File
152 $expDir = $this->cont_obj->getExportDirectory();
153 include_once './Services/Logging/classes/class.ilLog.php';
154 $expLog = new ilLog($expDir, "export.log");
155 $expLog->delete();
156 $expLog->setLogFormat("");
157 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
158
159 // get xml content
160//echo "ContObjExport:".$this->inst_id.":<br>";
161 $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
162 $this->cont_obj->exportXML($this->xml, $this->inst_id,
163 $this->export_dir."/".$this->subdir, $expLog);
164 $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
165
166 // export style
167 if ($this->cont_obj->getStyleSheetId() > 0)
168 {
169 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
170 $style_obj = new ilObjStyleSheet($this->cont_obj->getStyleSheetId(), false);
171 //$style_obj->exportXML($this->export_dir."/".$this->subdir);
172 $style_obj->setExportSubDir("style");
173 $style_file = $style_obj->export();
174 if (is_file($style_file))
175 {
176 copy($style_file, $this->export_dir."/".$this->subdir."/style.zip");
177 }
178 }
179
180 // dump xml document to screen (only for debugging reasons)
181 /*
182 echo "<PRE>";
183 echo htmlentities($this->xml->xmlDumpMem($format));
184 echo "</PRE>";
185 */
186
187 // dump xml document to file
188 $this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
189 , false);
190
191 // help export (workaround to use ref id here)
193 {
194 include_once("./Services/Export/classes/class.ilExport.php");
195 $exp = new ilExport();
196 $exp->exportEntity("help", $this->cont_obj->getId(), "4.3.0", "Services/Help",
197 "OnlineHelp", $this->export_dir."/".$this->subdir);
198 }
199
200 // zip the file
201 ilUtil::zip($this->export_dir."/".$this->subdir,
202 $this->export_dir."/".$this->subdir.".zip");
203
204 // destroy writer object
205 $this->xml->_XmlWriter;
206
207 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
208 $ilBench->stop("ContentObjectExport", "buildExportFile");
209
210 return $this->export_dir."/".$this->subdir.".zip";
211 }
212
217 {
218 die("deprecated.");
219 }
220
225 {
226 global $ilBench;
227
228 // create directories
229 if ($this->lang == "")
230 {
231 $this->cont_obj->createExportDirectory("html");
232 }
233 else
234 {
235 $this->cont_obj->createExportDirectory("html_".$this->lang);
236 }
237
238
239 // get html content
240 $this->cont_obj->exportHTML($this->export_dir."/".$this->subdir, $expLog, true, "html", $this->lang);
241 }
242
247 {
248 global $ilBench;
249
250 $ilBench->start("ContentObjectExport", "buildSCORMPackage");
251
252 // create directories
253 $this->cont_obj->createExportDirectory("scorm");
254
255 // get html content
256 $ilBench->start("ContentObjectExport", "buildSCORMPackage_getSCORM");
257 $this->cont_obj->exportSCORM($this->export_dir."/".$this->subdir, $expLog);
258 $ilBench->stop("ContentObjectExport", "buildSCORMPackage_getSCORM");
259
260 //$expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
261 $ilBench->stop("ContentObjectExport", "buildSCORMPackage");
262 }
263
264}
265
266?>
$_GET["client_id"]
Export class for content objects.
ilContObjectExport(&$a_cont_obj, $a_mode="xml", $a_lang="")
Constructor @access public.
buildExportFileXML($a_master_only=false)
build xml export file
buildExportFilePDF()
build pdf offline file
buildExportFile($a_master_only=false)
build export file (complete zip file)
buildExportFileSCORM()
build scorm package
buildExportFileHTML()
build html package
logging
Definition: class.ilLog.php:19
static isOnlineHelpModule($a_id, $a_as_obj_id=false)
Is module an online module.
Class ilObjStyleSheet.
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 ...
XML writer class.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
global $ilBench
Definition: ilias.php:18
global $ilDB