ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 public $err; // error object
19 public $db; // database object
20 public $cont_obj; // content object (learning module | digilib book)
21 public $inst_id; // installation id
22 public $mode;
23
28 public function __construct(&$a_cont_obj, $a_mode = "xml", $a_lang = "")
29 {
30 global $DIC;
31
32 $ilErr = $DIC["ilErr"];
33 $ilDB = $DIC->database();
34
35 $this->cont_obj = $a_cont_obj;
36
37 $this->err = $ilErr;
38 $this->db = $ilDB;
39 $this->mode = $a_mode;
40 $this->lang = $a_lang;
41
42 $this->inst_id = IL_INST_ID;
43
44 $date = time();
45 switch ($this->mode) {
46 case "html":
47 if ($this->lang == "") {
48 $this->export_dir = $this->cont_obj->getExportDirectory("html");
49 } else {
50 $this->export_dir = $this->cont_obj->getExportDirectory("html_" . $this->lang);
51 }
52 $this->subdir = $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
53 $this->filename = $this->subdir . ".zip";
54 break;
55
56 case "scorm":
57 $this->export_dir = $this->cont_obj->getExportDirectory("scorm");
58 $this->subdir = $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
59 $this->filename = $this->subdir . ".zip";
60 break;
61
62 case "pdf":
63 $this->export_dir = $this->cont_obj->getOfflineDirectory();
64 $this->subdir = $date . "__" . $this->inst_id . "__" .
65 $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
66 $this->filename = $this->subdir . ".fo";
67 break;
68
69 default:
70 $this->export_dir = $this->cont_obj->getExportDirectory();
71 $this->subdir = $date . "__" . $this->inst_id . "__" .
72 $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
73 $this->filename = $this->subdir . ".xml";
74 break;
75 }
76 }
77
78 public function getInstId()
79 {
80 return $this->inst_id;
81 }
82
89 public function buildExportFile($a_mode = "")
90 {
91 switch ($this->mode) {
92 case "html":
93 $this->buildExportFileHTML();
94 break;
95
96 case "scorm":
97 $this->buildExportFileSCORM();
98 break;
99
100 case "pdf":
101 $this->buildExportFilePDF();
102 break;
103
104 default:
105 return $this->buildExportFileXML($a_mode);
106 break;
107 }
108 }
109
113 public function buildExportFileXML($a_mode = "")
114 {
115 if (in_array($a_mode, array("master", "masternomedia"))) {
116 include_once("./Services/Export/classes/class.ilExport.php");
117 $exp = new ilExport();
118 $conf = $exp->getConfig("Modules/LearningModule");
119 $conf->setMasterLanguageOnly(true, ($a_mode == "master"));
120 $exp->exportObject($this->cont_obj->getType(), $this->cont_obj->getId(), "5.1.0");
121 return;
122 }
123
124 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
125
126 $this->xml = new ilXmlWriter;
127
128 // set dtd definition
129 $this->xml->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
130
131 // set generated comment
132 $this->xml->xmlSetGenCmt("Export of ILIAS Content Module " .
133 $this->cont_obj->getId() . " of installation " . $this->inst . ".");
134
135 // set xml header
136 $this->xml->xmlHeader();
137
138 // create directories
139 $this->cont_obj->createExportDirectory();
140 ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
141 ilUtil::makeDir($this->export_dir . "/" . $this->subdir . "/objects");
142
143 // get Log File
144 $expDir = $this->cont_obj->getExportDirectory();
145 include_once './Services/Logging/classes/class.ilLog.php';
146 $expLog = new ilLog($expDir, "export.log");
147 $expLog->delete();
148 $expLog->setLogFormat("");
149 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
150
151 // get xml content
152 $this->cont_obj->exportXML(
153 $this->xml,
154 $this->inst_id,
155 $this->export_dir . "/" . $this->subdir,
156 $expLog
157 );
158
159 // export style
160 if ($this->cont_obj->getStyleSheetId() > 0) {
161 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
162 $style_obj = new ilObjStyleSheet($this->cont_obj->getStyleSheetId(), false);
163 //$style_obj->exportXML($this->export_dir."/".$this->subdir);
164 $style_obj->setExportSubDir("style");
165 $style_file = $style_obj->export();
166 if (is_file($style_file)) {
167 copy($style_file, $this->export_dir . "/" . $this->subdir . "/style.zip");
168 }
169 }
170
171 // dump xml document to screen (only for debugging reasons)
172 /*
173 echo "<PRE>";
174 echo htmlentities($this->xml->xmlDumpMem($format));
175 echo "</PRE>";
176 */
177
178 // dump xml document to file
179 $this->xml->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->filename, false);
180
181 // help export (workaround to use ref id here)
182 if (ilObjContentObject::isOnlineHelpModule((int) $_GET["ref_id"])) {
183 include_once("./Services/Export/classes/class.ilExport.php");
184 $exp = new ilExport();
185 $exp->exportEntity(
186 "help",
187 $this->cont_obj->getId(),
188 "4.3.0",
189 "Services/Help",
190 "OnlineHelp",
191 $this->export_dir . "/" . $this->subdir
192 );
193 }
194
195 // zip the file
197 $this->export_dir . "/" . $this->subdir,
198 $this->export_dir . "/" . $this->subdir . ".zip"
199 );
200
201 // destroy writer object
202 $this->xml->_XmlWriter;
203
204 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
205
206 return $this->export_dir . "/" . $this->subdir . ".zip";
207 }
208
212 public function buildExportFilePDF()
213 {
214 die("deprecated.");
215 }
216
220 public function buildExportFileHTML()
221 {
222 // create directories
223 if ($this->lang == "") {
224 $this->cont_obj->createExportDirectory("html");
225 } else {
226 $this->cont_obj->createExportDirectory("html_" . $this->lang);
227 }
228
229
230 // get html content
231 $this->cont_obj->exportHTML($this->export_dir . "/" . $this->subdir, $expLog, true, "html", $this->lang);
232 }
233
237 public function buildExportFileSCORM()
238 {
239 // create directories
240 $this->cont_obj->createExportDirectory("scorm");
241
242 // get html content
243 $this->cont_obj->exportSCORM($this->export_dir . "/" . $this->subdir, $expLog);
244 }
245}
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Export class for content objects.
buildExportFileXML($a_mode="")
build xml export file
buildExportFilePDF()
build pdf offline file
__construct(&$a_cont_obj, $a_mode="xml", $a_lang="")
Constructor @access public.
buildExportFile($a_mode="")
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)
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 ...
XML writer class.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
global $ilErr
Definition: raiseError.php:16
global $DIC
Definition: saml.php:7
global $ilDB