Public Member Functions | Data Fields | Static Public Attributes

ilFileXMLWriter Class Reference

XML writer class. More...

Inheritance diagram for ilFileXMLWriter:
Collaboration diagram for ilFileXMLWriter:

Public Member Functions

 ilFileXMLWriter ()
 constructor
 setFile (ilObjFile $file)
 setAttachFileContents ($attachFileContents)
 set attachment content mode
 start ()
 getXML ()
 __buildHeader ()
 __buildFooter ()

Data Fields

 $attachFileContents
 $file

Static Public Attributes

static $CONTENT_ATTACH_NO = 0
static $CONTENT_ATTACH_ENCODED = 1
static $CONTENT_ATTACH_ZLIB_ENCODED = 2
static $CONTENT_ATTACH_GZIP_ENCODED = 3

Detailed Description

XML writer class.

Class to simplify manual writing of xml documents. It only supports writing xml sequentially, because the xml document is saved in a string with no additional structure information. The author is responsible for well-formedness and validity of the xml document.

Author:
Roland Küstermann <Roland@kuestermann.com>
Version:
Id:
class.ilExerciseXMLWriter.php,v 1.3 2005/11/04 12:50:24 smeyer Exp

Definition at line 43 of file class.ilFileXMLWriter.php.


Member Function Documentation

ilFileXMLWriter::__buildFooter (  ) 

Definition at line 187 of file class.ilFileXMLWriter.php.

Referenced by start().

        {

        }

Here is the caller graph for this function:

ilFileXMLWriter::__buildHeader (  ) 

Definition at line 178 of file class.ilFileXMLWriter.php.

References ilXmlWriter::xmlHeader(), ilXmlWriter::xmlSetDtdDef(), and ilXmlWriter::xmlSetGenCmt().

Referenced by start().

        {
                $this->xmlSetDtdDef("<!DOCTYPE Exercise PUBLIC \"-//ILIAS//DTD FileAdministration//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_file_3_8.dtd\">");
                $this->xmlSetGenCmt("Exercise Object");
                $this->xmlHeader();

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilFileXMLWriter::getXML (  ) 

Definition at line 172 of file class.ilFileXMLWriter.php.

References ilXmlWriter::xmlDumpMem().

        {
                return $this->xmlDumpMem(FALSE);
        }

Here is the call graph for this function:

ilFileXMLWriter::ilFileXMLWriter (  ) 

constructor

Parameters:
string xml version
string output encoding
string input encoding public

Definition at line 70 of file class.ilFileXMLWriter.php.

References $CONTENT_ATTACH_NO, and ilXmlWriter::ilXmlWriter().

        {
                parent::ilXmlWriter();
                $this->attachFileContents = ilFileXMLWriter::$CONTENT_ATTACH_NO;
        }

Here is the call graph for this function:

ilFileXMLWriter::setAttachFileContents ( attachFileContents  ) 

set attachment content mode

Parameters:
int $attachFileContents
Exceptions:
ilExerciseException if mode is not supported

Definition at line 91 of file class.ilFileXMLWriter.php.

References $attachFileContents, $CONTENT_ATTACH_GZIP_ENCODED, $CONTENT_ATTACH_ZLIB_ENCODED, and ilFileException::$ID_DEFLATE_METHOD_MISMATCH.

        {
                 if ($attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED && !function_exists("gzencode"))
                 {
                      throw new ilFileException ("Inflating with gzip is not supported", ilFileException::$ID_DEFLATE_METHOD_MISMATCH);
         }
         if ($attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED && !function_exists("gzcompress"))
         {
            throw new ilFileException ("Inflating with zlib (compress/uncompress) is not supported", ilFileException::$ID_DEFLATE_METHOD_MISMATCH);
         }
             $this->attachFileContents = $attachFileContents;
        }

ilFileXMLWriter::setFile ( ilObjFile file  ) 

Definition at line 77 of file class.ilFileXMLWriter.php.

        {
                $this->file = & $file;
        }

ilFileXMLWriter::start (  ) 

Definition at line 105 of file class.ilFileXMLWriter.php.

References $CONTENT_ATTACH_GZIP_ENCODED, $CONTENT_ATTACH_ZLIB_ENCODED, $filename, ilXmlWriter::$version, __buildFooter(), __buildHeader(), ilHistory::_getEntriesForObject(), ilUtil::date_mysql2time(), ilXmlWriter::xmlElement(), ilXmlWriter::xmlEndTag(), and ilXmlWriter::xmlStartTag().

        {
                $this->__buildHeader();

                $attribs =array (
                  "obj_id" => "il_".IL_INST_ID."_file_".$this->file->getId(),
                  "version" => $this->file->getVersion(),
                  "size" => $this->file->getFileSize(),
                  "type" => $this->file->getFileType()
                );

        $this->xmlStartTag("File", $attribs);
        $this->xmlElement("Filename",null,$this->file->getFileName());

                $this->xmlElement("Title",  null,$this->file->getTitle());
        $this->xmlElement("Description",  null,$this->file->getDescription());


        if ($this->attachFileContents)
        {
            $filename = $this->file->getDirectory($this->file->getVersion())."/".$this->file->getFileName();
            if (@is_file($filename))
            {
                $content = @file_get_contents($filename);
                $attribs = array("mode" =>"PLAIN");
                if ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED)
                {
                    $attribs ["mode"] ="ZLIB";
                    $content = @gzcompress($content, 9);
                }elseif ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED)
                {
                    $attribs ["mode"] ="GZIP";
                    $content = @gzencode($content, 9);
                }
                $content = base64_encode($content);
                $this->xmlElement("Content",$attribs, $content);
            }

        }

        include_once("classes/class.ilHistory.php");

                $versions = ilHistory::_getEntriesForObject($this->file->getId(), $this->file->getType());

                if (count($versions)) {
                    $this->xmlStartTag("Versions");
                    foreach ($versions as $version) {
                        $info_params = $version["info_params"];
                        list($filename,$history_id) = split(",",$info_params);
                        $attribs = array (
                          "id" => $history_id,
                          "date" => ilUtil::date_mysql2time($version["date"]),
                          "usr_id" => "il_".IL_INST_ID."_usr_".$version["user_id"]
                        );
                        $this->xmlElement("Version", $attribs);
                    }
            $this->xmlEndTag("Versions");

                }

        $this->xmlEndTag("File");

                $this->__buildFooter();

                return true;
        }

Here is the call graph for this function:


Field Documentation

ilFileXMLWriter::$attachFileContents

Definition at line 54 of file class.ilFileXMLWriter.php.

Referenced by setAttachFileContents().

ilFileXMLWriter::$CONTENT_ATTACH_ENCODED = 1 [static]

Definition at line 46 of file class.ilFileXMLWriter.php.

ilFileXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED = 3 [static]

Definition at line 48 of file class.ilFileXMLWriter.php.

Referenced by setAttachFileContents(), and start().

ilFileXMLWriter::$CONTENT_ATTACH_NO = 0 [static]

Definition at line 45 of file class.ilFileXMLWriter.php.

Referenced by ilFileXMLWriter().

ilFileXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED = 2 [static]

Definition at line 47 of file class.ilFileXMLWriter.php.

Referenced by setAttachFileContents(), and start().

ilFileXMLWriter::$file

Definition at line 61 of file class.ilFileXMLWriter.php.


The documentation for this class was generated from the following file: