ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
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

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

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

35  {
36  $this->mapping = $mapping;
37  $this->xml = $xml;
38  $this->cont_log = ilLoggerFactory::getLogger('cont');
39  }
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 204 of file class.ilContainerXmlParser.php.

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

Referenced by initItem().

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

References $ilSetting, $ref_id, $title, ilObject\_lookupObjId(), createObject(), getMapping(), parseTiming(), and string.

Referenced by parse().

69  {
70  global $ilSetting;
71 
72  $title = (string) $item['Title'];
73  $ref_id = (string) $item['RefId'];
74  $obj_id = (string) $item['Id'];
75  $type = (string) $item['Type'];
76 
77 
78  $new_ref = $this->getMapping()->getMapping('Services/Container', 'refs', $ref_id);
79 
80  if(
81  !$new_ref &&
82  ($obj_id == $this->root_id)
83  )
84  {
85  // if container without subitems a dummy container has already been created
86  // see ilImportContainer::createDummy()
87  $new_ref = $this->mapping->getMapping('Services/Container', 'refs', 0);
88 
89  // see below and ilContainerImporter::finalProcessing()
90  $this->mapping->addMapping('Services/Container','objs', $obj_id, ilObject::_lookupObjId($new_ref));
91  }
92 
93  if(!$new_ref)
94  {
95  $new_ref = $this->createObject($ref_id,$obj_id,$type,$title,$a_parent_node);
96  }
97 
98  // Course item information
99  foreach($item->Timing as $timing)
100  {
101  $this->parseTiming($new_ref,$a_parent_node,$timing);
102  }
103 
104  foreach($item->Item as $subitem)
105  {
106  $this->initItem($subitem, $new_ref);
107  }
108 
109  $new_obj_id = $this->mapping->getMapping('Services/Container', 'objs', $obj_id);
110 
111  // style
112  if((int)$item['Style'])
113  {
114  self::$style_map[(int)$item['Style']][] = $new_obj_id;
115  }
116 
117  // pages
118  if($ilSetting->get('enable_cat_page_edit', false))
119  {
120  if($item['Page'] == "1")
121  {
122  $this->mapping->addMapping('Services/COPage', 'pg', 'cont:'.$obj_id, 'cont:'.$new_obj_id);
123  $this->cont_log->debug("add pg cont mapping, old: ".$obj_id.", new: ".$new_obj_id.", Page: -".$item['Page']."-");
124  }
125 
126  if($item['StartPage'] == "1")
127  {
128  $this->mapping->addMapping('Services/COPage', 'pg', 'cstr:'.$obj_id, 'cstr:'.$new_obj_id);
129  }
130  }
131  }
initItem($item, $a_parent_node)
Init Item.
getMapping()
Get ilImportMapping object.
Add rich text string
The name of the decorator.
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.
$ref_id
Definition: sahs_server.php:39
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 51 of file class.ilContainerXmlParser.php.

References initItem().

52  {
53  $this->sxml = simplexml_load_string($this->xml);
54  $this->root_id = $a_root_id;
55 
56  foreach($this->sxml->Item as $item)
57  {
58  $this->initItem($item,$this->mapping->getTargetId());
59  }
60  }
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 140 of file class.ilContainerXmlParser.php.

References IL_CAL_DATETIME, IL_CAL_UNIX, string, and ilTimeZone\UTC.

Referenced by initItem().

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

◆ $mapping

ilContainerXmlParser::$mapping = null
private

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

Referenced by __construct(), and getMapping().

◆ $root_id

ilContainerXmlParser::$root_id = 0
private

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

◆ $source

ilContainerXmlParser::$source = 0
private

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

◆ $style_map

ilContainerXmlParser::$style_map = array()
static

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

Referenced by ilContainerImporter\finalProcessing().

◆ $sxml

ilContainerXmlParser::$sxml = null
private

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

◆ $xml

ilContainerXmlParser::$xml = ''
private

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

Referenced by __construct().


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