19declare(strict_types=1);
22use Psr\Http\Message\RequestInterface;
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'];
86 $this->data_factory =
new DataFactory();
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":
141 $this->
ctrl->forwardCommand($form);
143 case 'ilmultilingualismgui':
146 !$this->
access->checkAccess(
'write',
'', $this->ref_id) ||
149 $this->
ctrl->redirect($this,
"overview");
153 $defaultl = $this->setting->getTranslationObject()->getDefaultLanguage();
154 $transgui->setStartValues(
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'));
275 $file->setSuffixes([
'xml']);
276 $file->setRequired(
true);
277 $form->addItem($file);
280 $icon->setAllowDeletion(
false);
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");
327 $setting = $this->initTemplateFromRequest();
329 $form = $this->editImportForm();
331 $form = $this->createImportForm();
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
348 $this->showEditImportForm($form);
350 $this->showImportForm($form);
356 $settings = $import->
import();
358 $this->editImport($settings);
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'),
379 $this->
ctrl->redirect($this,
'editTemplate');
381 $this->
ctrl->redirect($this,
'overview');
388 if (is_null($template_id)) {
389 $setting = $this->initTemplateFromRequest();
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');
398 $this->setEditTabs(
"edit");
399 $this->
ctrl->saveParameter($this,
'tplid');
401 $form = $this->initEditTemplate($this->setting);
403 $this->tpl->setContent($form->
getHTML());
408 $setting = $this->initTemplateFromRequest();
409 $this->
ctrl->saveParameter($this,
'tplid');
411 if (!$this->
access->checkAccess(
'write',
'', $this->ref_id)) {
412 $this->
ctrl->redirect($this,
"overview");
415 $form = $this->initEditTemplate($this->setting);
418 $tmp_file = $_FILES[
'icon'][
'tmp_name'] ??
'';
421 ($tmp_file !==
'' || ($tmp_file ===
'' && $this->setting->getIconIdentifier())) &&
422 !$this->objDefinition->isContainer($form->
getInput(
'type')) &&
423 !$upload_element->getDeletionFlag()
426 $this->handleUpdateFailure($form);
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();
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');
466 $this->handleUpdateFailure($form);
471 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
473 $this->editTemplate(
null, $form);
481 $form->
setTitle($this->
lng->txt(
'didactic_edit_tpl'));
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"]);
524 } elseif (isset($def[
'description'])) {
525 $desc->setValue($def[
"description"]);
533 $icon->setInfo($this->
lng->txt(
'didactic_icon_info'));
534 $icon->setAllowDeletion(
true);
535 $icon->setSuffixes([
'svg']);
552 $type->setRequired(
true);
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);
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;
588 $effrom->getExplorerGUI()->setTypeWhiteList($white_list);
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"));
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");
671 $template_ids = $this->initTemplatesFromRequest();
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);
767 $this->initTemplateFromRequest();
768 $this->setEditTabs(
"import");
770 $form = $this->editImportForm();
772 $this->tpl->setContent($form->
getHTML());
780 $form->
setTitle($this->
lng->txt(
'didactic_import_table_title'));
784 $file =
new ilFileInputGUI($this->
lng->txt(
'didactic_template_update_import'),
'file');
785 $file->setRequired(
true);
786 $file->setSuffixes([
'xml']);
787 $file->setInfo($this->
lng->txt(
'didactic_template_update_import_info'));
798 foreach ($assignments as $obj) {
801 $this->
ctrl->setParameter($this,
"tplid", $a_settings->
getId());
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Customizing of pimple-DIC for ILIAS.
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
Class ilCtrl provides processing control methods.
Copy a didactic template and all subitems.
Description of ilDidacticTemplateImportException.
Description of ilDidacticTemplateImport.
setInputFile(string $a_file)
import(int $a_dtpl_id=0)
Do import.
static transferAutoGenerateStatus(int $a_src, int $a_dest)
Transfer auto generated flag if source is auto generated.
static getAssignmentsByTemplateID(int $a_tpl_id)
static assignTemplate(int $a_ref_id, int $a_obj_id, int $a_tpl_id)
getPresentationDescription(string $a_lng="")
getTranslations()
Get all translations from this object.
getInfo()
Get installation info text.
getPresentationTitle(string $a_lng="")
Settings for a single didactic template.
__construct(ilObjectGUI $a_parent_obj)
copyTemplate(int $template_id)
StaticURLService $static_url
initEditTemplate(ilDidacticTemplateSetting $set)
handleUpdateFailure(ilPropertyFormGUI $form)
ilDidacticTemplateSetting $setting
showImportForm(?ilPropertyFormGUI $form=null)
exportTemplate(int $template_id)
initTemplateFromRequest()
setEditTabs(string $a_tab_active="edit")
editImport(ilDidacticTemplateSetting $a_settings)
checkInput(ilPropertyFormGUI $form, ilDidacticTemplateImport $import)
ilObjectDefinition $objDefinition
editTemplate(?int $template_id=null, ?ilPropertyFormGUI $form=null)
initTemplatesFromRequest()
transforms selected tpls from post to SplFixedArray
showEditImportForm(?ilPropertyFormGUI $form=null)
initReferenceFromRequest()
LOMServices $lom_services
activateTemplates(array $template_ids)
DataFactory $data_factory
confirmDelete(array $template_ids)
deactivateTemplates(array $template_ids)
ilGlobalTemplateInterface $tpl
Description of ilDidacticTemplateSettingsTableGUI.
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parses the objects.xml it handles the xml-description of all ilias objects
Class ilObjectGUI Basic methods of all Output classes.
static lookupTxtById(string $plugin_id, string $lang_var)
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
Interface GlobalHttpState.
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
An entity that renders components to a string output.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
static http()
Fetches the global http state from ILIAS.