ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDidacticTemplateSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
5 
6 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSetting.php';
7 
17 {
18  private $parent_object;
19 
23  private $object = null;
27  private $dic;
31  private $lng;
35  private $rbacsystem;
39  private $ctrl;
40 
44  private $objDefinition;
45 
49  private $request;
50 
54  public function __construct($a_parent_obj)
55  {
56  global $DIC;
57 
58  $this->parent_object = $a_parent_obj;
59  $this->dic = $DIC;
60  $this->lng = $this->dic->language();
61  $this->rbacsystem = $this->dic->rbac()->system();
62  $this->ctrl = $this->dic->ctrl();
63  $this->objDefinition = $DIC['objDefinition'];
64  $this->request = $DIC->http()->request();
65 
66  if (isset($_REQUEST["tplid"])) {
67  $this->initObject($_REQUEST["tplid"]);
68  }
69  }
70 
75  protected function initObject($a_id)
76  {
77  return $this->object = new ilDidacticTemplateSetting($a_id);
78  }
79 
84  public function executeCommand()
85  {
89  global $DIC;
90 
91  $ilCtrl = $DIC['ilCtrl'];
92  $ilAccess = $DIC['ilAccess'];
93 
94  $next_class = $ilCtrl->getNextClass($this);
95  $cmd = $ilCtrl->getCmd();
96 
97  switch ($next_class) {
98  case "ilpropertyformgui":
99  $settings = new ilDidacticTemplateSetting((int) $_REQUEST['tplid']);
100  $form = $this->initEditTemplate($settings);
101  $ilCtrl->forwardCommand($form);
102  // no break
103  case 'ilmultilingualismgui':
104  if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"]) ||
105  !isset($this->object) ||
106  $this->object->isAutoGenerated()) {
107  $ilCtrl->redirect($this, "overview");
108  }
109  //$this->tabs_gui->setTabActive('export');
110  $this->setEditTabs("settings_trans");
111  include_once("./Services/Multilingualism/classes/class.ilMultilingualismGUI.php");
112  $transgui = new ilMultilingualismGUI($_REQUEST["tplid"], 'dtpl');
113  $defaultl = $this->object->getTranslationObject()->getDefaultLanguage();
114 
115  $transgui->setStartValues(
116  $this->object->getPresentationTitle($defaultl),
117  $this->object->getPresentationDescription($defaultl)
118  );
119 
120  $ilCtrl->forwardCommand($transgui);
121  break;
122  default:
123  if (!$cmd) {
124  $cmd = 'overview';
125  }
126  $this->$cmd();
127 
128  break;
129  }
130  return true;
131  }
132 
138  protected function overview()
139  {
140  global $DIC;
141 
142  $tpl = $DIC->ui()->mainTemplate();
143 
144  if ($this->rbacsystem->checkAccess('write', $_REQUEST["ref_id"])) {
145  $this->dic->toolbar()->addButton(
146  $this->lng->txt('didactic_import_btn'),
147  $this->ctrl->getLinkTarget($this, 'showImportForm')
148  );
149  }
150 
151  $filter = new ilDidacticTemplateSettingsTableFilter($this->ctrl->getFormAction($this, 'overview'));
152  $filter->init();
153 
154 
155  $table = new ilDidacticTemplateSettingsTableGUI($this, 'overview');
156  $table->init();
157  $table->parse($filter);
158 
159  $tpl->setContent(
160  $filter->render() . '' . $table->getHTML()
161  );
162  }
163 
167  public function applyFilter()
168  {
169  $table = new ilDidacticTemplateSettingsTableGUI($this, 'overview');
170  $table->init();
171  $table->resetOffset();
172  $table->writeFilterToSession();
173  $this->overview();
174  }
175 
179  public function resetFilter()
180  {
181  $table = new ilDidacticTemplateSettingsTableGUI($this, 'overview');
182  $table->init();
183  $table->resetOffset();
184  $table->resetFilter();
185  $this->overview();
186  }
187 
188 
194  protected function showImportForm(ilPropertyFormGUI $form = null)
195  {
196  global $DIC;
197 
198  $ilTabs = $DIC->tabs();
199  $ilCtrl = $DIC->ctrl();
200 
201  if (isset($_REQUEST["tplid"])) {
202  $this->setEditTabs('import');
203  } else {
204  $ilTabs->clearTargets();
205  $ilTabs->setBackTarget(
206  $this->lng->txt('didactic_back_to_overview'),
207  $ilCtrl->getLinkTarget($this, 'overview')
208  );
209  }
210 
211  if (!$form instanceof ilPropertyFormGUI) {
212  $form = $this->createImportForm();
213  }
214  $GLOBALS['DIC']['tpl']->setContent($form->getHTML());
215  }
216 
221  protected function createImportForm()
222  {
223  global $DIC;
224 
225  $ilCtrl = $DIC['ilCtrl'];
226 
227  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
228  $form = new ilPropertyFormGUI();
229  $form->setShowTopButtons(false);
230  $form->setFormAction($ilCtrl->getFormAction($this));
231  $form->setTitle($this->lng->txt('didactic_import_table_title'));
232  $form->addCommandButton('importTemplate', $this->lng->txt('import'));
233  $form->addCommandButton('overview', $this->lng->txt('cancel'));
234 
235  $file = new ilFileInputGUI($this->lng->txt('import_file'), 'file');
236  $file->setSuffixes(['xml']);
237  $file->setRequired(true);
238  $form->addItem($file);
239 
240  $icon = new ilImageFileInputGUI($this->lng->txt('icon'), 'icon');
241  $icon->setAllowDeletion(false);
242  $icon->setSuffixes(['svg']);
243  $icon->setInfo($this->lng->txt('didactic_icon_info'));
244  $form->addItem($icon);
245 
246  $created = true;
247 
248  return $form;
249  }
250 
254  protected function importTemplate()
255  {
256  global $DIC;
257 
258  $ilCtrl = $DIC['ilCtrl'];
259  $ilAccess = $DIC['ilAccess'];
260 
261  if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
262  $ilCtrl->redirect($this, "overview");
263  }
264 
265  $edit = $this->request->getQueryParams()['tplid'] ?? false;
266  if ($edit) {
267  $this->initObject($this->request->getQueryParams()['tplid']);
268  $form = $this->editImportForm();
269  } else {
270  $form = $this->createImportForm();
271  }
272 
273 
274  if (!$form->checkInput()) {
275  ilUtil::sendFailure($this->lng->txt('err_check_input'));
276  $form->setValuesByPost();
277 
278  if ($edit) {
279  $this->showEditImportForm($form);
280  } else {
281  $this->showImportForm($form);
282  }
283  return;
284  }
285 
286  // Do import
288 
289  $file = $form->getInput('file');
290  $tmp = ilUtil::ilTempnam() . '.xml';
291 
292  // move uploaded file
294  $file['tmp_name'],
295  $file['name'],
296  $tmp
297  );
298  $import->setInputFile($tmp);
299 
300  try {
301  $settings = $import->import();
302  if ($edit) {
303  $this->editImport($settings);
304  } else {
305  if ($settings->hasIconSupport($this->objDefinition)) {
306  $settings->getIconHandler()->handleUpload($DIC->upload(), $_FILES['icon']['tmp_name']);
307  }
308  }
310  ilLoggerFactory::getLogger('otpl')->error('Import failed with message: ' . $e->getMessage());
311  ilUtil::sendFailure($this->lng->txt('didactic_import_failed') . ': ' . $e->getMessage());
312 
313  $form->setValuesByPost();
314 
315  if ($edit) {
316  $this->showEditImportForm($form);
317  } else {
318  $this->showImportForm($form);
319  }
320  return;
321  }
322 
323  ilUtil::sendSuccess($this->lng->txt('didactic_import_success'), true);
324 
325  if ($edit) {
326  $ilCtrl->redirect($this, 'editTemplate');
327  } else {
328  $ilCtrl->redirect($this, 'overview');
329  }
330  }
331 
336  protected function editTemplate(ilPropertyFormGUI $form = null)
337  {
338  global $DIC;
339 
340  $ilCtrl = $DIC['ilCtrl'];
341  $ilTabs = $DIC['ilTabs'];
342 
343  $this->setEditTabs("edit");
344 
345  if (!$_REQUEST['tplid']) {
346  ilUtil::sendFailure($this->lng->txt('select_one'), true);
347  $ilCtrl->redirect($this, 'overview');
348  }
349 
350  //$ilTabs->clearTargets();
351  //$ilTabs->setBackTarget(
352  // $this->lng->txt('didactic_back_to_overview'),
353  // $ilCtrl->getLinkTarget($this,'overview')
354  //);
355 
356 
357  $ilCtrl->saveParameter($this, 'tplid');
358 
359  if (!$form instanceof ilPropertyFormGUI) {
360  $form = $this->initEditTemplate($this->object);
361  }
362  $GLOBALS['DIC']['tpl']->setContent($form->getHTML());
363  }
364 
368  protected function updateTemplate()
369  {
370  global $DIC;
371 
372  $ilCtrl = $DIC['ilCtrl'];
373  $ilAccess = $DIC['ilAccess'];
374 
375  $tpl_id = $this->request->getQueryParams()['tplid'] ?? 0;
376  $this->ctrl->saveParameter($this, 'tplid');
377 
378 
379  if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
380  $this->ctrl->redirect($this, "overview");
381  }
382 
383  $temp = new ilDidacticTemplateSetting((int) $tpl_id);
384  $form = $this->initEditTemplate($temp);
385 
386  if ($form->checkInput()) {
387  $tmp_file = $_FILES['icon']['tmp_name'];
388  $upload_element = $form->getItemByPostVar('icon');
389  if (
390  (strlen($tmp_file) || (!strlen($tmp_file) && $temp->getIconIdentifier())) &&
391  !$this->objDefinition->isContainer($form->getInput('type')) &&
392  !$upload_element->getDeletionFlag()
393  ) {
394  $icon = $form->getItemByPostVar('icon')->setAlert($this->lng->txt('didactic_icon_error'));
395  return $this->handleUpdateFailure($form);
396  }
397  //change default entries if translation is active
398  if (count($lang = $temp->getTranslationObject()->getLanguages())) {
399  $temp->getTranslationObject()->setDefaultTitle($form->getInput('title'));
400  $temp->getTranslationObject()->setDefaultDescription($form->getInput('description'));
401  $temp->getTranslationObject()->save();
402  }
403 
404  if (!$temp->isAutoGenerated()) {
405  $temp->setTitle($form->getInput('title'));
406  $temp->setDescription($form->getInput('description'));
407  }
408 
409  $temp->setInfo($form->getInput('info'));
410  $temp->enable($form->getInput('enable'));
411 
412  if (!$temp->isAutoGenerated()) {
413  $temp->setAssignments(array($form->getInput('type')));
414  }
415 
416  if ($form->getInput('local_template') && count($form->getInput('effective_from')) > 0) {
417  $temp->setEffectiveFrom($form->getInput('effective_from'));
418  } else {
419  $temp->setEffectiveFrom(array());
420  }
421 
422  $temp->setExclusive((bool) $form->getInput('exclusive_template'));
423 
424  $temp->update();
425 
426  $upload = $form->getItemByPostVar('icon');
427  if ($upload->getDeletionFlag()) {
428  $temp->getIconHandler()->delete();
429  }
430  $temp->getIconHandler()->handleUpload($DIC->upload(), $_FILES['icon']['tmp_name']);
431  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
432  $ilCtrl->redirect($this, 'overview');
433  }
434  $this->handleUpdateFailure($form);
435  }
436 
437  protected function handleUpdateFailure(ilPropertyFormGUI $form)
438  {
439  ilUtil::sendFailure($this->lng->txt('err_check_input'));
440  $form->setValuesByPost();
441  $this->editTemplate($form);
442  }
443 
451  {
452  global $DIC;
453 
454  $ilCtrl = $DIC['ilCtrl'];
455  $objDefinition = $DIC['objDefinition'];
456 
457  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
458  $form = new ilPropertyFormGUI();
459  $form->setShowTopButtons(false);
460  $form->setFormAction($ilCtrl->getFormAction($this, 'updateTemplate'));
461  $form->setTitle($this->lng->txt('didactic_edit_tpl'));
462  $form->addCommandButton('updateTemplate', $this->lng->txt('save'));
463  $form->addCommandButton('overview', $this->lng->txt('cancel'));
464 
465  // title
466  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
467  $title->setSize(40);
468  $title->setMaxLength(64);
469  $title->setRequired(true);
470  //use presentation title if autogenerated is set
471  $title->setDisabled($set->isAutoGenerated());
472 
473  if (!$set->isAutoGenerated()) {
474  $trans = $set->getTranslations();
475  $def = $trans[0]; // default
476 
477  if (sizeof($trans) > 1) {
478  include_once('Services/MetaData/classes/class.ilMDLanguageItem.php');
479  $languages = ilMDLanguageItem::_getLanguages();
480  $title->setInfo($this->lng->txt("language") . ": " . $languages[$def["lang_code"]] .
481  ' <a href="' . $ilCtrl->getLinkTargetByClass("ilmultilingualismgui", "listTranslations") .
482  '">&raquo; ' . $this->lng->txt("more_translations") . '</a>');
483  }
484  }
485 
486  if ($set->isAutoGenerated()) {
487  $title->setValue($set->getPresentationTitle());
488  } else {
489  $title->setValue($def["title"]);
490  }
491 
492  $form->addItem($title);
493 
494  // desc
495  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
496  //use presentation title if autogenerated is set
497  if ($set->isAutoGenerated()) {
498  $desc->setValue($set->getPresentationDescription());
499  } else {
500  $desc->setValue($def["description"]);
501  }
502  $desc->setRows(3);
503  $desc->setDisabled($set->isAutoGenerated());
504  $form->addItem($desc);
505 
506 
507  $icon = new ilImageFileInputGUI($this->lng->txt('didactic_icon'), 'icon');
508  $icon->setImage($set->getIconHandler()->getAbsolutePath());
509  $icon->setInfo($this->lng->txt('didactic_icon_info'));
510  $icon->getAllowDeletion(true);
511  $icon->setSuffixes(['svg']);
512  $form->addItem($icon);
513 
514  // info
515  $info = new ilTextAreaInputGUI($this->lng->txt('didactic_install_info'), 'info');
516  $info->setValue($set->getInfo());
517  $info->setRows(6);
518  $form->addItem($info);
519 
520  //activate
521  $enable = new ilCheckboxInputGUI($this->lng->txt('active'), 'enable');
522  $enable->setChecked($set->isEnabled());
523  $enable->setRequired(true);
524  $form->addItem($enable);
525 
526  // object type
527  if (!$set->isAutoGenerated()) {
528  $type = new ilSelectInputGUI($this->lng->txt('obj_type'), 'type');
529  $type->setRequired(true);
530  $type->setInfo($this->lng->txt('dtpl_obj_type_info'));
531  $assigned = $set->getAssignments();
532  $type->setValue(isset($assigned[0]) ? $assigned[0] : '');
533  $subs = $objDefinition->getSubObjectsRecursively('root', false);
534  $options = array();
535  foreach (array_merge($subs, array('fold' => 1)) as $obj => $null) {
536  ilLoggerFactory::getLogger('root')->dump($null);
537  if ($objDefinition->isPlugin($obj)) {
538  $options[$obj] = ilObjectPlugin::lookupTxtById($obj, "obj_" . $obj);
539  } elseif ($objDefinition->isAllowedInRepository($obj)) {
540  $options[$obj] = $this->lng->txt('obj_' . $obj);
541  }
542  }
543  asort($options);
544 
545  $type->setOptions($options);
546  $form->addItem($type);
547 
548  $lokal_templates = new ilCheckboxInputGUI($this->lng->txt("activate_local_didactic_template"), "local_template");
549  $lokal_templates->setChecked(count($set->getEffectiveFrom()) > 0);
550  $lokal_templates->setInfo($this->lng->txt("activate_local_didactic_template_info"));
551 
552  //effective from (multinode)
553  include_once("./Services/Form/classes/class.ilRepositorySelector2InputGUI.php");
554  $effrom = new ilRepositorySelector2InputGUI($this->lng->txt("effective_form"), "effective_from", true);
555  //$effrom->setMulti(true);
556  $definition = $GLOBALS['DIC']['objDefinition'];
557  $white_list = [];
558  foreach ($definition->getAllRepositoryTypes() as $type) {
559  if ($definition->isContainer($type)) {
560  $white_list[] = $type;
561  }
562  }
563  $effrom->getExplorerGUI()->setTypeWhiteList($white_list);
564  $effrom->setValue($set->getEffectiveFrom());
565 
566  $lokal_templates->addSubItem($effrom);
567  $form->addItem($lokal_templates);
568 
569  $excl = new ilCheckboxInputGUI($this->lng->txt("activate_exclusive_template"), "exclusive_template");
570  $excl->setInfo($this->lng->txt("activate_exclusive_template_info"));
571  $excl->setChecked($set->isExclusive());
572 
573  $form->addItem($excl);
574  }
575 
576 
577 
578  return $form;
579  }
580 
584  protected function copyTemplate()
585  {
586  global $DIC;
587 
588  $ilErr = $DIC['ilErr'];
589  $ilCtrl = $DIC['ilCtrl'];
590  $ilAccess = $DIC['ilAccess'];
591 
592  if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
593  $this->ctrl->redirect($this, "overview");
594  }
595 
596  if (!$_REQUEST['tplid']) {
597  ilUtil::sendFailure($this->lng->txt('select_one'));
598  return $ilCtrl->redirect($this, 'overview');
599  }
600 
601  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateCopier.php';
602 
603  $copier = new ilDidacticTemplateCopier((int) $_REQUEST['tplid']);
604  $copier->start();
605 
606  ilUtil::sendSuccess($this->lng->txt('didactic_copy_suc_message'), true);
607  $ilCtrl->redirect($this, 'overview');
608  }
609 
613  protected function exportTemplate()
614  {
615  global $DIC;
616 
617  $ilErr = $DIC['ilErr'];
618  $ilCtrl = $DIC['ilCtrl'];
619 
620  if (!$_REQUEST['tplid']) {
621  ilUtil::sendFailure($this->lng->txt('select_one'));
622  return $ilCtrl->redirect($this, 'overview');
623  }
624 
625  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateXmlWriter.php';
626  $writer = new ilDidacticTemplateXmlWriter((int) $_REQUEST['tplid']);
627  $writer->write();
628 
630  $writer->xmlDumpMem(true),
631  $writer->getSetting()->getTitle() . '.xml',
632  'application/xml'
633  );
634  }
635 
641  protected function confirmDelete()
642  {
646  global $DIC;
647 
648  $ilErr = $DIC['ilErr'];
649  $ilCtrl = $DIC['ilCtrl'];
650 
651  if (!$_REQUEST['tpls']) {
652  ilUtil::sendFailure($this->lng->txt('select_one'));
653  return $ilCtrl->redirect($this, 'overview');
654  }
655 
656  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
657 
658  $confirm = new ilConfirmationGUI();
659  $confirm->setFormAction($ilCtrl->getFormAction($this));
660  $confirm->setConfirm($this->lng->txt('delete'), 'deleteTemplates');
661  $confirm->setCancel($this->lng->txt('cancel'), 'overview');
662 
663  $forbidden = array();
664 
665  foreach ((array) $_REQUEST['tpls'] as $tplid) {
666  $tpl = new ilDidacticTemplateSetting($tplid);
667 
668  if (!$tpl->isAutoGenerated()) {
669  $confirm->addItem('tpls[]', $tpl->getId(), $tpl->getPresentationTitle());
670  } else {
671  $forbidden[] = $tpl->getId();
672  }
673  }
674 
675  if (count($forbidden) > 0 && count($_REQUEST['tpls']) == 1) {
676  ilUtil::sendFailure($this->lng->txt('didactic_cannot_delete_auto_generated'), true);
677  $ilCtrl->redirect($this, "overview");
678  } elseif (count($forbidden) > 0 && count($_REQUEST['tpls']) > 1) {
679  ilUtil::sendInfo($this->lng->txt('didactic_cannot_delete_auto_generated_confirmation'));
680  }
681 
682  ilUtil::sendQuestion($this->lng->txt('didactic_confirm_delete_msg'));
683  $GLOBALS['DIC']['tpl']->setContent($confirm->getHTML());
684  }
685 
692  protected function deleteTemplates()
693  {
694  global $DIC;
695 
696  $ilErr = $DIC['ilErr'];
697  $ilCtrl = $DIC['ilCtrl'];
698  $ilAccess = $DIC['ilAccess'];
699 
700  if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
701  $this->ctrl->redirect($this, "overview");
702  }
703 
704  if (!$_REQUEST['tpls']) {
705  ilUtil::sendFailure($this->lng->txt('select_one'));
706  return $ilCtrl->redirect($this, 'overview');
707  }
708 
709  foreach ((array) $_REQUEST['tpls'] as $tplid) {
710  $tpl = new ilDidacticTemplateSetting($tplid);
711  $tpl->delete();
712  }
713 
714  ilUtil::sendSuccess($this->lng->txt('didactic_delete_msg'), true);
715  $ilCtrl->redirect($this, 'overview');
716  }
717 
724  protected function activateTemplates()
725  {
726  global $DIC;
727 
728  $ilErr = $DIC['ilErr'];
729  $ilCtrl = $DIC['ilCtrl'];
730  $ilAccess = $DIC['ilAccess'];
731 
732  if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
733  $this->ctrl->redirect($this, "overview");
734  }
735  if (!$_REQUEST['tpls']) {
736  ilUtil::sendFailure($this->lng->txt('select_one'));
737  return $ilCtrl->redirect($this, 'overview');
738  }
739 
740  foreach ($_REQUEST['tpls'] as $tplid) {
741  $tpl = new ilDidacticTemplateSetting($tplid);
742  $tpl->enable(true);
743  $tpl->update();
744  }
745 
746  ilUtil::sendSuccess($this->lng->txt('didactic_activated_msg'), true);
747  $ilCtrl->redirect($this, 'overview');
748  }
749 
756  protected function deactivateTemplates()
757  {
758  global $DIC;
759 
760  $ilErr = $DIC['ilErr'];
761  $ilCtrl = $DIC['ilCtrl'];
762  $ilAccess = $DIC['ilAccess'];
763 
764  if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
765  $this->ctrl->redirect($this, "overview");
766  }
767 
768  if (!$_REQUEST['tpls']) {
769  ilUtil::sendFailure($this->lng->txt('select_one'));
770  $ilCtrl->redirect($this, 'overview');
771  }
772 
773  foreach ($_REQUEST['tpls'] as $tplid) {
774  $tpl = new ilDidacticTemplateSetting($tplid);
775  $tpl->enable(false);
776  $tpl->update();
777  }
778 
779  ilUtil::sendSuccess($this->lng->txt('didactic_deactivated_msg'), true);
780  $ilCtrl->redirect($this, 'overview');
781  }
782 
786  protected function setEditTabs($a_tab_active = "edit")
787  {
792  global $DIC;
793 
794  $ilCtrl = $DIC['ilCtrl'];
795  $ilTabs = $DIC['ilTabs'];
796 
797 
798  $ilTabs->clearTargets();
799  $ilTabs->setBackTarget(
800  $this->lng->txt('didactic_back_to_overview'),
801  $ilCtrl->getLinkTarget($this, 'overview')
802  );
803  $ilCtrl->saveParameter($this, "tplid");
804 
805  if (!$this->object->isAutoGenerated()) {
806  $ilTabs->addTab('edit', $this->lng->txt('settings'), $ilCtrl->getLinkTarget($this, 'editTemplate'));
807  $ilTabs->addTab('import', $this->lng->txt('import'), $ilCtrl->getLinkTarget($this, 'showEditImportForm'));
808 
809  if (in_array($a_tab_active, array('edit', 'settings_trans'))) {
810  $ilTabs->addSubTab('edit', $this->lng->txt('settings'), $ilCtrl->getLinkTarget($this, 'editTemplate'));
811  $ilTabs->addSubTab('settings_trans', $this->lng->txt("obj_multilinguality"), $ilCtrl->getLinkTargetByClass(array( "ilmultilingualismgui"), 'listTranslations'));
812  $ilTabs->setTabActive('edit');
813  $ilTabs->setSubTabActive($a_tab_active);
814  } else {
815  $ilTabs->setTabActive($a_tab_active);
816  }
817  }
818  }
819 
820  public function showEditImportForm(ilPropertyFormGUI $form = null)
821  {
822  $this->setEditTabs("import");
823  if (!$form instanceof ilPropertyFormGUI) {
824  $form = $this->editImportForm();
825  }
826  $GLOBALS['DIC']['tpl']->setContent($form->getHTML());
827  }
828 
829  public function editImportForm()
830  {
831  global $DIC;
832 
833  $ilCtrl = $DIC['ilCtrl'];
834 
835  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
836  $form = new ilPropertyFormGUI();
837  $form->setShowTopButtons(false);
838  $form->setFormAction($ilCtrl->getFormAction($this));
839  $form->setTitle($this->lng->txt('didactic_import_table_title'));
840  $form->addCommandButton('importTemplate', $this->lng->txt('import'));
841  $form->addCommandButton('overview', $this->lng->txt('cancel'));
842 
843  $file = new ilFileInputGUI($this->lng->txt('didactic_template_update_import'), 'file');
844  $file->setRequired(true);
845  $file->setSuffixes(['xml']);
846  $file->setInfo($this->lng->txt('didactic_template_update_import_info'));
847  $form->addItem($file);
848 
849  return $form;
850  }
851 
856  public function editImport($a_settings)
857  {
858  global $DIC;
859 
860  $ilCtrl = $DIC['ilCtrl'];
861  $tplid = $_REQUEST['tplid'];
862 
863  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
864  ilDidacticTemplateObjSettings::transferAutoGenerateStatus($tplid, $a_settings->getId());
865 
867 
868  $this->object->delete();
869 
870  foreach ($assignments as $obj) {
871  ilDidacticTemplateObjSettings::assignTemplate($obj["ref_id"], $obj["obj_id"], $a_settings->getId());
872  }
873 
874  $ilCtrl->setParameter($this, "tplid", $a_settings->getId());
875  }
876 }
GUI class for object translation handling.
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
isEnabled()
Check if template is enabled.
Description of ilDidacticTemplateSettingsTableGUI.
static lookupTxtById($plugin_id, $lang_var)
deleteTemplates()
Delete chosen didactic templates ilErrorHandling $ilErr ilCtrl $ilCtrl.
deactivateTemplates()
Activate didactic templates ilErrorHandling $ilErr ilCtrl $ilCtrl.
This class represents a property form user interface.
$type
This class represents a file property in a property form.
static transferAutoGenerateStatus($a_src, $a_dest)
transfer auto generated flag if source is auto generated
static getAssignmentsByTemplateID($a_tpl_id)
Lookup template id ilDB $ilDB.
setValue($a_value)
Set Value.
initEditTemplate(ilDidacticTemplateSetting $set)
Init edit template form.
This class represents a checkbox property in a property form.
showImportForm(ilPropertyFormGUI $form=null)
Show template import form.
$ilErr
Definition: raiseError.php:18
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setChecked($a_checked)
Set Checked.
static assignTemplate($a_ref_id, $a_obj_id, $a_tpl_id)
Assign template to object ilDB $ilDB.
editTemplate(ilPropertyFormGUI $form=null)
Edit template.
setImage($a_image)
Set Image.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
global $DIC
Definition: goto.php:24
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Description of ilDidacticTemplateImportException.
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
Description of ilDidacticTemplateImport.
setValuesByPost()
Set form values from POST values.
Copy a didactic template and all subitems.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$lang
Definition: xapiexit.php:8
static ilTempnam($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.
This class represents a text area property in a property form.
getInfo()
Get installation info text.
Settings for a single didactic template.
static getLogger($a_component_id)
Get component logger.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
getTranslations()
get all translations from this object
setSuffixes($a_suffixes)
Set Accepted Suffixes.
activateTemplates()
Activate didactic templates ilErrorHandling $ilErr ilCtrl $ilCtrl.
setRequired($a_required)
Set Required.
Confirmation screen class.
overview()
Show didactic template administration.