Merge branch 'bugfix/rebuild-form-builder-5525' into bugfix/commands-6593

This commit is contained in:
Eric Lippmann 2014-09-03 23:23:02 +02:00
commit a4da3b61b3
15 changed files with 337 additions and 337 deletions

View File

@ -26,8 +26,7 @@ class LoginForm extends Form
*/ */
public function createElements($formData) public function createElements($formData)
{ {
return array( $this->addElement(
$this->createElement(
'text', 'text',
'username', 'username',
array( array(
@ -36,8 +35,8 @@ class LoginForm extends Form
'placeholder' => t('Please enter your username...'), 'placeholder' => t('Please enter your username...'),
'class' => false === isset($formData['username']) ? 'autofocus' : '' 'class' => false === isset($formData['username']) ? 'autofocus' : ''
) )
), );
$this->createElement( $this->addElement(
'password', 'password',
'password', 'password',
array( array(
@ -46,14 +45,15 @@ class LoginForm extends Form
'placeholder' => t('...and your password'), 'placeholder' => t('...and your password'),
'class' => isset($formData['username']) ? 'autofocus' : '' 'class' => isset($formData['username']) ? 'autofocus' : ''
) )
), );
$this->createElement( $this->addElement(
'hidden', 'hidden',
'redirect', 'redirect',
array( array(
'value' => Url::fromRequest()->getParam('redirect') 'value' => Url::fromRequest()->getParam('redirect')
) )
)
); );
return $this;
} }
} }

View File

