36 include_once
'classes/class.ilSaxParser.php';
37 include_once
'Modules/File/classes/class.ilFileException.php';
38 include_once
'Services/Utilities/classes/class.ilFileUtils.php';
107 $this->result =
false;
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"])) {
163 if ($a_attribs[
"mode"] ==
"GZIP")
165 if (!function_exists(
"gzread"))
169 }
elseif ($a_attribs[
"mode"] ==
"ZLIB")
171 if (!function_exists(
"gzuncompress"))
191 $this->cdata = trim($this->cdata);
195 $this->result =
true;
198 if (strlen($this->cdata) == 0)
201 $this->file->setFilename($this->cdata);
202 $this->file->setTitle($this->cdata);
206 $this->file->setTitle(trim($this->cdata));
209 $this->file->setDescription(trim($this->cdata));
212 $this->isReadingFile =
false;
224 unlink ($baseDecodedFilename);
232 unlink ($baseDecodedFilename);
236 $this->tmpFilename = $baseDecodedFilename;
239 $this->file->setFileSize(filesize($this->tmpFilename));
242 if(!$this->file->getFileType())
246 #$ilLog->write(__METHOD__.': Trying to detect mime type...');
247 include_once(
'./Services/Utilities/classes/class.ilFileUtils.php');
269 if ($this->isReadingFile)
271 $handle = fopen ($this->tmpFilename,
"a");
272 fwrite ($handle, $a_data);
275 $this->cdata .= $a_data;
288 #$ilLog->write(__METHOD__.' '.filesize($this->tmpFilename));
290 if (filesize ($this->tmpFilename) == 0) {
294 $filedir = $this->file->getDirectory($this->file->getVersion());
295 #$ilLog->write(__METHOD__.' '.$filedir);
297 if (!is_dir($filedir))
299 $this->file->createDirectory();
303 $filename = $filedir.
"/".$this->file->getFileName();
306 return rename($this->tmpFilename,
$filename);
320 require_once(
"classes/class.ilHistory.php");
321 ilHistory::_createEntry($this->file->getId(),
"replace", $this->file->getFilename().
",".$this->file->getVersion());
322 $this->file->addNewsNotification(
"file_updated");
335 return $this->result > 0;