19 declare(strict_types=1);
70 $this->
lng = $DIC->language();
71 $this->rbacsystem = $DIC->rbac()->system();
72 $this->
ctrl = $DIC->ctrl();
73 $this->objDefinition = $DIC[
'objDefinition'];
74 $this->
access = $DIC->access();
75 $this->
toolbar = $DIC->toolbar();
76 $this->
http = $DIC->http();
78 $this->
logger = $DIC->logger()->otpl();
79 $this->tpl = $DIC->ui()->mainTemplate();
80 $this->
tabs = $DIC->tabs();
81 $this->
upload = $DIC->upload();
82 $this->
renderer = $DIC->ui()->renderer();
83 $this->ui_factory = $DIC->ui()->factory();
84 $this->lom_services = $DIC->learningObjectMetadata();
85 $this->static_url = $DIC[
'static_url'];
91 if ($this->
http->wrapper()->query()->has(
'ref_id')) {
92 $this->ref_id = $this->
http->wrapper()->query()->retrieve(
104 if ($this->
http->wrapper()->query()->has(
'tpls')) {
105 return SplFixedArray::fromArray(explode(
107 $this->
http->wrapper()->query()->retrieve(
'tpls', $this->
refinery->custom()->transformation(fn($v) => $v))
110 return new SplFixedArray(0);
115 if ($this->
http->wrapper()->query()->has(
'tplid')) {
116 $tpl_id = $this->
http->wrapper()->query()->retrieve(
130 $next_class = $this->
ctrl->getNextClass($this);
131 $cmd = $this->
ctrl->getCmd();
133 switch ($next_class) {
135 case "ilpropertyformgui":
138 $setting =
new ilDidacticTemplateSetting();
141 $this->
ctrl->forwardCommand($form);
143 case 'ilmultilingualismgui':
146 !$this->
access->checkAccess(
'write',
'', $this->ref_id) ||
147 !$setting instanceof ilDidacticTemplateSetting ||
149 $this->
ctrl->redirect($this,
"overview");
153 $defaultl = $this->setting->getTranslationObject()->getDefaultLanguage();
155 $this->setting->getPresentationTitle($defaultl),
156 $this->setting->getPresentationDescription($defaultl)
158 $this->
ctrl->forwardCommand($transgui);
172 $query = $this->
http->wrapper()->query();
173 if (!$query->has(
'didactic_template_table_action')) {
176 $action = $query->retrieve(
'didactic_template_table_action', $this->
refinery->to()->string());
178 $ids = $this->
http->wrapper()->query()->retrieve(
179 'didactic_template_template_ids',
180 $this->
refinery->custom()->transformation(
function ($q_ids) {
181 if (is_array($q_ids)) {
184 return strlen($q_ids) > 0 ? explode(
',', $q_ids) : [];
192 case 'exportTemplate':
198 case 'activateTemplates':
201 case 'deactivateTemplates':
204 case 'confirmDelete':
212 if ($this->rbacsystem->checkAccess(
'write', $this->ref_id)) {
214 $this->
lng->txt(
'didactic_import_btn'),
215 $this->
ctrl->getLinkTarget($this,
'showImportForm')
231 $this->tpl->setContent(
232 $filter->render() . $table->getHTML($data_retrieval)
252 $this->
tabs->clearTargets();
253 $this->
tabs->setBackTarget(
254 $this->
lng->txt(
'didactic_back_to_overview'),
255 $this->
ctrl->getLinkTarget($this,
'overview')
262 $this->tpl->setContent($form->getHTML());
268 $form->setShowTopButtons(
false);
269 $form->setFormAction($this->
ctrl->getFormAction($this));
270 $form->setTitle($this->
lng->txt(
'didactic_import_table_title'));
271 $form->addCommandButton(
'importTemplate', $this->
lng->txt(
'import'));
272 $form->addCommandButton(
'overview', $this->
lng->txt(
'cancel'));
276 $file->setRequired(
true);
277 $form->addItem($file);
281 $icon->setSuffixes([
'svg']);
282 $icon->setInfo($this->
lng->txt(
'didactic_icon_info'));
283 $form->addItem($icon);
293 ): ilImportStatusCollection {
294 $status =
new ilImportStatusFactory();
298 return $status->collection();
314 $statuses = $statuses->withAddedStatus($status->handler()
315 ->withType(ImportStatusType::SUCCESS)
316 ->withContent($status->content()->builder()->string()->withString(
'')));
323 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
324 $this->
ctrl->redirect($this,
"overview");
335 $statuses = $this->
checkInput($form, $import);
337 if (!$statuses->hasStatusType(ImportStatusType::SUCCESS)) {
340 ->withNumberingEnabled(
true)
343 $this->tpl->setOnScreenMessage(
345 $this->
lng->txt(
'didactic_import_failed') . $error_msg
347 if ($setting instanceof ilDidacticTemplateSetting) {
356 $settings = $import->import();
357 if ($setting instanceof ilDidacticTemplateSetting) {
359 } elseif ($settings->hasIconSupport($this->objDefinition)) {
360 $settings->getIconHandler()->handleUpload($this->
upload, $_FILES[
'icon'][
'tmp_name']);
363 $this->
logger->error(
'Import failed with message: ' . $e->getMessage());
364 $this->tpl->setOnScreenMessage(
366 $this->
lng->txt(
'didactic_import_failed') .
': ' . $e->getMessage(),
369 $this->
ctrl->redirect($this,
'importTemplate');
372 $this->tpl->setOnScreenMessage(
374 $this->
lng->txt(
'didactic_import_success'),
378 if ($setting instanceof ilDidacticTemplateSetting) {
379 $this->
ctrl->redirect($this,
'editTemplate');
381 $this->
ctrl->redirect($this,
'overview');
388 if (is_null($template_id)) {
392 $this->
ctrl->setParameter($this,
'tplid', $template_id);
395 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
396 $this->
ctrl->redirect($this,
'overview');
399 $this->
ctrl->saveParameter($this,
'tplid');
403 $this->tpl->setContent($form->getHTML());
409 $this->
ctrl->saveParameter($this,
'tplid');
411 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
412 $this->
ctrl->redirect($this,
"overview");
417 if ($form->checkInput()) {
418 $tmp_file = $_FILES[
'icon'][
'tmp_name'] ??
'';
419 $upload_element = $form->getItemByPostVar(
'icon');
421 ($tmp_file !==
'' || ($tmp_file ===
'' && $this->setting->getIconIdentifier())) &&
422 !$this->objDefinition->isContainer($form->getInput(
'type')) &&
423 !$upload_element->getDeletionFlag()
425 $form->getItemByPostVar(
'icon')->setAlert($this->
lng->txt(
'didactic_icon_error'));
430 if (count(
$lang = $this->setting->getTranslationObject()->getLanguages())) {
431 $this->setting->getTranslationObject()->setDefaultTitle($form->getInput(
'title'));
432 $this->setting->getTranslationObject()->setDefaultDescription($form->getInput(
'description'));
433 $this->setting->getTranslationObject()->save();
436 if (!$this->setting->isAutoGenerated()) {
437 $this->setting->setTitle($form->getInput(
'title'));
438 $this->setting->setDescription($form->getInput(
'description'));
441 $this->setting->setInfo($form->getInput(
'info'));
442 $this->setting->enable((
bool) $form->getInput(
'enable'));
444 if (!$this->setting->isAutoGenerated()) {
445 $this->setting->setAssignments([$form->getInput(
'type')]);
448 if ($form->getInput(
'local_template') && count($form->getInput(
'effective_from')) > 0) {
449 $this->setting->setEffectiveFrom($form->getInput(
'effective_from'));
451 $this->setting->setEffectiveFrom([]);
454 $this->setting->setExclusive((
bool) $form->getInput(
'exclusive_template'));
456 $this->setting->update();
458 $upload = $form->getItemByPostVar(
'icon');
459 if ($upload->getDeletionFlag()) {
460 $this->setting->getIconHandler()->delete();
462 $this->setting->getIconHandler()->handleUpload($this->
upload, $_FILES[
'icon'][
'tmp_name']);
463 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
464 $this->
ctrl->redirect($this,
'overview');
471 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
479 $form->setShowTopButtons(
false);
480 $form->setFormAction($this->
ctrl->getFormAction($this,
'updateTemplate'));
481 $form->setTitle($this->
lng->txt(
'didactic_edit_tpl'));
482 $form->addCommandButton(
'updateTemplate', $this->
lng->txt(
'save'));
483 $form->addCommandButton(
'overview', $this->
lng->txt(
'cancel'));
488 $title->setMaxLength(64);
489 $title->setRequired(
true);
498 if (count($trans) > 1) {
500 foreach ($this->lom_services->dataHelper()->getAllLanguages() as $lom_lang) {
501 if ($lom_lang->value() === ($def[
"lang_code"] ??
'')) {
502 $language = $lom_lang->presentableLabel();
505 $title->setInfo($this->
lng->txt(
"language") .
": " . $language .
506 ' <a href="' . $this->
ctrl->getLinkTargetByClass(
"ilmultilingualismgui",
"listTranslations") .
507 '">» ' . $this->
lng->txt(
"more_translations") .
'</a>');
513 } elseif (isset($def[
'title'])) {
514 $title->setValue($def[
"title"]);
517 $form->addItem($title);
524 } elseif (isset($def[
'description'])) {
525 $desc->setValue($def[
"description"]);
529 $form->addItem($desc);
533 $icon->setInfo($this->
lng->txt(
'didactic_icon_info'));
534 $icon->setAllowDeletion(
true);
535 $icon->setSuffixes([
'svg']);
536 $form->addItem($icon);
542 $form->addItem($info);
547 $form->addItem($enable);
553 $type->setInfo($this->
lng->txt(
'dtpl_obj_type_info'));
555 $type->setValue($assigned[0] ??
'');
556 $subs = $this->objDefinition->getSubObjectsRecursively(
'root',
false);
558 foreach (array_merge($subs, [
'fold' => 1]) as $obj => $null) {
560 if ($this->objDefinition->isPlugin($obj)) {
562 } elseif ($this->objDefinition->isAllowedInRepository($obj)) {
563 $options[$obj] = $this->
lng->txt(
'obj_' . $obj);
568 $type->setOptions($options);
569 $form->addItem($type);
572 $this->
lng->txt(
"activate_local_didactic_template"),
576 $lokal_templates->setInfo($this->
lng->txt(
"activate_local_didactic_template_info"));
583 foreach ($this->objDefinition->getAllRepositoryTypes() as $type) {
584 if ($this->objDefinition->isContainer($type)) {
585 $white_list[] = $type;
591 $lokal_templates->addSubItem($effrom);
592 $form->addItem($lokal_templates);
594 $excl =
new ilCheckboxInputGUI($this->
lng->txt(
"activate_exclusive_template"),
"exclusive_template");
595 $excl->setInfo($this->
lng->txt(
"activate_exclusive_template_info"));
598 $form->addItem($excl);
606 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
607 $this->
ctrl->redirect($this,
"overview");
612 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'didactic_copy_suc_message'),
true);
613 $this->
ctrl->redirect($this,
'overview');
622 $writer->xmlDumpMem(
true),
623 $writer->getSetting()->getTitle() .
'.xml',
633 $this->
ctrl->setParameterByClass(ilDidacticTemplateSettingsGUI::class,
'tpls', implode(
',', $template_ids));
634 $del_action = $this->
ctrl->getLinkTarget($this,
'deleteTemplates');
635 $this->
ctrl->clearParameterByClass(ilDidacticTemplateSettingsGUI::class,
'tpls');
638 $tpls->readInactive();
639 $templates = $tpls->getTemplates();
640 foreach ($templates as $template) {
641 foreach ($template_ids as
$id) {
642 if ((
int) $id !== $template->getId()) {
645 $items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
647 $template->getTitle()
652 $this->ui_factory->modal()->interruptive(
653 $this->
lng->txt(
'delete'),
654 $this->
lng->txt(
'modal_confirm_deletion_text'),
657 ->withAffectedItems($items)
658 ->withAdditionalOnLoadCode(
static fn(
$id):
string =>
"console.log('ASYNC JS');")
668 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
669 $this->
ctrl->redirect($this,
"overview");
672 if (0 === count($template_ids) || $template_ids[0] ===
'') {
673 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
677 foreach ($template_ids as $tplid) {
682 $this->
ctrl->redirect($this,
'overview');
690 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
691 $this->
ctrl->redirect($this,
"overview");
693 if (0 === count($template_ids)) {
694 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
695 $this->
ctrl->redirect($this,
'overview');
698 foreach ($template_ids as $tplid) {
704 $this->
ctrl->redirect($this,
'overview');
712 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
713 $this->
ctrl->redirect($this,
"overview");
715 if (0 === count($template_ids)) {
716 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
717 $this->
ctrl->redirect($this,
'overview');
719 foreach ($template_ids as $tplid) {
725 $this->
ctrl->redirect($this,
'overview');
728 protected function setEditTabs(
string $a_tab_active =
"edit"): void
730 $this->
lng->loadLanguageModule(
'obj');
731 $this->
tabs->clearTargets();
732 $this->
tabs->setBackTarget(
733 $this->
lng->txt(
'didactic_back_to_overview'),
734 $this->
ctrl->getLinkTarget($this,
'overview')
736 $this->
ctrl->saveParameter($this,
"tplid");
738 if (!$this->setting->isAutoGenerated()) {
739 $this->
tabs->addTab(
'edit', $this->
lng->txt(
'settings'), $this->
ctrl->getLinkTarget($this,
'editTemplate'));
742 $this->
lng->txt(
'import'),
743 $this->
ctrl->getLinkTarget($this,
'showEditImportForm')
746 if (in_array($a_tab_active, [
'edit',
'settings_trans'])) {
747 $this->
tabs->addSubTab(
749 $this->
lng->txt(
'settings'),
750 $this->
ctrl->getLinkTarget($this,
'editTemplate')
752 $this->
tabs->addSubTab(
754 $this->
lng->txt(
"obj_multilinguality"),
755 $this->
ctrl->getLinkTargetByClass([
"ilmultilingualismgui"],
'listTranslations')
757 $this->
tabs->setTabActive(
'edit');
758 $this->
tabs->setSubTabActive($a_tab_active);
760 $this->
tabs->setTabActive($a_tab_active);
772 $this->tpl->setContent($form->getHTML());
778 $form->setShowTopButtons(
false);
779 $form->setFormAction($this->
ctrl->getFormAction($this));
780 $form->setTitle($this->
lng->txt(
'didactic_import_table_title'));
781 $form->addCommandButton(
'importTemplate', $this->
lng->txt(
'import'));
782 $form->addCommandButton(
'overview', $this->
lng->txt(
'cancel'));
784 $file =
new ilFileInputGUI($this->
lng->txt(
'didactic_template_update_import'),
'file');
786 $file->setSuffixes([
'xml']);
787 $file->setInfo($this->
lng->txt(
'didactic_template_update_import_info'));
788 $form->addItem($file);
798 foreach ($assignments as $obj) {
801 $this->
ctrl->setParameter($this,
"tplid", $a_settings->
getId());
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
editImport(ilDidacticTemplateSetting $a_settings)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static assignTemplate(int $a_ref_id, int $a_obj_id, int $a_tpl_id)
initTemplateFromRequest()
static getAssignmentsByTemplateID(int $a_tpl_id)
Description of ilDidacticTemplateSettingsTableGUI.
copyTemplate(int $template_id)
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
deactivateTemplates(array $template_ids)
setEditTabs(string $a_tab_active="edit")
confirmDelete(array $template_ids)
initEditTemplate(ilDidacticTemplateSetting $set)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
__construct(ilObjectGUI $a_parent_obj)
static transferAutoGenerateStatus(int $a_src, int $a_dest)
Transfer auto generated flag if source is auto generated.
checkInput(ilPropertyFormGUI $form, ilDidacticTemplateImport $import)
Customizing of pimple-DIC for ILIAS.
setInputFile(string $a_file)
showEditImportForm(?ilPropertyFormGUI $form=null)
initTemplatesFromRequest()
transforms selected tpls from post to SplFixedArray
setValue(string $a_value)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
showImportForm(?ilPropertyFormGUI $form=null)
setStartValues(string $a_title, string $a_description)
ilObjectDefinition $objDefinition
static http()
Fetches the global http state from ILIAS.
ilDidacticTemplateSetting $setting
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
exportTemplate(int $template_id)
Class ilObjectGUI Basic methods of all Output classes.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
LOMServices $lom_services
Description of ilDidacticTemplateImportException.
StaticURLService $static_url
Description of ilDidacticTemplateImport.
Copy a didactic template and all subitems.
start()
Start copy process.
static lookupTxtById(string $plugin_id, string $lang_var)
initReferenceFromRequest()
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This class represents a text area property in a property form.
getInfo()
Get installation info text.
Settings for a single didactic template.
getPresentationTitle(string $a_lng="")
ilGlobalTemplateInterface $tpl
getPresentationDescription(string $a_lng="")
getTranslations()
Get all translations from this object.
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
activateTemplates(array $template_ids)
DataFactory $data_factory
handleUpdateFailure(ilPropertyFormGUI $form)
editTemplate(?int $template_id=null, ?ilPropertyFormGUI $form=null)