ILIAS  release_4-3 Revision
 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 
96  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
97  $sort = new ilContainerSortingSettings($this->getFolder()->getId());
98  $sort->delete();
99 
100  switch($a_attribs['type'])
101  {
102  case 'Manual':
103  $sort->setSortMode(ilContainer::SORT_MANUAL);
104  break;
105 
106  case 'Title':
107  default:
108  $sort->setSortMode(ilContainer::SORT_TITLE);
109  }
110  $sort->save();
111  break;
112 
113  case 'Title':
114  case 'Description':
115  break;
116  }
117 
118  }
119 
128  public function handlerEndTag($a_xml_parser,$a_name)
129  {
130 
131  $GLOBALS['ilLog']->write(__METHOD__.': Called '.$a_name);
132 
133  switch($a_name)
134  {
135 
136  case 'Folder':
137  $this->getFolder()->update();
138  break;
139 
140  case 'Title':
141  $this->getFolder()->setTitle(trim($this->cdata));
142  break;
143 
144  case 'Description':
145  $this->getFolder()->setDescription(trim($this->cdata));
146  break;
147 
148  }
149 
150  // Reset cdata
151  $this->cdata = '';
152  }
153 
154 
155 
162  public function handlerCharacterData($a_xml_parser,$a_data)
163  {
164  if($a_data != "\n")
165  {
166  // Replace multiple tabs with one space
167  $a_data = preg_replace("/\t+/"," ",$a_data);
168  $this->cdata .= $a_data;
169  }
170  }
171 }
172 ?>