ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilContainerXmlParser Class Reference

XML parser for container structure. More...

+ Collaboration diagram for ilContainerXmlParser:

Public Member Functions

 __construct (ilImportMapping $mapping, $xml='')
 Constructor. More...
 
 getMapping ()
 Get ilImportMapping object. More...
 
 parse ($a_root_id)
 

Static Public Attributes

static $style_map = array()
 

Protected Member Functions

 initItem ($item, $a_parent_node)
 Init Item. More...
 
 parseTiming ($a_ref_id, $a_parent_id, $timing)
 Parse timing info. More...
 
 createObject ($ref_id, $obj_id, $type, $title, $parent_node)
 Create the objects. More...
 

Protected Attributes

 $settings
 
 $obj_definition
 
 $cont_log
 

Private Attributes

 $source = 0
 
 $mapping = null
 
 $xml = ''
 
 $sxml = null
 
 $root_id = 0
 

Detailed Description

XML parser for container structure.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 14 of file class.ilContainerXmlParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilContainerXmlParser::__construct ( ilImportMapping  $mapping,
  $xml = '' 
)

Constructor.

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

44 {
45 global $DIC;
46
47 $this->settings = $DIC->settings();
48 $this->obj_definition = $DIC["objDefinition"];
49 $this->mapping = $mapping;
50 $this->xml = $xml;
51 $this->cont_log = ilLoggerFactory::getLogger('cont');
52 }
static getLogger($a_component_id)
Get component logger.
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2

References $DIC, $mapping, $xml, ilLoggerFactory\getLogger(), and settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ createObject()

ilContainerXmlParser::createObject (   $ref_id,
  $obj_id,
  $type,
  $title,
  $parent_node 
)
protected

Create the objects.

Parameters
object$ref_id
object$obj_id
object$type
object$title
object$parent_node
Returns

Definition at line 205 of file class.ilContainerXmlParser.php.

206 {
207 $objDefinition = $this->obj_definition;
208
209 // A mapping for this object already exists => create reference
210 $new_obj_id = $this->getMapping()->getMapping('Services/Container', 'objs', $obj_id);
211 if ($new_obj_id) {
212 include_once './Services/Object/classes/class.ilObjectFactory.php';
213 $obj = ilObjectFactory::getInstanceByObjId($new_obj_id, false);
214 if ($obj instanceof ilObject) {
215 $obj->createReference();
216 $obj->putInTree($parent_node);
217 $obj->setPermissions($parent_node);
218 $this->mapping->addMapping('Services/Container', 'refs', $ref_id, $obj->getRefId());
219 return $obj->getRefId();
220 }
221 }
222
223 $class_name = "ilObj" . $objDefinition->getClassName($type);
224 $location = $objDefinition->getLocation($type);
225
226 include_once($location . "/class." . $class_name . ".php");
227 $new = new $class_name();
228 $new->setTitle($title);
229 $new->create(true);
230 $new->createReference();
231 $new->putInTree($parent_node);
232 $new->setPermissions($parent_node);
233
234 $this->mapping->addMapping('Services/Container', 'objs', $obj_id, $new->getId());
235 $this->mapping->addMapping('Services/Container', 'refs', $ref_id, $new->getRefId());
236
237 return $new->getRefId();
238 }
$location
Definition: buildRTE.php:44
getMapping()
Get ilImportMapping object.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObject Basic functions for all objects.
$type

References $location, $new, $obj_definition, $title, $type, ilObjectFactory\getInstanceByObjId(), and getMapping().

Referenced by initItem().

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

◆ getMapping()

ilContainerXmlParser::getMapping ( )

Get ilImportMapping object.

Returns
ilImportMapping $map

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

60 {
61 return $this->mapping;
62 }

References $mapping.

Referenced by createObject(), and initItem().

+ Here is the caller graph for this function:

◆ initItem()

ilContainerXmlParser::initItem (   $item,
  $a_parent_node 
)
protected

Init Item.

Parameters
object$item
object$a_parent_node
Returns

Definition at line 80 of file class.ilContainerXmlParser.php.

