ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 @access 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 @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

 $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

 $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

@access public

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

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

References $withrol.

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

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

◆ handlerBeginTag()

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

handler for begin of element

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

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

References ilObject\setImportId().

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilCategoryImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

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

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

◆ handlerEndTag()

ilCategoryImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

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

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

References ilSaxParser\$ilias.

◆ setHandlers()

ilCategoryImportParser::setHandlers (   $a_xml_parser)

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

Reimplemented from ilSaxParser.

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

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

◆ startParsing()

ilCategoryImportParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

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

76 {
77 parent::startParsing();
78 }

Field Documentation

◆ $cat_log

ilCategoryImportParser::$cat_log
protected

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

◆ $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 __construct().


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