ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
24 require_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
25 
36 {
40  protected $settings;
41 
42  public $err; // error object
43  public $db; // database object
44  public $glo_obj; // glossary
45  public $inst_id; // installation id
46 
51  public function __construct(&$a_glo_obj, $a_mode = "xml")
52  {
53  global $DIC;
54 
55  $this->settings = $DIC->settings();
56  $ilErr = $DIC["ilErr"];
57  $ilDB = $DIC->database();
58  $ilSetting = $DIC->settings();
59 
60  $this->glo_obj = $a_glo_obj;
61 
62  $this->err = $ilErr;
63  $this->db = $ilDB;
64  $this->mode = $a_mode;
65 
66  $settings = $ilSetting->getAll();
67  // The default '0' is required for the directory structure (smeyer)
68  $this->inst_id = $settings["inst_id"] ? $settings['inst_id'] : 0;
69 
70  $date = time();
71  switch ($this->mode) {
72  case "xml":
73  $this->export_dir = $this->glo_obj->getExportDirectory();
74  $this->subdir = $date . "__" . $this->inst_id . "__" .
75  $this->glo_obj->getType() . "_" . $this->glo_obj->getId();
76  $this->filename = $this->subdir . ".xml";
77  break;
78 
79  case "html":
80  $this->export_dir = $this->glo_obj->getExportDirectory("html");
81  $this->subdir = $this->glo_obj->getType() . "_" . $this->glo_obj->getId();
82  $this->filename = $this->subdir . ".zip";
83  break;
84 
85  }
86  }
87 
88  public function getInstId()
89  {
90  return $this->inst_id;
91  }
92 
99  public function buildExportFile()
100  {
101  switch ($this->mode) {
102  case "html":
103  return $this->buildExportFileHTML();
104  break;
105 
106  default:
107  return $this->buildExportFileXML();
108  break;
109  }
110  }
111 
115  public function buildExportFileXML()
116  {
117  require_once("./Services/Xml/classes/class.ilXmlWriter.php");
118 
119  $this->xml = new ilXmlWriter;
120 
121  // set dtd definition
122  $this->xml->xmlSetDtdDef("<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co_3_7.dtd\">");
123 
124  // set generated comment
125  $this->xml->xmlSetGenCmt("Export of ILIAS Glossary " .
126  $this->glo_obj->getId() . " of installation " . $this->inst . ".");
127 
128  // set xml header
129  $this->xml->xmlHeader();
130 
131  // create directories
132  $this->glo_obj->createExportDirectory();
133  ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
134  ilUtil::makeDir($this->export_dir . "/" . $this->subdir . "/objects");
135 
136  // get Log File
137  $expDir = $this->glo_obj->getExportDirectory();
138  include_once './Services/Logging/classes/class.ilLog.php';
139  $expLog = new ilLog($expDir, "export.log");
140  $expLog->delete();
141  $expLog->setLogFormat("");
142  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
143 
144  // get xml content
145  $this->glo_obj->exportXML(
146  $this->xml,
147  $this->inst_id,
148  $this->export_dir . "/" . $this->subdir,
149  $expLog
150  );
151 
152 
153 
154  // dump xml document to file
155  $this->xml->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->filename, false);
156 
157  // zip the file
158  ilUtil::zip(
159  $this->export_dir . "/" . $this->subdir,
160  $this->export_dir . "/" . $this->subdir . ".zip"
161  );
162 
163  // destroy writer object
164  $this->xml->_XmlWriter;
165 
166  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
167 
168  return $this->export_dir . "/" . $this->subdir . ".zip";
169  }
170 
174  public function buildExportFileHTML()
175  {
176  // create directories
177  $this->glo_obj->createExportDirectory("html");
178 
179  // get Log File
180  $expDir = $this->glo_obj->getExportDirectory();
181 
182  // get xml content
183  $this->glo_obj->exportHTML($this->export_dir . "/" . $this->subdir, $expLog);
184  }
185 }
global $ilErr
Definition: raiseError.php:16
buildExportFileHTML()
build html export file
xmlSetDtdDef($dtdDef)
Sets dtd definition.
global $DIC
Definition: saml.php:7
XML writer class.
logging
Definition: class.ilLog.php:18
buildExportFileXML()
build export file (complete zip file)
buildExportFile()
build export file (complete zip file)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
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 ...
settings()
Definition: settings.php:2
global $ilSetting
Definition: privfeed.php:17
global $ilDB
__construct(&$a_glo_obj, $a_mode="xml")
Constructor public.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Export class for content objects.