diff --git a/PHPCI/Controller/SettingsController.php b/PHPCI/Controller/SettingsController.php index 6ca538f0..b33d87db 100644 --- a/PHPCI/Controller/SettingsController.php +++ b/PHPCI/Controller/SettingsController.php @@ -51,9 +51,9 @@ class SettingsController extends Controller $this->layout->title = Lang::get('settings'); $this->view->settings = $this->settings; - $emailSettings = array(); - if (isset($this->settings['phpci']['email_settings'])) { - $emailSettings = $this->settings['phpci']['email_settings']; + $basicSettings = array(); + if (isset($this->settings['phpci']['basic'])) { + $basicSettings = $this->settings['phpci']['basic']; } $buildSettings = array(); @@ -61,9 +61,15 @@ class SettingsController extends Controller $buildSettings = $this->settings['phpci']['build']; } + $emailSettings = array(); + if (isset($this->settings['phpci']['email_settings'])) { + $emailSettings = $this->settings['phpci']['email_settings']; + } + + $this->view->basicSettings = $this->getBasicForm($basicSettings); + $this->view->buildSettings = $this->getBuildForm($buildSettings); $this->view->github = $this->getGithubForm(); $this->view->emailSettings = $this->getEmailForm($emailSettings); - $this->view->buildSettings = $this->getBuildForm($buildSettings); $this->view->isWriteable = $this->canWriteConfig(); if (!empty($this->settings['phpci']['github']['token'])) { @@ -134,6 +140,26 @@ class SettingsController extends Controller die; } + /** + * Save basic settings. + */ + public function basic() + { + $this->requireAdmin(); + + $this->settings['phpci']['basic'] = $this->getParams(); + + $error = $this->storeSettings(); + + if ($error) { + header('Location: ' . PHPCI_URL . 'settings?saved=2'); + } else { + header('Location: ' . PHPCI_URL . 'settings?saved=1'); + } + + die; + } + /** * Github redirects users back to this URL when t */ @@ -347,6 +373,37 @@ class SettingsController extends Controller $form->addField($field); + $field = new Form\Element\Submit(); + $field->setValue(Lang::get('save')); + $field->setClass('btn btn-success pull-right'); + $form->addField($field); + + $form->setValues($values); + + return $form; + } + + /** + * Get the Basic settings form. + * @param array $values + * @return Form + */ + protected function getBasicForm($values = array()) + { + $form = new Form(); + $form->setMethod('POST'); + $form->setAction(PHPCI_URL . 'settings/basic'); + + $field = new Form\Element\Select('language'); + $field->setRequired(true); + $field->setLabel(Lang::get('language')); + $field->setClass('form-control'); + $field->setContainerClass('form-group'); + $field->setOptions(Lang::getLanguageOptions()); + $field->setValue('en'); + $form->addField($field); + + $field = new Form\Element\Submit(); $field->setValue(Lang::get('save')); $field->setClass('btn btn-success pull-right'); diff --git a/PHPCI/Helper/Lang.php b/PHPCI/Helper/Lang.php index d3b8f6fb..514342b9 100644 --- a/PHPCI/Helper/Lang.php +++ b/PHPCI/Helper/Lang.php @@ -131,7 +131,7 @@ class Lang } // Try the installation default language: - $language = $config->get('phpci.default_language', null); + $language = $config->get('phpci.basic.language', null); if (in_array($language, self::$languages)) { self::$language = $language; diff --git a/PHPCI/View/Settings/index.phtml b/PHPCI/View/Settings/index.phtml index 7e74abff..7a13b6e1 100644 --- a/PHPCI/View/Settings/index.phtml +++ b/PHPCI/View/Settings/index.phtml @@ -30,6 +30,12 @@

+
+
+ +
+
+