ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilCategoryXmlParser Class Reference

Group Import Parser. More...

+ Inheritance diagram for ilCategoryXmlParser:
+ Collaboration diagram for ilCategoryXmlParser:

Public Member Functions

 __construct ($a_xml, $a_parent_id)
 Constructor. More...
 
 getParentId ()
 Get parent id. More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access private More...
 
 startParsing ()
 start the parser More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 Handler end tag. More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 setMode ($mode)
 Set import mode. More...
 
 setCategory ($cat)
 Set category object. More...
 
 getCategory ()
 
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object @access public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

const MODE_CREATE = 1
 
const MODE_UPDATE = 2
 
- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Protected Member Functions

 getCurrentTranslation ()
 Get current translation. More...
 
 save ()
 Save category object. More...
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Private Attributes

 $cat = null
 
 $parent_id = 0
 
 $current_translation = array()
 
 $current_container_setting
 

Detailed Description

Group Import Parser.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 38 of file class.ilCategoryXmlParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilCategoryXmlParser::__construct (   $a_xml,
  $a_parent_id 
)

Constructor.

Parameters
string$a_xml_filexml file

@access public

Definition at line 58 of file class.ilCategoryXmlParser.php.

59 {
60 parent::__construct(null);
61
63 $this->parent_id = $a_parent_id;
64 $this->setXMLContent($a_xml);
65 }
setXMLContent($a_xml_content)

References MODE_CREATE, and ilSaxParser\setXMLContent().

+ Here is the call graph for this function:

Member Function Documentation

◆ getCategory()

ilCategoryXmlParser::getCategory ( )

Definition at line 265 of file class.ilCategoryXmlParser.php.

References $cat.

Referenced by handlerBeginTag(), handlerEndTag(), and save().

+ Here is the caller graph for this function:

◆ getCurrentTranslation()

ilCategoryXmlParser::getCurrentTranslation ( )
protected

Get current translation.

Definition at line 79 of file class.ilCategoryXmlParser.php.

References $current_translation.

◆ getParentId()

ilCategoryXmlParser::getParentId ( )

Get parent id.

Returns
type

Definition at line 71 of file class.ilCategoryXmlParser.php.

References $parent_id.

Referenced by save().

+ Here is the caller graph for this function:

◆ handlerBeginTag()

ilCategoryXmlParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Definition at line 119 of file class.ilCategoryXmlParser.php.

120 {
121 global $ilErr;
122
123 switch($a_name)
124 {
125 case "Category":
126 break;
127
128 case 'Translations':
129 $this->getCategory()->removeTranslations();
130 break;
131
132 case 'Translation':
133 $this->current_translation = array();
134 $this->current_translation['default'] = $a_attribs['default'] ? 1 : 0;
135 $this->current_translation['lang'] = $a_attribs['language'];
136 break;
137
138 case 'Sorting':
139 case 'Sort':
140 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
142 break;
143
144 case 'ContainerSetting':
145 $this->current_container_setting = $a_attribs['id'];
146 break;
147 }
148 }
static _importContainerSortingSettings($attibs, $obj_id)
sorting import for all container objects

References $ilErr, ilContainerSortingSettings\_importContainerSortingSettings(), and getCategory().

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilCategoryXmlParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 211 of file class.ilCategoryXmlParser.php.

212 {
213 #$a_data = str_replace("<","&lt;",$a_data);
214 #$a_data = str_replace(">","&gt;",$a_data);
215
216 if(!empty($a_data))
217 {
218 $this->cdata .= $a_data;
219 }
220 }

◆ handlerEndTag()

ilCategoryXmlParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

Handler end tag.

Parameters
type$a_xml_parser
type$a_name

Definition at line 156 of file class.ilCategoryXmlParser.php.

