ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilDidacticTemplateImport Class Reference

Description of ilDidacticTemplateImport. More...

+ Collaboration diagram for ilDidacticTemplateImport:

Public Member Functions

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

Data Fields

const IMPORT_FILE = 1
 

Protected Member Functions

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

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

◆ __construct()

ilDidacticTemplateImport::__construct (   $a_type)

Constructor.

Parameters
<type>$a_type

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

25 {
26 $this->type = $a_type;
27 }

Member Function Documentation

◆ getInputFile()

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:

◆ getInputType()

ilDidacticTemplateImport::getInputType ( )

Get input type.

Returns
string

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

References $type.

Referenced by import().

+ Here is the caller graph for this function:

◆ import()

ilDidacticTemplateImport::import ( )

Do import.

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

60 {
61 libxml_use_internal_errors(true);
62
63 switch($this->getInputType())
64 {
66
67 $root = simplexml_load_file($this->getInputFile());
68 if($root == FALSE)
69 {
71 $this->parseXmlErrors()
72 );
73 }
74 break;
75 }
76
77 $settings = $this->parseSettings($root);
78 $this->parseActions($settings,$root->didacticTemplate->actions);
79
80 }
Description of ilDidacticTemplateImportException.
parseXmlErrors()
Parse xml errors from libxml_get_errors.
parseActions(ilDidacticTemplateSetting $set, SimpleXMLElement $actions=NULL)
Parse template action from xml.
parseSettings(SimpleXMLElement $root)
Parse settings.

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

+ Here is the call graph for this function:

◆ parseActions()

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.

132 {
133 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
134
135 if($actions === NULL)
136 {
137 return void;
138 }
139
141 // Local role action
143 foreach($actions->localRoleAction as $ele)
144 {
145 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalRoleAction.php';
147 $act->setTemplateId($set->getId());
148
149 foreach($ele->roleTemplate as $tpl)
150 {
151 // extract role
152 foreach($tpl->role as $roleDef)
153 {
154 include_once './Services/AccessControl/classes/class.ilRoleXmlImporter.php';
155 $rimporter = new ilRoleXmlImporter(ROLE_FOLDER_ID);
156 $role_id = $rimporter->importSimpleXml($roleDef);
157 $act->setRoleTemplateId($role_id);
158 }
159 $act->save();
160 }
161 }
162
164 // Block role action
166 foreach($actions->blockRoleAction as $ele)
167 {
168 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateBlockRoleAction.php';
170 $act->setTemplateId($set->getId());
171
172 // Role filter
173 foreach($ele->roleFilter as $rfi)
174 {
175 $act->setFilterType((string) $rfi->attributes()->source);
176 foreach($rfi->includePattern as $pat)
177 {
178 // @TODO other subtypes
179 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
182 $pattern->setPattern((string) $pat->attributes()->preg);
183 $act->addFilterPattern($pattern);
184 }
185 foreach($rfi->excludePattern as $pat)
186 {
187 // @TODO other subtypes
188 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
191 $pattern->setPattern((string) $pat->attributes()->preg);
192 $act->addFilterPattern($pattern);
193 }
194 }
195
196 $act->save();
197 }
198
199
200
202 // Local policy action
204 foreach($actions->localPolicyAction as $ele)
205 {
206 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalPolicyAction.php';
208 $act->setTemplateId($set->getId());
209
210 // Role filter
211 foreach($ele->roleFilter as $rfi)
212 {
213 $act->setFilterType((string) $rfi->attributes()->source);
214 foreach($rfi->includePattern as $pat)
215 {
216 // @TODO other subtypes
217 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
220 $pattern->setPattern((string) $pat->attributes()->preg);
221 $act->addFilterPattern($pattern);
222 }
223 foreach($rfi->excludePattern as $pat)
224 {
225 // @TODO other subtypes
226 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
229 $pattern->setPattern((string) $pat->attributes()->preg);
230 $act->addFilterPattern($pattern);
231 }
232 }
233
234 // role template assignment
235 foreach($ele->localPolicyTemplate as $lpo)
236 {
238 switch((string) $lpo->attributes()->type)
239 {
240 case 'overwrite':
242 break;
243
244 case 'union':
246 break;
247
248 case 'intersect':
250 break;
251 }
252
253 // extract role
254 foreach($lpo->role as $roleDef)
255 {
256 include_once './Services/AccessControl/classes/class.ilRoleXmlImporter.php';
257 $rimporter = new ilRoleXmlImporter(ROLE_FOLDER_ID);
258 $role_id = $rimporter->importSimpleXml($roleDef);
259 $act->setRoleTemplateId($role_id);
260 }
261 }
262
263 // Save action including all filter patterns
264 $act->save();
265 }
266
267 }
global $tpl
Definition: ilias.php:8
Description of ilDidacticTemplateBlockRoleAction.
Implementation of an include filter pattern for didactic template actions.
Implementation of an include filter pattern for didactic template actions.
represents a creation of local roles action
Description of class.

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseSettings()

ilDidacticTemplateImport::parseSettings ( SimpleXMLElement  $root)
protected

Parse settings.

Parameters
SimpleXMLElement$el
Returns
ilDidacticTemplateSetting

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

88 {
89
90 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSetting.php';
91 $setting = new ilDidacticTemplateSetting();
92
93 foreach($root->didacticTemplate as $tpl)
94 {
95 switch((string) $tpl->attributes()->type)
96 {
97 case 'creation':
98 default:
100 break;
101 }
102 $setting->setTitle(trim((string) $tpl->title));
103 $setting->setDescription(trim((string) $tpl->description));
104
105 $info = '';
106 foreach((array) $tpl->info->p as $paragraph)
107 {
108 if(strlen($info))
109 {
110 $info .= "\n";
111 }
112 $info .= trim((string) $paragraph);
113 }
114 $setting->setInfo($info);
115
116 foreach($tpl->assignments->assignment as $element)
117 {
118 $setting->addAssignment(trim((string) $element));
119 }
120 }
121 $setting->save();
122 return $setting;
123 }
$info
Definition: example_052.php:80

References $info, $tpl, and ilDidacticTemplateSetting\TYPE_CREATION.

Referenced by import().

+ Here is the caller graph for this function:

◆ parseXmlErrors()

ilDidacticTemplateImport::parseXmlErrors ( )
protected

Parse xml errors from libxml_get_errors.

Returns
string

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

275 {
276 $errors = '';
277 foreach(libxml_get_errors() as $err)
278 {
279 $errors .= $err->code.'<br/>';
280 }
281 return $errors;
282 }
$errors

References $errors.

Referenced by import().

+ Here is the caller graph for this function:

◆ setInputFile()

ilDidacticTemplateImport::setInputFile (   $a_file)

Set input file.

Parameters
string$a_file

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

34 {
35 $this->xmlfile = $a_file;
36 }

Field Documentation

◆ $type

ilDidacticTemplateImport::$type = 0
private

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

Referenced by getInputType().

◆ $xmlfile

ilDidacticTemplateImport::$xmlfile = ''
private

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

Referenced by getInputFile().

◆ IMPORT_FILE

const ilDidacticTemplateImport::IMPORT_FILE = 1

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