17 include_once
'classes/class.ilSaxParser.php';
18 include_once
'Modules/File/classes/class.ilFileException.php';
19 include_once
'Services/Utilities/classes/class.ilFileUtils.php';
89 $this->result =
false;
100 $this->importDirectory = $a_val;
110 return $this->importDirectory;
120 xml_set_object($a_xml_parser,$this);
121 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
122 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
143 if (isset($a_attribs[
"obj_id"]))
146 if ($this->obj_id != -1 && (
int) $read_obj_id != -1 && (
int) $this->obj_id != (
int) $read_obj_id)
151 if (isset($a_attribs[
"type"]))
153 $this->file->setFileType($a_attribs[
"type"]);
155 $this->file->setVersion($this->file->getVersion() + 1);
160 $this->isReadingFile =
true;
161 #echo $a_attribs["mode"];
162 if (isset($a_attribs[
"mode"]))
164 if($a_attribs[
"mode"] ==
"GZIP")
166 if (!function_exists(
"gzread"))
171 elseif ($a_attribs[
"mode"] ==
"ZLIB")
173 if (!function_exists(
"gzuncompress"))
178 elseif ($a_attribs[
"mode"] ==
"COPY")
197 $this->cdata = trim($this->cdata);
202 $this->result =
true;
205 if (strlen($this->cdata) == 0)
208 $this->file->setFilename($this->cdata);
209 $this->file->setTitle($this->cdata);
213 $this->file->setTitle(trim($this->cdata));
216 $this->file->setDescription(trim($this->cdata));
219 $this->isReadingFile =
false;
237 unlink ($baseDecodedFilename);
245 unlink ($baseDecodedFilename);
249 $this->tmpFilename = $baseDecodedFilename;
253 $this->file->setFileSize(filesize($this->tmpFilename));
256 if(!$this->file->getFileType())
260 #$ilLog->write(__METHOD__.': Trying to detect mime type...');
261 include_once(
'./Services/Utilities/classes/class.ilFileUtils.php');
285 $handle = fopen ($this->tmpFilename,
"a");
289 $this->cdata .= $a_data;
302 #$ilLog->write(__METHOD__.' '.filesize($this->tmpFilename));
304 if (filesize ($this->tmpFilename) == 0) {
308 $filedir = $this->file->getDirectory($this->file->getVersion());
309 #$ilLog->write(__METHOD__.' '.$filedir);
311 if (!is_dir($filedir))
313 $this->file->createDirectory();
317 $filename = $filedir.
"/".$this->file->getFileName();
321 return rename($this->tmpFilename,
$filename);
335 require_once(
"classes/class.ilHistory.php");
336 ilHistory::_createEntry($this->file->getId(),
"replace", $this->file->getFilename().
",".$this->file->getVersion());
337 $this->file->addNewsNotification(
"file_updated");
350 return $this->result > 0;