17 include_once
'./Services/Xml/classes/class.ilSaxParser.php';
18 include_once
'Modules/File/classes/class.ilFileException.php';
19 include_once
'Services/Utilities/classes/class.ilFileUtils.php';
92 $this->result =
false;
103 $this->importDirectory = $a_val;
113 return $this->importDirectory;
123 xml_set_object($a_xml_parser,$this);
124 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
125 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
146 if (isset($a_attribs[
"obj_id"]))
149 if ($this->obj_id != -1 && (
int) $read_obj_id != -1 && (
int) $this->obj_id != (
int) $read_obj_id)
154 if (isset($a_attribs[
"type"]))
156 $this->file->setFileType($a_attribs[
"type"]);
158 $this->file->setVersion($this->file->getVersion() + 1);
163 $this->isReadingFile =
true;
164 #echo $a_attribs["mode"];
165 if (isset($a_attribs[
"mode"]))
167 if($a_attribs[
"mode"] ==
"GZIP")
169 if (!function_exists(
"gzread"))
174 elseif ($a_attribs[
"mode"] ==
"ZLIB")
176 if (!function_exists(
"gzuncompress"))
181 elseif ($a_attribs[
"mode"] ==
"COPY")
186 elseif($a_attribs[
'mode'] ==
'REST')
205 $this->cdata = trim($this->cdata);
207 $GLOBALS[
'ilLog']->write(__METHOD__.
': '.$this->cdata);
212 $this->result =
true;
215 if (strlen($this->cdata) == 0)
218 $this->file->setFilename($this->cdata);
219 $this->file->setTitle($this->cdata);
223 $this->file->setTitle(trim($this->cdata));
226 $this->file->setDescription(trim($this->cdata));
229 $GLOBALS[
'ilLog']->write($this->mode);
230 $this->isReadingFile =
false;
239 include_once
'./Services/WebServices/Rest/classes/class.ilRestFileStorage.php';
241 $this->tmpFilename = $storage->getStoredFilePath($this->cdata);
246 $this->tmpFilename = $baseDecodedFilename;
261 unlink ($baseDecodedFilename);
269 unlink ($baseDecodedFilename);
273 $this->tmpFilename = $baseDecodedFilename;
277 $this->file->setFileSize(filesize($this->tmpFilename));
280 if(!$this->file->getFileType())
284 #$ilLog->write(__METHOD__.': Trying to detect mime type...');
285 include_once(
'./Services/Utilities/classes/class.ilFileUtils.php');
311 $handle = fopen($this->tmpFilename,
"a");
312 fwrite ($handle, $a_data);
315 $this->cdata .= $a_data;
328 #$ilLog->write(__METHOD__.' '.filesize($this->tmpFilename));
330 if (filesize ($this->tmpFilename) == 0) {
334 $filedir = $this->file->getDirectory($this->file->getVersion());
335 #$ilLog->write(__METHOD__.' '.$filedir);
337 if (!is_dir($filedir))
339 $this->file->createDirectory();
343 $filename = $filedir.
"/".$this->file->getFileName();
347 return rename($this->tmpFilename,
$filename);
361 require_once(
"./Services/History/classes/class.ilHistory.php");
362 ilHistory::_createEntry($this->file->getId(),
"replace", $this->file->getFilename().
",".$this->file->getVersion());
363 $this->file->addNewsNotification(
"file_updated");
376 return $this->result > 0;