ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilDidacticTemplateSettingsGUI Class Reference

Settings for a single didactic template. More...

+ Collaboration diagram for ilDidacticTemplateSettingsGUI:

Public Member Functions

 __construct (ilObjectGUI $a_parent_obj)
 
 executeCommand ()
 
 applyFilter ()
 
 resetFilter ()
 
 showEditImportForm (ilPropertyFormGUI $form=null)
 
 editImportForm ()
 
 editImport (ilDidacticTemplateSetting $a_settings)
 

Protected Member Functions

 initReferenceFromRequest ()
 
 initTemplatesFromRequest ()
 transforms selected tpls from post to SplFixedArray More...
 
 initTemplateFromRequest ()
 
 handleTableActions ()
 
 overview ()
 
 showImportForm (ilPropertyFormGUI $form=null)
 
 createImportForm ()
 
 checkInput (ilPropertyFormGUI $form, ilDidacticTemplateImport $import)
 
 importTemplate ()
 
 editTemplate (?int $template_id=null, ilPropertyFormGUI $form=null)
 
 updateTemplate ()
 
 handleUpdateFailure (ilPropertyFormGUI $form)
 
 initEditTemplate (ilDidacticTemplateSetting $set)
 
 copyTemplate (int $template_id)
 
 exportTemplate (int $template_id)
 
 confirmDelete (array $template_ids)
 
 deleteTemplates ()
 
 activateTemplates (array $template_ids)
 
 deactivateTemplates (array $template_ids)
 
 setEditTabs (string $a_tab_active="edit")
 

Protected Attributes

UIRenderer $renderer
 
UIFactory $ui_factory
 

Private Attributes

ilLogger $logger
 
ilDidacticTemplateSetting $setting = null
 
Container $dic
 
ilLanguage $lng
 
ilRbacSystem $rbacsystem
 
ilCtrl $ctrl
 
ilAccessHandler $access
 
ilToolbarGUI $toolbar
 
ilObjectDefinition $objDefinition
 
GlobalHttpState $http
 
Factory $refinery
 
ilGlobalTemplateInterface $tpl
 
ilTabsGUI $tabs
 
FileUpload $upload
 
int $ref_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateSettingsGUI::__construct ( ilObjectGUI  $a_parent_obj)

Definition at line 61 of file class.ilDidacticTemplateSettingsGUI.php.

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), ILIAS\Repository\refinery(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\upload().

62  {
63  global $DIC;
64  $this->lng = $DIC->language();
65  $this->rbacsystem = $DIC->rbac()->system();
66  $this->ctrl = $DIC->ctrl();
67  $this->objDefinition = $DIC['objDefinition'];
68  $this->access = $DIC->access();
69  $this->toolbar = $DIC->toolbar();
70  $this->http = $DIC->http();
71  $this->refinery = $DIC->refinery();
72  $this->logger = $DIC->logger()->otpl();
73  $this->tpl = $DIC->ui()->mainTemplate();
74  $this->tabs = $DIC->tabs();
75  $this->upload = $DIC->upload();
76  $this->renderer = $DIC->ui()->renderer();
77  $this->ui_factory = $DIC->ui()->factory();
78  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

Member Function Documentation

◆ activateTemplates()

ilDidacticTemplateSettingsGUI::activateTemplates ( array  $template_ids)
protected
Parameters
string[]$template_ids

Definition at line 672 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilGlobalTemplateInterface\setOnScreenMessage().

Referenced by handleTableActions().

672  : void
673  {
674  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
675  $this->ctrl->redirect($this, "overview");
676  }
677  if (0 === count($template_ids)) {
678  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
679  $this->ctrl->redirect($this, 'overview');
680  return;
681  }
682  foreach ($template_ids as $tplid) {
683  $tpl = new ilDidacticTemplateSetting((int) $tplid);
684  $tpl->enable(true);
685  $tpl->update();
686  }
687  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_activated_msg'), true);
688  $this->ctrl->redirect($this, 'overview');
689  }
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyFilter()

ilDidacticTemplateSettingsGUI::applyFilter ( )

Definition at line 225 of file class.ilDidacticTemplateSettingsGUI.php.

References overview().

225  : void
226  {
227  $this->overview();
228  }
+ Here is the call graph for this function:

◆ checkInput()

ilDidacticTemplateSettingsGUI::checkInput ( ilPropertyFormGUI  $form,
ilDidacticTemplateImport  $import 
)
protected

Definition at line 279 of file class.ilDidacticTemplateSettingsGUI.php.

References ilPropertyFormGUI\checkInput(), ILIAS\Export\ImportStatus\FAILED, ilPropertyFormGUI\getInput(), ilFileUtils\ilTempnam(), ilFileUtils\moveUploadedFile(), ilDidacticTemplateImport\setInputFile(), ilPropertyFormGUI\setValuesByPost(), and ilDidacticTemplateImport\validateImportFile().

Referenced by importTemplate().

282  : ilImportStatusCollection {
283  $status = new ilImportStatusFactory();
284 
285  if (!$form->checkInput()) {
286  $form->setValuesByPost();
287  return $status->collection();
288  }
289 
290  $file = $form->getInput('file');
291  $tmp = ilFileUtils::ilTempnam() . '.xml';
292 
293  // move uploaded file
295  $file['tmp_name'],
296  $file['name'],
297  $tmp
298  );
299  $import->setInputFile($tmp);
300  $statuses = $import->validateImportFile();
301 
302  if (!$statuses->hasStatusType(ImportStatusType::FAILED)) {
303  $statuses = $statuses->withAddedStatus($status->handler()
304  ->withType(ImportStatusType::SUCCESS)
305  ->withContent($status->content()->builder()->string()->withString('')));
306  }
307  return $statuses;
308  }
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-...
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 ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDelete()

ilDidacticTemplateSettingsGUI::confirmDelete ( array  $template_ids)
protected
Parameters
string[]$template_ids

Definition at line 615 of file class.ilDidacticTemplateSettingsGUI.php.

References $id, ILIAS\Repository\ctrl(), exit, ilDidacticTemplateSettings\getInstance(), and ILIAS\Repository\lng().

Referenced by handleTableActions().

615  : never
616  {
617  $this->ctrl->setParameterByClass(ilDidacticTemplateSettingsGUI::class, 'tpls', implode(',', $template_ids));
618  $del_action = $this->ctrl->getLinkTarget($this, 'deleteTemplates');
619  $this->ctrl->clearParameterByClass(ilDidacticTemplateSettingsGUI::class, 'tpls');
620  $items = [];
622  $tpls->readInactive();
623  $templates = $tpls->getTemplates();
624  foreach ($templates as $template) {
625  foreach ($template_ids as $id) {
626  if ((int) $id !== $template->getId()) {
627  continue;
628  }
629  $items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
630  $id,
631  $template->getTitle()
632  );
633  }
634  }
635  echo($this->renderer->renderAsync([
636  $this->ui_factory->modal()->interruptive(
637  $this->lng->txt('delete'),
638  $this->lng->txt('modal_confirm_deletion_text'),
639  $del_action
640  )
641  ->withAffectedItems($items)
642  ->withAdditionalOnLoadCode(static fn($id): string => "console.log('ASYNC JS');")
643  ]));
644  exit();
645  }
exit
Definition: login.php:29
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyTemplate()

ilDidacticTemplateSettingsGUI::copyTemplate ( int  $template_id)
protected

Definition at line 588 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilDidacticTemplateSetting\getId(), ILIAS\Repository\lng(), and ilDidacticTemplateCopier\start().

Referenced by handleTableActions().

588  : void
589  {
590  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
591  $this->ctrl->redirect($this, "overview");
592  }
593  $setting = ($this->setting = new ilDidacticTemplateSetting($template_id));
594  $copier = new ilDidacticTemplateCopier($setting->getId());
595  $copier->start();
596  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_copy_suc_message'), true);
597  $this->ctrl->redirect($this, 'overview');
598  }
Copy a didactic template and all subitems.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createImportForm()

ilDidacticTemplateSettingsGUI::createImportForm ( )
protected

Definition at line 254 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\LTI\ToolProvider\$created, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilImageFileInputGUI\setAllowDeletion(), and ilFileInputGUI\setSuffixes().

Referenced by importTemplate(), and showImportForm().

255  {
256  $form = new ilPropertyFormGUI();
257  $form->setShowTopButtons(false);
258  $form->setFormAction($this->ctrl->getFormAction($this));
259  $form->setTitle($this->lng->txt('didactic_import_table_title'));
260  $form->addCommandButton('importTemplate', $this->lng->txt('import'));
261  $form->addCommandButton('overview', $this->lng->txt('cancel'));
262 
263  $file = new ilFileInputGUI($this->lng->txt('import_file'), 'file');
264  $file->setSuffixes(['xml']);
265  $file->setRequired(true);
266  $form->addItem($file);
267 
268  $icon = new ilImageFileInputGUI($this->lng->txt('icon'), 'icon');
269  $icon->setAllowDeletion(false);
270  $icon->setSuffixes(['svg']);
271  $icon->setInfo($this->lng->txt('didactic_icon_info'));
272  $form->addItem($icon);
273 
274  $created = true;
275 
276  return $form;
277  }
This class represents a file property in a property form.
setSuffixes(array $a_suffixes)
This class represents an image file property in a property form.
int $created
Timestamp for when the object was created.
Definition: System.php:151
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deactivateTemplates()

ilDidacticTemplateSettingsGUI::deactivateTemplates ( array  $template_ids)
protected
Parameters
string[]$template_ids

Definition at line 694 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilGlobalTemplateInterface\setOnScreenMessage().

Referenced by handleTableActions().

694  : void
695  {
696  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
697  $this->ctrl->redirect($this, "overview");
698  }
699  if (0 === count($template_ids)) {
700  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
701  $this->ctrl->redirect($this, 'overview');
702  }
703  foreach ($template_ids as $tplid) {
704  $tpl = new ilDidacticTemplateSetting((int) $tplid);
705  $tpl->enable(false);
706  $tpl->update();
707  }
708  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_deactivated_msg'), true);
709  $this->ctrl->redirect($this, 'overview');
710  }
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteTemplates()

