ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilDidacticTemplateSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
29 use ILIAS\Export\ImportStatus\ilCollection as ilImportStatusCollection;
30 use ILIAS\Export\ImportStatus\ilFactory as ilImportStatusFactory;
35 
44 {
45  protected UIRenderer $renderer;
47  private ilLogger $logger;
49  private Container $dic;
50  private ilLanguage $lng;
52  private ilCtrl $ctrl;
57  private Factory $refinery;
59  private ilTabsGUI $tabs;
64 
65  private int $ref_id;
66 
67  public function __construct(ilObjectGUI $a_parent_obj)
68  {
69  global $DIC;
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();
77  $this->refinery = $DIC->refinery();
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();
87  }
88 
89  protected function initReferenceFromRequest(): void
90  {
91  if ($this->http->wrapper()->query()->has('ref_id')) {
92  $this->ref_id = $this->http->wrapper()->query()->retrieve(
93  'ref_id',
94  $this->refinery->kindlyTo()->int()
95  );
96  }
97  }
98 
102  protected function initTemplatesFromRequest(): SplFixedArray
103  {
104  if ($this->http->wrapper()->query()->has('tpls')) {
105  return SplFixedArray::fromArray(explode(
106  ',',
107  $this->http->wrapper()->query()->retrieve('tpls', $this->refinery->custom()->transformation(fn($v) => $v))
108  ));
109  }
110  return new SplFixedArray(0);
111  }
112 
114  {
115  if ($this->http->wrapper()->query()->has('tplid')) {
116  $tpl_id = $this->http->wrapper()->query()->retrieve(
117  'tplid',
118  $this->refinery->kindlyTo()->int()
119  );
120  return $this->setting = new ilDidacticTemplateSetting($tpl_id);
121  }
122 
123  return null;
124  }
125 
126  public function executeCommand(): string
127  {
128  $this->initReferenceFromRequest();
129 
130  $next_class = $this->ctrl->getNextClass($this);
131  $cmd = $this->ctrl->getCmd();
132 
133  switch ($next_class) {
135  case "ilpropertyformgui":
136  $setting = $this->initTemplateFromRequest();
137  if (!$setting instanceof ilDidacticTemplateSetting) {
138  $setting = new ilDidacticTemplateSetting();
139  }
140  $form = $this->initEditTemplate($setting);
141  $this->ctrl->forwardCommand($form);
142  // no break
143  case 'ilmultilingualismgui':
144  $setting = $this->initTemplateFromRequest();
145  if (
146  !$this->access->checkAccess('write', '', $this->ref_id) ||
147  !$setting instanceof ilDidacticTemplateSetting ||
148  $setting->isAutoGenerated()) {
149  $this->ctrl->redirect($this, "overview");
150  }
151  $this->setEditTabs("settings_trans");
152  $transgui = new ilMultilingualismGUI($this->setting->getId(), 'dtpl');
153  $defaultl = $this->setting->getTranslationObject()->getDefaultLanguage();
154  $transgui->setStartValues(
155  $this->setting->getPresentationTitle($defaultl),
156  $this->setting->getPresentationDescription($defaultl)
157  );
158  $this->ctrl->forwardCommand($transgui);
159  break;
160  default:
161  if (!$cmd) {
162  $cmd = 'overview';
163  }
164  $this->$cmd();
165  break;
166  }
167  return '';
168  }
169 
170  protected function handleTableActions(): void
171  {
172  $query = $this->http->wrapper()->query();
173  if (!$query->has('didactic_template_table_action')) {
174  return;
175  }
176  $action = $query->retrieve('didactic_template_table_action', $this->refinery->to()->string());
177 
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)) {
182  return $q_ids;
183  }
184  return strlen($q_ids) > 0 ? explode(',', $q_ids) : [];
185  })
186  );
187 
188  switch ($action) {
189  case 'editTemplate':
190  $this->editTemplate((int) $ids[0]);
191  break;
192  case 'exportTemplate':
193  $this->exportTemplate((int) $ids[0]);
194  break;
195  case 'copyTemplate':
196  $this->copyTemplate((int) $ids[0]);
197  break;
198  case 'activateTemplates':
199  $this->activateTemplates($ids);
200  break;
201  case 'deactivateTemplates':
202  $this->deactivateTemplates($ids);
203  break;
204  case 'confirmDelete':
205  $this->confirmDelete($ids);
206  break;
207  }
208  }
209 
210  protected function overview(): void
211  {
212  if ($this->rbacsystem->checkAccess('write', $this->ref_id)) {
213  $this->toolbar->addButton(
214  $this->lng->txt('didactic_import_btn'),
215  $this->ctrl->getLinkTarget($this, 'showImportForm')
216  );
217  }
218  $filter = new ilDidacticTemplateSettingsTableFilter($this->ctrl->getFormAction($this, 'overview'));
219  $filter->init();
220 
221  $data_retrieval = new ilDidacticTemplateSettingsTableDataRetrieval(
222  $filter,
223  $this->lng,
224  $this->ui_factory,
225  $this->renderer,
226  $this->static_url,
227  $this->data_factory
228  );
229 
230  $table = new ilDidacticTemplateSettingsTableGUI($this, $this->ref_id);
231  $this->tpl->setContent(
232  $filter->render() . $table->getHTML($data_retrieval)
233  );
234  }
235 
236  public function applyFilter(): void
237  {
238  $this->overview();
239  }
240 
241  public function resetFilter(): void
242  {
243  $this->overview();
244  }
245 
246  protected function showImportForm(?ilPropertyFormGUI $form = null): void
247  {
248  $setting = $this->initTemplateFromRequest();
249  if ($setting instanceof ilDidacticTemplateSetting) {
250  $this->setEditTabs('import');
251  } else {
252  $this->tabs->clearTargets();
253  $this->tabs->setBackTarget(
254  $this->lng->txt('didactic_back_to_overview'),
255  $this->ctrl->getLinkTarget($this, 'overview')
256  );
257  }
258 
259  if (!$form instanceof ilPropertyFormGUI) {
260  $form = $this->createImportForm();
261  }
262  $this->tpl->setContent($form->getHTML());
263  }
264 
265  protected function createImportForm(): ilPropertyFormGUI
266  {
267  $form = new ilPropertyFormGUI();
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'));
273 
274  $file = new ilFileInputGUI($this->lng->txt('import_file'), 'file');
275  $file->setSuffixes(['xml']);
276  $file->setRequired(true);
277  $form->addItem($file);
278 
279  $icon = new ilImageFileInputGUI($this->lng->txt('icon'), 'icon');
280  $icon->setAllowDeletion(false);
281  $icon->setSuffixes(['svg']);
282  $icon->setInfo($this->lng->txt('didactic_icon_info'));
283  $form->addItem($icon);
284 
285  $created = true;
286 
287  return $form;
288  }
289 
290  protected function checkInput(
291  ilPropertyFormGUI $form,
293  ): ilImportStatusCollection {
294  $status = new ilImportStatusFactory();
295 
296  if (!$form->checkInput()) {
297  $form->setValuesByPost();
298  return $status->collection();
299  }
300 
301  $file = $form->getInput('file');
302  $tmp = ilFileUtils::ilTempnam() . '.xml';
303 
304  // move uploaded file
306  $file['tmp_name'],
307  $file['name'],
308  $tmp
309  );
310  $import->setInputFile($tmp);
311  $statuses = $import->validateImportFile();
312 
313  if (!$statuses->hasStatusType(ImportStatusType::FAILED)) {
314  $statuses = $statuses->withAddedStatus($status->handler()
315  ->withType(ImportStatusType::SUCCESS)
316  ->withContent($status->content()->builder()->string()->withString('')));
317  }
318  return $statuses;
319  }
320 
321  protected function importTemplate(): void
322  {
323  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
324  $this->ctrl->redirect($this, "overview");
325  }
326 
327  $setting = $this->initTemplateFromRequest();
328  if ($setting instanceof ilDidacticTemplateSetting) {
329  $form = $this->editImportForm();
330  } else {
331  $form = $this->createImportForm();
332  }
333 
335  $statuses = $this->checkInput($form, $import);
336 
337  if (!$statuses->hasStatusType(ImportStatusType::SUCCESS)) {
338  $error_msg = ($statuses->getCollectionOfAllByType(ImportStatusType::FAILED)->count() > 0)
339  ? $statuses
340  ->withNumberingEnabled(true)
341  ->toString(ImportStatusType::FAILED)
342  : '';
343  $this->tpl->setOnScreenMessage(
344  'failure',
345  $this->lng->txt('didactic_import_failed') . $error_msg
346  );
347  if ($setting instanceof ilDidacticTemplateSetting) {
348  $this->showEditImportForm($form);
349  } else {
350  $this->showImportForm($form);
351  }
352  return;
353  }
354 
355  try {
356  $settings = $import->import();
357  if ($setting instanceof ilDidacticTemplateSetting) {
358  $this->editImport($settings);
359  } elseif ($settings->hasIconSupport($this->objDefinition)) {
360  $settings->getIconHandler()->handleUpload($this->upload, $_FILES['icon']['tmp_name']);
361  }
363  $this->logger->error('Import failed with message: ' . $e->getMessage());
364  $this->tpl->setOnScreenMessage(
365  'failure',
366  $this->lng->txt('didactic_import_failed') . ': ' . $e->getMessage(),
367  true
368  );
369  $this->ctrl->redirect($this, 'importTemplate');
370  }
371 
372  $this->tpl->setOnScreenMessage(
373  'success',
374  $this->lng->txt('didactic_import_success'),
375  true
376  );
377 
378  if ($setting instanceof ilDidacticTemplateSetting) {
379  $this->ctrl->redirect($this, 'editTemplate');
380  } else {
381  $this->ctrl->redirect($this, 'overview');
382  }
383  }
384 
385  protected function editTemplate(?int $template_id = null, ?ilPropertyFormGUI $form = null): void
386  {
387  $setting = null;
388  if (is_null($template_id)) {
389  $setting = $this->initTemplateFromRequest();
390  } else {
391  $setting = ($this->setting = new ilDidacticTemplateSetting($template_id));
392  $this->ctrl->setParameter($this, 'tplid', $template_id);
393  }
394  if (!$setting instanceof ilDidacticTemplateSetting) {
395  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
396  $this->ctrl->redirect($this, 'overview');
397  }
398  $this->setEditTabs("edit");
399  $this->ctrl->saveParameter($this, 'tplid');
400  if (!$form instanceof ilPropertyFormGUI) {
401  $form = $this->initEditTemplate($this->setting);
402  }
403  $this->tpl->setContent($form->getHTML());
404  }
405 
406  protected function updateTemplate(): void
407  {
408  $setting = $this->initTemplateFromRequest();
409  $this->ctrl->saveParameter($this, 'tplid');
410 
411  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
412  $this->ctrl->redirect($this, "overview");
413  }
414 
415  $form = $this->initEditTemplate($this->setting);
416 
417  if ($form->checkInput()) {
418  $tmp_file = $_FILES['icon']['tmp_name'] ?? '';
419  $upload_element = $form->getItemByPostVar('icon');
420  if (
421  ($tmp_file !== '' || ($tmp_file === '' && $this->setting->getIconIdentifier())) &&
422  !$this->objDefinition->isContainer($form->getInput('type')) &&
423  !$upload_element->getDeletionFlag()
424  ) {
425  $form->getItemByPostVar('icon')->setAlert($this->lng->txt('didactic_icon_error'));
426  $this->handleUpdateFailure($form);
427  return;
428  }
429  //change default entries if translation is active
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();
434  }
435 
436  if (!$this->setting->isAutoGenerated()) {
437  $this->setting->setTitle($form->getInput('title'));
438  $this->setting->setDescription($form->getInput('description'));
439  }
440 
441  $this->setting->setInfo($form->getInput('info'));
442  $this->setting->enable((bool) $form->getInput('enable'));
443 
444  if (!$this->setting->isAutoGenerated()) {
445  $this->setting->setAssignments([$form->getInput('type')]);
446  }
447 
448  if ($form->getInput('local_template') && count($form->getInput('effective_from')) > 0) {
449  $this->setting->setEffectiveFrom($form->getInput('effective_from'));
450  } else {
451  $this->setting->setEffectiveFrom([]);
452  }
453 
454  $this->setting->setExclusive((bool) $form->getInput('exclusive_template'));
455 
456  $this->setting->update();
457 
458  $upload = $form->getItemByPostVar('icon');
459  if ($upload->getDeletionFlag()) {
460  $this->setting->getIconHandler()->delete();
461  }
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');
465  }
466  $this->handleUpdateFailure($form);
467  }
468 
469  protected function handleUpdateFailure(ilPropertyFormGUI $form): void
470  {
471  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
472  $form->setValuesByPost();
473  $this->editTemplate(null, $form);
474  }
475 
477  {
478  $form = new ilPropertyFormGUI();
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'));
484 
485  // title
486  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
487  $title->setSize(40);
488  $title->setMaxLength(64);
489  $title->setRequired(true);
490  //use presentation title if autogenerated is set
491  $title->setDisabled($set->isAutoGenerated());
492 
493  $def = [];
494  if (!$set->isAutoGenerated()) {
495  $trans = $set->getTranslations();
496  $def = $trans[0]; // default
497 
498  if (count($trans) > 1) {
499  $language = '';
500  foreach ($this->lom_services->dataHelper()->getAllLanguages() as $lom_lang) {
501  if ($lom_lang->value() === ($def["lang_code"] ?? '')) {
502  $language = $lom_lang->presentableLabel();
503  }
504  }
505  $title->setInfo($this->lng->txt("language") . ": " . $language .
506  ' <a href="' . $this->ctrl->getLinkTargetByClass("ilmultilingualismgui", "listTranslations") .
507  '">&raquo; ' . $this->lng->txt("more_translations") . '</a>');
508  }
509  }
510 
511  if ($set->isAutoGenerated()) {
512  $title->setValue($set->getPresentationTitle());
513  } elseif (isset($def['title'])) {
514  $title->setValue($def["title"]);
515  }
516 
517  $form->addItem($title);
518 
519  // desc
520  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
521  //use presentation title if autogenerated is set
522  if ($set->isAutoGenerated()) {
523  $desc->setValue($set->getPresentationDescription());
524  } elseif (isset($def['description'])) {
525  $desc->setValue($def["description"]);
526  }
527  $desc->setRows(3);
528  $desc->setDisabled($set->isAutoGenerated());
529  $form->addItem($desc);
530 
531  $icon = new ilImageFileInputGUI($this->lng->txt('didactic_icon'), 'icon');
532  $icon->setImage($set->getIconHandler()->getAbsolutePath());
533  $icon->setInfo($this->lng->txt('didactic_icon_info'));
534  $icon->setAllowDeletion(true);
535  $icon->setSuffixes(['svg']);
536  $form->addItem($icon);
537 
538  // info
539  $info = new ilTextAreaInputGUI($this->lng->txt('didactic_install_info'), 'info');
540  $info->setValue($set->getInfo());
541  $info->setRows(6);
542  $form->addItem($info);
543 
544  //activate
545  $enable = new ilCheckboxInputGUI($this->lng->txt('active'), 'enable');
546  $enable->setChecked($set->isEnabled());
547  $form->addItem($enable);
548 
549  // object type
550  if (!$set->isAutoGenerated()) {
551  $type = new ilSelectInputGUI($this->lng->txt('obj_type'), 'type');
552  $type->setRequired(true);
553  $type->setInfo($this->lng->txt('dtpl_obj_type_info'));
554  $assigned = $set->getAssignments();
555  $type->setValue($assigned[0] ?? '');
556  $subs = $this->objDefinition->getSubObjectsRecursively('root', false);
557  $options = [];
558  foreach (array_merge($subs, ['fold' => 1]) as $obj => $null) {
559  ilLoggerFactory::getLogger('root')->dump($null);
560  if ($this->objDefinition->isPlugin($obj)) {
561  $options[$obj] = ilObjectPlugin::lookupTxtById($obj, "obj_" . $obj);
562  } elseif ($this->objDefinition->isAllowedInRepository($obj)) {
563  $options[$obj] = $this->lng->txt('obj_' . $obj);
564  }
565  }
566  asort($options);
567 
568  $type->setOptions($options);
569  $form->addItem($type);
570 
571  $lokal_templates = new ilCheckboxInputGUI(
572  $this->lng->txt("activate_local_didactic_template"),
573  "local_template"
574  );
575  $lokal_templates->setChecked(count($set->getEffectiveFrom()) > 0);
576  $lokal_templates->setInfo($this->lng->txt("activate_local_didactic_template_info"));
577 
578  //effective from (multinode)
579 
580  $effrom = new ilRepositorySelector2InputGUI($this->lng->txt("effective_form"), "effective_from", true);
581  //$effrom->setMulti(true);
582  $white_list = [];
583  foreach ($this->objDefinition->getAllRepositoryTypes() as $type) {
584  if ($this->objDefinition->isContainer($type)) {
585  $white_list[] = $type;
586  }
587  }
588  $effrom->getExplorerGUI()->setTypeWhiteList($white_list);
589  $effrom->setValue($set->getEffectiveFrom());
590 
591  $lokal_templates->addSubItem($effrom);
592  $form->addItem($lokal_templates);
593 
594  $excl = new ilCheckboxInputGUI($this->lng->txt("activate_exclusive_template"), "exclusive_template");
595  $excl->setInfo($this->lng->txt("activate_exclusive_template_info"));
596  $excl->setChecked($set->isExclusive());
597 
598  $form->addItem($excl);
599  }
600 
601  return $form;
602  }
603 
604  protected function copyTemplate(int $template_id): void
605  {
606  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
607  $this->ctrl->redirect($this, "overview");
608  }
609  $setting = ($this->setting = new ilDidacticTemplateSetting($template_id));
610  $copier = new ilDidacticTemplateCopier($setting->getId());
611  $copier->start();
612  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_copy_suc_message'), true);
613  $this->ctrl->redirect($this, 'overview');
614  }
615 
616  protected function exportTemplate(int $template_id): void
617  {
618  $setting = ($this->setting = new ilDidacticTemplateSetting($template_id));
619  $writer = new ilDidacticTemplateXmlWriter($setting->getId());
620  $writer->write();
622  $writer->xmlDumpMem(true),
623  $writer->getSetting()->getTitle() . '.xml',
624  'application/xml'
625  );
626  }
627 
631  protected function confirmDelete(array $template_ids): never
632  {
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');
636  $items = [];
638  $tpls->readInactive();
639  $templates = $tpls->getTemplates();
640  foreach ($templates as $template) {
641  foreach ($template_ids as $id) {
642  if ((int) $id !== $template->getId()) {
643  continue;
644  }
645  $items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
646  $id,
647  $template->getTitle()
648  );
649  }
650  }
651  echo($this->renderer->renderAsync([
652  $this->ui_factory->modal()->interruptive(
653  $this->lng->txt('delete'),
654  $this->lng->txt('modal_confirm_deletion_text'),
655  $del_action
656  )
657  ->withAffectedItems($items)
658  ->withAdditionalOnLoadCode(static fn($id): string => "console.log('ASYNC JS');")
659  ]));
660  exit();
661  }
662 
666  protected function deleteTemplates(): void
667  {
668  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
669  $this->ctrl->redirect($this, "overview");
670  }
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);
674  //$this->ctrl->redirect($this, 'overview');
675  return;
676  }
677  foreach ($template_ids as $tplid) {
678  $tpl = new ilDidacticTemplateSetting((int) $tplid);
679  $tpl->delete();
680  }
681  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_delete_msg'), true);
682  $this->ctrl->redirect($this, 'overview');
683  }
684 
688  protected function activateTemplates(array $template_ids): void
689  {
690  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
691  $this->ctrl->redirect($this, "overview");
692  }
693  if (0 === count($template_ids)) {
694  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
695  $this->ctrl->redirect($this, 'overview');
696  return;
697  }
698  foreach ($template_ids as $tplid) {
699  $tpl = new ilDidacticTemplateSetting((int) $tplid);
700  $tpl->enable(true);
701  $tpl->update();
702  }
703  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_activated_msg'), true);
704  $this->ctrl->redirect($this, 'overview');
705  }
706 
710  protected function deactivateTemplates(array $template_ids): void
711  {
712  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
713  $this->ctrl->redirect($this, "overview");
714  }
715  if (0 === count($template_ids)) {
716  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
717  $this->ctrl->redirect($this, 'overview');
718  }
719  foreach ($template_ids as $tplid) {
720  $tpl = new ilDidacticTemplateSetting((int) $tplid);
721  $tpl->enable(false);
722  $tpl->update();
723  }
724  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_deactivated_msg'), true);
725  $this->ctrl->redirect($this, 'overview');
726  }
727 
728  protected function setEditTabs(string $a_tab_active = "edit"): void
729  {
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')
735  );
736  $this->ctrl->saveParameter($this, "tplid");
737 
738  if (!$this->setting->isAutoGenerated()) {
739  $this->tabs->addTab('edit', $this->lng->txt('settings'), $this->ctrl->getLinkTarget($this, 'editTemplate'));
740  $this->tabs->addTab(
741  'import',
742  $this->lng->txt('import'),
743  $this->ctrl->getLinkTarget($this, 'showEditImportForm')
744  );
745 
746  if (in_array($a_tab_active, ['edit', 'settings_trans'])) {
747  $this->tabs->addSubTab(
748  'edit',
749  $this->lng->txt('settings'),
750  $this->ctrl->getLinkTarget($this, 'editTemplate')
751  );
752  $this->tabs->addSubTab(
753  'settings_trans',
754  $this->lng->txt("obj_multilinguality"),
755  $this->ctrl->getLinkTargetByClass(["ilmultilingualismgui"], 'listTranslations')
756  );
757  $this->tabs->setTabActive('edit');
758  $this->tabs->setSubTabActive($a_tab_active);
759  } else {
760  $this->tabs->setTabActive($a_tab_active);
761  }
762  }
763  }
764 
765  public function showEditImportForm(?ilPropertyFormGUI $form = null): void
766  {
767  $this->initTemplateFromRequest();
768  $this->setEditTabs("import");
769  if (!$form instanceof ilPropertyFormGUI) {
770  $form = $this->editImportForm();
771  }
772  $this->tpl->setContent($form->getHTML());
773  }
774 
776  {
777  $form = new ilPropertyFormGUI();
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'));
783 
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'));
788  $form->addItem($file);
789 
790  return $form;
791  }
792 
793  public function editImport(ilDidacticTemplateSetting $a_settings): void
794  {
797  $a_settings->delete();
798  foreach ($assignments as $obj) {
799  ilDidacticTemplateObjSettings::assignTemplate($obj["ref_id"], $obj["obj_id"], $a_settings->getId());
800  }
801  $this->ctrl->setParameter($this, "tplid", $a_settings->getId());
802  }
803 }
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)
Description of ilDidacticTemplateSettingsTableGUI.
static getLogger(string $a_component_id)
Get component logger.
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a file property in a property form.
renderer()
initEditTemplate(ilDidacticTemplateSetting $set)
setSuffixes(array $a_suffixes)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
static transferAutoGenerateStatus(int $a_src, int $a_dest)
Transfer auto generated flag if source is auto generated.
checkInput(ilPropertyFormGUI $form, ilDidacticTemplateImport $import)
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
showEditImportForm(?ilPropertyFormGUI $form=null)
initTemplatesFromRequest()
transforms selected tpls from post to SplFixedArray
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setStartValues(string $a_title, string $a_description)
static http()
Fetches the global http state from ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjectGUI Basic methods of all Output classes.
global $DIC
Definition: shib_login.php:22
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.
Class FileUpload.
Definition: FileUpload.php:37
setRequired(bool $a_required)
Description of ilDidacticTemplateImport.
Copy a didactic template and all subitems.
static lookupTxtById(string $plugin_id, string $lang_var)
$lang
Definition: xapiexit.php:25
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
This class represents an image file property in a property form.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This class represents a text area property in a property form.
getInfo()
Get installation info text.
Settings for a single didactic template.
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...
editTemplate(?int $template_id=null, ?ilPropertyFormGUI $form=null)