ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilFolderXmlParser.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 
5 include_once './Services/Xml/classes/class.ilSaxParser.php';
6 
16 {
17  private $folder = null;
18 
19 
23  public function __construct($folder,$xml)
24  {
26  $this->setXMLContent($xml);
27  $this->setFolder($folder);
28  $this->setThrowException(true);
29  }
30 
36  public function setFolder(ilObject $folder)
37  {
38  $this->folder = $folder;
39  }
40 
45  public function getFolder()
46  {
47  return $this->folder;
48  }
49 
50 
58  public function start()
59  {
60  return $this->startParsing();
61  }
62 
69  public function setHandlers($a_xml_parser)
70  {
71  xml_set_object($a_xml_parser,$this);
72  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
73  xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
74  }
75 
83  public function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
84  {
85  global $ilErr;
86 
87  switch($a_name)
88  {
89 
90  case 'Folder':
91  break;
92 
93 
94  case 'Sorting':
95  case 'Sort':
96  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
98  break;
99 
100  case 'Title':
101  case 'Description':
102  break;
103  }
104 
105  }
106 
115  public function handlerEndTag($a_xml_parser,$a_name)
116  {
117 
118  $GLOBALS['ilLog']->write(__METHOD__.': Called '.$a_name);
119 
120  switch($a_name)
121  {
122 
123  case 'Folder':
124  $this->getFolder()->update();
125  break;
126 
127  case 'Title':
128  $this->getFolder()->setTitle(trim($this->cdata));
129  break;
130 
131  case 'Description':
132  $this->getFolder()->setDescription(trim($this->cdata));
133  break;
134 
135  }
136 
137  // Reset cdata
138  $this->cdata = '';
139  }
140 
141 
142 
149  public function handlerCharacterData($a_xml_parser,$a_data)
150  {
151  if($a_data != "\n")
152  {
153  // Replace multiple tabs with one space
154  $a_data = preg_replace("/\t+/"," ",$a_data);
155  $this->cdata .= $a_data;
156  }
157  }
158 }
159 ?>