ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilCategoryImportParser Class Reference

Category Import Parser. More...

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

Public Member Functions

 setHandlers ($a_xml_parser)
 
 buildTag (string $type, string $name, array $attr=null)
 
 handlerBeginTag ($a_xml_parser, string $a_name, array $a_attribs)
 
 handlerEndTag ($a_xml_parser, string $a_name)
 
 handlerCharacterData ($a_xml_parser, string $a_data)
 
- Public Member Functions inherited from ilSaxParser
 __construct (?string $path_to_file='', ?bool $throw_exception=false)
 
 setXMLContent (string $a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 

Data Fields

array $parent
 
int $parent_cnt
 
int $withrol
 
- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 

Protected Attributes

ilRbacAdmin $rbacadmin
 
ilRbacReview $rbacreview
 
ilRbacSystem $rbacsystem
 
ilLogger $cat_log
 
ilObjCategory $category = null
 
string $default_language = ""
 
string $cur_spec_lang = ""
 
string $cur_title = ""
 
string $cur_description = ""
 
string $cdata = ""
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Additional Inherited Members

- Protected Member Functions inherited from ilContainerBaseXmlParser
 trimAndStripAttribs (array $attribs)
 
 trimAndStrip (string $input)
 
- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 

Detailed Description

Category Import Parser.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Member Function Documentation

◆ buildTag()

ilCategoryImportParser::buildTag ( string  $type,
string  $name,
array  $attr = null 
)

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

77  : string {
78  $tag = "<";
79 
80  if ($type === "end") {
81  $tag .= "/";
82  }
83 
84  $tag .= $name;
85 
86  if (is_array($attr)) {
87  foreach ($attr as $k => $v) {
88  $tag .= " " . $k . "=\"$v\"";
89  }
90  }
91 
92  $tag .= ">";
93 
94  return $tag;
95  }

◆ handlerBeginTag()

ilCategoryImportParser::handlerBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)
Parameters
XMLParser | resource$a_xml_parser
string$a_name
array$a_attribs
Returns
void

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

References ilContainerBaseXmlParser\trimAndStripAttribs().

103  : void
104  {
105  $a_attribs = $this->trimAndStripAttribs($a_attribs);
106  switch ($a_name) {
107  case "Category":
108  $cur_parent = $this->parent[$this->parent_cnt - 1];
109  $this->category = new ilObjCategory();
110  $this->category->setImportId($a_attribs["Id"] . " (#" . $cur_parent . ")");
111  $this->default_language = $a_attribs["DefaultLanguage"];
112  $this->category->setTitle($a_attribs["Id"]);
113  $this->category->create();
114  $this->category->createReference();
115  $this->category->putInTree($cur_parent);
116  $this->parent[$this->parent_cnt++] = $this->category->getRefId();
117  break;
118 
119  case "CategorySpec":
120  $this->cur_spec_lang = $a_attribs["Language"];
121  break;
122  }
123  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ handlerCharacterData()

ilCategoryImportParser::handlerCharacterData (   $a_xml_parser,
string  $a_data 
)
Parameters
XMLParser | resource$a_xml_parser
string$a_data
Returns
void

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

172  : void
173  {
174  // i don't know why this is necessary, but
175  // the parser seems to convert "&gt;" to ">" and "&lt;" to "<"
176  // in character data, but we don't want that, because it's the
177  // way we mask user html in our content, so we convert back...
178  $a_data = str_replace(["<", ">"], ["&lt;", "&gt;"], $a_data);
179 
180  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
181  $a_data = preg_replace("/\n/", "", $a_data);
182  $a_data = preg_replace("/\t+/", "", $a_data);
183  if (!empty($a_data)) {
184  $this->cdata .= $a_data;
185  }
186  }

◆ handlerEndTag()

ilCategoryImportParser::handlerEndTag (   $a_xml_parser,
string  $a_name 
)
Parameters
XMLParser | resource$a_xml_parser
string$a_name
Returns
void

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

References $cdata, and ilContainerBaseXmlParser\trimAndStrip().

130  : void
131  {
132  $this->cdata = $this->trimAndStrip($this->cdata);
133  switch ($a_name) {
134  case "Category":
135  unset($this->category, $this->parent[$this->parent_cnt - 1]);
136  $this->parent_cnt--;
137  break;
138 
139  case "CategorySpec":
140  $is_def = '0';
141  if ($this->cur_spec_lang === $this->default_language) {
142  $this->category->setTitle($this->cur_title);
143  $this->category->setDescription($this->cur_description);
144  $this->category->update();
145  $is_def = '1';
146  }
147  $this->category->addTranslation(
148  $this->cur_title,
149  $this->cur_description,
150  $this->cur_spec_lang,
151  $is_def
152  );
153  break;
154 
155  case "Title":
156  $this->cur_title = $this->cdata;
157  break;
158 
159  case "Description":
160  $this->cur_description = $this->cdata;
161  break;
162  }
163 
164  $this->cdata = "";
165  }
+ Here is the call graph for this function:

◆ setHandlers()

ilCategoryImportParser::setHandlers (   $a_xml_parser)

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

65  : void
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  }

Field Documentation

◆ $cat_log

ilLogger ilCategoryImportParser::$cat_log
protected

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

◆ $category

ilObjCategory ilCategoryImportParser::$category = null
protected

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

◆ $cdata

string ilCategoryImportParser::$cdata = ""
protected

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

Referenced by handlerEndTag().

◆ $cur_description

string ilCategoryImportParser::$cur_description = ""
protected

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

◆ $cur_spec_lang

string ilCategoryImportParser::$cur_spec_lang = ""
protected

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

◆ $cur_title

string ilCategoryImportParser::$cur_title = ""
protected

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

◆ $default_language

string ilCategoryImportParser::$default_language = ""
protected

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

◆ $parent

array ilCategoryImportParser::$parent

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

◆ $parent_cnt

int ilCategoryImportParser::$parent_cnt

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

◆ $rbacadmin

ilRbacAdmin ilCategoryImportParser::$rbacadmin
protected

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

◆ $rbacreview

ilRbacReview ilCategoryImportParser::$rbacreview
protected

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

◆ $rbacsystem

ilRbacSystem ilCategoryImportParser::$rbacsystem
protected

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

◆ $withrol

int ilCategoryImportParser::$withrol

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


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