3 declare(strict_types=1);
26 $this->
logger = $DIC->logger()->otpl();
27 $this->type = $a_type;
28 $this->objDefinition = $DIC[
'objDefinition'];
34 $this->xmlfile = $a_file;
53 $use_internal_errors = libxml_use_internal_errors(
true);
55 case self::IMPORT_FILE:
56 $root = simplexml_load_string(file_get_contents($this->
getInputFile()));
59 libxml_use_internal_errors($use_internal_errors);
60 if (!$root instanceof SimpleXMLElement) {
66 $this->
parseActions($settings, $root->didacticTemplate->actions);
77 foreach ($root->didacticTemplate as
$tpl) {
78 switch ((
string) $tpl->attributes()->type) {
84 $setting->setTitle(trim((
string) $tpl->title));
85 $setting->setDescription(trim((
string) $tpl->description));
87 $icon = (string) $tpl->icon;
90 foreach ((array) $tpl->info->p as $paragraph) {
94 $info .= trim((
string) $paragraph);
96 $setting->setInfo($info);
98 if (isset($tpl->effectiveFrom) && (
string) $tpl->effectiveFrom[
"nic_id"] == $this->settings->get(
'inst_id')) {
100 foreach ($tpl->effectiveFrom->node as $element) {
101 $node[] = (
int) $element;
104 $setting->setEffectiveFrom($node);
107 if (isset($tpl->exclusive)) {
108 $setting->setExclusive(
true);
111 foreach ($tpl->assignments->assignment as $element) {
112 $setting->addAssignment(trim((
string) $element));
117 if ($icon !==
'' && $this->
canUseIcons($setting)) {
118 $setting->getIconHandler()->writeSvg($icon);
121 if (isset($root->didacticTemplate->translations)) {
122 $trans->fromXML($root->didacticTemplate->translations);
132 if (!$this->objDefinition->isContainer($assignment)) {
145 if ($actions === null) {
151 foreach ($actions->localRoleAction as $ele) {
153 $act->setTemplateId($set->
getId());
155 foreach ($ele->roleTemplate as
$tpl) {
157 foreach ($tpl->role as $roleDef) {
159 $role_id = $rimporter->importSimpleXml($roleDef);
160 $act->setRoleTemplateId($role_id);
169 foreach ($actions->blockRoleAction as $ele) {
171 $act->setTemplateId($set->
getId());
174 foreach ($ele->roleFilter as $rfi) {
175 switch ((
string) $rfi->attributes()->source) {
188 foreach ($rfi->includePattern as $pat) {
193 $pattern->setPattern((
string) $pat->attributes()->preg);
194 $act->addFilterPattern($pattern);
196 foreach ($rfi->excludePattern as $pat) {
201 $pattern->setPattern((
string) $pat->attributes()->preg);
202 $act->addFilterPattern($pattern);
212 foreach ($actions->localPolicyAction as $ele) {
214 $act->setTemplateId($set->
getId());
217 foreach ($ele->roleFilter as $rfi) {
220 'Current filter source: ' . $rfi->attributes()->source
223 switch ((
string) $rfi->attributes()->source) {
240 foreach ($rfi->includePattern as $pat) {
245 $pattern->setPattern((
string) $pat->attributes()->preg);
246 $act->addFilterPattern($pattern);
248 foreach ($rfi->excludePattern as $pat) {
253 $pattern->setPattern((
string) $pat->attributes()->preg);
254 $act->addFilterPattern($pattern);
259 foreach ($ele->localPolicyTemplate as $lpo) {
260 switch ((
string) $lpo->attributes()->type) {
275 foreach ($lpo->role as $roleDef) {
278 $role_id = $rimporter->importSimpleXml($roleDef);
279 $act->setRoleTemplateId($role_id);
299 foreach (libxml_get_errors() as $err) {
300 $errors .= $err->code .
'<br/>';
const FILTER_PARENT_ROLES
static getInstance(int $a_obj_id, string $a_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TPL_ACTION_INTERSECT
const TPL_ACTION_OVERWRITE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parseXmlErrors()
Parse xml errors from libxml_get_errors.
setInputFile(string $a_file)
parses the objects.xml it handles the xml-description of all ilias objects
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.
ilObjectDefinition $objDefinition
represents a creation of local roles action
const PATTERN_SUBTYPE_REGEX
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
const FILTER_SOURCE_TITLE
canUseIcons(ilDidacticTemplateSetting $setting)
Implementation of an include filter pattern for didactic template actions.