diff --git a/application/controllers/SettingsController.php b/application/controllers/SettingsController.php new file mode 100644 index 00000000..25ed0e77 --- /dev/null +++ b/application/controllers/SettingsController.php @@ -0,0 +1,50 @@ +view->tabs = $this->Module()->getConfigTabs()->activate('config'); + + $resource = $this->Config()->get('db', 'resource'); + + $form = new ConfigForm(); + + $form->setIniConfig($this->Config('config')); + $form->addElement('select', 'resource', array( + 'required' => true, + 'label' => $this->translate('DB Resource'), + 'multiOptions' => $this->getResources(), + 'value' => $resource + )); + $form->setSubmitLabel($this->translate('Save')); + + $form->setOnSuccess(function($form) { + /** @var $form ConfigForm */ + $this->Config('config')->setSection('db', array( + 'resource' => $form->getValue('resource') + )); + $form->save(); + }); + + $form->handleRequest(); + + $this->view->form = $form; + } + + public function getResources() + { + $resources = array(); + foreach (ResourceFactory::getResourceConfigs() as $name => $resource) { + if ($resource->type === 'db') { + $resources['ido'][$name] = $name; + } + } + return $resources; + } +} diff --git a/application/views/scripts/settings/index.phtml b/application/views/scripts/settings/index.phtml new file mode 100644 index 00000000..37d437e0 --- /dev/null +++ b/application/views/scripts/settings/index.phtml @@ -0,0 +1,7 @@ +