@ -25,8 +25,7 @@ class AutologinBackendForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
return array( $this->addElement(
$this->createElement(
'text', 'text',
'name', 'name',
array( array(
@ -46,8 +45,8 @@ class AutologinBackendForm extends Form
) )
) )
) )
), );
$this->createElement( $this->addElement(
'text', 'text',
'strip_username_regexp', 'strip_username_regexp',
array( array(
@ -61,16 +60,17 @@ class AutologinBackendForm extends Form
}) })
) )
) )
), );
$this->createElement( $this->addElement(
'hidden', 'hidden',
'backend', 'backend',
array( array(
'required' => true, 'required' => true,
'value' => 'autologin' 'value' => 'autologin'
) )
)
); );
return $this;
} }
/** /**

View File

@ -48,8 +48,7 @@ class DbBackendForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
return array( $this->addElement(
$this->createElement(
'text', 'text',
'name', 'name',
array( array(
@ -57,8 +56,8 @@ class DbBackendForm extends Form
'label' => t('Backend Name'), 'label' => t('Backend Name'),
'description' => t('The name of this authentication provider'), 'description' => t('The name of this authentication provider'),
) )
), );
$this->createElement( $this->addElement(
'select', 'select',
'resource', 'resource',
array( array(
@ -69,16 +68,17 @@ class DbBackendForm extends Form
? array_combine($this->resources, $this->resources) ? array_combine($this->resources, $this->resources)
: array() : array()
) )
), );
$this->createElement( $this->addElement(
'hidden', 'hidden',
'backend', 'backend',
array( array(
'required' => true, 'required' => true,
'value' => 'db' 'value' => 'db'
) )
)
); );
return $this;
} }
/** /**

View File

@ -47,8 +47,7 @@ class LdapBackendForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
return array( $this->addElement(
$this->createElement(
'text', 'text',
'name', 'name',
array( array(
@ -56,8 +55,8 @@ class LdapBackendForm extends Form
'label' => t('Backend Name'), 'label' => t('Backend Name'),
'description' => t('The name of this authentication backend') 'description' => t('The name of this authentication backend')
) )
), );
$this->createElement( $this->addElement(
'select', 'select',
'resource', 'resource',
array( array(
@ -68,8 +67,8 @@ class LdapBackendForm extends Form
? array_combine($this->resources, $this->resources) ? array_combine($this->resources, $this->resources)
: array() : array()
) )
), );
$this->createElement( $this->addElement(
'text', 'text',
'user_class', 'user_class',
array( array(
@ -78,8 +77,8 @@ class LdapBackendForm extends Form
'description' => t('The object class used for storing users on the ldap server'), 'description' => t('The object class used for storing users on the ldap server'),
'value' => 'inetOrgPerson' 'value' => 'inetOrgPerson'
) )
), );
$this->createElement( $this->addElement(
'text', 'text',
'user_name_attribute', 'user_name_attribute',
array( array(
@ -88,16 +87,17 @@ class LdapBackendForm extends Form
'description' => t('The attribute name used for storing the user name on the ldap server'), 'description' => t('The attribute name used for storing the user name on the ldap server'),
'value' => 'uid' 'value' => 'uid'
) )
), );
$this->createElement( $this->addElement(
'hidden', 'hidden',
'backend', 'backend',
array( array(
'required' => true, 'required' => true,
'value' => 'ldap' 'value' => 'ldap'
) )
)
); );
return $this;
} }
/** /**

View File

@ -299,8 +299,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
$backendTypes['autologin'] = t('Autologin'); $backendTypes['autologin'] = t('Autologin');
} }
$elements = array(); $this->addElement(
$elements[] = $this->createElement(
'select', 'select',
'type', 'type',
array( array(
@ -315,9 +314,11 @@ class AuthenticationBackendConfigForm extends ConfigForm
if (isset($formData['force_creation']) && $formData['force_creation']) { if (isset($formData['force_creation']) && $formData['force_creation']) {
// In case another error occured and the checkbox was displayed before // In case another error occured and the checkbox was displayed before
$elements[] = $this->getForceCreationCheckbox(); $this->addElement($this->getForceCreationCheckbox());
} }
return array_merge($elements, $this->getBackendForm($backendType)->createElements($formData)); $this->addElements($this->getBackendForm($backendType)->createElements($formData)->getElements());
return $this;
} }
} }

View File

@ -27,14 +27,12 @@ class ApplicationConfigForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
$elements = array();
$languages = array(); $languages = array();
foreach (Translator::getAvailableLocaleCodes() as $language) { foreach (Translator::getAvailableLocaleCodes() as $language) {
$languages[$language] = $language; $languages[$language] = $language;
} }
$elements[] = $this->createElement( $this->addElement(
'select', 'select',
'global_language', 'global_language',
array( array(
@ -52,7 +50,7 @@ class ApplicationConfigForm extends Form
$tzList[$tz] = $tz; $tzList[$tz] = $tz;
} }
$elements[] = $this->createElement( $this->addElement(
'select', 'select',
'global_timezone', 'global_timezone',
array( array(
@ -67,7 +65,7 @@ class ApplicationConfigForm extends Form
) )
); );
$elements[] = $this->createElement( $this->addElement(
'text', 'text',
'global_modulePath', 'global_modulePath',
array( array(
@ -82,7 +80,7 @@ class ApplicationConfigForm extends Form
) )
); );
$elements[] = $this->createElement( $this->addElement(
'select', 'select',
'preferences_type', 'preferences_type',
array( array(
@ -104,7 +102,7 @@ class ApplicationConfigForm extends Form
} }
} }
$elements[] = $this->createElement( $this->addElement(
'select', 'select',
'preferences_resource', 'preferences_resource',
array( array(
@ -115,6 +113,6 @@ class ApplicationConfigForm extends Form
); );
} }
return $elements; return $this;
} }
} }

View File

@ -23,9 +23,7 @@ class LoggingConfigForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
$elements = array(); $this->addElement(
$elements[] = $this->createElement(
'select', 'select',
'logging_level', 'logging_level',
array( array(
@ -41,7 +39,7 @@ class LoggingConfigForm extends Form
) )
) )
); );
$elements[] = $this->createElement( $this->addElement(
'select', 'select',
'logging_type', 'logging_type',
array( array(
@ -57,7 +55,7 @@ class LoggingConfigForm extends Form
); );
if (false === isset($formData['logging_type']) || $formData['logging_type'] === 'syslog') { if (false === isset($formData['logging_type']) || $formData['logging_type'] === 'syslog') {
$elements[] = $this->createElement( $this->addElement(
'text', 'text',
'logging_application', 'logging_application',
array( array(
@ -79,7 +77,7 @@ class LoggingConfigForm extends Form
) )
) )
); );
$elements[] = $this->createElement( $this->addElement(
'select', 'select',
'logging_facility', 'logging_facility',
array( array(
@ -92,7 +90,7 @@ class LoggingConfigForm extends Form
) )
); );
} elseif ($formData['logging_type'] === 'file') { } elseif ($formData['logging_type'] === 'file') {
$elements[] = $this->createElement( $this->addElement(
'text', 'text',
'logging_target', 'logging_target',
array( array(
@ -105,7 +103,7 @@ class LoggingConfigForm extends Form
); );
} }
return $elements; return $this;
} }
/** /**

View File

@ -31,11 +31,10 @@ class GeneralConfigForm extends ConfigForm
{ {
$appConfigForm = new ApplicationConfigForm(); $appConfigForm = new ApplicationConfigForm();
$loggingConfigForm = new LoggingConfigForm(); $loggingConfigForm = new LoggingConfigForm();
$this->addElements($appConfigForm->createElements($formData)->getElements());
$this->addElements($loggingConfigForm->createElements($formData)->getElements());
return array_merge( return $this;
$appConfigForm->createElements($formData),
$loggingConfigForm->createElements($formData)
);
} }
/** /**

View File

@ -29,8 +29,7 @@ class DbResourceForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
return array( $this->addElement(
$this->createElement(
'select', 'select',
'db', 'db',
array( array(
@ -43,8 +42,8 @@ class DbResourceForm extends Form
//'oracle' => 'Oracle' //'oracle' => 'Oracle'
) )
) )
), );
$this->createElement( $this->addElement(
'text', 'text',
'host', 'host',
array ( array (
@ -53,7 +52,8 @@ class DbResourceForm extends Form
'description' => t('The hostname of the database'), 'description' => t('The hostname of the database'),
'value' => 'localhost' 'value' => 'localhost'
) )
), );
$this->addElement(
new Number( new Number(
array( array(
'required' => true, 'required' => true,
@ -62,8 +62,9 @@ class DbResourceForm extends Form
'description' => t('The port to use'), 'description' => t('The port to use'),
'value' => 3306 'value' => 3306
) )
), )
$this->createElement( );
$this->addElement(
'text', 'text',
'dbname', 'dbname',
array( array(
@ -71,8 +72,8 @@ class DbResourceForm extends Form
'label' => t('Database Name'), 'label' => t('Database Name'),
'description' => t('The name of the database to use') 'description' => t('The name of the database to use')
) )
), );
$this->createElement( $this->addElement(
'text', 'text',
'username', 'username',
array ( array (
@ -80,8 +81,8 @@ class DbResourceForm extends Form
'label' => t('Username'), 'label' => t('Username'),
'description' => t('The user name to use for authentication') 'description' => t('The user name to use for authentication')
) )
), );
$this->createElement( $this->addElement(
'password', 'password',
'password', 'password',
array( array(
@ -90,8 +91,9 @@ class DbResourceForm extends Form
'label' => t('Password'), 'label' => t('Password'),
'description' => t('The password to use for authentication') 'description' => t('The password to use for authentication')
) )
)
); );
return $this;
} }
/** /**

View File

@ -25,8 +25,7 @@ class FileResourceForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
return array( $this->addElement(
$this->createElement(
'text', 'text',
'filename', 'filename',
array( array(
@ -35,8 +34,8 @@ class FileResourceForm extends Form
'description' => t('The filename to fetch information from'), 'description' => t('The filename to fetch information from'),
'validators' => array(new ReadablePathValidator()) 'validators' => array(new ReadablePathValidator())
) )
), );
$this->createElement( $this->addElement(
'text', 'text',
'fields', 'fields',
array( array(
@ -44,7 +43,8 @@ class FileResourceForm extends Form
'label' => t('Pattern'), 'label' => t('Pattern'),
'description' => t('The regular expression by which to identify columns') 'description' => t('The regular expression by which to identify columns')
) )
)
); );
return $this;
} }
} }

View File

@ -29,8 +29,7 @@ class LdapResourceForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
return array( $this->addElement(
$this->createElement(
'text', 'text',
'hostname', 'hostname',
array( array(
@ -39,7 +38,8 @@ class LdapResourceForm extends Form
'description' => t('The hostname or address of the LDAP server to use for authentication'), 'description' => t('The hostname or address of the LDAP server to use for authentication'),
'value' => 'localhost' 'value' => 'localhost'
) )
), );
$this->addElement(
new Number( new Number(
array( array(
'required' => true, 'required' => true,
@ -48,8 +48,9 @@ class LdapResourceForm extends Form
'description' => t('The port of the LDAP server to use for authentication'), 'description' => t('The port of the LDAP server to use for authentication'),
'value' => 389 'value' => 389
) )
), )
$this->createElement( );
$this->addElement(
'text', 'text',
'root_dn', 'root_dn',
array( array(
@ -57,8 +58,8 @@ class LdapResourceForm extends Form
'label' => t('Root DN'), 'label' => t('Root DN'),
'description' => t('The path where users can be found on the ldap server') 'description' => t('The path where users can be found on the ldap server')
) )
), );
$this->createElement( $this->addElement(
'text', 'text',
'bind_dn', 'bind_dn',
array( array(
@ -66,8 +67,8 @@ class LdapResourceForm extends Form
'label' => t('Bind DN'), 'label' => t('Bind DN'),
'description' => t('The user dn to use for querying the ldap server') 'description' => t('The user dn to use for querying the ldap server')
) )
), );
$this->createElement( $this->addElement(
'password', 'password',
'bind_pw', 'bind_pw',
array( array(
@ -76,8 +77,9 @@ class LdapResourceForm extends Form
'label' => t('Bind Password'), 'label' => t('Bind Password'),
'description' => t('The password to use for querying the ldap server') 'description' => t('The password to use for querying the ldap server')
) )
)
); );
return $this;
} }
/** /**

View File

@ -29,8 +29,7 @@ class LivestatusResourceForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
return array( $this->addElement(
$this->createElement(
'text', 'text',
'socket', 'socket',
array( array(
@ -39,8 +38,9 @@ class LivestatusResourceForm extends Form
'description' => t('The path to your livestatus socket used for querying monitoring data'), 'description' => t('The path to your livestatus socket used for querying monitoring data'),
'value' => realpath(Icinga::app()->getApplicationDir() . '/../var/rw/livestatus') 'value' => realpath(Icinga::app()->getApplicationDir() . '/../var/rw/livestatus')
) )
)
); );
return $this;
} }
/** /**

View File

@ -26,8 +26,7 @@ class StatusdatResourceForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
return array( $this->addElement(
$this->createElement(
'text', 'text',
'status_file', 'status_file',
array( array(
@ -37,8 +36,8 @@ class StatusdatResourceForm extends Form
'value' => realpath(Icinga::app()->getApplicationDir() . '/../var/status.dat'), 'value' => realpath(Icinga::app()->getApplicationDir() . '/../var/status.dat'),
'validators' => array(new ReadablePathValidator()) 'validators' => array(new ReadablePathValidator())
) )
), );
$this->createElement( $this->addElement(
'text', 'text',
'object_file', 'object_file',
array( array(
@ -48,7 +47,8 @@ class StatusdatResourceForm extends Form
'value' => realpath(Icinga::app()->getApplicationDir() . '/../var/objects.cache'), 'value' => realpath(Icinga::app()->getApplicationDir() . '/../var/objects.cache'),
'validators' => array(new ReadablePathValidator()) 'validators' => array(new ReadablePathValidator())
) )
)
); );
return $this;
} }
} }

View File

@ -224,8 +224,7 @@ class ResourceConfigForm extends ConfigForm
$resourceTypes['db'] = t('SQL Database'); $resourceTypes['db'] = t('SQL Database');
} }
$elements = array( $this->addElement(
$this->createElement(
'text', 'text',
'name', 'name',
array( array(
@ -233,8 +232,8 @@ class ResourceConfigForm extends ConfigForm
'label' => t('Resource Name'), 'label' => t('Resource Name'),
'description' => t('The unique name of this resource') 'description' => t('The unique name of this resource')
) )
), );
$this->createElement( $this->addElement(
'select', 'select',
'type', 'type',
array( array(
@ -245,14 +244,15 @@ class ResourceConfigForm extends ConfigForm
'multiOptions' => $resourceTypes, 'multiOptions' => $resourceTypes,
'value' => $resourceType 'value' => $resourceType
) )
)
); );
if (isset($formData['force_creation']) && $formData['force_creation']) { if (isset($formData['force_creation']) && $formData['force_creation']) {
// In case another error occured and the checkbox was displayed before // In case another error occured and the checkbox was displayed before
$elements[] = $this->getForceCreationCheckbox(); $this->addElement($this->getForceCreationCheckbox());
} }
return array_merge($elements, $this->getResourceForm($resourceType)->createElements($formData)); $this->addElements($this->getResourceForm($resourceType)->createElements($formData)->getElements());
return $this;
} }
} }

View File

@ -269,8 +269,8 @@ class Form extends Zend_Form
public function create(array $formData = array()) public function create(array $formData = array())
{ {
if (false === $this->created) { if (false === $this->created) {
$this->addElements($this->createElements($formData)); $this->createElements($formData)
$this->addFormIdentification() ->addFormIdentification()
->addCsrfCounterMeasure() ->addCsrfCounterMeasure()
->addSubmitButton(); ->addSubmitButton();
@ -287,17 +287,17 @@ class Form extends Zend_Form
} }
/** /**
* Create and return the elements to add to this form * Create and add elements to this form
* *
* Intended to be implemented by concrete form classes. * Intended to be implemented by concrete form classes.
* *
* @param array $formData The data sent by the user * @param array $formData The data sent by the user
* *
* @return array * @return self
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
return array(); return $this;
} }
/** /**