Do not populate using createElements() and fix documentation blocks
refs #5525
This commit is contained in:
parent
bc05d2ee64
commit
2b879b344f
|
@ -6,6 +6,9 @@ namespace Icinga\Form\Config\Authentication;
|
|||
|
||||
use Zend_Validate_Callback;
|
||||
|
||||
/**
|
||||
* Form class for adding/modifying autologin authentication backends
|
||||
*/
|
||||
class AutologinBackendForm extends BaseBackendForm
|
||||
{
|
||||
public function isValidAuthenticationBackend()
|
||||
|
@ -13,6 +16,9 @@ class AutologinBackendForm extends BaseBackendForm
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Form::createElements()
|
||||
*/
|
||||
public function createElements(array $formData)
|
||||
{
|
||||
return array(
|
||||
|
@ -24,7 +30,6 @@ class AutologinBackendForm extends BaseBackendForm
|
|||
'allowEmpty' => false,
|
||||
'label' => t('Backend Name'),
|
||||
'helptext' => t('The name of this authentication backend'),
|
||||
'value' => '',
|
||||
'validators' => array(
|
||||
array(
|
||||
'Regex',
|
||||
|
|
|
@ -31,9 +31,9 @@ class GeneralForm extends Form
|
|||
public function createElements(array $formData)
|
||||
{
|
||||
$elements = array(
|
||||
$this->getLanguageSelection($formData),
|
||||
$this->getTimezoneSelection($formData),
|
||||
$this->getModulePathInput($formData)
|
||||
$this->getLanguageSelection(),
|
||||
$this->getTimezoneSelection(),
|
||||
$this->getModulePathInput()
|
||||
);
|
||||
|
||||
return array_merge(
|
||||
|
@ -102,11 +102,9 @@ class GeneralForm extends Form
|
|||
*
|
||||
* Possible values are determined by Translator::getAvailableLocaleCodes.
|
||||
*
|
||||
* @param array $formData The data to populate the elements with
|
||||
*
|
||||
* @return Zend_Form_Element
|
||||
*/
|
||||
protected function getLanguageSelection(array $formData)
|
||||
protected function getLanguageSelection()
|
||||
{
|
||||
$languages = array();
|
||||
foreach (Translator::getAvailableLocaleCodes() as $language) {
|
||||
|
@ -122,8 +120,7 @@ class GeneralForm extends Form
|
|||
'multiOptions' => $languages,
|
||||
'helptext' => t(
|
||||
'Select the language to use by default. Can be overwritten by a user in his preferences.'
|
||||
),
|
||||
'value' => isset($formData['language']) ? $formData['language'] : Translator::DEFAULT_LOCALE
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -133,11 +130,9 @@ class GeneralForm extends Form
|
|||
*
|
||||
* Possible values are determined by DateTimeZone::listIdentifiers.
|
||||
*
|
||||
* @param array $formData The data to populate the elements with
|
||||
*
|
||||
* @return Zend_Form_Element
|
||||
*/
|
||||
protected function getTimezoneSelection(array $formData)
|
||||
protected function getTimezoneSelection()
|
||||
{
|
||||
$tzList = array();
|
||||
foreach (DateTimeZone::listIdentifiers() as $tz) {
|
||||
|
@ -155,17 +150,15 @@ class GeneralForm extends Form
|
|||
'Select the timezone to be used as the default. User\'s can set their own timezone if'
|
||||
. ' they like to, but this is the timezone to be used as the default setting .'
|
||||
),
|
||||
'value' => isset($formData['timezone']) ? $formData['timezone'] : date_default_timezone_get()
|
||||
'value' => date_default_timezone_get()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a input field for setting the module path
|
||||
*
|
||||
* @param array $formData The data to populate the elements with
|
||||
*/
|
||||
protected function getModulePathInput(array $formData)
|
||||
protected function getModulePathInput()
|
||||
{
|
||||
$this->addElement(
|
||||
'text',
|
||||
|
@ -178,9 +171,7 @@ class GeneralForm extends Form
|
|||
. 'colons. Modules that don\'t exist in these directories can still be symlinked in '
|
||||
. 'the module folder, but won\'t show up in the list of disabled modules.'
|
||||
),
|
||||
'value' => isset($formData['modulePath'])
|
||||
? $formData['modulePath']
|
||||
: realpath(ICINGAWEB_APPDIR . '/../modules')
|
||||
'value' => realpath(ICINGAWEB_APPDIR . '/../modules')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -188,7 +179,7 @@ class GeneralForm extends Form
|
|||
/**
|
||||
* Return form elements for setting the user preference storage backend
|
||||
*
|
||||
* @param array $formData The data to populate the elements with
|
||||
* @param array $formData The data sent by the user
|
||||
*/
|
||||
protected function getPreferencesElements(array $formData)
|
||||
{
|
||||
|
@ -200,7 +191,6 @@ class GeneralForm extends Form
|
|||
'required' => true,
|
||||
'class' => 'autosubmit',
|
||||
'label' => t('User Preference Storage Type'),
|
||||
'value' => isset($formData['preferences_type']) ? $formData['preferences_type'] : 'ini',
|
||||
'multiOptions' => array(
|
||||
'ini' => t('File System (INI Files)'),
|
||||
'db' => t('Database'),
|
||||
|
@ -224,10 +214,7 @@ class GeneralForm extends Form
|
|||
array(
|
||||
'required' => true,
|
||||
'multiOptions' => $backends,
|
||||
'label' => t('Database Connection'),
|
||||
'value' => isset($formData['preferences_resource'])
|
||||
? $formData['preferences_resource']
|
||||
: null
|
||||
'label' => t('Database Connection')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class GeneralForm extends Form
|
|||
* Possible values are determined by Translator::getAvailableLocaleCodes.
|
||||
* Also, a 'use browser language' checkbox is added in order to allow a user to discard his setting
|
||||
*
|
||||
* @param array $formData The data to populate the elements with
|
||||
* @param array $formData The data sent by the user
|
||||
*/
|
||||
protected function getLanguageElements(array $formData)
|
||||
{
|
||||
|
@ -43,9 +43,7 @@ class GeneralForm extends Form
|
|||
'required' => false === $useBrowserLanguage,
|
||||
'multiOptions' => $languages,
|
||||
'helptext' => t('Use the following language to display texts and messages'),
|
||||
'value' => isset($formData['language'])
|
||||
? $formData['language']
|
||||
: substr(setlocale(LC_ALL, 0), 0, 5)
|
||||
'value' => substr(setlocale(LC_ALL, 0), 0, 5)
|
||||
);
|
||||
if ($useBrowserLanguage) {
|
||||
$selectOptions['disabled'] = 'disabled';
|
||||
|
@ -72,7 +70,7 @@ class GeneralForm extends Form
|
|||
* Possible values are determined by DateTimeZone::listIdentifiers.
|
||||
* Also, a 'use local timezone' checkbox is added in order to allow a user to discard his overwritten setting
|
||||
*
|
||||
* @param array $formData The data to populate the elements with
|
||||
* @param array $formData The data sent by the user
|
||||
*/
|
||||
protected function getTimezoneElements(array $formData)
|
||||
{
|
||||
|
@ -87,9 +85,7 @@ class GeneralForm extends Form
|
|||
'required' => false === $useLocalTimezone,
|
||||
'multiOptions' => $tzList,
|
||||
'helptext' => t('Use the following timezone for dates and times'),
|
||||
'value' => isset($formData['timezone'])
|
||||
? $formData['timezone']
|
||||
: date_default_timezone_get()
|
||||
'value' => date_default_timezone_get()
|
||||
);
|
||||
if ($useLocalTimezone) {
|
||||
$selectOptions['disabled'] = 'disabled';
|
||||
|
@ -120,8 +116,7 @@ class GeneralForm extends Form
|
|||
'checkbox',
|
||||
'show_benchmark',
|
||||
array(
|
||||
'label' => t('Use benchmark'),
|
||||
'value' => isset($formData['show_benchmark']) ? $formData['show_benchmark'] : 0
|
||||
'label' => t('Use benchmark')
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ class Form extends Zend_Form
|
|||
/**
|
||||
* Create this form
|
||||
*
|
||||
* @param array $formData The data to populate the form with
|
||||
* @param array $formData The data sent by the user
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
|
@ -150,7 +150,7 @@ class Form extends Zend_Form
|
|||
*
|
||||
* Intended to be implemented by concrete form classes.
|
||||
*
|
||||
* @param array $formData The data to populate the elements with
|
||||
* @param array $formData The data sent by the user
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
|
|
@ -7,6 +7,9 @@ namespace Icinga\Module\Monitoring\Form\Config;
|
|||
use Zend_Config;
|
||||
use Icinga\Web\Form;
|
||||
|
||||
/**
|
||||
* Form for modifying security relevant settings
|
||||
*/
|
||||
class SecurityForm extends Form
|
||||
{
|
||||
/**
|
||||
|
@ -26,7 +29,6 @@ class SecurityForm extends Form
|
|||
array(
|
||||
'label' => 'Protected Custom Variables',
|
||||
'required' => true,
|
||||
'value' => $this->config->protected_customvars,
|
||||
'helptext' => 'Comma separated case insensitive list of protected custom variables.'
|
||||
. ' Use * as a placeholder for zero or more wildcard characters.'
|
||||
. ' Existance of those custom variables will be shown, but their values will be masked.'
|
||||
|
|
Loading…
Reference in New Issue