ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCategoryXmlParser Class Reference

Group Import Parser. More...

+ Inheritance diagram for ilCategoryXmlParser:
+ Collaboration diagram for ilCategoryXmlParser:

Public Member Functions

 __construct (string $a_xml, int $a_parent_id)
 
 getParentId ()
 
 setHandlers ($a_xml_parser)
 
 startParsing ()
 stores xml data in array More...
 
 handlerBeginTag ($a_xml_parser, string $a_name, array $a_attribs)
 
 handlerEndTag ($a_xml_parser, string $a_name)
 
 handlerCharacterData ($a_xml_parser, string $a_data)
 
 setMode (int $mode)
 
 setCategory (ilObjCategory $cat)
 
 getCategory ()
 
- 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

const MODE_CREATE = 1
 
const MODE_UPDATE = 2
 
- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 

Protected Member Functions

 getCurrentTranslation ()
 
 save ()
 
- 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)
 

Protected Attributes

ilLogger $cat_log
 
int $mode
 
string $cdata = ""
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Private Attributes

ilObjCategory $cat = null
 
int $parent_id = 0
 
array $current_translation = []
 
string $current_container_setting
 

Detailed Description

Group Import Parser.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilCategoryXmlParser::__construct ( string  $a_xml,
int  $a_parent_id 
)

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

40 {
42
43 $this->mode = self::MODE_CREATE;
44 $this->parent_id = $a_parent_id;
45 $this->setXMLContent($a_xml);
46
47 $this->cat_log = ilLoggerFactory::getLogger("cat");
48 }
static getLogger(string $a_component_id)
Get component logger.
setXMLContent(string $a_xml_content)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), ilLoggerFactory\getLogger(), MODE_CREATE, and ilSaxParser\setXMLContent().

+ Here is the call graph for this function:

Member Function Documentation

◆ getCategory()

ilCategoryXmlParser::getCategory ( )

Definition at line 209 of file class.ilCategoryXmlParser.php.

210 {
211 return $this->cat;
212 }
Class ilObjCategory.

References $cat.

Referenced by handlerBeginTag(), handlerEndTag(), and save().

+ Here is the caller graph for this function:

◆ getCurrentTranslation()

ilCategoryXmlParser::getCurrentTranslation ( )
protected
Returns
array

Definition at line 58 of file class.ilCategoryXmlParser.php.

58 : array
59 {
61 }

References $current_translation.

◆ getParentId()

ilCategoryXmlParser::getParentId ( )

Definition at line 50 of file class.ilCategoryXmlParser.php.

50 : int
51 {
52 return $this->parent_id;
53 }

References $parent_id.

Referenced by save().

+ Here is the caller graph for this function:

◆ handlerBeginTag()

ilCategoryXmlParser::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 84 of file class.ilCategoryXmlParser.php.

84 : void
85 {
86 $a_attribs = $this->trimAndStripAttribs($a_attribs);
87 switch ($a_name) {
88 case "Category":
89 break;
90
91 case 'Translations':
92 $this->getCategory()->removeTranslations();
93 break;
94
95 case 'Translation':
96 $this->current_translation = [];
97 $this->current_translation['default'] = $a_attribs['default'] ? 1 : 0;
98 $this->current_translation['lang'] = $a_attribs['language'];
99 break;
100
101 case 'Sorting':
102 case 'Sort':
104 break;
105
106 case 'ContainerSetting':
107 $this->current_container_setting = $a_attribs['id'];
108 break;
109 }
110 }
static _importContainerSortingSettings(array $attibs, int $obj_id)
sorting import for all container objects

References ilContainerSortingSettings\_importContainerSortingSettings(), getCategory(), ILIAS\Survey\Mode\getId(), and ilContainerBaseXmlParser\trimAndStripAttribs().

Referenced by setHandlers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handlerCharacterData()

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

Definition at line 177 of file class.ilCategoryXmlParser.php.

177 : void
178 {
179 if (!empty($a_data)) {
180 $this->cdata .= $a_data;
181 }
182 }

Referenced by setHandlers().

+ Here is the caller graph for this function:

◆ handlerEndTag()

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

Definition at line 117 of file class.ilCategoryXmlParser.php.

117 : void
118 {
119 $this->cdata = $this->trimAndStrip($this->cdata);
120 switch ($a_name) {
121 case "Category":
122 $this->save();
123 break;
124
125 case 'Title':
126 $this->current_translation['title'] = trim($this->cdata);
127
128 if ($this->current_translation['default']) {
129 $this->getCategory()->setTitle(trim($this->cdata));
130 }
131
132 break;
133
134 case 'Description':
135 $this->current_translation['description'] = trim($this->cdata);
136
137 if ($this->current_translation['default']) {
138 $this->getCategory()->setDescription(trim($this->cdata));
139 }
140
141 break;
142
143 case 'Translation':
144 // Add translation
145 $this->getCategory()->addTranslation(
146 (string) $this->current_translation['title'],
147 (string) $this->current_translation['description'],
148 (string) $this->current_translation['lang'],
149 (string) ((int) $this->current_translation['default'])
150 );
151 break;
152
153 case 'ContainerSetting':
154 if ($this->current_container_setting) {
155 $this->cat_log->debug("Write container Setting, ID: " . $this->getCategory()->getId() . ", setting: " .
156 $this->current_container_setting . ", data: " . $this->cdata);
158 $this->getCategory()->getId(),
159 $this->current_container_setting,
160 $this->cdata
161 );
162 }
163 break;
164
165 case 'ContainerSettings':
166 $this->cat->readContainerSettings(); // read container settings to member vars (call getter/setter), see #0019870
167 break;
168 }
169 $this->cdata = '';
170 }
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)

References ilContainer\_writeContainerSetting(), getCategory(), ILIAS\Survey\Mode\getId(), save(), and ilContainerBaseXmlParser\trimAndStrip().

Referenced by setHandlers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilCategoryXmlParser::save ( )
protected

mode can be create or update

Definition at line 184 of file class.ilCategoryXmlParser.php.

184 : bool
185 {
189 if ($this->mode === self::MODE_CREATE) {
190 $this->getCategory()->create();
191 $this->getCategory()->createReference();
192 $this->getCategory()->putInTree($this->getParentId());
193 $this->getCategory()->setPermissions($this->getParentId());
194 }
195 $this->getCategory()->update();
196 return true;
197 }

References getCategory(), and getParentId().

Referenced by handlerEndTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCategory()

ilCategoryXmlParser::setCategory ( ilObjCategory  $cat)

Definition at line 204 of file class.ilCategoryXmlParser.php.

204 : void
205 {
206 $this->cat = $cat;
207 }

References $cat.

◆ setHandlers()

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

Reimplemented from ilSaxParser.

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

63 : void
64 {
65 xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
66 xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
67 }
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
handlerEndTag($a_xml_parser, string $a_name)
handlerCharacterData($a_xml_parser, string $a_data)

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

+ Here is the call graph for this function:

◆ setMode()

ilCategoryXmlParser::setMode ( int  $mode)

Definition at line 199 of file class.ilCategoryXmlParser.php.

199 : void
200 {
201 $this->mode = $mode;
202 }

References $mode.

◆ startParsing()

ilCategoryXmlParser::startParsing ( )

stores xml data in array

Exceptions
ilSaxParserException

Reimplemented from ilSaxParser.

Definition at line 69 of file class.ilCategoryXmlParser.php.

69 : void
70 {
71 parent::startParsing();
72
73 if ($this->mode !== self::MODE_CREATE) {
74 $this->cat->update();
75 }
76 }

Field Documentation

◆ $cat

ilObjCategory ilCategoryXmlParser::$cat = null
private

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

Referenced by getCategory(), and setCategory().

◆ $cat_log

ilLogger ilCategoryXmlParser::$cat_log
protected

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

◆ $cdata

string ilCategoryXmlParser::$cdata = ""
protected

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

◆ $current_container_setting

string ilCategoryXmlParser::$current_container_setting
private

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

◆ $current_translation

array ilCategoryXmlParser::$current_translation = []
private

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

Referenced by getCurrentTranslation().

◆ $mode

int ilCategoryXmlParser::$mode
protected

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

Referenced by setMode().

◆ $parent_id

int ilCategoryXmlParser::$parent_id = 0
private

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

Referenced by getParentId().

◆ MODE_CREATE

const ilCategoryXmlParser::MODE_CREATE = 1

◆ MODE_UPDATE

const ilCategoryXmlParser::MODE_UPDATE = 2

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


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