ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 __construct ($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
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). 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...
 
 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...
 

Protected Attributes

 $cat_log
 

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from PEAR
static & 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...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 

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

Reimplemented from ilSaxParser.

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

64 {
65 parent::__construct(null);
66
68 $this->parent_id = $a_parent_id;
69 $this->setXMLContent($a_xml);
70
71 $this->cat_log = ilLoggerFactory::getLogger("cat");
72 }
static getLogger($a_component_id)
Get component logger.
setXMLContent($a_xml_content)

References ilLoggerFactory\getLogger(), MODE_CREATE, and ilSaxParser\setXMLContent().

+ Here is the call graph for this function:

Member Function Documentation

◆ getCategory()

ilCategoryXmlParser::getCategory ( )

Definition at line 278 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 86 of file class.ilCategoryXmlParser.php.

References $current_translation.

◆ getParentId()

ilCategoryXmlParser::getParentId ( )

Get parent id.

Returns
type

Definition at line 78 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 126 of file class.ilCategoryXmlParser.php.

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

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 224 of file class.ilCategoryXmlParser.php.

225 {
226 #$a_data = str_replace("<","&lt;",$a_data);
227 #$a_data = str_replace(">","&gt;",$a_data);
228
229 if(!empty($a_data))
230 {
231 $this->cdata .= $a_data;
232 }
233 }

◆ handlerEndTag()

ilCategoryXmlParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

Handler end tag.

Parameters
type$a_xml_parser
type$a_name

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

164 {
165 switch($a_name)
166 {
167 case "Category":
168 $this->save();
169 break;
170
171 case 'Title':
172 $this->current_translation['title'] = trim($this->cdata);
173
174 if($this->current_translation['default'])
175 {
176 $this->getCategory()->setTitle(trim($this->cdata));
177 }
178
179 break;
180
181 case 'Description':
182 $this->current_translation['description'] = trim($this->cdata);
183
184 if($this->current_translation['default'])
185 {
186 $this->getCategory()->setDescription(trim($this->cdata));
187 }
188
189 break;
190
191 case 'Translation':
192 // Add translation
193 $this->getCategory()->addTranslation(
194 (string) $this->current_translation['title'],
195 (string) $this->current_translation['description'],
196 (string) $this->current_translation['lang'],
197 (int) $this->current_translation['default']
198 );
199 break;
200
201 case 'ContainerSetting':
202 if($this->current_container_setting)
203 {
204 $this->cat_log->debug("Write container Setting, ID: ".$this->getCategory()->getId().", setting: ".
205 $this->current_container_setting.", data: ".$this->cdata);
207 $this->getCategory()->getId(),
208 $this->current_container_setting,
209 $this->cdata);
210 }
211 break;
212
213 case 'ContainerSettings':
214 $this->cat->readContainerSettings(); // read container settings to member vars (call getter/setter), see #0019870
215 break;
216 }
217 $this->cdata = '';
218 }
save()
Save category object.
static _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 239 of file class.ilCategoryXmlParser.php.

240 {
241
245 if ($this->mode == ilCategoryXmlParser::MODE_CREATE)
246 {
247 $this->create();
248 $this->getCategory()->create();
249 $this->getCategory()->createReference();
250 $this->getCategory()->putInTree($this->getParentId());
251 $this->getCategory()->setPermissions($this->getParentId());
252 }
253 $this->getCategory()->update();
254 return true;
255 }

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 273 of file class.ilCategoryXmlParser.php.

274 {
275 $this->cat = $cat;
276 }

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 98 of file class.ilCategoryXmlParser.php.

99 {
100 xml_set_object($a_xml_parser,$this);
101 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
102 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
103 }

◆ setMode()

ilCategoryXmlParser::setMode (   $mode)

Set import mode.

Parameters
type$mode

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

265 {
266 $this->mode = $mode;
267 }

◆ startParsing()

ilCategoryXmlParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

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

109 {
110 parent::startParsing();
111
112 if ($this->mode == ilCategoryXmlParser::MODE_CREATE)
113 {
114 return is_object($this->cat) ? $this->cat->getRefId() : false;
115 }
116 else
117 {
118 return is_object($this->cat) ? $this->cat->update() : false;
119 }
120 }

References MODE_CREATE.

Field Documentation

◆ $cat

ilCategoryXmlParser::$cat = null
private

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

Referenced by getCategory(), and setCategory().

◆ $cat_log

ilCategoryXmlParser::$cat_log
protected

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

◆ $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: