ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 

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

29 {
30 $this->mapping = $mapping;
31 $this->xml = $xml;
32 }

References $mapping, and $xml.

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

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

References $location, $ref_id, 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 39 of file class.ilContainerXmlParser.php.

40 {
41 return $this->mapping;
42 }

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

62 {
63 global $ilSetting;
64
65 $title = (string) $item['Title'];
66 $ref_id = (string) $item['RefId'];
67 $obj_id = (string) $item['Id'];
68 $type = (string) $item['Type'];
69
70
71 $new_ref = $this->getMapping()->getMapping('Services/Container', 'refs', $ref_id);
72
73 if(
74 !$new_ref &&
75 ($obj_id == $this->root_id)
76 )
77 {
78 // if container without subitems a dummy container has already been created
79 // see ilImportContainer::createDummy()
80 $new_ref = $this->mapping->getMapping('Services/Container', 'refs', 0);
81
82 // see below and ilContainerImporter::finalProcessing()
83 $this->mapping->addMapping('Services/Container','objs', $obj_id, ilObject::_lookupObjId($new_ref));
84 }
85
86 if(!$new_ref)
87 {
88 $new_ref = $this->createObject($ref_id,$obj_id,$type,$title,$a_parent_node);
89 }
90
91 // Course item information
92 foreach($item->Timing as $timing)
93 {
94 $this->parseTiming($new_ref,$a_parent_node,$timing);
95 }
96
97 foreach($item->Item as $subitem)
98 {
99 $this->initItem($subitem, $new_ref);
100 }
101
102 $new_obj_id = $this->mapping->getMapping('Services/Container', 'objs', $obj_id);
103
104 // style
105 if((int)$item['Style'])
106 {
107 self::$style_map[(int)$item['Style']][] = $new_obj_id;
108 }
109
110 // pages
111 if($ilSetting->get('enable_cat_page_edit', false))
112 {
113 if((bool)$item['Page'])
114 {
115 $this->mapping->addMapping('Services/COPage', 'pg', 'cont:'.$obj_id, 'cont:'.$new_obj_id);
116 }
117
118 if((bool)$item['StartPage'])
119 {
120 $this->mapping->addMapping('Services/COPage', 'pg', 'cstr:'.$obj_id, 'cstr:'.$new_obj_id);
121 }
122 }
123 }
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:40

References $ilSetting, $ref_id, 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 44 of file class.ilContainerXmlParser.php.

45 {
46 $this->sxml = simplexml_load_string($this->xml);
47 $this->root_id = $a_root_id;
48
49 foreach($this->sxml->Item as $item)
50 {
51 $this->initItem($item,$this->mapping->getTargetId());
52 }
53 }

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

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

References IL_CAL_DATETIME, IL_CAL_UNIX, and ilTimeZone\UTC.

Referenced by initItem().

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

◆ $root_id

ilContainerXmlParser::$root_id = 0
private

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

◆ $source

ilContainerXmlParser::$source = 0
private

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

◆ $style_map

ilContainerXmlParser::$style_map = array()
static

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

Referenced by ilContainerImporter\finalProcessing().

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