ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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\GlobalScreen\Provider\__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(Container $dic, ilPlugin $plugin)
setXMLContent(string $a_xml_content)
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilContainerReferenceXmlParser::create ( )
protected

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

Referenced by save().

161  : void
162  {
163  }
+ 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 188 of file class.ilContainerReferenceXmlParser.php.

References $ref.

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

189  {
190  return $this->ref;
191  }
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 $target_id, 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']) {
84 
86  default:
88  break;
89  }
90  break;
91 
92  case 'Target':
93  $target_id = $this->parseTargetId($a_attribs['id'] ?? '');
94  if ($target_id) {
95  $this->logger->debug('Using mapped target_id: ' . $target_id);
96  $this->getReference()->setTargetId($target_id);
97  } else {
98  $this->logger->info('No mapping found for: ' . $a_attribs['id']);
99  $this->getReference()->setTargetId(0);
100  }
101  break;
102  }
103  }
$target_id
Definition: goto.php:52
+ 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 152 of file class.ilContainerReferenceXmlParser.php.

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

◆ handlerEndTag()

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

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

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

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

◆ parseTargetId()

ilContainerReferenceXmlParser::parseTargetId ( string  $attribute_target)
protected

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

References ILIAS\Repository\logger().

Referenced by handlerBeginTag().

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

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

Referenced by handlerEndTag().

165  : void
166  {
167  if ($this->mode === ilCategoryXmlParser::MODE_CREATE) {
168  $this->create();
169  $this->getReference()->create();
170  $this->getReference()->createReference();
171  $this->getReference()->putInTree($this->getParentId());
172  $this->getReference()->setPermissions($this->getParentId());
173  }
174  $this->getReference()->update();
175  }
+ 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 177 of file class.ilContainerReferenceXmlParser.php.

References $mode.

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

◆ setReference()

ilContainerReferenceXmlParser::setReference ( ilContainerReference  $ref)

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

References $ref.

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

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: