19 declare(strict_types=1);
64 $this->
lng = $DIC->language();
65 $this->rbacsystem = $DIC->rbac()->system();
66 $this->
ctrl = $DIC->ctrl();
67 $this->objDefinition = $DIC[
'objDefinition'];
68 $this->
access = $DIC->access();
69 $this->
toolbar = $DIC->toolbar();
70 $this->
http = $DIC->http();
72 $this->
logger = $DIC->logger()->otpl();
73 $this->tpl = $DIC->ui()->mainTemplate();
74 $this->
tabs = $DIC->tabs();
75 $this->
upload = $DIC->upload();
76 $this->renderer = $DIC->ui()->renderer();
77 $this->ui_factory = $DIC->ui()->factory();
82 if ($this->
http->wrapper()->query()->has(
'ref_id')) {
83 $this->ref_id = $this->
http->wrapper()->query()->retrieve(
95 if ($this->
http->wrapper()->query()->has(
'tpls')) {
96 return SplFixedArray::fromArray(explode(
98 $this->
http->wrapper()->query()->retrieve(
'tpls', $this->
refinery->custom()->transformation(fn($v) => $v))
101 return new SplFixedArray(0);
106 if ($this->
http->wrapper()->query()->has(
'tplid')) {
107 $tpl_id = $this->
http->wrapper()->query()->retrieve(
121 $next_class = $this->
ctrl->getNextClass($this);
122 $cmd = $this->
ctrl->getCmd();
124 switch ($next_class) {
126 case "ilpropertyformgui":
129 $setting =
new ilDidacticTemplateSetting();
132 $this->
ctrl->forwardCommand($form);
134 case 'ilmultilingualismgui':
137 !$this->
access->checkAccess(
'write',
'', $this->ref_id) ||
138 !$setting instanceof ilDidacticTemplateSetting ||
140 $this->
ctrl->redirect($this,
"overview");
144 $defaultl = $this->setting->getTranslationObject()->getDefaultLanguage();
146 $this->setting->getPresentationTitle($defaultl),
147 $this->setting->getPresentationDescription($defaultl)
149 $this->
ctrl->forwardCommand($transgui);
163 $query = $this->
http->wrapper()->query();
164 if (!$query->has(
'didactic_template_table_action')) {
167 $action = $query->retrieve(
'didactic_template_table_action', $this->
refinery->to()->string());
169 $ids = $this->
http->wrapper()->query()->retrieve(
170 'didactic_template_template_ids',
171 $this->
refinery->custom()->transformation(
function ($q_ids) {
172 if (is_array($q_ids)) {
175 return strlen($q_ids) > 0 ? explode(
',', $q_ids) : [];
183 case 'exportTemplate':
189 case 'activateTemplates':
192 case 'deactivateTemplates':
195 case 'confirmDelete':
203 if ($this->rbacsystem->checkAccess(
'write', $this->ref_id)) {
205 $this->
lng->txt(
'didactic_import_btn'),
206 $this->
ctrl->getLinkTarget($this,
'showImportForm')
220 $this->tpl->setContent(
221 $filter->render() . $table->getHTML($data_retrieval)
241 $this->
tabs->clearTargets();
242 $this->
tabs->setBackTarget(
243 $this->
lng->txt(
'didactic_back_to_overview'),
244 $this->
ctrl->getLinkTarget($this,
'overview')
251 $this->tpl->setContent($form->getHTML());
257 $form->setShowTopButtons(
false);
258 $form->setFormAction($this->
ctrl->getFormAction($this));
259 $form->setTitle($this->
lng->txt(
'didactic_import_table_title'));
260 $form->addCommandButton(
'importTemplate', $this->
lng->txt(
'import'));
261 $form->addCommandButton(
'overview', $this->
lng->txt(
'cancel'));
265 $file->setRequired(
true);
266 $form->addItem($file);
270 $icon->setSuffixes([
'svg']);
271 $icon->setInfo($this->
lng->txt(
'didactic_icon_info'));
272 $form->addItem($icon);
282 ): ilImportStatusCollection {
283 $status =
new ilImportStatusFactory();
287 return $status->collection();
303 $statuses = $statuses->withAddedStatus($status->handler()
304 ->withType(ImportStatusType::SUCCESS)
305 ->withContent($status->content()->builder()->string()->withString(
'')));
312 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
313 $this->
ctrl->redirect($this,
"overview");
324 $statuses = $this->
checkInput($form, $import);
326 if (!$statuses->hasStatusType(ImportStatusType::SUCCESS)) {
329 ->withNumberingEnabled(
true)
332 $this->tpl->setOnScreenMessage(
334 $this->
lng->txt(
'didactic_import_failed') . $error_msg
336 if ($setting instanceof ilDidacticTemplateSetting) {
346 if ($setting instanceof ilDidacticTemplateSetting) {
348 } elseif (
$settings->hasIconSupport($this->objDefinition)) {
349 $settings->getIconHandler()->handleUpload($this->
upload, $_FILES[
'icon'][
'tmp_name']);
352 $this->
logger->error(
'Import failed with message: ' . $e->getMessage());
353 $this->tpl->setOnScreenMessage(
355 $this->
lng->txt(
'didactic_import_failed') .
': ' . $e->getMessage(),
358 $this->
ctrl->redirect($this,
'importTemplate');
361 $this->tpl->setOnScreenMessage(
363 $this->
lng->txt(
'didactic_import_success'),
367 if ($setting instanceof ilDidacticTemplateSetting) {
368 $this->
ctrl->redirect($this,
'editTemplate');
370 $this->
ctrl->redirect($this,
'overview');
377 if (is_null($template_id)) {
381 $this->
ctrl->setParameter($this,
'tplid', $template_id);
384 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
385 $this->
ctrl->redirect($this,
'overview');
388 $this->
ctrl->saveParameter($this,
'tplid');
392 $this->tpl->setContent($form->getHTML());
398 $this->
ctrl->saveParameter($this,
'tplid');
400 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
401 $this->
ctrl->redirect($this,
"overview");
406 if ($form->checkInput()) {
407 $tmp_file = $_FILES[
'icon'][
'tmp_name'] ??
'';
408 $upload_element = $form->getItemByPostVar(
'icon');
410 ($tmp_file !==
'' || ($tmp_file ===
'' && $this->setting->getIconIdentifier())) &&
411 !$this->objDefinition->isContainer($form->getInput(
'type')) &&
412 !$upload_element->getDeletionFlag()
414 $form->getItemByPostVar(
'icon')->setAlert($this->
lng->txt(
'didactic_icon_error'));
419 if (count(
$lang = $this->setting->getTranslationObject()->getLanguages())) {
420 $this->setting->getTranslationObject()->setDefaultTitle($form->getInput(
'title'));
421 $this->setting->getTranslationObject()->setDefaultDescription($form->getInput(
'description'));
422 $this->setting->getTranslationObject()->save();
425 if (!$this->setting->isAutoGenerated()) {
426 $this->setting->setTitle($form->getInput(
'title'));
427 $this->setting->setDescription($form->getInput(
'description'));
430 $this->setting->setInfo($form->getInput(
'info'));
431 $this->setting->enable((
bool) $form->getInput(
'enable'));
433 if (!$this->setting->isAutoGenerated()) {
434 $this->setting->setAssignments([$form->getInput(
'type')]);
437 if ($form->getInput(
'local_template') && count($form->getInput(
'effective_from')) > 0) {
438 $this->setting->setEffectiveFrom($form->getInput(
'effective_from'));
440 $this->setting->setEffectiveFrom([]);
443 $this->setting->setExclusive((
bool) $form->getInput(
'exclusive_template'));
445 $this->setting->update();
447 $upload = $form->getItemByPostVar(
'icon');
448 if ($upload->getDeletionFlag()) {
449 $this->setting->getIconHandler()->delete();
451 $this->setting->getIconHandler()->handleUpload($this->
upload, $_FILES[
'icon'][
'tmp_name']);
452 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
453 $this->
ctrl->redirect($this,
'overview');
460 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
468 $form->setShowTopButtons(
false);
469 $form->setFormAction($this->
ctrl->getFormAction($this,
'updateTemplate'));
470 $form->setTitle($this->
lng->txt(
'didactic_edit_tpl'));
471 $form->addCommandButton(
'updateTemplate', $this->
lng->txt(
'save'));
472 $form->addCommandButton(
'overview', $this->
lng->txt(
'cancel'));
477 $title->setMaxLength(64);
478 $title->setRequired(
true);
487 if (count($trans) > 1) {
489 $title->setInfo($this->
lng->txt(
"language") .
": " . $languages[$def[
"lang_code"]] .
490 ' <a href="' . $this->
ctrl->getLinkTargetByClass(
"ilmultilingualismgui",
"listTranslations") .
491 '">» ' . $this->
lng->txt(
"more_translations") .
'</a>');
497 } elseif (isset($def[
'title'])) {
498 $title->setValue($def[
"title"]);
501 $form->addItem($title);
508 } elseif (isset($def[
'description'])) {
509 $desc->setValue($def[
"description"]);
513 $form->addItem($desc);
517 $icon->setInfo($this->
lng->txt(
'didactic_icon_info'));
518 $icon->setAllowDeletion(
true);
519 $icon->setSuffixes([
'svg']);
520 $form->addItem($icon);
526 $form->addItem($info);
531 $form->addItem($enable);
537 $type->setInfo($this->
lng->txt(
'dtpl_obj_type_info'));
539 $type->setValue($assigned[0] ??
'');
540 $subs = $this->objDefinition->getSubObjectsRecursively(
'root',
false);
542 foreach (array_merge($subs, [
'fold' => 1]) as $obj => $null) {
544 if ($this->objDefinition->isPlugin($obj)) {
546 } elseif ($this->objDefinition->isAllowedInRepository($obj)) {
547 $options[$obj] = $this->
lng->txt(
'obj_' . $obj);
552 $type->setOptions($options);
553 $form->addItem($type);
556 $this->
lng->txt(
"activate_local_didactic_template"),
560 $lokal_templates->setInfo($this->
lng->txt(
"activate_local_didactic_template_info"));
567 foreach ($this->objDefinition->getAllRepositoryTypes() as $type) {
568 if ($this->objDefinition->isContainer($type)) {
569 $white_list[] = $type;
575 $lokal_templates->addSubItem($effrom);
576 $form->addItem($lokal_templates);
578 $excl =
new ilCheckboxInputGUI($this->
lng->txt(
"activate_exclusive_template"),
"exclusive_template");
579 $excl->setInfo($this->
lng->txt(
"activate_exclusive_template_info"));
582 $form->addItem($excl);
590 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
591 $this->
ctrl->redirect($this,
"overview");
596 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'didactic_copy_suc_message'),
true);
597 $this->
ctrl->redirect($this,
'overview');
606 $writer->xmlDumpMem(
true),
607 $writer->getSetting()->getTitle() .
'.xml',
617 $this->
ctrl->setParameterByClass(ilDidacticTemplateSettingsGUI::class,
'tpls', implode(
',', $template_ids));
618 $del_action = $this->
ctrl->getLinkTarget($this,
'deleteTemplates');
619 $this->
ctrl->clearParameterByClass(ilDidacticTemplateSettingsGUI::class,
'tpls');
622 $tpls->readInactive();
623 $templates = $tpls->getTemplates();
624 foreach ($templates as $template) {
625 foreach ($template_ids as
$id) {
626 if ((
int) $id !== $template->getId()) {
629 $items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
631 $template->getTitle()
635 echo($this->renderer->renderAsync([
636 $this->ui_factory->modal()->interruptive(
637 $this->
lng->txt(
'delete'),
638 $this->
lng->txt(
'modal_confirm_deletion_text'),
641 ->withAffectedItems($items)
642 ->withAdditionalOnLoadCode(
static fn(
$id):
string =>
"console.log('ASYNC JS');")
652 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
653 $this->
ctrl->redirect($this,
"overview");
656 if (0 === count($template_ids) || $template_ids[0] ===
'') {
657 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
661 foreach ($template_ids as $tplid) {
666 $this->
ctrl->redirect($this,
'overview');
674 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
675 $this->
ctrl->redirect($this,
"overview");
677 if (0 === count($template_ids)) {
678 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
679 $this->
ctrl->redirect($this,
'overview');
682 foreach ($template_ids as $tplid) {
688 $this->
ctrl->redirect($this,
'overview');
696 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
697 $this->
ctrl->redirect($this,
"overview");
699 if (0 === count($template_ids)) {
700 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
701 $this->
ctrl->redirect($this,
'overview');
703 foreach ($template_ids as $tplid) {
709 $this->
ctrl->redirect($this,
'overview');
712 protected function setEditTabs(
string $a_tab_active =
"edit"): void
714 $this->
lng->loadLanguageModule(
'obj');
715 $this->
tabs->clearTargets();
716 $this->
tabs->setBackTarget(
717 $this->
lng->txt(
'didactic_back_to_overview'),
718 $this->
ctrl->getLinkTarget($this,
'overview')
720 $this->
ctrl->saveParameter($this,
"tplid");
722 if (!$this->setting->isAutoGenerated()) {
723 $this->
tabs->addTab(
'edit', $this->
lng->txt(
'settings'), $this->
ctrl->getLinkTarget($this,
'editTemplate'));
726 $this->
lng->txt(
'import'),
727 $this->
ctrl->getLinkTarget($this,
'showEditImportForm')
730 if (in_array($a_tab_active, [
'edit',
'settings_trans'])) {
731 $this->
tabs->addSubTab(
733 $this->
lng->txt(
'settings'),
734 $this->
ctrl->getLinkTarget($this,
'editTemplate')
736 $this->
tabs->addSubTab(
738 $this->
lng->txt(
"obj_multilinguality"),
739 $this->
ctrl->getLinkTargetByClass([
"ilmultilingualismgui"],
'listTranslations')
741 $this->
tabs->setTabActive(
'edit');
742 $this->
tabs->setSubTabActive($a_tab_active);
744 $this->
tabs->setTabActive($a_tab_active);
756 $this->tpl->setContent($form->getHTML());
762 $form->setShowTopButtons(
false);
763 $form->setFormAction($this->
ctrl->getFormAction($this));
764 $form->setTitle($this->
lng->txt(
'didactic_import_table_title'));
765 $form->addCommandButton(
'importTemplate', $this->
lng->txt(
'import'));
766 $form->addCommandButton(
'overview', $this->
lng->txt(
'cancel'));
768 $file =
new ilFileInputGUI($this->
lng->txt(
'didactic_template_update_import'),
'file');
770 $file->setSuffixes([
'xml']);
771 $file->setInfo($this->
lng->txt(
'didactic_template_update_import_info'));
772 $form->addItem($file);
782 foreach ($assignments as $obj) {
785 $this->
ctrl->setParameter($this,
"tplid", $a_settings->
getId());
editImport(ilDidacticTemplateSetting $a_settings)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface GlobalHttpState.
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)
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
setEditTabs(string $a_tab_active="edit")
confirmDelete(array $template_ids)
initEditTemplate(ilDidacticTemplateSetting $set)
showImportForm(ilPropertyFormGUI $form=null)
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)
initTemplatesFromRequest()
transforms selected tpls from post to SplFixedArray
setValue(string $a_value)
setStartValues(string $a_title, string $a_description)
parses the objects.xml it handles the xml-description of all ilias objects
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
Description of ilDidacticTemplateImportException.
Description of ilDidacticTemplateImport.
Copy a didactic template and all subitems.
start()
Start copy process.
static lookupTxtById(string $plugin_id, string $lang_var)
initReferenceFromRequest()
editTemplate(?int $template_id=null, ilPropertyFormGUI $form=null)
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
This class represents a text area property in a property form.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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.
activateTemplates(array $template_ids)
handleUpdateFailure(ilPropertyFormGUI $form)
showEditImportForm(ilPropertyFormGUI $form=null)