ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 26 of file class.ilCategoryImportParser.php.

Member Function Documentation

◆ buildTag()

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

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

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

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

105 : void
106 {
107 $a_attribs = $this->trimAndStripAttribs($a_attribs);
108 switch ($a_name) {
109 case "Category":
110 $cur_parent = $this->parent[$this->parent_cnt - 1];
111 $this->category = new ilObjCategory();
112 $this->category->setImportId($a_attribs["Id"] . " (#" . $cur_parent . ")");
113 $this->default_language = $a_attribs["DefaultLanguage"];
114 $this->category->setTitle($a_attribs["Id"]);
115 $this->category->create();
116 $this->category->createReference();
117 $this->category->putInTree($cur_parent);
118 $this->parent[$this->parent_cnt++] = $this->category->getRefId();
119 break;
120
121 case "CategorySpec":
122 $this->cur_spec_lang = $a_attribs["Language"];
123 break;
124 }
125 }
Class ilObjCategory.

Referenced by setHandlers().

+ Here is the caller 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 174 of file class.ilCategoryImportParser.php.

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

Referenced by setHandlers().

+ Here is the caller graph for this function:

◆ handlerEndTag()

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

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

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

Referenced by setHandlers().

+ Here is the caller graph for this function:

◆ setHandlers()

ilCategoryImportParser::setHandlers (   $a_xml_parser)
Parameters
XMLParser | resource$a_xml_parser
Returns
void

Reimplemented from ilSaxParser.

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

68 : void
69 {
70 xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
71 xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
72 }
handlerEndTag($a_xml_parser, string $a_name)
handlerCharacterData($a_xml_parser, string $a_data)
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)

References handlerBeginTag(), handlerCharacterData(), and handlerEndTag().

+ Here is the call graph for this function:

Field Documentation

◆ $cat_log

ilLogger ilCategoryImportParser::$cat_log
protected

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

◆ $category

ilObjCategory ilCategoryImportParser::$category = null
protected

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

◆ $cdata

string ilCategoryImportParser::$cdata = ""
protected

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

◆ $cur_description

string ilCategoryImportParser::$cur_description = ""
protected

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

◆ $cur_spec_lang

string ilCategoryImportParser::$cur_spec_lang = ""
protected

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

◆ $cur_title

string ilCategoryImportParser::$cur_title = ""
protected

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

◆ $default_language

string ilCategoryImportParser::$default_language = ""
protected

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

◆ $parent

int[] ilCategoryImportParser::$parent

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

◆ $parent_cnt

int ilCategoryImportParser::$parent_cnt

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

◆ $rbacadmin

ilRbacAdmin ilCategoryImportParser::$rbacadmin
protected

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

◆ $rbacreview

ilRbacReview ilCategoryImportParser::$rbacreview
protected

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

◆ $rbacsystem

ilRbacSystem ilCategoryImportParser::$rbacsystem
protected

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

◆ $withrol

int ilCategoryImportParser::$withrol

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


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