Allow admins to change the default language for their installation.
This commit is contained in:
parent
b99b09d13c
commit
c230d1c347
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="box box-primary">
|
||||
<div class="box-body clearfix">
|
||||
<?php print $basicSettings; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box box-primary">
|
||||
<div class="box-header"><h3 class="box-title"><?php Lang::out('build_settings'); ?></h3></div>
|
||||
<div class="box-body clearfix">
|
||||
|
|
Loading…
Reference in a new issue