ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilContainerXmlParser Class Reference

XML parser for container structure. More...

+ Collaboration diagram for ilContainerXmlParser:

Public Member Functions

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

Protected Member Functions

 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.

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

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

Constructor.

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

References $mapping, and $xml.

{
$this->mapping = $mapping;
$this->xml = $xml;
}

Member Function Documentation

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, $title, ilObjectFactory\getInstanceByObjId(), and getMapping().

Referenced by initItem().

{
global $objDefinition;
// A mapping for this object already exists => create reference
$new_obj_id = $this->getMapping()->getMapping('Services/Container', 'objs', $obj_id);
if($new_obj_id)
{
include_once './Services/Object/classes/class.ilObjectFactory.php';
$obj = ilObjectFactory::getInstanceByObjId($new_obj_id,false);
if($obj instanceof ilObject)
{
$obj->createReference();
$obj->putInTree($parent_node);
$obj->setPermissions($parent_node);
$this->mapping->addMapping('Services/Container','refs',$ref_id,$obj->getRefId());
return $obj->getRefId();
}
}
$class_name = "ilObj".$objDefinition->getClassName($type);
$location = $objDefinition->getLocation($type);
include_once($location."/class.".$class_name.".php");
$new = new $class_name();
$new->setTitle($title);
$new->create(true);
$new->createReference();
$new->putInTree($parent_node);
$new->setPermissions($parent_node);
$this->mapping->addMapping('Services/Container','objs', $obj_id, $new->getId());
$this->mapping->addMapping('Services/Container','refs',$ref_id,$new->getRefId());
return $new->getRefId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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:

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, $title, createObject(), and parseTiming().

Referenced by parse().

{
$title = (string) $item['Title'];
$ref_id = (string) $item['RefId'];
$obj_id = (string) $item['Id'];
$type = (string) $item['Type'];
$new_ref = $this->createObject($ref_id,$obj_id,$type,$title,$a_parent_node);
// Course item information
foreach($item->Timing as $timing)
{
$this->parseTiming($new_ref,$a_parent_node,$timing);
}
foreach($item->Item as $subitem)
{
$this->initItem($subitem, $new_ref);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilContainerXmlParser::parse ( )

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

References initItem().

{
$this->sxml = simplexml_load_string($this->xml);
foreach($this->sxml->Item as $item)
{
$this->initItem($item,$this->mapping->getTargetId());
}
}

+ Here is the call graph for this function:

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

{
$type = (string) $timing['Type'];
$visible = (string) $timing['Visible'];
$changeable = (string) $timing['Changeable'];
include_once './Services/Object/classes/class.ilObjectActivation.php';
$crs_item = new ilObjectActivation();
$crs_item->setTimingType($type);
$crs_item->toggleVisible((bool) $visible);
$crs_item->toggleChangeable((bool) $changeable);
foreach($timing->children() as $sub)
{
switch((string) $sub->getName())
{
case 'Start':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_item->setTimingStart($dt->get(IL_CAL_UNIX));
break;
case 'End':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_item->setTimingEnd($dt->get(IL_CAL_UNIX));
break;
case 'SuggestionStart':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_item->setSuggestionStart($dt->get(IL_CAL_UNIX));
break;
case 'SuggestionEnd':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_item->setSuggestionEnd($dt->get(IL_CAL_UNIX));
break;
case 'EarliestStart':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_item->setEarliestStart($dt->get(IL_CAL_UNIX));
break;
case 'LatestEnd':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_item->setLatestEnd($dt->get(IL_CAL_UNIX));
break;
}
}
if($crs_item->getTimingStart())
{
$crs_item->update($a_ref_id, $a_parent_id);
}
}

+ Here is the caller graph for this function:

Field Documentation

ilContainerXmlParser::$mapping = null
private

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

Referenced by __construct(), and getMapping().

ilContainerXmlParser::$source = 0
private

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

ilContainerXmlParser::$sxml = null
private

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

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: