ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilGlossaryExport.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
25
36{
37 var $err; // error object
38 var $db; // database object
39 var $ilias; // ilias object
40 var $glo_obj; // glossary
41 var $inst_id; // installation id
42
47 function ilGlossaryExport(&$a_glo_obj, $a_mode = "xml")
48 {
49 global $ilErr, $ilDB, $ilias;
50
51 $this->glo_obj =& $a_glo_obj;
52
53 $this->err =& $ilErr;
54 $this->ilias =& $ilias;
55 $this->db =& $ilDB;
56 $this->mode = $a_mode;
57
58 $settings = $this->ilias->getAllSettings();
59 // The default '0' is required for the directory structure (smeyer)
60 $this->inst_id = $settings["inst_id"] ? $settings['inst_id'] : 0;
61
62 $date = time();
63 switch($this->mode)
64 {
65 case "xml":
66 $this->export_dir = $this->glo_obj->getExportDirectory();
67 $this->subdir = $date."__".$this->inst_id."__".
68 $this->glo_obj->getType()."_".$this->glo_obj->getId();
69 $this->filename = $this->subdir.".xml";
70 break;
71
72 case "html":
73 $this->export_dir = $this->glo_obj->getExportDirectory("html");
74 $this->subdir = $this->glo_obj->getType()."_".$this->glo_obj->getId();
75 $this->filename = $this->subdir.".zip";
76 break;
77
78 }
79
80 }
81
82 function getInstId()
83 {
84 return $this->inst_id;
85 }
86
93 function buildExportFile()
94 {
95 switch ($this->mode)
96 {
97 case "html":
98 return $this->buildExportFileHTML();
99 break;
100
101 default:
102 return $this->buildExportFileXML();
103 break;
104 }
105 }
106
111 {
112 global $ilBench;
113
114 $ilBench->start("GlossaryExport", "buildExportFile");
115
116 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
117
118 $this->xml = new ilXmlWriter;
119
120 // set dtd definition
121 $this->xml->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co_3_7.dtd\">");
122
123 // set generated comment
124 $this->xml->xmlSetGenCmt("Export of ILIAS Glossary ".
125 $this->glo_obj->getId()." of installation ".$this->inst.".");
126
127 // set xml header
128 $this->xml->xmlHeader();
129
130 // create directories
131 $this->glo_obj->createExportDirectory();
132 ilUtil::makeDir($this->export_dir."/".$this->subdir);
133 ilUtil::makeDir($this->export_dir."/".$this->subdir."/objects");
134
135 // get Log File
136 $expDir = $this->glo_obj->getExportDirectory();
137 include_once './Services/Logging/classes/class.ilLog.php';
138 $expLog = new ilLog($expDir, "export.log");
139 $expLog->delete();
140 $expLog->setLogFormat("");
141 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
142
143 // get xml content
144//echo "ContObjExport:".$this->inst_id.":<br>";
145 $ilBench->start("GlossaryExport", "buildExportFile_getXML");
146 $this->glo_obj->exportXML($this->xml, $this->inst_id,
147 $this->export_dir."/".$this->subdir, $expLog);
148 $ilBench->stop("GlossaryExport", "buildExportFile_getXML");
149
150 // dump xml document to screen (only for debugging reasons)
151 /*
152 echo "<PRE>";
153 echo htmlentities($this->xml->xmlDumpMem($format));
154 echo "</PRE>";
155 */
156
157
158 // dump xml document to file
159 $ilBench->start("GlossaryExport", "buildExportFile_dumpToFile");
160 $this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
161 , false);
162 $ilBench->stop("GlossaryExport", "buildExportFile_dumpToFile");
163
164 // zip the file
165 $ilBench->start("GlossaryExport", "buildExportFile_zipFile");
166 ilUtil::zip($this->export_dir."/".$this->subdir,
167 $this->export_dir."/".$this->subdir.".zip");
168 $ilBench->stop("GlossaryExport", "buildExportFile_zipFile");
169
170 // destroy writer object
171 $this->xml->_XmlWriter;
172
173 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
174 $ilBench->stop("GlossaryExport", "buildExportFile");
175
176 return $this->export_dir."/".$this->subdir.".zip";
177 }
178
183 {
184 global $ilBench;
185
186 // create directories
187 $this->glo_obj->createExportDirectory("html");
188
189 // get Log File
190 $expDir = $this->glo_obj->getExportDirectory();
191
192 // get xml content
193 $this->glo_obj->exportHTML($this->export_dir."/".$this->subdir, $expLog);
194 }
195
196}
197
198?>
Export class for content objects.
buildExportFile()
build export file (complete zip file)
buildExportFileHTML()
build html export file
ilGlossaryExport(&$a_glo_obj, $a_mode="xml")
Constructor @access public.
buildExportFileXML()
build export file (complete zip file)
logging
Definition: class.ilLog.php:19
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
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB