ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
5include_once './Services/Xml/classes/class.ilSaxParser.php';
6
16{
20 protected $error;
21
22 private $folder = null;
23
24
28 public function __construct($folder, $xml)
29 {
30 global $DIC;
31
32 $this->error = $DIC["ilErr"];
33 parent::__construct();
34 $this->setXMLContent($xml);
35 $this->setFolder($folder);
36 $this->setThrowException(true);
37 }
38
44 public function setFolder(ilObject $folder)
45 {
46 $this->folder = $folder;
47 }
48
53 public function getFolder()
54 {
55 return $this->folder;
56 }
57
58
66 public function start()
67 {
68 return $this->startParsing();
69 }
70
77 public function setHandlers($a_xml_parser)
78 {
79 xml_set_object($a_xml_parser, $this);
80 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
81 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
82 }
83
91 public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
92 {
94
95 switch ($a_name) {
96
97 case 'Folder':
98 break;
99
100
101 case 'Sorting':
102 case 'Sort':
103 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
105 break;
106
107 case 'Title':
108 case 'Description':
109 break;
110 }
111 }
112
121 public function handlerEndTag($a_xml_parser, $a_name)
122 {
123 $GLOBALS['ilLog']->write(__METHOD__ . ': Called ' . $a_name);
124
125 switch ($a_name) {
126
127 case 'Folder':
128 $this->getFolder()->update();
129 break;
130
131 case 'Title':
132 $this->getFolder()->setTitle(trim($this->cdata));
133 break;
134
135 case 'Description':
136 $this->getFolder()->setDescription(trim($this->cdata));
137 break;
138
139 }
140
141 // Reset cdata
142 $this->cdata = '';
143 }
144
145
146
153 public function handlerCharacterData($a_xml_parser, $a_data)
154 {
155 if ($a_data != "\n") {
156 // Replace multiple tabs with one space
157 $a_data = preg_replace("/\t+/", " ", $a_data);
158 $this->cdata .= $a_data;
159 }
160 }
161}
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
static _importContainerSortingSettings($attibs, $obj_id)
sorting import for all container objects
XML parser for folder xml.
getFolder()
Get folder object.
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
setFolder(ilObject $folder)
set weblink
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
setHandlers($a_xml_parser)
set event handlers
__construct($folder, $xml)
Constructor.
Class ilObject Basic functions for all objects.
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
setThrowException($throwException)
set error handling
setXMLContent($a_xml_content)
startParsing()
stores xml data in array
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$xml
Definition: metadata.php:240
global $ilErr
Definition: raiseError.php:16
global $DIC
Definition: saml.php:7