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';
86 function __construct(& $file, $a_xml_data, $obj_id = -1, $mode = 0)
88 parent::__construct();
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"]);
162 $this->isReadingFile =
true;
163 #echo $a_attribs["mode"]; 164 if (isset($a_attribs[
"mode"]))
166 if($a_attribs[
"mode"] ==
"GZIP")
168 if (!function_exists(
"gzread"))
173 elseif ($a_attribs[
"mode"] ==
"ZLIB")
175 if (!function_exists(
"gzuncompress"))
180 elseif ($a_attribs[
"mode"] ==
"COPY")
185 elseif($a_attribs[
'mode'] ==
'REST')
204 $this->cdata = trim($this->cdata);
206 $GLOBALS[
'ilLog']->write(__METHOD__.
': '.$this->cdata);
211 $this->result =
true;
214 if (strlen($this->cdata) == 0)
217 $this->
file->setFilename(basename(self::normalizeRelativePath($this->cdata)));
218 $this->
file->setTitle($this->cdata);
222 $this->
file->setTitle(trim($this->cdata));
225 $this->
file->setDescription(trim($this->cdata));
228 $this->
file->setRating((
bool)$this->cdata);
231 $GLOBALS[
'ilLog']->write($this->mode);
232 $this->isReadingFile =
false;
236 $this->tmpFilename = $this->
getImportDirectory().
"/".self::normalizeRelativePath($this->cdata);
241 include_once
'./Services/WebServices/Rest/classes/class.ilRestFileStorage.php';
243 $this->tmpFilename = $storage->getStoredFilePath(self::normalizeRelativePath($this->cdata));
248 $this->tmpFilename = $baseDecodedFilename;
263 unlink ($baseDecodedFilename);
271 unlink ($baseDecodedFilename);
275 $this->tmpFilename = $baseDecodedFilename;
280 if (is_file($this->tmpFilename))
282 $this->
file->setFileSize(filesize($this->tmpFilename));
286 if(!$this->
file->getFileType())
290 #$ilLog->write(__METHOD__.': Trying to detect mime type...'); 291 include_once(
'./Services/Utilities/classes/class.ilFileUtils.php');
317 $handle = fopen($this->tmpFilename,
"a");
318 fwrite ($handle, $a_data);
321 $this->cdata .= $a_data;
332 if(!file_exists($this->tmpFilename))
338 if (filesize ($this->tmpFilename) == 0) {
342 $filedir = $this->
file->getDirectory($this->
file->getVersion());
344 if (!is_dir($filedir))
346 $this->
file->createDirectory();
354 require_once(
'./Services/Utilities/classes/class.ilFileUtils.php');
368 require_once(
"./Services/History/classes/class.ilHistory.php");
370 $this->
file->addNewsNotification(
"file_updated");
383 return $this->result > 0;
402 while (preg_match(
'#\p{C}+|^\./#u',
$path)) {
403 $path = preg_replace(
'#\p{C}+|^\./#u',
'',
$path);
407 foreach (explode(
'/',
$path) as $part) {
421 return implode(
'/', $parts);
setImportDirectory($a_val)
Set import directory.
static $DECOMPRESSION_FAILED
static normalizeRelativePath($path)
Normalize relative directories in a path.
startParsing()
stores xml data in array
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Exercise XML Parser which completes/updates a given file by an xml string.
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
start()
starts parsing an changes object by side effect.
static _lookupMimeType($a_file)
static rename($a_source, $a_target)
Rename a file.
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
static $CONTENT_ZLIB_COMPRESSED
__construct(& $file, $a_xml_data, $obj_id=-1, $mode=0)
Constructor.
Class to report exception.
Reload workbook from saved file
static _createEntry($a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static $ID_DEFLATE_METHOD_MISMATCH
setHandlers($a_xml_parser)
set event handlers
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
static $CONTENT_GZ_COMPRESSED
fastBase64Decode($filein, $fileout)
decodes base encoded file row by row to prevent memory exhaust
updateFileContents()
update file according to filename and version and create history entry has to be called after (!) fil...
static getLogger($a_component_id)
Get component logger.
fastGunzip($in, $out)
fast uncompressing the file with the zlib-extension without memory consumption
getImportDirectory()
Get import directory.
setXMLContent($a_xml_content)
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
static $CONTENT_NOT_COMPRESSED
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
setFileContents()
update file according to filename and version, does not update history has to be called after (!) fil...