ILIAS  eassessment Revision 61809
 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.
 createSurveyPool ($title, $parent_node)
 Create pool for survey.

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

References $location, $ref_id, $title, $type, createSurveyPool(), 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 './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());
if($type == 'svy')
{
$pool = $this->createSurveyPool($title,$parent_node);
$this->mapping->addMapping('Services/Container', 'spl', $new->getId(), $pool->getRefId());
}
return $new->getRefId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilContainerXmlParser::createSurveyPool (   $title,
  $parent_node 
)
protected

Create pool for survey.

Parameters
object$title
object$parent_node
Returns

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

References $location, and $title.

Referenced by createObject().

{
global $objDefinition;
$class_name = "ilObj".$objDefinition->getClassName('spl');
$location = $objDefinition->getLocation('spl');
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);
return $new;
}

+ 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, $type, 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 $type, 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 './Modules/Course/classes/class.ilCourseItems.php';
$crs_items = new ilCourseItems($a_parent_id,$a_parent_id);
$crs_items->setTimingType($type);
$crs_items->toggleVisible((bool) $visible);
$crs_items->toggleChangeable((bool) $changeable);
$crs_items->setItemId($a_ref_id);
foreach($timing->children() as $sub)
{
switch((string) $sub->getName())
{
case 'Start':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_items->setTimingStart($dt->get(IL_CAL_UNIX));
break;
case 'End':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_items->setTimingEnd($dt->get(IL_CAL_UNIX));
break;
case 'SuggestionStart':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_items->setSuggestionStart($dt->get(IL_CAL_UNIX));
break;
case 'SuggestionEnd':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_items->setSuggestionEnd($dt->get(IL_CAL_UNIX));
break;
case 'EarliestStart':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_items->setEarliestStart($dt->get(IL_CAL_UNIX));
break;
case 'LatestEnd':
$dt = new ilDateTime((string) $sub,IL_CAL_DATETIME,ilTimeZone::UTC);
$crs_items->setLatestEnd($dt->get(IL_CAL_UNIX));
break;
}
}
if($crs_items->getTimingStart())
{
$crs_items->update($a_ref_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: