ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilContainerReferenceXmlParser Class Reference

Group Import Parser. More...

+ Inheritance diagram for ilContainerReferenceXmlParser:
+ Collaboration diagram for ilContainerReferenceXmlParser:

Public Member Functions

 __construct ($a_xml, $a_parent_id=0)
 Constructor. More...
 
 setImportMapping (ilImportMapping $mapping)
 
 getParentId ()
 Get parent id. More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class @access private More...
 
 startParsing ()
 start the parser More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 Handler end tag. More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 setMode ($mode)
 Set import mode. More...
 
 setReference (ilContainerReference $ref)
 Set container reference. More...
 
 getReference ()
 Get container reference. 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

const MODE_CREATE = 1
 
const MODE_UPDATE = 2
 
- 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 Member Functions

 parseTargetId (string $attribute_target)
 
 save ()
 Save category object. 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...
 

Protected Attributes

 $error
 
 $logger
 
 $import_mapping
 

Private Attributes

 $ref = null
 
 $parent_id = 0
 

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

Detailed Description

Group Import Parser.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilContainerReferenceXmlParser::__construct (   $a_xml,
  $a_parent_id = 0 
)

Constructor.

Parameters
string$a_xml_filexml file

@access public

Reimplemented from ilSaxParser.

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

70 {
71 global $DIC;
72
73 $this->error = $DIC["ilErr"];
74 parent::__construct(null);
75
77 $this->setXMLContent($a_xml);
78
79 $this->logger = $DIC->logger()->exp();
80 }
error($a_errmsg)
set error message @access public
setXMLContent($a_xml_content)
global $DIC
Definition: saml.php:7

References $DIC, error(), MODE_CREATE, and ilSaxParser\setXMLContent().

+ Here is the call graph for this function:

Member Function Documentation

◆ getParentId()

ilContainerReferenceXmlParser::getParentId ( )

Get parent id.

Returns
type

Definition at line 94 of file class.ilContainerReferenceXmlParser.php.

References $parent_id.

Referenced by save().

+ Here is the caller graph for this function:

◆ getReference()

ilContainerReferenceXmlParser::getReference ( )

Get container reference.

Returns
ilContainerReference

Definition at line 265 of file class.ilContainerReferenceXmlParser.php.

References $ref.

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

+ Here is the caller graph for this function:

◆ handlerBeginTag()

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

handler for begin of element

Definition at line 128 of file class.ilContainerReferenceXmlParser.php.

129 {
131
132 switch ($a_name) {
133 case "ContainerReference":
134 break;
135
136 case 'Title':
137 switch ($a_attribs['type']) {
140 break;
141
142 default:
144 break;
145 }
146 break;
147
148 case 'Target':
149 $target_id = $this->parseTargetId(isset($a_attribs['id']) ? (string) $a_attribs['id'] : '');
150 if ($target_id) {
151 $this->logger->debug('Using mapped target_id: ' . $target_id);
152 $this->getReference()->setTargetId($target_id);
153 } else {
154 $this->logger->info('No mapping found for: ' . $a_attribs['id']);
155 $this->getReference()->setTargetId(0);
156 }
157 break;
158 }
159 }
$target_id
Definition: goto.php:49
$ilErr
Definition: raiseError.php:18

References $error, $ilErr, $target_id, getReference(), parseTargetId(), and ilContainerReference\TITLE_TYPE_REUSE.

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilContainerReferenceXmlParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 208 of file class.ilContainerReferenceXmlParser.php.

209 {
210 #$a_data = str_replace("<","&lt;",$a_data);
211 #$a_data = str_replace(">","&gt;",$a_data);
212
213 if (!empty($a_data)) {
214 $this->cdata .= $a_data;
215 }
216 }

◆ handlerEndTag()

ilContainerReferenceXmlParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

Handler end tag.

Parameters
type$a_xml_parser
type$a_name

Definition at line 188 of file class.ilContainerReferenceXmlParser.php.

189 {
190 switch ($a_name) {
191 case "ContainerReference":
192 $this->save();
193 break;
194
195 case 'Title':
196 if ($this->getReference()->getTitleType() == ilContainerReference::TITLE_TYPE_CUSTOM) {
197 $this->getReference()->setTitle(trim($this->cdata));
198 }
199 break;
200 }
201 $this->cdata = '';
202 }

References getReference(), save(), and ilContainerReference\TITLE_TYPE_CUSTOM.

+ Here is the call graph for this function:

◆ parseTargetId()

ilContainerReferenceXmlParser::parseTargetId ( string  $attribute_target)
protected
Parameters
string$attribute_target
Returns
int

Definition at line 165 of file class.ilContainerReferenceXmlParser.php.

165 : int
166 {
167 if (!strlen($attribute_target)) {
168 $this->logger->debug('No target id provided');
169 return 0;
170 }
171 if (!$this->import_mapping instanceof ilImportMapping) {
172 return 0;
173 }
174 $obj_mapping_id = $this->import_mapping->getMapping('Services/Container', 'objs', $attribute_target);
175 if (!$obj_mapping_id) {
176 $this->logger->debug('Cannot find object mapping for target_id: ' . $attribute_target);
177 return 0;
178 }
179 return $obj_mapping_id;
180 }

Referenced by handlerBeginTag().

+ Here is the caller graph for this function:

◆ save()

ilContainerReferenceXmlParser::save ( )
protected

Save category object.

Returns
type

mode can be create or update

Definition at line 222 of file class.ilContainerReferenceXmlParser.php.

223 {
227 include_once './Modules/Category/classes/class.ilCategoryXmlParser.php';
228 if ($this->mode == ilCategoryXmlParser::MODE_CREATE) {
229 $this->create();
230 $this->getReference()->create();
231 $this->getReference()->createReference();
232 $this->getReference()->putInTree($this->getParentId());
233 $this->getReference()->setPermissions($this->getParentId());
234 }
235 $this->getReference()->update();
236 return true;
237 }

References getParentId(), getReference(), and ilCategoryXmlParser\MODE_CREATE.

Referenced by handlerEndTag().

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

◆ setHandlers()

ilContainerReferenceXmlParser::setHandlers (   $a_xml_parser)

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

Reimplemented from ilSaxParser.

Definition at line 104 of file class.ilContainerReferenceXmlParser.php.

105 {
106 xml_set_object($a_xml_parser, $this);
107 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
108 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
109 }

◆ setImportMapping()

ilContainerReferenceXmlParser::setImportMapping ( ilImportMapping  $mapping)
Parameters
ilImportMapping$mapping

Definition at line 85 of file class.ilContainerReferenceXmlParser.php.

86 {
87 $this->import_mapping = $mapping;
88 }

◆ setMode()

ilContainerReferenceXmlParser::setMode (   $mode)

Set import mode.

Parameters
type$mode

Definition at line 246 of file class.ilContainerReferenceXmlParser.php.

247 {
248 $this->mode = $mode;
249 }

◆ setReference()

ilContainerReferenceXmlParser::setReference ( ilContainerReference  $ref)

Set container reference.

Parameters
ilContainerReference$ref

Definition at line 256 of file class.ilContainerReferenceXmlParser.php.

257 {
258 $this->ref = $ref;
259 }

References $ref.

◆ startParsing()

ilContainerReferenceXmlParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

Definition at line 114 of file class.ilContainerReferenceXmlParser.php.

115 {
116 parent::startParsing();
117
118 if ($this->ref instanceof ilContainerReference) {
119 return $this->ref;
120 }
121 return 0;
122 }

References $ref.

Field Documentation

◆ $error

ilContainerReferenceXmlParser::$error
protected

Definition at line 43 of file class.ilContainerReferenceXmlParser.php.

Referenced by handlerBeginTag().

◆ $import_mapping

ilContainerReferenceXmlParser::$import_mapping
protected

Definition at line 59 of file class.ilContainerReferenceXmlParser.php.

◆ $logger

ilContainerReferenceXmlParser::$logger
protected

Definition at line 54 of file class.ilContainerReferenceXmlParser.php.

◆ $parent_id

ilContainerReferenceXmlParser::$parent_id = 0
private

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

Referenced by getParentId().

◆ $ref

ilContainerReferenceXmlParser::$ref = null
private

◆ MODE_CREATE

const ilContainerReferenceXmlParser::MODE_CREATE = 1

Definition at line 45 of file class.ilContainerReferenceXmlParser.php.

Referenced by __construct().

◆ MODE_UPDATE

const ilContainerReferenceXmlParser::MODE_UPDATE = 2

Definition at line 46 of file class.ilContainerReferenceXmlParser.php.


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