ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

 $error
 
 $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 68 of file class.ilCategoryXmlParser.php.

69 {
70 global $DIC;
71
72 $this->error = $DIC["ilErr"];
73 parent::__construct(null);
74
76 $this->parent_id = $a_parent_id;
77 $this->setXMLContent($a_xml);
78
79 $this->cat_log = ilLoggerFactory::getLogger("cat");
80 }
error($a_errmsg)
set error message @access public
static getLogger($a_component_id)
Get component logger.
setXMLContent($a_xml_content)
global $DIC
Definition: saml.php:7

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getCategory()

ilCategoryXmlParser::getCategory ( )

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

References $current_translation.

◆ getParentId()

ilCategoryXmlParser::getParentId ( )

Get parent id.

Returns
type

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

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

References $error, $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 225 of file class.ilCategoryXmlParser.php.

226 {
227 #$a_data = str_replace("<","&lt;",$a_data);
228 #$a_data = str_replace(">","&gt;",$a_data);
229
230 if (!empty($a_data)) {
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 167 of file class.ilCategoryXmlParser.php.

168 {
169 switch ($a_name) {
170 case "Category":
171 $this->save();
172 break;
173
174 case 'Title':
175 $this->current_translation['title'] = trim($this->cdata);
176
177 if ($this->current_translation['default']) {
178 $this->getCategory()->setTitle(trim($this->cdata));
179 }
180
181 break;
182
183 case 'Description':
184 $this->current_translation['description'] = trim($this->cdata);
185
186 if ($this->current_translation['default']) {
187 $this->getCategory()->setDescription(trim($this->cdata));
188 }
189
190 break;
191
192 case 'Translation':
193 // Add translation
194 $this->getCategory()->addTranslation(
195 (string) $this->current_translation['title'],
196 (string) $this->current_translation['description'],
197 (string) $this->current_translation['lang'],
198 (int) $this->current_translation['default']
199 );
200 break;
201
202 case 'ContainerSetting':
203 if ($this->current_container_setting) {
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 }
212 break;
213
214 case 'ContainerSettings':
215 $this->cat->readContainerSettings(); // read container settings to member vars (call getter/setter), see #0019870
216 break;
217 }
218 $this->cdata = '';
219 }
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 $this->create();
247 $this->getCategory()->create();
248 $this->getCategory()->createReference();
249 $this->getCategory()->putInTree($this->getParentId());
250 $this->getCategory()->setPermissions($this->getParentId());
251 }
252 $this->getCategory()->update();
253 return true;
254 }

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

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

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

107 {
108 xml_set_object($a_xml_parser, $this);
109 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
110 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
111 }

◆ setMode()

ilCategoryXmlParser::setMode (   $mode)

Set import mode.

Parameters
type$mode

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

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

◆ startParsing()

ilCategoryXmlParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

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

117 {
118 parent::startParsing();
119
120 if ($this->mode == ilCategoryXmlParser::MODE_CREATE) {
121 return is_object($this->cat) ? $this->cat->getRefId() : false;
122 } else {
123 return is_object($this->cat) ? $this->cat->update() : false;
124 }
125 }

References MODE_CREATE.

Field Documentation

◆ $cat

ilCategoryXmlParser::$cat = null
private

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

Referenced by getCategory(), and setCategory().

◆ $cat_log

ilCategoryXmlParser::$cat_log
protected

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

◆ $current_container_setting

ilCategoryXmlParser::$current_container_setting
private

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

◆ $current_translation

ilCategoryXmlParser::$current_translation = array()
private

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

Referenced by getCurrentTranslation().

◆ $error

ilCategoryXmlParser::$error
protected

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

Referenced by handlerBeginTag().

◆ $parent_id

ilCategoryXmlParser::$parent_id = 0
private

Definition at line 49 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: