From 4fccc86b039ae15df7fac85bf41989dd8c130c2a Mon Sep 17 00:00:00 2001 From: "Roman Schmerold (BNoiZe)" Date: Tue, 3 Feb 2015 21:32:23 +0100 Subject: [PATCH] Updated HTMLform2 with some tweaks Signed-off-by: Roman Schmerold (BNoiZe) --- lib/classes/output/class.HTMLform2.php | 19 ++++++++++++++----- lib/formfields/admin/formfield.admin.php | 3 ++- lib/formfields/customer/formfield.mysql.php | 4 ++++ .../admin/customers/customers_edit.tpl | 2 +- templates/Sparkle/htmlform/checkbox.tpl | 2 +- .../Sparkle/htmlform/skeleton_checkbox.tpl | 4 ++++ 6 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 templates/Sparkle/htmlform/skeleton_checkbox.tpl diff --git a/lib/classes/output/class.HTMLform2.php b/lib/classes/output/class.HTMLform2.php index b2d182a4..4c755710 100644 --- a/lib/classes/output/class.HTMLform2.php +++ b/lib/classes/output/class.HTMLform2.php @@ -67,7 +67,16 @@ class HTMLform2 { } else { $desc = ''; } - eval("self::\$_form .= \"" . getTemplate("htmlform/skeleton", "1") . "\";"); + + switch($fielddata['type']) { + case 'checkbox': + eval("self::\$_form .= \"" . getTemplate("htmlform/skeleton_checkbox", "1") . "\";"); + break; + default: + eval("self::\$_form .= \"" . getTemplate("htmlform/skeleton", "1") . "\";"); + break; + } + } } } @@ -263,14 +272,14 @@ class HTMLform2 { $checkboxdata = array( //'label' => $lng['admin']['stdsubdomain_add'].'?', 'type' => 'checkbox', - 'sublabel' => $lng['customer']['unlimited'], + 'label' => $lng['customer']['unlimited'], 'value' => '-1', 'attributes' => array( 'checked' => ($fielddata['value'] == '-1') ? true : false ) ); - $checkbox = self::_inputCheckbox($fieldname . "_ul", $checkboxdata); + $checkbox = self::_inputCheckbox($fieldname . "_ul", $checkboxdata, false); eval("\$return = \"" . getTemplate("htmlform/textul", "1") . "\";"); @@ -306,12 +315,12 @@ class HTMLform2 { * @param array $fielddata (default: array()) * @return void */ - private static function _inputCheckbox($fieldname, $fielddata = array()) { + private static function _inputCheckbox($fieldname, $fielddata = array(), $labelHidden = true) { $attributes = self::_parseAttributes($fieldname, $fielddata); $attributes['type'] = $fielddata['type']; $attributes = self::_glueAttributes($attributes); - $sublabel = $fielddata['sublabel']; + $label = $fielddata['label']; eval("\$return = \"" . getTemplate("htmlform/checkbox", "1") . "\";"); return $return; } diff --git a/lib/formfields/admin/formfield.admin.php b/lib/formfields/admin/formfield.admin.php index 93fd193a..35826c06 100644 --- a/lib/formfields/admin/formfield.admin.php +++ b/lib/formfields/admin/formfield.admin.php @@ -22,7 +22,8 @@ return array( 'loginname' => array( 'label' => $lng['login']['username'], 'type' => (isset($result['loginname'])) ? 'static' : 'text', - 'mandatory' => true, ), + 'mandatory' => true, + ), 'deactivated' => array( 'label' => $lng['admin']['deactivated_user'], 'type' => 'checkbox', diff --git a/lib/formfields/customer/formfield.mysql.php b/lib/formfields/customer/formfield.mysql.php index 1cf17b73..ffa50b6e 100644 --- a/lib/formfields/customer/formfield.mysql.php +++ b/lib/formfields/customer/formfield.mysql.php @@ -26,6 +26,7 @@ return array( 'label' => $lng['mysql']['mysql_server'], 'type' => (isset($result)) ? 'select' : 'text', 'visible' => (1 < $count_mysqlservers ? true : false), + ), 'mysql_password' => array( 'label' => $lng['login']['password'], @@ -39,6 +40,9 @@ return array( 'type' => 'text', 'visible' => (Settings::Get('panel.password_regex') == ''), 'value' => generatePassword(), + 'attributes' => array( + 'readonly' => true + ) ), 'sendinfomail' => array( 'label' => $lng['customer']['sendinfomail'], diff --git a/templates/Sparkle/admin/customers/customers_edit.tpl b/templates/Sparkle/admin/customers/customers_edit.tpl index bddab026..0826e57d 100644 --- a/templates/Sparkle/admin/customers/customers_edit.tpl +++ b/templates/Sparkle/admin/customers/customers_edit.tpl @@ -2,7 +2,7 @@ $header

- {$title}  +   {$lng['admin']['customer_edit']}

diff --git a/templates/Sparkle/htmlform/checkbox.tpl b/templates/Sparkle/htmlform/checkbox.tpl index 0647b37f..ca710a8d 100644 --- a/templates/Sparkle/htmlform/checkbox.tpl +++ b/templates/Sparkle/htmlform/checkbox.tpl @@ -1 +1 @@ -{$sublabel} + diff --git a/templates/Sparkle/htmlform/skeleton_checkbox.tpl b/templates/Sparkle/htmlform/skeleton_checkbox.tpl new file mode 100644 index 00000000..cc6b167f --- /dev/null +++ b/templates/Sparkle/htmlform/skeleton_checkbox.tpl @@ -0,0 +1,4 @@ + +
{$desc}
+ {$field} +