ILIAS  release_8 Revision v8.24
ilContObjectExport Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilContObjectExport:

Public Member Functions

 __construct (ilObjLearningModule $a_cont_obj, string $a_mode="xml", string $a_lang="")
 
 getInstId ()
 
 buildExportFile (string $a_mode="")
 
 buildExportFileXML (string $a_mode="")
 build xml export file More...
 
 buildExportFileHTML ()
 

Data Fields

ilDBInterface $db
 
ilObjLearningModule $cont_obj
 
int $inst_id
 
string $mode
 

Protected Attributes

int $inst
 
ilXmlWriter $xml
 
string $filename
 
string $subdir
 
string $export_dir
 
string $lang
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Export class for content objects

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de
Databay AG ay@da.nosp@m.taba.nosp@m.y.de

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

Constructor & Destructor Documentation

◆ __construct()

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

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

42 {
43 global $DIC;
44
45 $ilDB = $DIC->database();
46
47 $this->cont_obj = $a_cont_obj;
48
49 $this->db = $ilDB;
50 $this->mode = $a_mode;
51 $this->lang = $a_lang;
52
53 $this->inst_id = (int) IL_INST_ID;
54
55 $date = time();
56 switch ($this->mode) {
57 case "html":
58 if ($this->lang == "") {
59 $this->export_dir = $this->cont_obj->getExportDirectory("html");
60 } else {
61 $this->export_dir = $this->cont_obj->getExportDirectory("html_" . $this->lang);
62 }
63 $this->subdir = $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
64 $this->filename = $this->subdir . ".zip";
65 break;
66
67 default:
68 $this->export_dir = $this->cont_obj->getExportDirectory();
69 $this->subdir = $date . "__" . $this->inst_id . "__" .
70 $this->cont_obj->getType() . "_" . $this->cont_obj->getId();
71 $this->filename = $this->subdir . ".xml";
72 break;
73 }
74 }
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: feed.php:28

References $DIC, $ilDB, IL_INST_ID, and ILIAS\Repository\int().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportFile()

ilContObjectExport::buildExportFile ( string  $a_mode = "")

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

83 : void {
84 switch ($this->mode) {
85 case "html":
86 $this->buildExportFileHTML();
87 break;
88
89 default:
90 $this->buildExportFileXML($a_mode);
91 break;
92 }
93 }
buildExportFileXML(string $a_mode="")
build xml export file

References buildExportFileHTML(), and buildExportFileXML().

+ Here is the call graph for this function:

◆ buildExportFileHTML()

ilContObjectExport::buildExportFileHTML ( )

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

181 : void
182 {
183 // create directories
184 if ($this->lang == "") {
185 $this->cont_obj->createExportDirectory("html");
186 } else {
187 $this->cont_obj->createExportDirectory("html_" . $this->lang);
188 }
189
190 // get html content
191 $exp = new \ILIAS\LearningModule\Export\LMHtmlExport(
192 $this->cont_obj,
193 $this->export_dir,
194 $this->subdir,
195 "html",
196 $this->lang
197 );
198 $exp->exportHTML(true);
199 }

Referenced by buildExportFile().

+ Here is the caller graph for this function:

◆ buildExportFileXML()

ilContObjectExport::buildExportFileXML ( string  $a_mode = "")

build xml export file

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

100 : string {
101 if (in_array($a_mode, array("master", "masternomedia"))) {
102 $exp = new ilExport();
103 $conf = $exp->getConfig("Modules/LearningModule");
104 $conf->setMasterLanguageOnly(true, ($a_mode == "master"));
105 $exp->exportObject($this->cont_obj->getType(), $this->cont_obj->getId(), "5.1.0");
106 return "";
107 }
108
109 $this->xml = new ilXmlWriter();
110
111 // set dtd definition
112 $this->xml->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"https://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
113
114 // set generated comment
115 $this->xml->xmlSetGenCmt("Export of ILIAS Content Module " .
116 $this->cont_obj->getId() . " of installation " . $this->inst . ".");
117
118 // set xml header
119 $this->xml->xmlHeader();
120
121 // create directories
122 $this->cont_obj->createExportDirectory();
123 ilFileUtils::makeDir($this->export_dir . "/" . $this->subdir);
124 ilFileUtils::makeDir($this->export_dir . "/" . $this->subdir . "/objects");
125
126 // get Log File
127 $expDir = $this->cont_obj->getExportDirectory();
128 $expLog = new ilLog($expDir, "export.log");
129 $expLog->delete();
130 $expLog->setLogFormat("");
131 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
132
133 // get xml content
134 $this->cont_obj->exportXML(
135 $this->xml,
136 $this->inst_id,
137 $this->export_dir . "/" . $this->subdir,
138 $expLog
139 );
140
141 // export style
142 /*
143 if ($this->cont_obj->getStyleSheetId() > 0) {
144 $style_obj = new ilObjStyleSheet($this->cont_obj->getStyleSheetId(), false);
145 $style_obj->setExportSubDir("style");
146 $style_file = $style_obj->export();
147 if (is_file($style_file)) {
148 copy($style_file, $this->export_dir . "/" . $this->subdir . "/style.zip");
149 }
150 }*/
151
152 // dump xml document to file
153 $this->xml->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->filename, false);
154
155 // help export (workaround to use ref id here)
157 $this->cont_obj->getRefId()
158 )) {
159 $exp = new ilExport();
160 $exp->exportEntity(
161 "help",
162 $this->cont_obj->getId(),
163 "4.3.0",
164 "Services/Help",
165 "OnlineHelp",
166 $this->export_dir . "/" . $this->subdir
167 );
168 }
169
170 // zip the file
172 $this->export_dir . "/" . $this->subdir,
173 $this->export_dir . "/" . $this->subdir . ".zip"
174 );
175
176 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
177
178 return $this->export_dir . "/" . $this->subdir . ".zip";
179 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilLog.php:31
static isOnlineHelpModule(int $a_id, bool $a_as_obj_id=false)
Is module an online module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by buildExportFile().

+ Here is the caller graph for this function:

◆ getInstId()

ilContObjectExport::getInstId ( )

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

76 : int
77 {
78 return $this->inst_id;
79 }

References $inst_id.

Field Documentation

◆ $cont_obj

ilObjLearningModule ilContObjectExport::$cont_obj

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

◆ $db

ilDBInterface ilContObjectExport::$db

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

◆ $export_dir

string ilContObjectExport::$export_dir
protected

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

◆ $filename

string ilContObjectExport::$filename
protected

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

◆ $inst

int ilContObjectExport::$inst
protected

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

◆ $inst_id

int ilContObjectExport::$inst_id

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

Referenced by getInstId().

◆ $lang

string ilContObjectExport::$lang
protected

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

◆ $mode

string ilContObjectExport::$mode

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

◆ $subdir

string ilContObjectExport::$subdir
protected

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

◆ $xml

ilXmlWriter ilContObjectExport::$xml
protected

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


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