ilDidacticTemplateSettingsGUI::deleteTemplates ( )
protected
Parameters
string[]$template_ids

Definition at line 650 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), initTemplatesFromRequest(), ILIAS\Repository\lng(), and ilGlobalTemplateInterface\setOnScreenMessage().

650  : void
651  {
652  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
653  $this->ctrl->redirect($this, "overview");
654  }
655  $template_ids = $this->initTemplatesFromRequest();
656  if (0 === count($template_ids) || $template_ids[0] === '') {
657  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
658  //$this->ctrl->redirect($this, 'overview');
659  return;
660  }
661  foreach ($template_ids as $tplid) {
662  $tpl = new ilDidacticTemplateSetting((int) $tplid);
663  $tpl->delete();
664  }
665  $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_delete_msg'), true);
666  $this->ctrl->redirect($this, 'overview');
667  }
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
initTemplatesFromRequest()
transforms selected tpls from post to SplFixedArray
+ Here is the call graph for this function:

◆ editImport()

ilDidacticTemplateSettingsGUI::editImport ( ilDidacticTemplateSetting  $a_settings)

Definition at line 777 of file class.ilDidacticTemplateSettingsGUI.php.

References ilDidacticTemplateObjSettings\assignTemplate(), ILIAS\Repository\ctrl(), ilDidacticTemplateSetting\delete(), ilDidacticTemplateObjSettings\getAssignmentsByTemplateID(), ilDidacticTemplateSetting\getId(), and ilDidacticTemplateObjSettings\transferAutoGenerateStatus().

Referenced by importTemplate().

777  : void
778  {
781  $a_settings->delete();
782  foreach ($assignments as $obj) {
783  ilDidacticTemplateObjSettings::assignTemplate($obj["ref_id"], $obj["obj_id"], $a_settings->getId());
784  }
785  $this->ctrl->setParameter($this, "tplid", $a_settings->getId());
786  }
static assignTemplate(int $a_ref_id, int $a_obj_id, int $a_tpl_id)
static transferAutoGenerateStatus(int $a_src, int $a_dest)
Transfer auto generated flag if source is auto generated.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editImportForm()

ilDidacticTemplateSettingsGUI::editImportForm ( )

Definition at line 759 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setRequired().

Referenced by importTemplate(), and showEditImportForm().

760  {
761  $form = new ilPropertyFormGUI();
762  $form->setShowTopButtons(false);
763  $form->setFormAction($this->ctrl->getFormAction($this));
764  $form->setTitle($this->lng->txt('didactic_import_table_title'));
765  $form->addCommandButton('importTemplate', $this->lng->txt('import'));
766  $form->addCommandButton('overview', $this->lng->txt('cancel'));
767 
768  $file = new ilFileInputGUI($this->lng->txt('didactic_template_update_import'), 'file');
769  $file->setRequired(true);
770  $file->setSuffixes(['xml']);
771  $file->setInfo($this->lng->txt('didactic_template_update_import_info'));
772  $form->addItem($file);
773 
774  return $form;
775  }
This class represents a file property in a property form.
setRequired(bool $a_required)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editTemplate()

ilDidacticTemplateSettingsGUI::editTemplate ( ?int  $template_id = null,
ilPropertyFormGUI  $form = null 
)
protected

Definition at line 374 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\Repository\ctrl(), initEditTemplate(), initTemplateFromRequest(), ILIAS\Repository\lng(), and setEditTabs().

Referenced by handleTableActions(), and handleUpdateFailure().

374  : void
375  {
376  $setting = null;
377  if (is_null($template_id)) {
379  } else {
380  $setting = ($this->setting = new ilDidacticTemplateSetting($template_id));
381  $this->ctrl->setParameter($this, 'tplid', $template_id);
382  }
383  if (!$setting instanceof ilDidacticTemplateSetting) {
384  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
385  $this->ctrl->redirect($this, 'overview');
386  }
387  $this->setEditTabs("edit");
388  $this->ctrl->saveParameter($this, 'tplid');
389  if (!$form instanceof ilPropertyFormGUI) {
390  $form = $this->initEditTemplate($this->setting);
391  }
392  $this->tpl->setContent($form->getHTML());
393  }
initEditTemplate(ilDidacticTemplateSetting $set)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilDidacticTemplateSettingsGUI::executeCommand ( )

PhpMissingBreakStatementInspection

Definition at line 117 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), initEditTemplate(), initReferenceFromRequest(), initTemplateFromRequest(), ilDidacticTemplateSetting\isAutoGenerated(), setEditTabs(), and ilMultilingualismGUI\setStartValues().