157 {
158 switch($a_name)
159 {
160 case "Category":
161 $this->save();
162 break;
163
164 case 'Title':
165 $this->current_translation['title'] = trim($this->cdata);
166
167 if($this->current_translation['default'])
168 {
169 $this->getCategory()->setTitle(trim($this->cdata));
170 }
171
172 break;
173
174 case 'Description':
175 $this->current_translation['description'] = trim($this->cdata);
176
177 if($this->current_translation['default'])
178 {
179 $this->getCategory()->setDescription(trim($this->cdata));
180 }
181
182 break;
183
184 case 'Translation':
185 // Add translation
186 $this->getCategory()->addTranslation(
187 (string) $this->current_translation['title'],
188 (string) $this->current_translation['description'],
189 (string) $this->current_translation['lang'],
190 (int) $this->current_translation['default']
191 );
192 break;
193
194 case 'ContainerSetting':
195 if($this->current_container_setting)
196 {
198 $this->getCategory()->getId(),
199 $this->current_container_setting,
200 $this->cdata);
201 }
202 break;
203 }
204 $this->cdata = '';
205 }
save()
Save category object.
_writeContainerSetting($a_id, $a_keyword, $a_value)

References ilContainer\_writeContainerSetting(), getCategory(), and save().

+ Here is the call graph for this function:

◆ save()

ilCategoryXmlParser::save ( )
protected

Save category object.

Returns
type

mode can be create or update

Definition at line 226 of file class.ilCategoryXmlParser.php.

227 {
228
232 if ($this->mode == ilCategoryXmlParser::MODE_CREATE)
233 {
234 $this->create();
235 $this->getCategory()->create();
236 $this->getCategory()->createReference();
237 $this->getCategory()->putInTree($this->getParentId());
238 $this->getCategory()->setPermissions($this->getParentId());
239 }
240 $this->getCategory()->update();
241 return true;
242 }

References getCategory(), getParentId(), and MODE_CREATE.

Referenced by handlerEndTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCategory()

ilCategoryXmlParser::setCategory (   $cat)

Set category object.

Parameters
type$cat

Definition at line 260 of file class.ilCategoryXmlParser.php.

261 {
262 $this->cat = $cat;
263 }

References $cat.

◆ setHandlers()

ilCategoryXmlParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class @access private

Reimplemented from ilSaxParser.

Definition at line 91 of file class.ilCategoryXmlParser.php.

92 {
93 xml_set_object($a_xml_parser,$this);
94 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
95 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
96 }

◆ setMode()

ilCategoryXmlParser::setMode (   $mode)

Set import mode.

Parameters
type$mode

Definition at line 251 of file class.ilCategoryXmlParser.php.

252 {
253 $this->mode = $mode;
254 }

◆ startParsing()

ilCategoryXmlParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

Definition at line 101 of file class.ilCategoryXmlParser.php.

102 {
103 parent::startParsing();
104
105 if ($this->mode == ilCategoryXmlParser::MODE_CREATE)
106 {
107 return is_object($this->cat) ? $this->cat->getRefId() : false;
108 }
109 else
110 {
111 return is_object($this->cat) ? $this->cat->update() : false;
112 }
113 }

References MODE_CREATE.

Field Documentation

◆ $cat

ilCategoryXmlParser::$cat = null
private

Definition at line 43 of file class.ilCategoryXmlParser.php.

Referenced by getCategory(), and setCategory().

◆ $current_container_setting

ilCategoryXmlParser::$current_container_setting
private

Definition at line 47 of file class.ilCategoryXmlParser.php.

◆ $current_translation

ilCategoryXmlParser::$current_translation = array()
private

Definition at line 46 of file class.ilCategoryXmlParser.php.

Referenced by getCurrentTranslation().

◆ $parent_id

ilCategoryXmlParser::$parent_id = 0
private

Definition at line 44 of file class.ilCategoryXmlParser.php.

Referenced by getParentId().

◆ MODE_CREATE

const ilCategoryXmlParser::MODE_CREATE = 1

◆ MODE_UPDATE

const ilCategoryXmlParser::MODE_UPDATE = 2

The documentation for this class was generated from the following file: