ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilContainerReferenceXmlParser Class Reference

Import Parser. More...

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

Public Member Functions

 __construct (string $a_xml, int $a_parent_id=0)
 
 setImportMapping (ilImportMapping $mapping)
 
 getParentId ()
 
 setHandlers ($a_xml_parser)
 
 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)
 
 setReference (ilContainerReference $ref)
 
 getReference ()
 
- 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

 parseTargetId (string $attribute_target)
 
 create ()
 
 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 $logger
 
ilImportMapping $import_mapping
 
string $cdata = ""
 
int $mode = 0
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Private Attributes

ilContainerReference $ref = null
 
int $parent_id = 0
 

Detailed Description

Import Parser.

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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, ILIAS\MetaData\Repository\Validation\Data\__construct(), ILIAS\Repository\logger(), and ilSaxParser\setXMLContent().

38  {
39  global $DIC;
40 
41  parent::__construct(null);
42 
43  $this->mode = self::MODE_CREATE;
44  $this->setXMLContent($a_xml);
45 
46  $this->logger = $DIC->logger()->exp();
47  }
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
setXMLContent(string $a_xml_content)
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilContainerReferenceXmlParser::create ( )
protected

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

Referenced by save().

160  : void
161  {
162  }
+ Here is the caller graph for this function:

◆ getParentId()

ilContainerReferenceXmlParser::getParentId ( )

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

References $parent_id.

Referenced by save().

54  : int
55  {
56  return $this->parent_id;
57  }
+ Here is the caller graph for this function:

◆ getReference()

ilContainerReferenceXmlParser::getReference ( )

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

References $ref.

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

188  {
189  return $this->ref;
190  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ handlerBeginTag()

ilContainerReferenceXmlParser::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 72 of file class.ilContainerReferenceXmlParser.php.

References getReference(), ILIAS\Repository\logger(), parseTargetId(), ilContainerReference\TITLE_TYPE_REUSE, and ilContainerBaseXmlParser\trimAndStripAttribs().

76  : void {
77  $a_attribs = $this->trimAndStripAttribs($a_attribs);
78  switch ($a_name) {
79  case "ContainerReference":
80  break;
81 
82  case 'Title':
83  switch ($a_attribs['type']) {
85  default:
87  break;
88  }
89  break;
90 
91  case 'Target':
92  $target_id = $this->parseTargetId($a_attribs['id'] ?? '');
93  if ($target_id) {
94  $this->logger->debug('Using mapped target_id: ' . $target_id);
95  $this->getReference()->setTargetId($target_id);
96  } else {
97  $this->logger->info('No mapping found for: ' . $a_attribs['id']);
98  $this->getReference()->setTargetId(0);
99  }
100  break;
101  }
102  }
+ Here is the call graph for this function:

◆ handlerCharacterData()

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

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

154  : void {
155  if (!empty($a_data)) {
156  $this->cdata .= $a_data;
157  }
158  }

◆ handlerEndTag()

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

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

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

130  : void {
131  $this->cdata = $this->trimAndStrip($this->cdata);
132  switch ($a_name) {
133  case "ContainerReference":
134  $this->save();
135  break;
136 
137  case 'Title':
138  if ($this->getReference()->getTitleType() === ilContainerReference::TITLE_TYPE_CUSTOM) {
139  $this->getReference()->setTitle(trim($this->cdata));
140  }
141  break;
142  }
143  $this->cdata = '';
144  }
+ Here is the call graph for this function:

◆ parseTargetId()

ilContainerReferenceXmlParser::parseTargetId ( string  $attribute_target)
protected

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

References ILIAS\Repository\logger().

Referenced by handlerBeginTag().

104  : int
105  {
106  if ($attribute_target === '') {
107  $this->logger->debug('No target id provided');
108  return 0;
109  }
110  if (!$this->import_mapping instanceof ilImportMapping) {
111  return 0;
112  }
113  $obj_mapping_id = $this->import_mapping->getMapping('Services/Container', 'objs', $attribute_target);
114  if (!$obj_mapping_id) {
115  $this->logger->debug('Cannot find object mapping for target_id: ' . $attribute_target);
116  return 0;
117  }
118 
119  return (int) $obj_mapping_id;
120  }
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:
+ Here is the caller graph for this function:

◆ save()

ilContainerReferenceXmlParser::save ( )
protected

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

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

Referenced by handlerEndTag().

164  : void
165  {
166  if ($this->mode === ilCategoryXmlParser::MODE_CREATE) {
167  $this->create();
168  $this->getReference()->create();
169  $this->getReference()->createReference();
170  $this->getReference()->putInTree($this->getParentId());
171  $this->getReference()->setPermissions($this->getParentId());
172  }
173  $this->getReference()->update();
174  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHandlers()

ilContainerReferenceXmlParser::setHandlers (   $a_xml_parser)

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

59  : void
60  {
61  xml_set_object($a_xml_parser, $this);
62  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
63  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
64  }

◆ setImportMapping()

ilContainerReferenceXmlParser::setImportMapping ( ilImportMapping  $mapping)

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

49  : void
50  {
51  $this->import_mapping = $mapping;
52  }

◆ setMode()

ilContainerReferenceXmlParser::setMode ( int  $mode)

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

References $mode.

176  : void
177  {
178  $this->mode = $mode;
179  }

◆ setReference()

ilContainerReferenceXmlParser::setReference ( ilContainerReference  $ref)

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

References $ref.

182  : void
183  {
184  $this->ref = $ref;
185  }

Field Documentation

◆ $cdata

string ilContainerReferenceXmlParser::$cdata = ""
protected

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

◆ $import_mapping

ilImportMapping ilContainerReferenceXmlParser::$import_mapping
protected

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

◆ $logger

ilLogger ilContainerReferenceXmlParser::$logger
protected

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

◆ $mode

int ilContainerReferenceXmlParser::$mode = 0
protected

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

Referenced by setMode().

◆ $parent_id

int ilContainerReferenceXmlParser::$parent_id = 0
private

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

Referenced by getParentId().

◆ $ref

ilContainerReference ilContainerReferenceXmlParser::$ref = null
private

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

Referenced by getReference(), and setReference().

◆ MODE_CREATE

const ilContainerReferenceXmlParser::MODE_CREATE = 1

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

◆ MODE_UPDATE

const ilContainerReferenceXmlParser::MODE_UPDATE = 2

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