4 include_once
'./Services/DidacticTemplate/exceptions/class.ilDidacticTemplateImportException.php';
38 $this->logger = $DIC->logger()->otpl();
39 $this->type = $a_type;
40 $this->objDefinition = $DIC[
'objDefinition'];
49 $this->xmlfile = $a_file;
73 public function import($a_dtpl_id = 0)
75 libxml_use_internal_errors(
true);
78 case self::IMPORT_FILE:
90 $this->
parseActions($settings, $root->didacticTemplate->actions);
107 include_once
'./Services/DidacticTemplate/classes/class.ilDidacticTemplateSetting.php';
110 foreach ($root->didacticTemplate as
$tpl) {
111 switch ((
string) $tpl->attributes()->type) {
117 $setting->setTitle(trim((
string) $tpl->title));
118 $setting->setDescription(trim((
string) $tpl->description));
120 $icon = (string) $tpl->icon;
123 foreach ((array) $tpl->info->p as $paragraph) {
127 $info .= trim((
string) $paragraph);
129 $setting->setInfo($info);
131 if (isset($tpl->effectiveFrom) && (
string) $tpl->effectiveFrom[
"nic_id"] ==
$ilSetting->get(
'inst_id')) {
133 foreach ($tpl->effectiveFrom->node as $element) {
134 $node[] = (int) $element;
137 $setting->setEffectiveFrom($node);
140 if (isset($tpl->exclusive)) {
141 $setting->setExclusive(
true);
144 foreach ($tpl->assignments->assignment as $element) {
145 $setting->addAssignment(trim((
string) $element));
150 if (strlen($icon) && $this->
canUseIcons($setting)) {
151 $setting->getIconHandler()->writeSvg($icon);
154 include_once(
"./Services/Multilingualism/classes/class.ilMultilingualism.php");
157 if (isset($root->didacticTemplate->translations)) {
158 $trans->fromXML($root->didacticTemplate->translations);
168 if (!$this->objDefinition->isContainer($assignment)) {
183 include_once
'./Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
185 if ($actions === null) {
192 foreach ($actions->localRoleAction as $ele) {
193 include_once
'./Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalRoleAction.php';
195 $act->setTemplateId($set->
getId());
197 foreach ($ele->roleTemplate as
$tpl) {
199 foreach ($tpl->role as $roleDef) {
200 include_once
'./Services/AccessControl/classes/class.ilRoleXmlImporter.php';
202 $role_id = $rimporter->importSimpleXml($roleDef);
203 $act->setRoleTemplateId($role_id);
212 foreach ($actions->blockRoleAction as $ele) {
213 include_once
'./Services/DidacticTemplate/classes/class.ilDidacticTemplateBlockRoleAction.php';
215 $act->setTemplateId($set->
getId());
218 foreach ($ele->roleFilter as $rfi) {
219 switch ((
string) $rfi->attributes()->source) {
232 foreach ($rfi->includePattern as $pat) {
234 include_once
'./Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
237 $pattern->setPattern((
string) $pat->attributes()->preg);
238 $act->addFilterPattern($pattern);
240 foreach ($rfi->excludePattern as $pat) {
242 include_once
'./Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
245 $pattern->setPattern((
string) $pat->attributes()->preg);
246 $act->addFilterPattern($pattern);
258 foreach ($actions->localPolicyAction as $ele) {
259 include_once
'./Services/DidacticTemplate/classes/class.ilDidacticTemplateLocalPolicyAction.php';
261 $act->setTemplateId($set->
getId());
264 foreach ($ele->roleFilter as $rfi) {
266 $this->logger->debug(
'Current filter source: ' . (
string) $rfi->attributes()->source);
268 switch ((
string) $rfi->attributes()->source) {
285 foreach ($rfi->includePattern as $pat) {
287 include_once
'./Services/DidacticTemplate/classes/class.ilDidacticTemplateIncludeFilterPattern.php';
290 $pattern->setPattern((
string) $pat->attributes()->preg);
291 $act->addFilterPattern($pattern);
293 foreach ($rfi->excludePattern as $pat) {
295 include_once
'./Services/DidacticTemplate/classes/class.ilDidacticTemplateExcludeFilterPattern.php';
298 $pattern->setPattern((
string) $pat->attributes()->preg);
299 $act->addFilterPattern($pattern);
304 foreach ($ele->localPolicyTemplate as $lpo) {
305 switch ((
string) $lpo->attributes()->type) {
320 foreach ($lpo->role as $roleDef) {
323 $role_id = $rimporter->importSimpleXml($roleDef);
324 $act->setRoleTemplateId($role_id);
346 foreach (libxml_get_errors() as $err) {
347 $errors .= $err->code .
'<br/>';
const FILTER_PARENT_ROLES
static getInstance($a_obj_id, $a_type)
Get instance.
Description of ilDidacticTemplateBlockRoleAction.
getAssignments()
Get object assignemnts.
const TPL_ACTION_INTERSECT
getInputType()
Get input type.
const TPL_ACTION_OVERWRITE
parseXmlErrors()
Parse xml errors from libxml_get_errors.
parseSettings(SimpleXMLElement $root)
Parse settings.
parseActions(ilDidacticTemplateSetting $set, SimpleXMLElement $actions=null)
Parse template action from xml.
const FILTER_SOURCE_OBJ_ID
Implementation of an include filter pattern for didactic template actions.
Description of ilDidacticTemplateImportException.
Description of ilDidacticTemplateImport.
represents a creation of local roles action
setInputFile($a_file)
Set input file.
const PATTERN_SUBTYPE_REGEX
__construct($a_type)
Constructor.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
const FILTER_SOURCE_TITLE
canUseIcons(ilDidacticTemplateSetting $setting)
getInputFile()
Get inputfile.
Implementation of an include filter pattern for didactic template actions.