3 declare(strict_types=1);
57 $this->parent_object = $a_parent_obj;
58 $this->
lng = $DIC->language();
59 $this->rbacsystem = $DIC->rbac()->system();
60 $this->
ctrl = $DIC->ctrl();
61 $this->objDefinition = $DIC[
'objDefinition'];
62 $this->request = $DIC->http()->request();
63 $this->
access = $DIC->access();
64 $this->
toolbar = $DIC->toolbar();
65 $this->
http = $DIC->http();
67 $this->
logger = $DIC->logger()->otpl();
68 $this->tpl = $DIC->ui()->mainTemplate();
69 $this->
tabs = $DIC->tabs();
70 $this->
upload = $DIC->upload();
75 if ($this->
http->wrapper()->query()->has(
'ref_id')) {
76 $this->ref_id = $this->
http->wrapper()->query()->retrieve(
88 if ($this->
http->wrapper()->post()->has(
'tpls')) {
89 return SplFixedArray::fromArray(
90 $this->
http->wrapper()->post()->retrieve(
99 return new SplFixedArray(0);
104 if ($this->
http->wrapper()->query()->has(
'tplid')) {
105 $tpl_id = $this->
http->wrapper()->query()->retrieve(
119 $next_class = $this->
ctrl->getNextClass($this);
120 $cmd = $this->
ctrl->getCmd();
122 switch ($next_class) {
124 case "ilpropertyformgui":
127 $setting =
new ilDidacticTemplateSetting();
130 $this->
ctrl->forwardCommand($form);
132 case 'ilmultilingualismgui':
135 !$this->
access->checkAccess(
'write',
'', $this->ref_id) ||
136 !$setting instanceof ilDidacticTemplateSetting ||
138 $this->
ctrl->redirect($this,
"overview");
142 $defaultl = $this->setting->getTranslationObject()->getDefaultLanguage();
144 $this->setting->getPresentationTitle($defaultl),
145 $this->setting->getPresentationDescription($defaultl)
147 $this->
ctrl->forwardCommand($transgui);
161 if ($this->rbacsystem->checkAccess(
'write', $this->ref_id)) {
163 $this->
lng->txt(
'didactic_import_btn'),
164 $this->
ctrl->getLinkTarget($this,
'showImportForm')
173 $table->parse($filter);
175 $this->tpl->setContent(
176 $filter->render() . $table->getHTML()
184 $table->resetOffset();
185 $table->writeFilterToSession();
193 $table->resetOffset();
194 $table->resetFilter();
204 $this->
tabs->clearTargets();
205 $this->
tabs->setBackTarget(
206 $this->
lng->txt(
'didactic_back_to_overview'),
207 $this->
ctrl->getLinkTarget($this,
'overview')
214 $this->tpl->setContent($form->getHTML());
220 $form->setShowTopButtons(
false);
221 $form->setFormAction($this->
ctrl->getFormAction($this));
222 $form->setTitle($this->
lng->txt(
'didactic_import_table_title'));
223 $form->addCommandButton(
'importTemplate', $this->
lng->txt(
'import'));
224 $form->addCommandButton(
'overview', $this->
lng->txt(
'cancel'));
228 $file->setRequired(
true);
229 $form->addItem($file);
233 $icon->setSuffixes([
'svg']);
234 $icon->setInfo($this->
lng->txt(
'didactic_icon_info'));
235 $form->addItem($icon);
244 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
245 $this->
ctrl->redirect($this,
"overview");
255 if (!$form->checkInput()) {
256 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
257 $form->setValuesByPost();
259 if ($setting instanceof ilDidacticTemplateSetting) {
270 $file = $form->getInput(
'file');
279 $import->setInputFile($tmp);
283 if ($setting instanceof ilDidacticTemplateSetting) {
285 } elseif (
$settings->hasIconSupport($this->objDefinition)) {
286 $settings->getIconHandler()->handleUpload($this->
upload, $_FILES[
'icon'][
'tmp_name']);
289 $this->
logger->error(
'Import failed with message: ' . $e->getMessage());
290 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'didactic_import_failed') .
': ' . $e->getMessage());
291 $form->setValuesByPost();
293 if ($setting instanceof ilDidacticTemplateSetting) {
301 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'didactic_import_success'),
true);
303 if ($setting instanceof ilDidacticTemplateSetting) {
304 $this->
ctrl->redirect($this,
'editTemplate');
306 $this->
ctrl->redirect($this,
'overview');
314 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
315 $this->
ctrl->redirect($this,
'overview');
318 $this->
ctrl->saveParameter($this,
'tplid');
322 $this->tpl->setContent($form->getHTML());
328 $this->
ctrl->saveParameter($this,
'tplid');
330 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
331 $this->
ctrl->redirect($this,
"overview");
336 if ($form->checkInput()) {
337 $tmp_file = $_FILES[
'icon'][
'tmp_name'] ??
'';
338 $upload_element = $form->getItemByPostVar(
'icon');
340 ($tmp_file !==
'' || ($tmp_file ===
'' && $this->setting->getIconIdentifier())) &&
341 !$this->objDefinition->isContainer($form->getInput(
'type')) &&
342 !$upload_element->getDeletionFlag()
344 $form->getItemByPostVar(
'icon')->setAlert($this->
lng->txt(
'didactic_icon_error'));
349 if (count(
$lang = $this->setting->getTranslationObject()->getLanguages())) {
350 $this->setting->getTranslationObject()->setDefaultTitle($form->getInput(
'title'));
351 $this->setting->getTranslationObject()->setDefaultDescription($form->getInput(
'description'));
352 $this->setting->getTranslationObject()->save();
355 if (!$this->setting->isAutoGenerated()) {
356 $this->setting->setTitle($form->getInput(
'title'));
357 $this->setting->setDescription($form->getInput(
'description'));
360 $this->setting->setInfo($form->getInput(
'info'));
361 $this->setting->enable((
bool) $form->getInput(
'enable'));
363 if (!$this->setting->isAutoGenerated()) {
364 $this->setting->setAssignments([$form->getInput(
'type')]);
367 if ($form->getInput(
'local_template') && count($form->getInput(
'effective_from')) > 0) {
368 $this->setting->setEffectiveFrom($form->getInput(
'effective_from'));
370 $this->setting->setEffectiveFrom([]);
373 $this->setting->setExclusive((
bool) $form->getInput(
'exclusive_template'));
375 $this->setting->update();
377 $upload = $form->getItemByPostVar(
'icon');
378 if ($upload->getDeletionFlag()) {
379 $this->setting->getIconHandler()->delete();
381 $this->setting->getIconHandler()->handleUpload($this->
upload, $_FILES[
'icon'][
'tmp_name']);
382 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'),
true);
383 $this->
ctrl->redirect($this,
'overview');
390 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
398 $form->setShowTopButtons(
false);
399 $form->setFormAction($this->
ctrl->getFormAction($this,
'updateTemplate'));
400 $form->setTitle($this->
lng->txt(
'didactic_edit_tpl'));
401 $form->addCommandButton(
'updateTemplate', $this->
lng->txt(
'save'));
402 $form->addCommandButton(
'overview', $this->
lng->txt(
'cancel'));
407 $title->setMaxLength(64);
408 $title->setRequired(
true);
417 if (count($trans) > 1) {
419 $title->setInfo($this->
lng->txt(
"language") .
": " . $languages[$def[
"lang_code"]] .
420 ' <a href="' . $this->
ctrl->getLinkTargetByClass(
"ilmultilingualismgui",
"listTranslations") .
421 '">» ' . $this->
lng->txt(
"more_translations") .
'</a>');
427 } elseif (isset($def[
'title'])) {
428 $title->setValue($def[
"title"]);
431 $form->addItem($title);
438 } elseif (isset($def[
'description'])) {
439 $desc->setValue($def[
"description"]);
443 $form->addItem($desc);
447 $icon->setInfo($this->
lng->txt(
'didactic_icon_info'));
448 $icon->setAllowDeletion(
true);
449 $icon->setSuffixes([
'svg']);
450 $form->addItem($icon);
456 $form->addItem($info);
461 $form->addItem($enable);
466 $type->setRequired(
true);
467 $type->setInfo($this->
lng->txt(
'dtpl_obj_type_info'));
469 $type->setValue($assigned[0] ??
'');
470 $subs = $this->objDefinition->getSubObjectsRecursively(
'root',
false);
472 foreach (array_merge($subs, [
'fold' => 1]) as $obj => $null) {
474 if ($this->objDefinition->isPlugin($obj)) {
476 } elseif ($this->objDefinition->isAllowedInRepository($obj)) {
477 $options[$obj] = $this->
lng->txt(
'obj_' . $obj);
482 $type->setOptions($options);
483 $form->addItem(
$type);
486 $this->
lng->txt(
"activate_local_didactic_template"),
490 $lokal_templates->setInfo($this->
lng->txt(
"activate_local_didactic_template_info"));
497 foreach ($this->objDefinition->getAllRepositoryTypes() as
$type) {
498 if ($this->objDefinition->isContainer(
$type)) {
499 $white_list[] =
$type;
502 $effrom->getExplorerGUI()->setTypeWhiteList($white_list);
505 $lokal_templates->addSubItem($effrom);
506 $form->addItem($lokal_templates);
508 $excl =
new ilCheckboxInputGUI($this->
lng->txt(
"activate_exclusive_template"),
"exclusive_template");
509 $excl->
setInfo($this->
lng->txt(
"activate_exclusive_template_info"));
512 $form->addItem($excl);
520 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
521 $this->
ctrl->redirect($this,
"overview");
526 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
527 $this->
ctrl->redirect($this,
'overview');
534 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'didactic_copy_suc_message'),
true);
535 $this->
ctrl->redirect($this,
'overview');
542 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
543 $this->
ctrl->redirect($this,
'overview');
550 $writer->xmlDumpMem(
true),
551 $writer->getSetting()->getTitle() .
'.xml',
559 if (0 === count($templates)) {
560 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
561 $this->
ctrl->redirect($this,
'overview');
566 $confirm->setHeaderText($this->
lng->txt(
'didactic_confirm_delete_msg'));
567 $confirm->setFormAction($this->
ctrl->getFormAction($this));
568 $confirm->setConfirm($this->
lng->txt(
'delete'),
'deleteTemplates');
569 $confirm->setCancel($this->
lng->txt(
'cancel'),
'overview');
572 foreach ($templates as $tplid) {
575 if (!$tpl->isAutoGenerated()) {
576 $confirm->addItem(
'tpls[]', (
string) $tpl->getId(), $tpl->getPresentationTitle());
578 $forbidden[] = $tpl->getId();
582 if (count($forbidden) > 0 && count($templates) === 1) {
583 $this->tpl->
setOnScreenMessage(
'failure', $this->
lng->txt(
'didactic_cannot_delete_auto_generated'),
true);
584 $this->
ctrl->redirect($this,
"overview");
585 } elseif (count($forbidden) > 0 && count($templates) > 1) {
586 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'didactic_cannot_delete_auto_generated_confirmation'));
589 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
'didactic_confirm_delete_msg'));
590 $this->tpl->setContent($confirm->getHTML());
595 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
596 $this->
ctrl->redirect($this,
"overview");
599 if (0 === count($templates)) {
600 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
601 $this->
ctrl->redirect($this,
'overview');
605 foreach ($templates as $tplid) {
611 $this->
ctrl->redirect($this,
'overview');
616 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
617 $this->
ctrl->redirect($this,
"overview");
620 if (0 === count($templates)) {
621 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
622 $this->
ctrl->redirect($this,
'overview');
626 foreach ($templates as $tplid) {
633 $this->
ctrl->redirect($this,
'overview');
638 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
639 $this->
ctrl->redirect($this,
"overview");
643 if (0 === count($templates)) {
644 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
645 $this->
ctrl->redirect($this,
'overview');
647 foreach ($templates as $tplid) {
653 $this->
ctrl->redirect($this,
'overview');
656 protected function setEditTabs(
string $a_tab_active =
"edit"): void
658 $this->
lng->loadLanguageModule(
'obj');
659 $this->
tabs->clearTargets();
660 $this->
tabs->setBackTarget(
661 $this->
lng->txt(
'didactic_back_to_overview'),
662 $this->
ctrl->getLinkTarget($this,
'overview')
664 $this->
ctrl->saveParameter($this,
"tplid");
666 if (!$this->setting->isAutoGenerated()) {
667 $this->
tabs->addTab(
'edit', $this->
lng->txt(
'settings'), $this->
ctrl->getLinkTarget($this,
'editTemplate'));
670 $this->
lng->txt(
'import'),
671 $this->
ctrl->getLinkTarget($this,
'showEditImportForm')
674 if (in_array($a_tab_active, [
'edit',
'settings_trans'])) {
675 $this->
tabs->addSubTab(
677 $this->
lng->txt(
'settings'),
678 $this->
ctrl->getLinkTarget($this,
'editTemplate')
680 $this->
tabs->addSubTab(
682 $this->
lng->txt(
"obj_multilinguality"),
683 $this->
ctrl->getLinkTargetByClass([
"ilmultilingualismgui"],
'listTranslations')
685 $this->
tabs->setTabActive(
'edit');
686 $this->
tabs->setSubTabActive($a_tab_active);
688 $this->
tabs->setTabActive($a_tab_active);
700 $this->tpl->setContent($form->getHTML());
706 $form->setShowTopButtons(
false);
707 $form->setFormAction($this->
ctrl->getFormAction($this));
708 $form->setTitle($this->
lng->txt(
'didactic_import_table_title'));
709 $form->addCommandButton(
'importTemplate', $this->
lng->txt(
'import'));
710 $form->addCommandButton(
'overview', $this->
lng->txt(
'cancel'));
712 $file =
new ilFileInputGUI($this->
lng->txt(
'didactic_template_update_import'),
'file');
714 $file->setSuffixes([
'xml']);
715 $file->setInfo($this->
lng->txt(
'didactic_template_update_import_info'));
716 $form->addItem($file);
726 foreach ($assignments as $obj) {
729 $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.
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...
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")
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.
Customizing of pimple-DIC for ILIAS.
initTemplatesFromRequest()
transforms selected tpls from post to SplFixedArray
setValue(string $a_value)
RequestInterface $request
setStartValues(string $a_title, string $a_description)
parses the objects.xml it handles the xml-description of all ilias objects
ilObjectDefinition $objDefinition
editTemplate(ilPropertyFormGUI $form=null)
static http()
Fetches the global http state from ILIAS.
ilDidacticTemplateSetting $setting
ilObjectGUI $parent_object
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()
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.
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.
handleUpdateFailure(ilPropertyFormGUI $form)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
showEditImportForm(ilPropertyFormGUI $form=null)