117  : string
118  {
119  $this->initReferenceFromRequest();
120 
121  $next_class = $this->ctrl->getNextClass($this);
122  $cmd = $this->ctrl->getCmd();
123 
124  switch ($next_class) {
126  case "ilpropertyformgui":
128  if (!$setting instanceof ilDidacticTemplateSetting) {
129  $setting = new ilDidacticTemplateSetting();
130  }
131  $form = $this->initEditTemplate($setting);
132  $this->ctrl->forwardCommand($form);
133  // no break
134  case 'ilmultilingualismgui':
136  if (
137  !$this->access->checkAccess('write', '', $this->ref_id) ||
138  !$setting instanceof ilDidacticTemplateSetting ||
140  $this->ctrl->redirect($this, "overview");
141  }
142  $this->setEditTabs("settings_trans");
143  $transgui = new ilMultilingualismGUI($this->setting->getId(), 'dtpl');
144  $defaultl = $this->setting->getTranslationObject()->getDefaultLanguage();
145  $transgui->setStartValues(
146  $this->setting->getPresentationTitle($defaultl),
147  $this->setting->getPresentationDescription($defaultl)
148  );
149  $this->ctrl->forwardCommand($transgui);
150  break;
151  default:
152  if (!$cmd) {
153  $cmd = 'overview';
154  }
155  $this->$cmd();
156  break;
157  }
158  return '';
159  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initEditTemplate(ilDidacticTemplateSetting $set)
setStartValues(string $a_title, string $a_description)
+ Here is the call graph for this function:

◆ exportTemplate()

ilDidacticTemplateSettingsGUI::exportTemplate ( int  $template_id)
protected

Definition at line 600 of file class.ilDidacticTemplateSettingsGUI.php.

References ilUtil\deliverData(), ilDidacticTemplateSetting\getId(), and ilDidacticTemplateXmlWriter\write().

Referenced by handleTableActions().

600  : void
601  {
602  $setting = ($this->setting = new ilDidacticTemplateSetting($template_id));
603  $writer = new ilDidacticTemplateXmlWriter($setting->getId());
604  $writer->write();
606  $writer->xmlDumpMem(true),
607  $writer->getSetting()->getTitle() . '.xml',
608  'application/xml'
609  );
610  }
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleTableActions()

ilDidacticTemplateSettingsGUI::handleTableActions ( )
protected

Definition at line 161 of file class.ilDidacticTemplateSettingsGUI.php.

References activateTemplates(), confirmDelete(), copyTemplate(), deactivateTemplates(), editTemplate(), exportTemplate(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

161  : void
162  {
163  $query = $this->http->wrapper()->query();
164  if (!$query->has('didactic_template_table_action')) {
165  return;
166  }
167  $action = $query->retrieve('didactic_template_table_action', $this->refinery->to()->string());
168 
169  $ids = $this->http->wrapper()->query()->retrieve(
170  'didactic_template_template_ids',
171  $this->refinery->custom()->transformation(function ($q_ids) {
172  if (is_array($q_ids)) {
173  return $q_ids;
174  }
175  return strlen($q_ids) > 0 ? explode(',', $q_ids) : [];
176  })
177  );
178 
179  switch ($action) {
180  case 'editTemplate':
181  $this->editTemplate((int) $ids[0]);
182  break;
183  case 'exportTemplate':
184  $this->exportTemplate((int) $ids[0]);
185  break;
186  case 'copyTemplate':
187  $this->copyTemplate((int) $ids[0]);
188  break;
189  case 'activateTemplates':
190  $this->activateTemplates($ids);
191  break;
192  case 'deactivateTemplates':
193  $this->deactivateTemplates($ids);
194  break;
195  case 'confirmDelete':
196  $this->confirmDelete($ids);
197  break;
198  }
199  }
static http()
Fetches the global http state from ILIAS.
editTemplate(?int $template_id=null, ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:

◆ handleUpdateFailure()

ilDidacticTemplateSettingsGUI::handleUpdateFailure ( ilPropertyFormGUI  $form)
protected

Definition at line 458 of file class.ilDidacticTemplateSettingsGUI.php.

References editTemplate(), ILIAS\Repository\lng(), and ilPropertyFormGUI\setValuesByPost().

Referenced by updateTemplate().

458  : void
459  {
460  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
461  $form->setValuesByPost();
462  $this->editTemplate(null, $form);
463  }
editTemplate(?int $template_id=null, ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importTemplate()

ilDidacticTemplateSettingsGUI::importTemplate ( )
protected

Definition at line 310 of file class.ilDidacticTemplateSettingsGUI.php.

References Vendor\Package\$e, ILIAS\LTI\ToolProvider\$settings, ILIAS\Repository\access(), checkInput(), createImportForm(), ILIAS\Repository\ctrl(), editImport(), editImportForm(), ILIAS\Export\ImportStatus\FAILED, ilDidacticTemplateImport\IMPORT_FILE, initTemplateFromRequest(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), showEditImportForm(), showImportForm(), and ILIAS\Repository\upload().

310  : void
311  {
312  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
313  $this->ctrl->redirect($this, "overview");
314  }
315 
317  if ($setting instanceof ilDidacticTemplateSetting) {
318  $form = $this->editImportForm();
319  } else {
320  $form = $this->createImportForm();
321  }
322 
324  $statuses = $this->checkInput($form, $import);
325 
326  if (!$statuses->hasStatusType(ImportStatusType::SUCCESS)) {
327  $error_msg = ($statuses->getCollectionOfAllByType(ImportStatusType::FAILED)->count() > 0)
328  ? $statuses
329  ->withNumberingEnabled(true)
330  ->toString(ImportStatusType::FAILED)
331  : '';
332  $this->tpl->setOnScreenMessage(
333  'failure',
334  $this->lng->txt('didactic_import_failed') . $error_msg
335  );
336  if ($setting instanceof ilDidacticTemplateSetting) {
337  $this->showEditImportForm($form);
338  } else {
339  $this->showImportForm($form);
340  }
341  return;
342  }
343 
344  try {
345  $settings = $import->import();
346  if ($setting instanceof ilDidacticTemplateSetting) {
347  $this->editImport($settings);
348  } elseif ($settings->hasIconSupport($this->objDefinition)) {
349  $settings->getIconHandler()->handleUpload($this->upload, $_FILES['icon']['tmp_name']);
350  }
352  $this->logger->error('Import failed with message: ' . $e->getMessage());
353  $this->tpl->setOnScreenMessage(
354  'failure',
355  $this->lng->txt('didactic_import_failed') . ': ' . $e->getMessage(),
356  true
357  );
358  $this->ctrl->redirect($this, 'importTemplate');
359  }
360 
361  $this->tpl->setOnScreenMessage(
362  'success',
363  $this->lng->txt('didactic_import_success'),
364  true
365  );
366 
367  if ($setting instanceof ilDidacticTemplateSetting) {
368  $this->ctrl->redirect($this, 'editTemplate');
369  } else {
370  $this->ctrl->redirect($this, 'overview');
371  }
372  }
editImport(ilDidacticTemplateSetting $a_settings)
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
checkInput(ilPropertyFormGUI $form, ilDidacticTemplateImport $import)
Description of ilDidacticTemplateImportException.
Description of ilDidacticTemplateImport.
+ Here is the call graph for this function:

◆ initEditTemplate()

ilDidacticTemplateSettingsGUI::initEditTemplate ( ilDidacticTemplateSetting  $set)
protected

Definition at line 465 of file class.ilDidacticTemplateSettingsGUI.php.

References ilMDLanguageItem\_getLanguages(), ILIAS\Repository\ctrl(), ilDidacticTemplateSetting\getAssignments(), ilDidacticTemplateSetting\getEffectiveFrom(), ilRepositorySelector2InputGUI\getExplorerGUI(), ilDidacticTemplateSetting\getIconHandler(), ilDidacticTemplateSetting\getInfo(), ilLoggerFactory\getLogger(), ilDidacticTemplateSetting\getPresentationDescription(), ilDidacticTemplateSetting\getPresentationTitle(), ilDidacticTemplateSetting\getTranslations(), ilDidacticTemplateSetting\isAutoGenerated(), ilDidacticTemplateSetting\isEnabled(), ilDidacticTemplateSetting\isExclusive(), ILIAS\Repository\lng(), ilObjectPlugin\lookupTxtById(), ilImageFileInputGUI\setImage(), ilFormPropertyGUI\setRequired(), and ilTextAreaInputGUI\setValue().

Referenced by editTemplate(), executeCommand(), and updateTemplate().

466  {
467  $form = new ilPropertyFormGUI();
468  $form->setShowTopButtons(false);
469  $form->setFormAction($this->ctrl->getFormAction($this, 'updateTemplate'));
470  $form->setTitle($this->lng->txt('didactic_edit_tpl'));
471  $form->addCommandButton('updateTemplate', $this->lng->txt('save'));
472  $form->addCommandButton('overview', $this->lng->txt('cancel'));
473 
474  // title
475  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
476  $title->setSize(40);
477  $title->setMaxLength(64);
478  $title->setRequired(true);
479  //use presentation title if autogenerated is set
480  $title->setDisabled($set->isAutoGenerated());
481 
482  $def = [];
483  if (!$set->isAutoGenerated()) {
484  $trans = $set->getTranslations();
485  $def = $trans[0]; // default
486 
487  if (count($trans) > 1) {
488  $languages = ilMDLanguageItem::_getLanguages();
489  $title->setInfo($this->lng->txt("language") . ": " . $languages[$def["lang_code"]] .
490  ' <a href="' . $this->ctrl->getLinkTargetByClass("ilmultilingualismgui", "listTranslations") .
491  '">&raquo; ' . $this->lng->txt("more_translations") . '</a>');
492  }
493  }
494 
495  if ($set->isAutoGenerated()) {
496  $title->setValue($set->getPresentationTitle());
497  } elseif (isset($def['title'])) {
498  $title->setValue($def["title"]);
499  }
500 
501  $form->addItem($title);
502 
503  // desc
504  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
505  //use presentation title if autogenerated is set
506  if ($set->isAutoGenerated()) {
507  $desc->setValue($set->getPresentationDescription());
508  } elseif (isset($def['description'])) {
509  $desc->setValue($def["description"]);
510  }
511  $desc->setRows(3);
512  $desc->setDisabled($set->isAutoGenerated());
513  $form->addItem($desc);
514 
515  $icon = new ilImageFileInputGUI($this->lng->txt('didactic_icon'), 'icon');
516  $icon->setImage($set->getIconHandler()->getAbsolutePath());
517  $icon->setInfo($this->lng->txt('didactic_icon_info'));
518  $icon->setAllowDeletion(true);
519  $icon->setSuffixes(['svg']);
520  $form->addItem($icon);
521 
522  // info
523  $info = new ilTextAreaInputGUI($this->lng->txt('didactic_install_info'), 'info');
524  $info->setValue($set->getInfo());
525  $info->setRows(6);
526  $form->addItem($info);
527 
528  //activate
529  $enable = new ilCheckboxInputGUI($this->lng->txt('active'), 'enable');
530  $enable->setChecked($set->isEnabled());
531  $form->addItem($enable);
532 
533  // object type
534  if (!$set->isAutoGenerated()) {
535  $type = new ilSelectInputGUI($this->lng->txt('obj_type'), 'type');
536  $type->setRequired(true);
537  $type->setInfo($this->lng->txt('dtpl_obj_type_info'));
538  $assigned = $set->getAssignments();
539  $type->setValue($assigned[0] ?? '');
540  $subs = $this->objDefinition->getSubObjectsRecursively('root', false);
541  $options = [];
542  foreach (array_merge($subs, ['fold' => 1]) as $obj => $null) {
543  ilLoggerFactory::getLogger('root')->dump($null);
544  if ($this->objDefinition->isPlugin($obj)) {
545  $options[$obj] = ilObjectPlugin::lookupTxtById($obj, "obj_" . $obj);
546  } elseif ($this->objDefinition->isAllowedInRepository($obj)) {
547  $options[$obj] = $this->lng->txt('obj_' . $obj);
548  }
549  }
550  asort($options);
551 
552  $type->setOptions($options);
553  $form->addItem($type);
554 
555  $lokal_templates = new ilCheckboxInputGUI(
556  $this->lng->txt("activate_local_didactic_template"),
557  "local_template"
558  );
559  $lokal_templates->setChecked(count($set->getEffectiveFrom()) > 0);
560  $lokal_templates->setInfo($this->lng->txt("activate_local_didactic_template_info"));
561 
562  //effective from (multinode)
563 
564  $effrom = new ilRepositorySelector2InputGUI($this->lng->txt("effective_form"), "effective_from", true);
565  //$effrom->setMulti(true);
566  $white_list = [];
567  foreach ($this->objDefinition->getAllRepositoryTypes() as $type) {
568  if ($this->objDefinition->isContainer($type)) {
569  $white_list[] = $type;
570  }
571  }
572  $effrom->getExplorerGUI()->setTypeWhiteList($white_list);
573  $effrom->setValue($set->getEffectiveFrom());
574 
575  $lokal_templates->addSubItem($effrom);
576  $form->addItem($lokal_templates);
577 
578  $excl = new ilCheckboxInputGUI($this->lng->txt("activate_exclusive_template"), "exclusive_template");
579  $excl->setInfo($this->lng->txt("activate_exclusive_template_info"));
580  $excl->setChecked($set->isExclusive());
581 
582  $form->addItem($excl);
583  }
584 
585  return $form;
586  }
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...
setRequired(bool $a_required)
static lookupTxtById(string $plugin_id, string $lang_var)
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.
getTranslations()
Get all translations from this object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initReferenceFromRequest()

ilDidacticTemplateSettingsGUI::initReferenceFromRequest ( )
protected

Definition at line 80 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by executeCommand().

80  : void
81  {
82  if ($this->http->wrapper()->query()->has('ref_id')) {
83  $this->ref_id = $this->http->wrapper()->query()->retrieve(
84  'ref_id',
85  $this->refinery->kindlyTo()->int()
86  );
87  }
88  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTemplateFromRequest()

ilDidacticTemplateSettingsGUI::initTemplateFromRequest ( )
protected

Definition at line 104 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by editTemplate(), executeCommand(), importTemplate(), showEditImportForm(), showImportForm(), and updateTemplate().

105  {
106  if ($this->http->wrapper()->query()->has('tplid')) {
107  $tpl_id = $this->http->wrapper()->query()->retrieve(
108  'tplid',
109  $this->refinery->kindlyTo()->int()
110  );
111  return $this->setting = new ilDidacticTemplateSetting($tpl_id);
112  }
113 
114  return null;
115  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTemplatesFromRequest()

ilDidacticTemplateSettingsGUI::initTemplatesFromRequest ( )
protected

transforms selected tpls from post to SplFixedArray

Definition at line 93 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by deleteTemplates().

93  : SplFixedArray
94  {
95  if ($this->http->wrapper()->query()->has('tpls')) {
96  return SplFixedArray::fromArray(explode(
97  ',',
98  $this->http->wrapper()->query()->retrieve('tpls', $this->refinery->custom()->transformation(fn($v) => $v))
99  ));
100  }
101  return new SplFixedArray(0);
102  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ overview()

ilDidacticTemplateSettingsGUI::overview ( )
protected

Definition at line 201 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\Repository\ctrl(), ilDidacticTemplateSettingsTableFilter\init(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by applyFilter(), and resetFilter().

201  : void
202  {
203  if ($this->rbacsystem->checkAccess('write', $this->ref_id)) {
204  $this->toolbar->addButton(
205  $this->lng->txt('didactic_import_btn'),
206  $this->ctrl->getLinkTarget($this, 'showImportForm')
207  );
208  }
209  $filter = new ilDidacticTemplateSettingsTableFilter($this->ctrl->getFormAction($this, 'overview'));
210  $filter->init();
211 
212  $data_retrieval = new ilDidacticTemplateSettingsTableDataRetrieval(
213  $filter,
214  $this->lng,
215  $this->ui_factory,
216  $this->renderer
217  );
218 
219  $table = new ilDidacticTemplateSettingsTableGUI($this, $this->ref_id);
220  $this->tpl->setContent(
221  $filter->render() . $table->getHTML($data_retrieval)
222  );
223  }
Description of ilDidacticTemplateSettingsTableGUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetFilter()

ilDidacticTemplateSettingsGUI::resetFilter ( )

Definition at line 230 of file class.ilDidacticTemplateSettingsGUI.php.

References overview().

230  : void
231  {
232  $this->overview();
233  }
+ Here is the call graph for this function:

◆ setEditTabs()

ilDidacticTemplateSettingsGUI::setEditTabs ( string  $a_tab_active = "edit")
protected

Definition at line 712 of file class.ilDidacticTemplateSettingsGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by editTemplate(), executeCommand(), showEditImportForm(), and showImportForm().

712  : void
713  {
714  $this->lng->loadLanguageModule('obj');
715  $this->tabs->clearTargets();
716  $this->tabs->setBackTarget(
717  $this->lng->txt('didactic_back_to_overview'),
718  $this->ctrl->getLinkTarget($this, 'overview')
719  );
720  $this->ctrl->saveParameter($this, "tplid");
721 
722  if (!$this->setting->isAutoGenerated()) {
723  $this->tabs->addTab('edit', $this->lng->txt('settings'), $this->ctrl->getLinkTarget($this, 'editTemplate'));
724  $this->tabs->addTab(
725  'import',
726  $this->lng->txt('import'),
727  $this->ctrl->getLinkTarget($this, 'showEditImportForm')
728  );
729 
730  if (in_array($a_tab_active, ['edit', 'settings_trans'])) {
731  $this->tabs->addSubTab(
732  'edit',
733  $this->lng->txt('settings'),
734  $this->ctrl->getLinkTarget($this, 'editTemplate')
735  );
736  $this->tabs->addSubTab(
737  'settings_trans',
738  $this->lng->txt("obj_multilinguality"),
739  $this->ctrl->getLinkTargetByClass(["ilmultilingualismgui"], 'listTranslations')
740  );
741  $this->tabs->setTabActive('edit');
742  $this->tabs->setSubTabActive($a_tab_active);
743  } else {
744  $this->tabs->setTabActive($a_tab_active);
745  }
746  }
747  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showEditImportForm()

ilDidacticTemplateSettingsGUI::showEditImportForm ( ilPropertyFormGUI  $form = null)

Definition at line 749 of file class.ilDidacticTemplateSettingsGUI.php.

References editImportForm(), initTemplateFromRequest(), and setEditTabs().

Referenced by importTemplate().

749  : void
750  {
751  $this->initTemplateFromRequest();
752  $this->setEditTabs("import");
753  if (!$form instanceof ilPropertyFormGUI) {
754  $form = $this->editImportForm();
755  }
756  $this->tpl->setContent($form->getHTML());
757  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showImportForm()

ilDidacticTemplateSettingsGUI::showImportForm ( ilPropertyFormGUI  $form = null)
protected

Definition at line 235 of file class.ilDidacticTemplateSettingsGUI.php.

References createImportForm(), ILIAS\Repository\ctrl(), initTemplateFromRequest(), ILIAS\Repository\lng(), setEditTabs(), and ILIAS\Repository\tabs().

Referenced by importTemplate().

235  : void
236  {
238  if ($setting instanceof ilDidacticTemplateSetting) {
239  $this->setEditTabs('import');
240  } else {
241  $this->tabs->clearTargets();
242  $this->tabs->setBackTarget(
243  $this->lng->txt('didactic_back_to_overview'),
244  $this->ctrl->getLinkTarget($this, 'overview')
245  );
246  }
247 
248  if (!$form instanceof ilPropertyFormGUI) {
249  $form = $this->createImportForm();
250  }
251  $this->tpl->setContent($form->getHTML());
252  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTemplate()

ilDidacticTemplateSettingsGUI::updateTemplate ( )
protected

Definition at line 395 of file class.ilDidacticTemplateSettingsGUI.php.

References $lang, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), handleUpdateFailure(), initEditTemplate(), initTemplateFromRequest(), ILIAS\Repository\lng(), and ILIAS\Repository\upload().

395  : void
396  {
398  $this->ctrl->saveParameter($this, 'tplid');
399 
400  if (!$this->access->checkAccess('write', '', $this->ref_id)) {
401  $this->ctrl->redirect($this, "overview");
402  }
403 
404  $form = $this->initEditTemplate($this->setting);
405 
406  if ($form->checkInput()) {
407  $tmp_file = $_FILES['icon']['tmp_name'] ?? '';
408  $upload_element = $form->getItemByPostVar('icon');
409  if (
410  ($tmp_file !== '' || ($tmp_file === '' && $this->setting->getIconIdentifier())) &&
411  !$this->objDefinition->isContainer($form->getInput('type')) &&
412  !$upload_element->getDeletionFlag()
413  ) {
414  $form->getItemByPostVar('icon')->setAlert($this->lng->txt('didactic_icon_error'));
415  $this->handleUpdateFailure($form);
416  return;
417  }
418  //change default entries if translation is active
419  if (count($lang = $this->setting->getTranslationObject()->getLanguages())) {
420  $this->setting->getTranslationObject()->setDefaultTitle($form->getInput('title'));
421  $this->setting->getTranslationObject()->setDefaultDescription($form->getInput('description'));
422  $this->setting->getTranslationObject()->save();
423  }
424 
425  if (!$this->setting->isAutoGenerated()) {
426  $this->setting->setTitle($form->getInput('title'));
427  $this->setting->setDescription($form->getInput('description'));
428  }
429 
430  $this->setting->setInfo($form->getInput('info'));
431  $this->setting->enable((bool) $form->getInput('enable'));
432 
433  if (!$this->setting->isAutoGenerated()) {
434  $this->setting->setAssignments([$form->getInput('type')]);
435  }
436 
437  if ($form->getInput('local_template') && count($form->getInput('effective_from')) > 0) {
438  $this->setting->setEffectiveFrom($form->getInput('effective_from'));
439  } else {
440  $this->setting->setEffectiveFrom([]);
441  }
442 
443  $this->setting->setExclusive((bool) $form->getInput('exclusive_template'));
444 
445  $this->setting->update();
446 
447  $upload = $form->getItemByPostVar('icon');
448  if ($upload->getDeletionFlag()) {
449  $this->setting->getIconHandler()->delete();
450  }
451  $this->setting->getIconHandler()->handleUpload($this->upload, $_FILES['icon']['tmp_name']);
452  $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
453  $this->ctrl->redirect($this, 'overview');
454  }
455  $this->handleUpdateFailure($form);
456  }
initEditTemplate(ilDidacticTemplateSetting $set)
$lang
Definition: xapiexit.php:26
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilDidacticTemplateSettingsGUI::$access
private

Definition at line 50 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $ctrl

ilCtrl ilDidacticTemplateSettingsGUI::$ctrl
private

Definition at line 49 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $dic

Container ilDidacticTemplateSettingsGUI::$dic
private

Definition at line 46 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $http

GlobalHttpState ilDidacticTemplateSettingsGUI::$http
private

Definition at line 53 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $lng

ilLanguage ilDidacticTemplateSettingsGUI::$lng
private

Definition at line 47 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $logger

ilLogger ilDidacticTemplateSettingsGUI::$logger
private

Definition at line 44 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $objDefinition

ilObjectDefinition ilDidacticTemplateSettingsGUI::$objDefinition
private

Definition at line 52 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $rbacsystem

ilRbacSystem ilDidacticTemplateSettingsGUI::$rbacsystem
private

Definition at line 48 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $ref_id

int ilDidacticTemplateSettingsGUI::$ref_id
private

Definition at line 59 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $refinery

Factory ilDidacticTemplateSettingsGUI::$refinery
private

Definition at line 54 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $renderer

UIRenderer ilDidacticTemplateSettingsGUI::$renderer
protected

Definition at line 42 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $setting

ilDidacticTemplateSetting ilDidacticTemplateSettingsGUI::$setting = null
private

Definition at line 45 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $tabs

ilTabsGUI ilDidacticTemplateSettingsGUI::$tabs
private

Definition at line 56 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $toolbar

ilToolbarGUI ilDidacticTemplateSettingsGUI::$toolbar
private

Definition at line 51 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilDidacticTemplateSettingsGUI::$tpl
private

Definition at line 55 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $ui_factory

UIFactory ilDidacticTemplateSettingsGUI::$ui_factory
protected

Definition at line 43 of file class.ilDidacticTemplateSettingsGUI.php.

◆ $upload

FileUpload ilDidacticTemplateSettingsGUI::$upload
private

Definition at line 57 of file class.ilDidacticTemplateSettingsGUI.php.


The documentation for this class was generated from the following file: