ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
ilCategoryImportParser Class Reference

Category Import Parser. More...

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

Public Member Functions

 ilCategoryImportParser ($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
 ilSaxParser ($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
 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

 $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()
 

Additional Inherited Members

- 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.

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 85 of file class.ilCategoryImportParser.php.

86  {
87  $tag = "<";
88 
89  if ($type == "end")
90  $tag.= "/";
91 
92  $tag.= $name;
93 
94  if (is_array($attr))
95  {
96  while (list($k,$v) = each($attr))
97  $tag.= " ".$k."=\"$v\"";
98  }
99 
100  $tag.= ">";
101 
102  return $tag;
103  }

◆ handlerBeginTag()

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

handler for begin of element

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

References ilObject\setImportId().

110  {
111 
112  global $rbacadmin, $rbacreview, $rbacsystem;
113 
114  switch($a_name)
115  {
116  case "Category":
117  $cur_parent = $this->parent[$this->parent_cnt - 1];
118  require_once("Modules/Category/classes/class.ilObjCategory.php");
119  $this->category = new ilObjCategory;
120  $this->category->setImportId($a_attribs["Id"]." (#".$cur_parent.")");
121  $this->default_language = $a_attribs["DefaultLanguage"];
122  $this->category->setTitle($a_attribs["Id"]);
123  $this->category->create();
124  $this->category->createReference();
125  $this->category->putInTree($cur_parent);
126  $this->parent[$this->parent_cnt++] = $this->category->getRefId();
127  break;
128 
129  case "CategorySpec":
130  $this->cur_spec_lang = $a_attribs["Language"];
131  break;
132 
133  }
134 
135  }
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 181 of file class.ilCategoryImportParser.php.

182  {
183  // i don't know why this is necessary, but
184  // the parser seems to convert "&gt;" to ">" and "&lt;" to "<"
185  // in character data, but we don't want that, because it's the
186  // way we mask user html in our content, so we convert back...
187  $a_data = str_replace("<","&lt;",$a_data);
188  $a_data = str_replace(">","&gt;",$a_data);
189 
190  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
191  $a_data = preg_replace("/\n/","",$a_data);
192  $a_data = preg_replace("/\t+/","",$a_data);
193  if(!empty($a_data))
194  {
195  $this->cdata .= $a_data;
196  }
197  }

◆ handlerEndTag()

ilCategoryImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

References ilSaxParser\$ilias.

142  {
143  global $ilias, $rbacadmin;
144 
145  switch($a_name)
146  {
147  case "Category":
148  unset($this->category);
149  unset($this->parent[$this->parent_cnt - 1]);
150  $this->parent_cnt--;
151  break;
152 
153  case "CategorySpec":
154  $is_def = 0;
155  if ($this->cur_spec_lang == $this->default_language)
156  {
157  $this->category->setTitle($this->cur_title);
158  $this->category->setDescription($this->cur_description);
159  $this->category->update();
160  $is_def = 1;
161  }
162  $this->category->addTranslation($this->cur_title,
163  $this->cur_description, $this->cur_spec_lang, $is_def);
164  break;
165 
166  case "Title":
167  $this->cur_title = $this->cdata;
168  break;
169 
170  case "Description":
171  $this->cur_description = $this->cdata;
172  break;
173  }
174 
175  $this->cdata = "";
176  }

◆ ilCategoryImportParser()

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

Constructor.

Parameters
string$a_xml_filexml file

public

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

References $withrol.

49  {
50  $this->parent_cnt = 0;
51  $this->parent[$this->parent_cnt] = $a_parent;
52  $this->parent_cnt++;
53  $this->withrol = $withrol;
54  parent::ilSaxParser($a_xml_file);
55  }

◆ setHandlers()

ilCategoryImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

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

64  {
65  xml_set_object($a_xml_parser,$this);
66  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
67  xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
68  }

◆ startParsing()

ilCategoryImportParser::startParsing ( )

start the parser

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

74  {
75  parent::startParsing();
76  }

Field Documentation

◆ $parent

ilCategoryImportParser::$parent

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

◆ $withrol

ilCategoryImportParser::$withrol

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

Referenced by ilCategoryImportParser().


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