ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDidacticTemplateImport Class Reference

Description of ilDidacticTemplateImport. More...

+ Collaboration diagram for ilDidacticTemplateImport:

Public Member Functions

 __construct ($a_type)
 Constructor.
 setInputFile ($a_file)
 Set input file.
 getInputFile ()
 Get inputfile.
 getInputType ()
 Get input type.
 import ()
 Do import.

Data Fields

const IMPORT_FILE = 1

Protected Member Functions

 parseSettings (SimpleXMLElement $root)
 Parse settings.
 parseActions (ilDidacticTemplateSetting $set, SimpleXMLElement $actions=NULL)
 Parse template action from xml.
 parseXmlErrors ()
 Parse xml errors from libxml_get_errors.

Private Attributes

 $type = 0
 $xmlfile = ''

Detailed Description

Description of ilDidacticTemplateImport.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 12 of file class.ilDidacticTemplateImport.php.

Constructor & Destructor Documentation

ilDidacticTemplateImport::__construct (   $a_type)

Constructor.

Parameters
<type>$a_type

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

{
$this->type = $a_type;
}

Member Function Documentation

ilDidacticTemplateImport::getInputFile ( )

Get inputfile.

Returns
<type>

Definition at line 42 of file class.ilDidacticTemplateImport.php.

References $xmlfile.

Referenced by import().

{
}

+ Here is the caller graph for this function:

ilDidacticTemplateImport::getInputType ( )

Get input type.

Returns
string

Definition at line 51 of file class.ilDidacticTemplateImport.php.

References $type.

Referenced by import().

{
return $this->type;
}

+ Here is the caller graph for this function:

ilDidacticTemplateImport::import ( )

Do import.

Definition at line 59 of file class.ilDidacticTemplateImport.php.

References getInputFile(), getInputType(), parseActions(), parseSettings(), and parseXmlErrors().

{
libxml_use_internal_errors(true);
switch($this->getInputType())
{
case self::IMPORT_FILE:
$root = simplexml_load_file($this->getInputFile());
if($root == FALSE)
{
$this->parseXmlErrors()
);
}
break;
}
$settings = $this->parseSettings($root);
$this->parseActions($settings,$root->didacticTemplate->actions);
}

+ Here is the call graph for this function:

ilDidacticTemplateImport::parseActions ( ilDidacticTemplateSetting  $set,
SimpleXMLElement  $actions = NULL 
)
protected

Parse template action from xml.

Parameters
ilDidacticTemplateSetting$set
SimpleXMLElement$root
Returns
void

Definition at line 131 of file class.ilDidacticTemplateImport.php.

References $tpl, ilDidacticTemplateAction\FILTER_SOURCE_TITLE, ilDidacticTemplateSetting\getId(), ilDidacticTemplateFilterPattern\PATTERN_SUBTYPE_REGEX, ilDidacticTemplateLocalPolicyAction\TPL_ACTION_INTERSECT, ilDidacticTemplateLocalPolicyAction\TPL_ACTION_OVERWRITE, and ilDidacticTemplateLocalPolicyAction\TPL_ACTION_UNION.

Referenced by import().

{
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
if($actions === NULL)
{
return void;
}
// Local role action
foreach($actions->localRoleAction as $ele)
{
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalRoleAction.php';
$act->setTemplateId($set->getId());
foreach($ele->roleTemplate as $tpl)
{
// extract role
foreach($tpl->role as $roleDef)
{
include_once './Services/AccessControl/classes/class.ilRoleXmlImporter.php';
$rimporter = new ilRoleXmlImporter(ROLE_FOLDER_ID);
$role_id = $rimporter->importSimpleXml($roleDef);
$act->setRoleTemplateId($role_id);
}
$act->save();
}
}
// Block role action
foreach($actions->blockRoleAction as $ele)
{
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateBlockRoleAction.php';
$act->setTemplateId($set->getId());
// Role filter
foreach($ele->roleFilter as $rfi)
{
$act->setFilterType((string) $rfi->attributes()->source);
foreach($rfi->includePattern as $pat)
{
// @TODO other subtypes
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
$pattern->setPattern((string) $pat->attributes()->preg);
$act->addFilterPattern($pattern);
}
foreach($rfi->excludePattern as $pat)
{
// @TODO other subtypes
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
$pattern->setPattern((string) $pat->attributes()->preg);
$act->addFilterPattern($pattern);
}
}
$act->save();
}
// Local policy action
foreach($actions->localPolicyAction as $ele)
{
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalPolicyAction.php';
$act->setTemplateId($set->getId());
// Role filter
foreach($ele->roleFilter as $rfi)
{
$act->setFilterType((string) $rfi->attributes()->source);
foreach($rfi->includePattern as $pat)
{
// @TODO other subtypes
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
$pattern->setPattern((string) $pat->attributes()->preg);
$act->addFilterPattern($pattern);
}
foreach($rfi->excludePattern as $pat)
{
// @TODO other subtypes
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
$pattern->setPattern((string) $pat->attributes()->preg);
$act->addFilterPattern($pattern);
}
}
// role template assignment
foreach($ele->localPolicyTemplate as $lpo)
{
switch((string) $lpo->attributes()->type)
{
case 'overwrite':
break;
case 'union':
break;
case 'intersect':
break;
}
// extract role
foreach($lpo->role as $roleDef)
{
include_once './Services/AccessControl/classes/class.ilRoleXmlImporter.php';
$rimporter = new ilRoleXmlImporter(ROLE_FOLDER_ID);
$role_id = $rimporter->importSimpleXml($roleDef);
$act->setRoleTemplateId($role_id);
}
}
// Save action including all filter patterns
$act->save();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDidacticTemplateImport::parseSettings ( SimpleXMLElement  $root)
protected

Parse settings.

Parameters
SimpleXMLElement$el
Returns
ilDidacticTemplateSetting

Definition at line 87 of file class.ilDidacticTemplateImport.php.

References $tpl, and ilDidacticTemplateSetting\TYPE_CREATION.

Referenced by import().

{
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSetting.php';
$setting = new ilDidacticTemplateSetting();
foreach($root->didacticTemplate as $tpl)
{
switch((string) $tpl->attributes()->type)
{
case 'creation':
default:
break;
}
$setting->setTitle(trim((string) $tpl->title));
$setting->setDescription(trim((string) $tpl->description));
$info = '';
foreach((array) $tpl->info->p as $paragraph)
{
if(strlen($info))
{
$info .= "\n";
}
$info .= trim((string) $paragraph);
}
$setting->setInfo($info);
foreach($tpl->assignments->assignment as $element)
{
$setting->addAssignment(trim((string) $element));
}
}
$setting->save();
return $setting;
}

+ Here is the caller graph for this function:

ilDidacticTemplateImport::parseXmlErrors ( )
protected

Parse xml errors from libxml_get_errors.

Returns
string

Definition at line 274 of file class.ilDidacticTemplateImport.php.

References $errors.

Referenced by import().

{
$errors = '';
foreach(libxml_get_errors() as $err)
{
$errors .= $err->code.'<br/>';
}
return $errors;
}

+ Here is the caller graph for this function:

ilDidacticTemplateImport::setInputFile (   $a_file)

Set input file.

Parameters
string$a_file

Definition at line 33 of file class.ilDidacticTemplateImport.php.

{
$this->xmlfile = $a_file;
}

Field Documentation

ilDidacticTemplateImport::$type = 0
private

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

Referenced by getInputType().

ilDidacticTemplateImport::$xmlfile = ''
private

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

Referenced by getInputFile().

const ilDidacticTemplateImport::IMPORT_FILE = 1

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