ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 26 of file class.ilContainerReferenceXmlParser.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\logger(), null, and ilSaxParser\setXMLContent().

41  {
42  global $DIC;
43 
45 
46  $this->mode = self::MODE_CREATE;
47  $this->setXMLContent($a_xml);
48 
49  $this->logger = $DIC->logger()->exp();
50  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
__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 162 of file class.ilContainerReferenceXmlParser.php.

Referenced by save().

162  : void
163  {
164  }
+ Here is the caller graph for this function:

◆ getParentId()

ilContainerReferenceXmlParser::getParentId ( )

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

References $parent_id.

Referenced by save().

57  : int
58  {
59  return $this->parent_id;
60  }
+ Here is the caller graph for this function:

◆ getReference()

ilContainerReferenceXmlParser::getReference ( )

Definition at line 189 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,
string  $a_name,
array  $a_attribs 
)
Parameters
XMLParser | resource$a_xml_parser
string$a_name
array$a_attribs
Returns
void

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

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

Referenced by setHandlers().

78  : void {
79  $a_attribs = $this->trimAndStripAttribs($a_attribs);
80  switch ($a_name) {
81  case "ContainerReference":
82  break;
83 
84  case 'Title':
85  switch ($a_attribs['type']) {
87  default:
89  break;
90  }
91  break;
92 
93  case 'Target':
94  $target_id = $this->parseTargetId($a_attribs['id'] ?? '');
95  if ($target_id) {
96  $this->logger->debug('Using mapped target_id: ' . $target_id);
97  $this->getReference()->setTargetId($target_id);
98  } else {
99  $this->logger->info('No mapping found for: ' . $a_attribs['id']);
100  $this->getReference()->setTargetId(0);
101  }
102  break;
103  }
104  }
+ Here is the call graph for this function:
+ Here is the caller 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 153 of file class.ilContainerReferenceXmlParser.php.

Referenced by setHandlers().

156  : void {
157  if (!empty($a_data)) {
158  $this->cdata .= $a_data;
159  }
160  }
+ Here is the caller graph for this function:

◆ handlerEndTag()

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

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

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

Referenced by setHandlers().

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

◆ parseTargetId()

ilContainerReferenceXmlParser::parseTargetId ( string  $attribute_target)
protected

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

References ILIAS\Repository\logger().

Referenced by handlerBeginTag().

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

◆ save()

ilContainerReferenceXmlParser::save ( )
protected

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

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

Referenced by handlerEndTag().

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

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

62  : void
63  {
64  xml_set_element_handler($a_xml_parser, $this->handlerBeginTag(...), $this->handlerEndTag(...));
65  xml_set_character_data_handler($a_xml_parser, $this->handlerCharacterData(...));
66  }
handlerBeginTag( $a_xml_parser, string $a_name, array $a_attribs)
handlerCharacterData( $a_xml_parser, string $a_data)
+ Here is the call graph for this function:

◆ setImportMapping()

ilContainerReferenceXmlParser::setImportMapping ( ilImportMapping  $mapping)

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

52  : void
53  {
54  $this->import_mapping = $mapping;
55  }

◆ setMode()

ilContainerReferenceXmlParser::setMode ( int  $mode)

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

References $mode.

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

◆ setReference()

ilContainerReferenceXmlParser::setReference ( ilContainerReference  $ref)

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

References $ref.

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

Field Documentation

◆ $cdata

string ilContainerReferenceXmlParser::$cdata = ""
protected

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

◆ $import_mapping

ilImportMapping ilContainerReferenceXmlParser::$import_mapping
protected

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

◆ $logger

ilLogger ilContainerReferenceXmlParser::$logger
protected

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

◆ $mode

int ilContainerReferenceXmlParser::$mode = 0
protected

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

Referenced by setMode().

◆ $parent_id

int ilContainerReferenceXmlParser::$parent_id = 0
private

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

Referenced by getParentId().

◆ $ref

ilContainerReference ilContainerReferenceXmlParser::$ref = null
private

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

Referenced by getReference(), and setReference().

◆ MODE_CREATE

const ilContainerReferenceXmlParser::MODE_CREATE = 1

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

◆ MODE_UPDATE

const ilContainerReferenceXmlParser::MODE_UPDATE = 2

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