16include_once 
'./Services/Xml/classes/class.ilSaxParser.php';
 
   17include_once 
'Modules/File/classes/class.ilFileException.php';
 
   18include_once 
'Services/Utilities/classes/class.ilFileUtils.php';
 
   80        parent::__construct();
 
   84        $this->result = 
false;
 
   96        $this->importDirectory = $a_val;
 
  107        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');
 
  146                if (isset($a_attribs[
"obj_id"])) {
 
  148                    if ($this->obj_id != -1 && (
int) $read_obj_id != -1 && (
int) $this->obj_id != (
int) $read_obj_id) {
 
  152                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") {
 
  164                        if (!function_exists(
"gzread")) {
 
  169                    } elseif ($a_attribs[
"mode"] == 
"ZLIB") {
 
  170                        if (!function_exists(
"gzuncompress")) {
 
  175                    } elseif ($a_attribs[
"mode"] == 
"COPY") {
 
  178                    elseif ($a_attribs[
'mode'] == 
'REST') {
 
  195        $this->cdata = trim($this->cdata);
 
  197        $GLOBALS[
'DIC'][
'ilLog']->write(__METHOD__ . 
': ' . $this->cdata);
 
  201                $this->result = 
true;
 
  204                if (strlen($this->cdata) == 0) {
 
  208                $this->file->setFilename(basename(self::normalizeRelativePath($this->cdata)));
 
  209                $this->file->setTitle($this->cdata);
 
  213                $this->file->setTitle(trim($this->cdata));
 
  216                $this->file->setDescription(trim($this->cdata));
 
  219                $this->file->setRating((
bool) $this->cdata);
 
  222                $GLOBALS[
'DIC'][
'ilLog']->write($this->mode);
 
  223                $this->isReadingFile = 
false;
 
  229                    include_once 
'./Services/WebServices/Rest/classes/class.ilRestFileStorage.php';
 
  231                    $this->tmpFilename = $storage->getStoredFilePath(self::normalizeRelativePath($this->cdata));
 
  235                    $this->tmpFilename = $baseDecodedFilename;
 
  245                        unlink($baseDecodedFilename);
 
  250                        unlink($baseDecodedFilename);
 
  252                        $this->tmpFilename = $baseDecodedFilename;
 
  257                if (is_file($this->tmpFilename)) {
 
  258                    $this->file->setFileSize(filesize($this->tmpFilename)); 
 
  262                if (!$this->file->getFileType()) {
 
  266                    #$ilLog->write(__METHOD__.': Trying to detect mime type...'); 
  267                    include_once(
'./Services/Utilities/classes/class.ilFileUtils.php');
 
  288        if ($a_data != 
"\n") {
 
  291                $handle = fopen($this->tmpFilename, 
"a");
 
  292                fwrite($handle, $a_data);
 
  295                $this->cdata .= $a_data;
 
  308        if (!file_exists($this->tmpFilename)) {
 
  314        if (filesize($this->tmpFilename) == 0) {
 
  318        $filedir = $this->file->getDirectory($this->file->getVersion());
 
  320        if (!is_dir($filedir)) {
 
  321            $this->file->createDirectory();
 
  325        $filename = $filedir . 
"/" . $this->file->getFileName();
 
  343            require_once(
"./Services/History/classes/class.ilHistory.php");
 
  344            ilHistory::_createEntry($this->file->getId(), 
"replace", $this->file->getFilename() . 
"," . $this->file->getVersion());
 
  345            $this->file->addNewsNotification(
"file_updated");
 
  361        return $this->result > 0;
 
  381        while (preg_match(
'#\p{C}+|^\./#u', 
$path)) {
 
  382            $path = preg_replace(
'#\p{C}+|^\./#u', 
'', 
$path);
 
  386        foreach (explode(
'/', 
$path) as $part) {
 
  400        return implode(
'/', $parts);
 
An exception for terminatinating execution or to throw for unit testing.
Class to report exception.
static $ID_DEFLATE_METHOD_MISMATCH
static $DECOMPRESSION_FAILED
fastGunzip($in, $out)
fast uncompressing the file with the zlib-extension without memory consumption
static _lookupMimeType($a_file)
static fastBase64Decode($filein, $fileout)
decodes base encoded file row by row to prevent memory exhaust
static rename($a_source, $a_target)
Rename a file.
Exercise XML Parser which completes/updates a given file by an xml string.
getImportDirectory()
Get import directory.
setHandlers($a_xml_parser)
set event handlers
setFileContents()
update file according to filename and version, does not update history has to be called after (!...
updateFileContents()
update file according to filename and version and create history entry has to be called after (!...
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
__construct(&$file, $a_xml_data, $obj_id=-1, $mode=0)
Constructor.
static $CONTENT_ZLIB_COMPRESSED
setImportDirectory($a_val)
Set import directory.
start()
starts parsing an changes object by side effect.
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
static $CONTENT_GZ_COMPRESSED
static $CONTENT_NOT_COMPRESSED
static normalizeRelativePath($path)
Normalize relative directories in a path.
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 getLogger($a_component_id)
Get component logger.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
setXMLContent($a_xml_content)
startParsing()
stores xml data in array
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.