ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

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

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  }
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
static getLogger($a_component_id)
Get component logger.
+ 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 203 of file class.ilContainerXmlParser.php.

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

Referenced by initItem().

204  {
205  $objDefinition = $this->obj_definition;
206 
207  // A mapping for this object already exists => create reference
208  $new_obj_id = $this->getMapping()->getMapping('Services/Container', 'objs', $obj_id);
209  if ($new_obj_id) {
210  include_once './Services/Object/classes/class.ilObjectFactory.php';
211  $obj = ilObjectFactory::getInstanceByObjId($new_obj_id, false);
212  if ($obj instanceof ilObject) {
213  $obj->createReference();
214  $obj->putInTree($parent_node);
215  $obj->setPermissions($parent_node);
216  $this->mapping->addMapping('Services/Container', 'refs', $ref_id, $obj->getRefId());
217  return $obj->getRefId();
218  }
219  }
220 
221  $class_name = "ilObj" . $objDefinition->getClassName($type);
222  $location = $objDefinition->getLocation($type);
223 
224  include_once($location . "/class." . $class_name . ".php");
225  $new = new $class_name();
226  $new->setTitle($title);
227  $new->create(true);
228  $new->createReference();
229  $new->putInTree($parent_node);
230  $new->setPermissions($parent_node);
231 
232  $this->mapping->addMapping('Services/Container', 'objs', $obj_id, $new->getId());
233  $this->mapping->addMapping('Services/Container', 'refs', $ref_id, $new->getRefId());
234 
235  return $new->getRefId();
236  }
$type
$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
+ 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.

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.

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

Referenced by parse().

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.
$type
getMapping()
Get ilImportMapping object.
static _lookupObjId($a_id)
createObject($ref_id, $obj_id, $type, $title, $parent_node)
Create the objects.
parseTiming($a_ref_id, $a_parent_id, $timing)
Parse timing info.
global $ilSetting
Definition: privfeed.php:17
+ 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.

References initItem().

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  }
initItem($item, $a_parent_node)
Init Item.
+ 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.

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

Referenced by initItem().

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  break;
185  }
186  }
187 
188 
189  if ($crs_item->getTimingStart()) {
190  $crs_item->update($a_ref_id, $a_parent_id);
191  }
192  }
const IL_CAL_DATETIME
$type
const IL_CAL_UNIX
Date and time handling
Class ilObjectActivation.
+ 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: