ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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 }
setXMLContent(string $a_xml_content)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilContainerReferenceXmlParser::create ( )
protected

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

162 : void
163 {
164 }

◆ getParentId()

ilContainerReferenceXmlParser::getParentId ( )

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

References $parent_id.

◆ getReference()

ilContainerReferenceXmlParser::getReference ( )

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

Referenced by handlerBeginTag().

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

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 }

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

Referenced by setHandlers().

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

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

Referenced by setHandlers().

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

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 }

References ilContainerReference\TITLE_TYPE_CUSTOM.

Referenced by setHandlers().

+ Here is the caller graph for this function:

◆ parseTargetId()

ilContainerReferenceXmlParser::parseTargetId ( string  $attribute_target)
protected

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

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 }

References ILIAS\Repository\logger().

Referenced by handlerBeginTag().

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

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 }

References ilCategoryXmlParser\MODE_CREATE.

◆ setHandlers()

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

Reimplemented from ilSaxParser.

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

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 }
handlerCharacterData( $a_xml_parser, string $a_data)
handlerBeginTag( $a_xml_parser, string $a_name, array $a_attribs)

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

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

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

◆ setReference()

ilContainerReferenceXmlParser::setReference ( ilContainerReference  $ref)

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

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.

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

◆ MODE_CREATE

const ilContainerReferenceXmlParser::MODE_CREATE = 1

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

Referenced by __construct().

◆ MODE_UPDATE

const ilContainerReferenceXmlParser::MODE_UPDATE = 2

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


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