ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 

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

Private Attributes

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

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 25 of file class.ilContainerXmlParser.php.

References $mapping, and $xml.

26  {
27  $this->mapping = $mapping;
28  $this->xml = $xml;
29  }

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 149 of file class.ilContainerXmlParser.php.

References $location, $ref_id, ilObjectFactory\getInstanceByObjId(), and getMapping().

Referenced by initItem().

150  {
151  global $objDefinition;
152 
153  // A mapping for this object already exists => create reference
154  $new_obj_id = $this->getMapping()->getMapping('Services/Container', 'objs', $obj_id);
155  if($new_obj_id)
156  {
157  include_once './Services/Object/classes/class.ilObjectFactory.php';
158  $obj = ilObjectFactory::getInstanceByObjId($new_obj_id,false);
159  if($obj instanceof ilObject)
160  {
161  $obj->createReference();
162  $obj->putInTree($parent_node);
163  $obj->setPermissions($parent_node);
164  $this->mapping->addMapping('Services/Container','refs',$ref_id,$obj->getRefId());
165  return $obj->getRefId();
166  }
167  }
168 
169  $class_name = "ilObj".$objDefinition->getClassName($type);
170  $location = $objDefinition->getLocation($type);
171 
172  include_once($location."/class.".$class_name.".php");
173  $new = new $class_name();
174  $new->setTitle($title);
175  $new->create(true);
176  $new->createReference();
177  $new->putInTree($parent_node);
178  $new->setPermissions($parent_node);
179 
180  $this->mapping->addMapping('Services/Container','objs', $obj_id, $new->getId());
181  $this->mapping->addMapping('Services/Container','refs',$ref_id,$new->getRefId());
182 
183  return $new->getRefId();
184  }
$location
Definition: buildRTE.php:44
Class ilObject Basic functions for all objects.
getMapping()
Get ilImportMapping object.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$ref_id
Definition: sahs_server.php:39
+ 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 36 of file class.ilContainerXmlParser.php.

References $mapping.

Referenced by createObject().

+ 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 57 of file class.ilContainerXmlParser.php.

References $ref_id, createObject(), and parseTiming().

Referenced by parse().

58  {
59  $title = (string) $item['Title'];
60  $ref_id = (string) $item['RefId'];
61  $obj_id = (string) $item['Id'];
62  $type = (string) $item['Type'];
63 
64  $new_ref = $this->createObject($ref_id,$obj_id,$type,$title,$a_parent_node);
65 
66  // Course item information
67  foreach($item->Timing as $timing)
68  {
69  $this->parseTiming($new_ref,$a_parent_node,$timing);
70  }
71 
72  foreach($item->Item as $subitem)
73  {
74  $this->initItem($subitem, $new_ref);
75  }
76  }
initItem($item, $a_parent_node)
Init Item.
createObject($ref_id, $obj_id, $type, $title, $parent_node)
Create the objects.
parseTiming($a_ref_id, $a_parent_id, $timing)
Parse timing info.
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse()

ilContainerXmlParser::parse ( )

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

References initItem().

42  {
43  $this->sxml = simplexml_load_string($this->xml);
44 
45  foreach($this->sxml->Item as $item)
46  {
47  $this->initItem($item,$this->mapping->getTargetId());
48  }
49  }
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 85 of file class.ilContainerXmlParser.php.

References IL_CAL_DATETIME, IL_CAL_UNIX, and ilTimeZone\UTC.

Referenced by initItem().

86  {
87  $type = (string) $timing['Type'];
88  $visible = (string) $timing['Visible'];
89  $changeable = (string) $timing['Changeable'];
90 
91  include_once './Services/Object/classes/class.ilObjectActivation.php';
92  $crs_item = new ilObjectActivation();
93  $crs_item->setTimingType($type);
94  $crs_item->toggleVisible((bool) $visible);
95  $crs_item->toggleChangeable((bool) $changeable);
96 
97  foreach($timing->children() as $sub)
98  {
99  switch((string) $sub->getName())
100  {
101  case 'Start':
102  $dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
103  $crs_item->setTimingStart($dt->get(IL_CAL_UNIX));
104  break;
105 
106  case 'End':
107  $dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
108  $crs_item->setTimingEnd($dt->get(IL_CAL_UNIX));
109  break;
110 
111  case 'SuggestionStart':
112  $dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
113  $crs_item->setSuggestionStart($dt->get(IL_CAL_UNIX));
114  break;
115 
116  case 'SuggestionEnd':
117  $dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
118  $crs_item->setSuggestionEnd($dt->get(IL_CAL_UNIX));
119  break;
120 
121  case 'EarliestStart':
122  $dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
123  $crs_item->setEarliestStart($dt->get(IL_CAL_UNIX));
124  break;
125 
126  case 'LatestEnd':
127  $dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
128  $crs_item->setLatestEnd($dt->get(IL_CAL_UNIX));
129  break;
130  }
131  }
132 
133 
134  if($crs_item->getTimingStart())
135  {
136  $crs_item->update($a_ref_id, $a_parent_id);
137  }
138  }
const IL_CAL_DATETIME
const IL_CAL_UNIX
Date and time handling
Class ilObjectActivation.
+ Here is the caller graph for this function:

Field Documentation

◆ $mapping

ilContainerXmlParser::$mapping = null
private

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

Referenced by __construct(), and getMapping().

◆ $source

ilContainerXmlParser::$source = 0
private

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

◆ $sxml

ilContainerXmlParser::$sxml = null
private

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

◆ $xml

ilContainerXmlParser::$xml = ''
private

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

Referenced by __construct().


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