ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_once("./Services/Xml/classes/class.ilSaxParser.php");
5 include_once "./Services/Xml/classes/class.ilXmlWriter.php";
6 
15 {
16  protected $item_xml = "";
17 
24  public 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::__construct($a_file, true);
30  $this->startParsing();
31  }
32 
39  public 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  public function startParsing()
50  {
51  parent::startParsing();
52  }
53 
57  public function handleBeginTag($a_xml_parser, $a_name, $a_attribs)
58  {
59  if ($this->in_export_item) {
60  $this->export_item_writer->xmlStartTag($a_name, $a_attribs);
61  }
62 
63  switch ($a_name) {
64  case "exp:Export":
65  $this->entity = $a_attribs["Entity"];
66  $this->install_id = $a_attribs["InstallationId"];
67  $this->install_url = $a_attribs["InstallationUrl"];
68  $this->schema_version = $a_attribs["SchemaVersion"];
69  break;
70 
71  case "exp:ExportItem":
72  $this->in_export_item = true;
73  $this->current_id = $a_attribs["Id"];
74 
75  $this->export_item_writer = new ilXmlWriter();
76 
77  $this->item_xml = "";
78  $this->expfiles[] = array("component" => $a_attribs["Component"],
79  "path" => $a_attribs["Path"]);
80  break;
81  }
82  }
83 
87  public function handleEndTag($a_xml_parser, $a_name)
88  {
89  switch ($a_name) {
90  case "exp:ExportItem":
91  $this->in_export_item = false;
92  $cf = $this->callback_func;
93  $this->callback_obj->$cf(
94  $this->entity,
95  $this->schema_version,
96  $this->current_id,
97  $this->export_item_writer->xmlDumpMem(false),
98  $this->install_id,
99  $this->install_url
100  );
101  break;
102 
103  }
104 
105  if ($this->in_export_item) {
106  $this->export_item_writer->xmlEndTag($a_name);
107  }
108 
109 
110  $this->chr_data = "";
111  }
112 
116  public function handleCharacterData($a_xml_parser, $a_data)
117  {
118  //$a_data = str_replace("<","&lt;",$a_data);
119  //$a_data = str_replace(">","&gt;",$a_data);
120  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
121  //$a_data = preg_replace("/\n/","",$a_data);
122  //$a_data = preg_replace("/\t+/","",$a_data);
123 
124  $this->chr_data .= $a_data;
125 
126  if ($this->in_export_item) {
127  $this->export_item_writer->xmlData($a_data);
128  }
129  }
130 }
__construct($a_file, $a_callback_obj, $a_callback_func)
Constructor.
handleCharacterData($a_xml_parser, $a_data)
End Tag.
handleEndTag($a_xml_parser, $a_name)
End Tag.
XML writer class.
setHandlers($a_xml_parser)
Set event handlers.
handleBeginTag($a_xml_parser, $a_name, $a_attribs)
Begin Tag.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
Create styles array
The data for the language used.