ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCategoryImportParser Class Reference

Category Import Parser. More...

+ Inheritance diagram for ilCategoryImportParser:
+ Collaboration diagram for ilCategoryImportParser:

Public Member Functions

 __construct ($a_xml_file, $a_parent, $withrol)
 Constructor. More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 startParsing ()
 start the parser More...
 
 buildTag ($type, $name, $attr="")
 generate a tag with given name and attributes More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
- Public Member Functions inherited from ilSaxParser
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object 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 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

 $parent
 
 $withrol
 
- 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 Attributes

 $rbacadmin
 
 $rbacreview
 
 $rbacsystem
 
 $cat_log
 

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...
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

Category Import Parser.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 34 of file class.ilCategoryImportParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilCategoryImportParser::__construct (   $a_xml_file,
  $a_parent,
  $withrol 
)

Constructor.

Parameters
string$a_xml_filexml file

public

Definition at line 64 of file class.ilCategoryImportParser.php.

References $DIC, and $withrol.

65  {
66  global $DIC;
67 
68  $this->rbacadmin = $DIC->rbac()->admin();
69  $this->rbacreview = $DIC->rbac()->review();
70  $this->rbacsystem = $DIC->rbac()->system();
71  $this->parent_cnt = 0;
72  $this->parent[$this->parent_cnt] = $a_parent;
73  $this->parent_cnt++;
74  $this->withrol = $withrol;
75 
76  parent::__construct($a_xml_file);
77  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ buildTag()

ilCategoryImportParser::buildTag (   $type,
  $name,
  $attr = "" 
)

generate a tag with given name and attributes

Parameters
string"start" | "end" for starting or ending tag
stringelement/tag name
arrayarray of attributes

Definition at line 107 of file class.ilCategoryImportParser.php.

References $name, $tag, and $type.

108  {
109  $tag = "<";
110 
111  if ($type == "end") {
112  $tag.= "/";
113  }
114 
115  $tag.= $name;
116 
117  if (is_array($attr)) {
118  foreach ($attr as $k => $v) {
119  $tag .= " " . $k . "=\"$v\"";
120  }
121  }
122 
123  $tag.= ">";
124 
125  return $tag;
126  }
$type
if($format !==null) $name
Definition: metadata.php:146
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

◆ handlerBeginTag()

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

handler for begin of element

Definition at line 131 of file class.ilCategoryImportParser.php.

References $rbacadmin, $rbacreview, $rbacsystem, and ilObject\setImportId().

132  {
136 
137  switch ($a_name) {
138  case "Category":
139  $cur_parent = $this->parent[$this->parent_cnt - 1];
140  require_once("Modules/Category/classes/class.ilObjCategory.php");
141  $this->category = new ilObjCategory;
142  $this->category->setImportId($a_attribs["Id"] . " (#" . $cur_parent . ")");
143  $this->default_language = $a_attribs["DefaultLanguage"];
144  $this->category->setTitle($a_attribs["Id"]);
145  $this->category->create();
146  $this->category->createReference();
147  $this->category->putInTree($cur_parent);
148  $this->parent[$this->parent_cnt++] = $this->category->getRefId();
149  break;
150 
151  case "CategorySpec":
152  $this->cur_spec_lang = $a_attribs["Language"];
153  break;
154 
155  }
156  }
Class ilObjCategory.
setImportId($a_import_id)
set import id
+ Here is the call graph for this function:

◆ handlerCharacterData()

ilCategoryImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 202 of file class.ilCategoryImportParser.php.

203  {
204  // i don't know why this is necessary, but
205  // the parser seems to convert "&gt;" to ">" and "&lt;" to "<"
206  // in character data, but we don't want that, because it's the
207  // way we mask user html in our content, so we convert back...
208  $a_data = str_replace("<", "&lt;", $a_data);
209  $a_data = str_replace(">", "&gt;", $a_data);
210 
211  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
212  $a_data = preg_replace("/\n/", "", $a_data);
213  $a_data = preg_replace("/\t+/", "", $a_data);
214  if (!empty($a_data)) {
215  $this->cdata .= $a_data;
216  }
217  }

◆ handlerEndTag()

ilCategoryImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Definition at line 162 of file class.ilCategoryImportParser.php.

163  {
164  switch ($a_name) {
165  case "Category":
166  unset($this->category);
167  unset($this->parent[$this->parent_cnt - 1]);
168  $this->parent_cnt--;
169  break;
170 
171  case "CategorySpec":
172  $is_def = 0;
173  if ($this->cur_spec_lang == $this->default_language) {
174  $this->category->setTitle($this->cur_title);
175  $this->category->setDescription($this->cur_description);
176  $this->category->update();
177  $is_def = 1;
178  }
179  $this->category->addTranslation(
180  $this->cur_title,
181  $this->cur_description,
182  $this->cur_spec_lang,
183  $is_def
184  );
185  break;
186 
187  case "Title":
188  $this->cur_title = $this->cdata;
189  break;
190 
191  case "Description":
192  $this->cur_description = $this->cdata;
193  break;
194  }
195 
196  $this->cdata = "";
197  }

◆ setHandlers()

ilCategoryImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Definition at line 85 of file class.ilCategoryImportParser.php.

86  {
87  xml_set_object($a_xml_parser, $this);
88  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
89  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
90  }

◆ startParsing()

ilCategoryImportParser::startParsing ( )

start the parser

Definition at line 95 of file class.ilCategoryImportParser.php.

96  {
97  parent::startParsing();
98  }

Field Documentation

◆ $cat_log

ilCategoryImportParser::$cat_log
protected

Definition at line 54 of file class.ilCategoryImportParser.php.

◆ $parent

ilCategoryImportParser::$parent

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

◆ $rbacadmin

ilCategoryImportParser::$rbacadmin
protected

Definition at line 39 of file class.ilCategoryImportParser.php.

Referenced by handlerBeginTag().

◆ $rbacreview

ilCategoryImportParser::$rbacreview
protected

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

Referenced by handlerBeginTag().

◆ $rbacsystem

ilCategoryImportParser::$rbacsystem
protected

Definition at line 49 of file class.ilCategoryImportParser.php.

Referenced by handlerBeginTag().

◆ $withrol

ilCategoryImportParser::$withrol

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

Referenced by __construct().


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