81 {
83
84 $title = (string) $item['Title'];
85 $ref_id = (string) $item['RefId'];
86 $obj_id = (string) $item['Id'];
87 $type = (string) $item['Type'];
88
89
90 $new_ref = $this->getMapping()->getMapping('Services/Container', 'refs', $ref_id);
91
92 if (
93 !$new_ref &&
94 ($obj_id == $this->root_id)
95 ) {
96 // if container without subitems a dummy container has already been created
97 // see ilImportContainer::createDummy()
98 $new_ref = $this->mapping->getMapping('Services/Container', 'refs', 0);
99
100 // see below and ilContainerImporter::finalProcessing()
101 $this->mapping->addMapping('Services/Container', 'objs', $obj_id, ilObject::_lookupObjId($new_ref));
102 }
103
104 if (!$new_ref) {
105 $new_ref = $this->createObject($ref_id, $obj_id, $type, $title, $a_parent_node);
106 }
107
108 // Course item information
109 foreach ($item->Timing as $timing) {
110 $this->parseTiming($new_ref, $a_parent_node, $timing);
111 }
112
113 foreach ($item->Item as $subitem) {
114 $this->initItem($subitem, $new_ref);
115 }
116
117 $new_obj_id = $this->mapping->getMapping('Services/Container', 'objs', $obj_id);
118
119 // style
120 if ((int) $item['Style']) {
121 self::$style_map[(int) $item['Style']][] = $new_obj_id;
122 }
123
124 // pages
125 if ($ilSetting->get('enable_cat_page_edit', false)) {
126 if ($item['Page'] == "1") {
127 $this->mapping->addMapping('Services/COPage', 'pg', 'cont:' . $obj_id, 'cont:' . $new_obj_id);
128 $this->cont_log->debug("add pg cont mapping, old: " . $obj_id . ", new: " . $new_obj_id . ", Page: -" . $item['Page'] . "-");
129 }
130
131 if ($item['StartPage'] == "1") {
132 $this->mapping->addMapping('Services/COPage', 'pg', 'cstr:' . $obj_id, 'cstr:' . $new_obj_id);
133 }
134 }
135 }
initItem($item, $a_parent_node)
Init Item.
parseTiming($a_ref_id, $a_parent_id, $timing)
Parse timing info.
createObject($ref_id, $obj_id, $type, $title, $parent_node)
Create the objects.
static _lookupObjId($a_id)
global $ilSetting
Definition: privfeed.php:17

References $ilSetting, $settings, $title, $type, ilObject\_lookupObjId(), createObject(), getMapping(), initItem(), and parseTiming().

Referenced by initItem(), and parse().

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

◆ parse()

ilContainerXmlParser::parse (   $a_root_id)

Definition at line 64 of file class.ilContainerXmlParser.php.

65 {
66 $this->sxml = simplexml_load_string($this->xml);
67 $this->root_id = $a_root_id;
68
69 foreach ($this->sxml->Item as $item) {
70 $this->initItem($item, $this->mapping->getTargetId());
71 }
72 }

References initItem().

+ Here is the call graph for this function:

◆ parseTiming()

ilContainerXmlParser::parseTiming (   $a_ref_id,
  $a_parent_id,
  $timing 
)
protected

Parse timing info.

Parameters
object$a_ref_id
object$a_parent_id
object$timing
Returns

Definition at line 144 of file class.ilContainerXmlParser.php.

145 {
146 $type = (string) $timing['Type'];
147 $visible = (string) $timing['Visible'];
148 $changeable = (string) $timing['Changeable'];
149
150 include_once './Services/Object/classes/class.ilObjectActivation.php';
151 $crs_item = new ilObjectActivation();
152 $crs_item->setTimingType($type);
153 $crs_item->toggleVisible((bool) $visible);
154 $crs_item->toggleChangeable((bool) $changeable);
155
156 foreach ($timing->children() as $sub) {
157 switch ((string) $sub->getName()) {
158 case 'Start':
159 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
160 $crs_item->setTimingStart($dt->get(IL_CAL_UNIX));
161 break;
162
163 case 'End':
164 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
165 $crs_item->setTimingEnd($dt->get(IL_CAL_UNIX));
166 break;
167
168 case 'SuggestionStart':
169 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
170 $crs_item->setSuggestionStart($dt->get(IL_CAL_UNIX));
171 break;
172
173 case 'SuggestionEnd':
174 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
175 $crs_item->setSuggestionEnd($dt->get(IL_CAL_UNIX));
176 break;
177
178 case 'EarliestStart':
179 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
180 $crs_item->setEarliestStart($dt->get(IL_CAL_UNIX));
181 break;
182
183 case 'LatestEnd':
184 $dt = new ilDateTime((string) $sub, IL_CAL_DATETIME, ilTimeZone::UTC);
185 $crs_item->setLatestEnd($dt->get(IL_CAL_UNIX));
186 break;
187 }
188 }
189
190
191 if ($crs_item->getTimingStart()) {
192 $crs_item->update($a_ref_id, $a_parent_id);
193 }
194 }
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
Class ilObjectActivation.

References $type, IL_CAL_DATETIME, IL_CAL_UNIX, and ilTimeZone\UTC.

Referenced by initItem().

+ Here is the caller graph for this function:

Field Documentation

◆ $cont_log

ilContainerXmlParser::$cont_log
protected

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

◆ $mapping

ilContainerXmlParser::$mapping = null
private

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

Referenced by __construct(), and getMapping().

◆ $obj_definition

ilContainerXmlParser::$obj_definition
protected

Definition at line 24 of file class.ilContainerXmlParser.php.

Referenced by createObject().

◆ $root_id

ilContainerXmlParser::$root_id = 0
private

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

◆ $settings

ilContainerXmlParser::$settings
protected

Definition at line 19 of file class.ilContainerXmlParser.php.

Referenced by initItem().

◆ $source

ilContainerXmlParser::$source = 0
private

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

◆ $style_map

ilContainerXmlParser::$style_map = array()
static

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

Referenced by ilContainerImporter\finalProcessing().

◆ $sxml

ilContainerXmlParser::$sxml = null
private

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

◆ $xml

ilContainerXmlParser::$xml = ''
private

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

Referenced by __construct().


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