ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDidacticTemplateSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
25 
34 {
35  private ilLogger $logger;
38  private Container $dic;
39  private ilLanguage $lng;
41  private ilCtrl $ctrl;
47  private Factory $refinery;
49  private ilTabsGUI $tabs;
51 
52  private int $ref_id;
53 
54  public function __construct(ilObjectGUI $a_parent_obj)
55  {
56  global $DIC;
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();
66  $this->refinery = $DIC->refinery();
67  $this->logger = $DIC->logger()->otpl();
68  $this->tpl = $DIC->ui()->mainTemplate();
69  $this->tabs = $DIC->tabs();
70  $this->upload = $DIC->upload();
71  }
72 
73  protected function initReferenceFromRequest(): void
74  {
75  if ($this->http->wrapper()->query()->has('ref_id')) {
76  $this->ref_id = $this->http->wrapper()->query()->retrieve(
77  'ref_id',
78  $this->refinery->kindlyTo()->int()
79  );
80  }
81  }
82 
86  protected function initTemplatesFromRequest(): SplFixedArray
87  {
88  if ($this->http->wrapper()->post()->has('tpls')) {
89  return SplFixedArray::fromArray(
90  $this->http->wrapper()->post()->retrieve(
91  'tpls',
92  $this->refinery->kindlyTo()->listOf(
93  $this->refinery->kindlyTo()->int()
94  )
95  )
96  );
97  }
98 
99  return new SplFixedArray(0);
100  }
101 
103  {
104  if ($this->http->wrapper()->query()->has('tplid')) {
105  $tpl_id = $this->http->wrapper()->query()->retrieve(
106  'tplid',
107  $this->refinery->kindlyTo()->int()
108  );
109  return $this->setting = new ilDidacticTemplateSetting($tpl_id);
110  }
111 
112  return null;
113  }
114 
115  public function executeCommand(): string
116  {
117  $this->initReferenceFromRequest();
118 
119  $next_class = $this->ctrl->getNextClass($this);
120  $cmd = $this->ctrl->getCmd();
121 
122  switch ($next_class) {
124  case "ilpropertyformgui":
125  $setting = $this->initTemplateFromRequest();
126  if (!$setting instanceof ilDidacticTemplateSetting) {
127  $setting = new ilDidacticTemplateSetting();
128  }
129  $form = $this->initEditTemplate($setting);
130  $this->ctrl->forwardCommand($form);
131  // no break
132  case 'ilmultilingualismgui':
133  $setting = $this->initTemplateFromRequest();
134  if (
135  !$this->access->checkAccess('write', '', $this->ref_id) ||
136  !$setting instanceof ilDidacticTemplateSetting ||
137  $setting->isAutoGenerated()) {
138  $this->ctrl->redirect($this, "overview");
139  }
140  $this->setEditTabs("settings_trans");
141  $transgui = new ilMultilingualismGUI($this->setting->getId(), 'dtpl');
142  $defaultl = $this->setting->getTranslationObject()->getDefaultLanguage();
143  $transgui->setStartValues(
144  $this->setting->getPresentationTitle($defaultl),
145  $this->setting->getPresentationDescription($defaultl)
146  );
147  $this->ctrl->forwardCommand($transgui);
148  break;
149  default:
150  if (!$cmd) {
151  $cmd = 'overview';
152  }
153  $this->$cmd();
154  break;
155  }
156  return '';
157  }
158 
159  protected function overview(): void
160  {
161  if ($this->rbacsystem->checkAccess('write', $this->ref_id)) {
162  $this->toolbar->addButton(
163  $this->lng->txt('didactic_import_btn'),
164  $this->ctrl->getLinkTarget($this, 'showImportForm')
165  );
166  }
167 
168  $filter = new ilDidacticTemplateSettingsTableFilter($this->ctrl->getFormAction($this, 'overview'));
169  $filter->init();
170 
171  $table = new ilDidacticTemplateSettingsTableGUI($this, 'overview', $this->ref_id);
172  $table->init();
173  $table->parse($filter);
174 
175  $this->tpl->setContent(
176  $filter->render() . $table->getHTML()
177  );
178  }
179 
180  public function applyFilter(): void
181  {
182  $table = new ilDidacticTemplateSettingsTableGUI($this, 'overview', $this->ref_id);
183  $table->init();
184  $table->resetOffset();
185  $table->writeFilterToSession();
186  $this->overview();
187  }
188 
189  public function resetFilter(): void
190  {
191  $table = new ilDidacticTemplateSettingsTableGUI($this, 'overview', $this->ref_id);
192  $table->init();
193  $table->resetOffset();
194  $table->resetFilter();
195  $this->overview();
196  }
197 
198  protected function showImportForm(ilPropertyFormGUI $form = null): void
199  {
200  $setting = $this->initTemplateFromRequest();
201  if ($setting instanceof ilDidacticTemplateSetting) {
202  $this->setEditTabs('import');
203  } else {
204  $this->tabs->clearTargets();
205  $this->tabs->setBackTarget(
206  $this->lng->txt('didactic_back_to_overview'),
207  $this->ctrl->getLinkTarget($this, 'overview')
208  );
209  }
210 
211  if (!$form instanceof ilPropertyFormGUI) {
212  $form = $this->createImportForm();
213  }
214  $this->tpl->setContent($form->getHTML());
215  }
216 
217  protected function createImportForm(): ilPropertyFormGUI
218  {
219  $form = new ilPropertyFormGUI();
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'));
225 
226  $file = new ilFileInputGUI($this->lng->txt('import_file'), 'file');
227  $file->setSuffixes(['xml']);
228  $file->setRequired(true);
229  $form->addItem($file);
230 
231  $icon = new ilImageFileInputGUI($this->lng->txt('icon'), 'icon');
232  $icon->setAllowDeletion(false);
233  $icon->setSuffixes(['svg']);
234  $icon->setInfo($this->lng->txt('didactic_icon_info'));
235  $form->addItem($icon);
236 
237  $created = true;
238 
239  return $form;
240  }
241 
242  protected function importTemplate(): void
243  {
244  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
245  $this->ctrl->redirect($this, "overview");
246  }
247 
248  $setting = $this->initTemplateFromRequest();
249  if ($setting instanceof ilDidacticTemplateSetting) {
250  $form = $this->editImportForm();
251  } else {
252  $form = $this->createImportForm();
253  }
254 
255  if (!$form->checkInput()) {
256  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
257  $form->setValuesByPost();
258 
259  if ($setting instanceof ilDidacticTemplateSetting) {
260  $this->showEditImportForm($form);
261  } else {
262  $this->showImportForm($form);
263  }
264  return;
265  }
266 
267  // Do import
269 
270  $file = $form->getInput('file');
271  $tmp = ilFileUtils::ilTempnam() . '.xml';
272 
273  // move uploaded file
275  $file['tmp_name'],
276  $file['name'],
277  $tmp
278  );
279  $import->setInputFile($tmp);
280 
281  try {
282  $settings = $import->import();
283  if ($setting instanceof ilDidacticTemplateSetting) {
284  $this->editImport($settings);
285  } elseif ($settings->hasIconSupport($this->objDefinition)) {
286  $settings->getIconHandler()->handleUpload($this->upload, $_FILES['icon']['tmp_name']);
287  }
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();
292 
293  if ($setting instanceof ilDidacticTemplateSetting) {
294  $this->showEditImportForm($form);
295  } else {
296  $this->showImportForm($form);
297  }
298  return;
299  }
300 
301  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_import_success'), true);
302 
303  if ($setting instanceof ilDidacticTemplateSetting) {
304  $this->ctrl->redirect($this, 'editTemplate');
305  } else {
306  $this->ctrl->redirect($this, 'overview');
307  }
308  }
309 
310  protected function editTemplate(ilPropertyFormGUI $form = null): void
311  {
312  $setting = $this->initTemplateFromRequest();
313  if (!$setting instanceof ilDidacticTemplateSetting) {
314  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
315  $this->ctrl->redirect($this, 'overview');
316  }
317  $this->setEditTabs("edit");
318  $this->ctrl->saveParameter($this, 'tplid');
319  if (!$form instanceof ilPropertyFormGUI) {
320  $form = $this->initEditTemplate($this->setting);
321  }
322  $this->tpl->setContent($form->getHTML());
323  }
324 
325  protected function updateTemplate(): void
326  {
327  $setting = $this->initTemplateFromRequest();
328  $this->ctrl->saveParameter($this, 'tplid');
329 
330  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
331  $this->ctrl->redirect($this, "overview");
332  }
333 
334  $form = $this->initEditTemplate($this->setting);
335 
336  if ($form->checkInput()) {
337  $tmp_file = $_FILES['icon']['tmp_name'] ?? '';
338  $upload_element = $form->getItemByPostVar('icon');
339  if (
340  ($tmp_file !== '' || ($tmp_file === '' && $this->setting->getIconIdentifier())) &&
341  !$this->objDefinition->isContainer($form->getInput('type')) &&
342  !$upload_element->getDeletionFlag()
343  ) {
344  $form->getItemByPostVar('icon')->setAlert($this->lng->txt('didactic_icon_error'));
345  $this->handleUpdateFailure($form);
346  return;
347  }
348  //change default entries if translation is active
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();
353  }
354 
355  if (!$this->setting->isAutoGenerated()) {
356  $this->setting->setTitle($form->getInput('title'));
357  $this->setting->setDescription($form->getInput('description'));
358  }
359 
360  $this->setting->setInfo($form->getInput('info'));
361  $this->setting->enable((bool) $form->getInput('enable'));
362 
363  if (!$this->setting->isAutoGenerated()) {
364  $this->setting->setAssignments([$form->getInput('type')]);
365  }
366 
367  if ($form->getInput('local_template') && count($form->getInput('effective_from')) > 0) {
368  $this->setting->setEffectiveFrom($form->getInput('effective_from'));
369  } else {
370  $this->setting->setEffectiveFrom([]);
371  }
372 
373  $this->setting->setExclusive((bool) $form->getInput('exclusive_template'));
374 
375  $this->setting->update();
376 
377  $upload = $form->getItemByPostVar('icon');
378  if ($upload->getDeletionFlag()) {
379  $this->setting->getIconHandler()->delete();
380  }
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');
384  }
385  $this->handleUpdateFailure($form);
386  }
387 
388  protected function handleUpdateFailure(ilPropertyFormGUI $form): void
389  {
390  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
391  $form->setValuesByPost();
392  $this->editTemplate($form);
393  }
394 
396  {
397  $form = new ilPropertyFormGUI();
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'));
403 
404  // title
405  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
406  $title->setSize(40);
407  $title->setMaxLength(64);
408  $title->setRequired(true);
409  //use presentation title if autogenerated is set
410  $title->setDisabled($set->isAutoGenerated());
411 
412  $def = [];
413  if (!$set->isAutoGenerated()) {
414  $trans = $set->getTranslations();
415  $def = $trans[0]; // default
416 
417  if (count($trans) > 1) {
418  $languages = ilMDLanguageItem::_getLanguages();
419  $title->setInfo($this->lng->txt("language") . ": " . $languages[$def["lang_code"]] .
420  ' <a href="' . $this->ctrl->getLinkTargetByClass("ilmultilingualismgui", "listTranslations") .
421  '">&raquo; ' . $this->lng->txt("more_translations") . '</a>');
422  }
423  }
424 
425  if ($set->isAutoGenerated()) {
426  $title->setValue($set->getPresentationTitle());
427  } elseif (isset($def['title'])) {
428  $title->setValue($def["title"]);
429  }
430 
431  $form->addItem($title);
432 
433  // desc
434  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
435  //use presentation title if autogenerated is set
436  if ($set->isAutoGenerated()) {
437  $desc->setValue($set->getPresentationDescription());
438  } elseif (isset($def['description'])) {
439  $desc->setValue($def["description"]);
440  }
441  $desc->setRows(3);
442  $desc->setDisabled($set->isAutoGenerated());
443  $form->addItem($desc);
444 
445  $icon = new ilImageFileInputGUI($this->lng->txt('didactic_icon'), 'icon');
446  $icon->setImage($set->getIconHandler()->getAbsolutePath());
447  $icon->setInfo($this->lng->txt('didactic_icon_info'));
448  $icon->setAllowDeletion(true);
449  $icon->setSuffixes(['svg']);
450  $form->addItem($icon);
451 
452  // info
453  $info = new ilTextAreaInputGUI($this->lng->txt('didactic_install_info'), 'info');
454  $info->setValue($set->getInfo());
455  $info->setRows(6);
456  $form->addItem($info);
457 
458  //activate
459  $enable = new ilCheckboxInputGUI($this->lng->txt('active'), 'enable');
460  $enable->setChecked($set->isEnabled());
461  $form->addItem($enable);
462 
463  // object type
464  if (!$set->isAutoGenerated()) {
465  $type = new ilSelectInputGUI($this->lng->txt('obj_type'), 'type');
466  $type->setRequired(true);
467  $type->setInfo($this->lng->txt('dtpl_obj_type_info'));
468  $assigned = $set->getAssignments();
469  $type->setValue($assigned[0] ?? '');
470  $subs = $this->objDefinition->getSubObjectsRecursively('root', false);
471  $options = [];
472  foreach (array_merge($subs, ['fold' => 1]) as $obj => $null) {
473  ilLoggerFactory::getLogger('root')->dump($null);
474  if ($this->objDefinition->isPlugin($obj)) {
475  $options[$obj] = ilObjectPlugin::lookupTxtById($obj, "obj_" . $obj);
476  } elseif ($this->objDefinition->isAllowedInRepository($obj)) {
477  $options[$obj] = $this->lng->txt('obj_' . $obj);
478  }
479  }
480  asort($options);
481 
482  $type->setOptions($options);
483  $form->addItem($type);
484 
485  $lokal_templates = new ilCheckboxInputGUI(
486  $this->lng->txt("activate_local_didactic_template"),
487  "local_template"
488  );
489  $lokal_templates->setChecked(count($set->getEffectiveFrom()) > 0);
490  $lokal_templates->setInfo($this->lng->txt("activate_local_didactic_template_info"));
491 
492  //effective from (multinode)
493 
494  $effrom = new ilRepositorySelector2InputGUI($this->lng->txt("effective_form"), "effective_from", true);
495  //$effrom->setMulti(true);
496  $white_list = [];
497  foreach ($this->objDefinition->getAllRepositoryTypes() as $type) {
498  if ($this->objDefinition->isContainer($type)) {
499  $white_list[] = $type;
500  }
501  }
502  $effrom->getExplorerGUI()->setTypeWhiteList($white_list);
503  $effrom->setValue($set->getEffectiveFrom());
504 
505  $lokal_templates->addSubItem($effrom);
506  $form->addItem($lokal_templates);
507 
508  $excl = new ilCheckboxInputGUI($this->lng->txt("activate_exclusive_template"), "exclusive_template");
509  $excl->setInfo($this->lng->txt("activate_exclusive_template_info"));
510  $excl->setChecked($set->isExclusive());
511 
512  $form->addItem($excl);
513  }
514 
515  return $form;
516  }
517 
518  protected function copyTemplate(): void
519  {
520  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
521  $this->ctrl->redirect($this, "overview");
522  }
523 
524  $setting = $this->initTemplateFromRequest();
525  if (!$setting instanceof ilDidacticTemplateSetting) {
526  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
527  $this->ctrl->redirect($this, 'overview');
528  return;
529  }
530 
531  $copier = new ilDidacticTemplateCopier($setting->getId());
532  $copier->start();
533 
534  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_copy_suc_message'), true);
535  $this->ctrl->redirect($this, 'overview');
536  }
537 
538  protected function exportTemplate(): void
539  {
540  $setting = $this->initTemplateFromRequest();
541  if (!$setting instanceof ilDidacticTemplateSetting) {
542  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
543  $this->ctrl->redirect($this, 'overview');
544  return;
545  }
546  $writer = new ilDidacticTemplateXmlWriter($setting->getId());
547  $writer->write();
548 
550  $writer->xmlDumpMem(true),
551  $writer->getSetting()->getTitle() . '.xml',
552  'application/xml'
553  );
554  }
555 
556  protected function confirmDelete(): void
557  {
558  $templates = $this->initTemplatesFromRequest();
559  if (0 === count($templates)) {
560  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
561  $this->ctrl->redirect($this, 'overview');
562  return;
563  }
564 
565  $confirm = new ilConfirmationGUI();
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');
570 
571  $forbidden = [];
572  foreach ($templates as $tplid) {
573  $tpl = new ilDidacticTemplateSetting((int) $tplid);
574 
575  if (!$tpl->isAutoGenerated()) {
576  $confirm->addItem('tpls[]', (string) $tpl->getId(), $tpl->getPresentationTitle());
577  } else {
578  $forbidden[] = $tpl->getId();
579  }
580  }
581 
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'));
587  }
588 
589  $this->tpl->setOnScreenMessage('question', $this->lng->txt('didactic_confirm_delete_msg'));
590  $this->tpl->setContent($confirm->getHTML());
591  }
592 
593  protected function deleteTemplates(): void
594  {
595  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
596  $this->ctrl->redirect($this, "overview");
597  }
598  $templates = $this->initTemplatesFromRequest();
599  if (0 === count($templates)) {
600  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
601  $this->ctrl->redirect($this, 'overview');
602  return;
603  }
604 
605  foreach ($templates as $tplid) {
606  $tpl = new ilDidacticTemplateSetting((int) $tplid);
607  $tpl->delete();
608  }
609 
610  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_delete_msg'), true);
611  $this->ctrl->redirect($this, 'overview');
612  }
613 
614  protected function activateTemplates(): void
615  {
616  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
617  $this->ctrl->redirect($this, "overview");
618  }
619  $templates = $this->initTemplatesFromRequest();
620  if (0 === count($templates)) {
621  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
622  $this->ctrl->redirect($this, 'overview');
623  return;
624  }
625 
626  foreach ($templates as $tplid) {
627  $tpl = new ilDidacticTemplateSetting((int) $tplid);
628  $tpl->enable(true);
629  $tpl->update();
630  }
631 
632  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_activated_msg'), true);
633  $this->ctrl->redirect($this, 'overview');
634  }
635 
636  protected function deactivateTemplates(): void
637  {
638  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
639  $this->ctrl->redirect($this, "overview");
640  }
641 
642  $templates = $this->initTemplatesFromRequest();
643  if (0 === count($templates)) {
644  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
645  $this->ctrl->redirect($this, 'overview');
646  }
647  foreach ($templates as $tplid) {
648  $tpl = new ilDidacticTemplateSetting((int) $tplid);
649  $tpl->enable(false);
650  $tpl->update();
651  }
652  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_deactivated_msg'), true);
653  $this->ctrl->redirect($this, 'overview');
654  }
655 
656  protected function setEditTabs(string $a_tab_active = "edit"): void
657  {
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')
663  );
664  $this->ctrl->saveParameter($this, "tplid");
665 
666  if (!$this->setting->isAutoGenerated()) {
667  $this->tabs->addTab('edit', $this->lng->txt('settings'), $this->ctrl->getLinkTarget($this, 'editTemplate'));
668  $this->tabs->addTab(
669  'import',
670  $this->lng->txt('import'),
671  $this->ctrl->getLinkTarget($this, 'showEditImportForm')
672  );
673 
674  if (in_array($a_tab_active, ['edit', 'settings_trans'])) {
675  $this->tabs->addSubTab(
676  'edit',
677  $this->lng->txt('settings'),
678  $this->ctrl->getLinkTarget($this, 'editTemplate')
679  );
680  $this->tabs->addSubTab(
681  'settings_trans',
682  $this->lng->txt("obj_multilinguality"),
683  $this->ctrl->getLinkTargetByClass(["ilmultilingualismgui"], 'listTranslations')
684  );
685  $this->tabs->setTabActive('edit');
686  $this->tabs->setSubTabActive($a_tab_active);
687  } else {
688  $this->tabs->setTabActive($a_tab_active);
689  }
690  }
691  }
692 
693  public function showEditImportForm(ilPropertyFormGUI $form = null): void
694  {
695  $this->initTemplateFromRequest();
696  $this->setEditTabs("import");
697  if (!$form instanceof ilPropertyFormGUI) {
698  $form = $this->editImportForm();
699  }
700  $this->tpl->setContent($form->getHTML());
701  }
702 
704  {
705  $form = new ilPropertyFormGUI();
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'));
711 
712  $file = new ilFileInputGUI($this->lng->txt('didactic_template_update_import'), 'file');
713  $file->setRequired(true);
714  $file->setSuffixes(['xml']);
715  $file->setInfo($this->lng->txt('didactic_template_update_import_info'));
716  $form->addItem($file);
717 
718  return $form;
719  }
720 
721  public function editImport(ilDidacticTemplateSetting $a_settings): void
722  {
725  $a_settings->delete();
726  foreach ($assignments as $obj) {
727  ilDidacticTemplateObjSettings::assignTemplate($obj["ref_id"], $obj["obj_id"], $a_settings->getId());
728  }
729  $this->ctrl->setParameter($this, "tplid", $a_settings->getId());
730  }
731 }
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)
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
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...
$type
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
This class represents a file property in a property form.
initEditTemplate(ilDidacticTemplateSetting $set)
This class represents a checkbox property in a property form.
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.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
initTemplatesFromRequest()
transforms selected tpls from post to SplFixedArray
global $DIC
Definition: feed.php:28
setStartValues(string $a_title, string $a_description)
parses the objects.xml it handles the xml-description of all ilias objects
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.
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:34
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:26
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
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.
getInfo()
Get installation info text.
Settings for a single didactic template.
getTranslations()
Get all translations from this object.
int $created
Timestamp for when the object was created.
Definition: System.php:151
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...