ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilExportFileParser.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Xml/classes/class.ilSaxParser.php");
5include_once "./Services/Xml/classes/class.ilXmlWriter.php";
6
15{
16 protected $item_xml = "";
17
24 function __construct($a_file, $a_callback_obj, $a_callback_func)
25 {
26 $this->callback_obj = $a_callback_obj;
27 $this->callback_func = $a_callback_func;
28
29 parent::ilSaxParser($a_file, true);
30 $this->startParsing();
31 }
32
39 function setHandlers($a_xml_parser)
40 {
41 xml_set_object($a_xml_parser,$this);
42 xml_set_element_handler($a_xml_parser, 'handleBeginTag', 'handleEndTag');
43 xml_set_character_data_handler($a_xml_parser, 'handleCharacterData');
44 }
45
49 function startParsing()
50 {
51 parent::startParsing();
52 }
53
57 function handleBeginTag($a_xml_parser, $a_name, $a_attribs)
58 {
59 if ($this->in_export_item)
60 {
61 $this->export_item_writer->xmlStartTag($a_name, $a_attribs);
62 }
63
64 switch ($a_name)
65 {
66 case "exp:Export":
67 $this->entity = $a_attribs["Entity"];
68 $this->install_id = $a_attribs["InstallationId"];
69 $this->install_url = $a_attribs["InstallationUrl"];
70 $this->schema_version = $a_attribs["SchemaVersion"];
71 break;
72
73 case "exp:ExportItem":
74 $this->in_export_item = true;
75 $this->current_id = $a_attribs["Id"];
76
77 $this->export_item_writer = new ilXmlWriter();
78
79 $this->item_xml = "";
80 $this->expfiles[] = array("component" => $a_attribs["Component"],
81 "path" => $a_attribs["Path"]);
82 break;
83 }
84 }
85
89 function handleEndTag($a_xml_parser, $a_name)
90 {
91 switch ($a_name)
92 {
93 case "exp:ExportItem":
94 $this->in_export_item = false;
95 $cf = $this->callback_func;
96 $this->callback_obj->$cf($this->entity, $this->schema_version, $this->current_id,
97 $this->export_item_writer->xmlDumpMem(false), $this->install_id,
98 $this->install_url);
99 break;
100
101 }
102
103 if ($this->in_export_item)
104 {
105 $this->export_item_writer->xmlEndTag($a_name);
106 }
107
108
109 $this->chr_data = "";
110 }
111
115 function handleCharacterData($a_xml_parser,$a_data)
116 {
117 //$a_data = str_replace("<","&lt;",$a_data);
118 //$a_data = str_replace(">","&gt;",$a_data);
119 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
120 //$a_data = preg_replace("/\n/","",$a_data);
121 //$a_data = preg_replace("/\t+/","",$a_data);
122
123 $this->chr_data .= $a_data;
124
125 if ($this->in_export_item)
126 {
127 $this->export_item_writer->xmlData($a_data);
128 }
129 }
130
131}
132?>
handleCharacterData($a_xml_parser, $a_data)
End Tag.
handleEndTag($a_xml_parser, $a_name)
End Tag.
setHandlers($a_xml_parser)
Set event handlers.
handleBeginTag($a_xml_parser, $a_name, $a_attribs)
Begin Tag.
__construct($a_file, $a_callback_obj, $a_callback_func)
Constructor.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
XML writer class.