diff --git a/admin_customers.php b/admin_customers.php
index ac393f73..27b98b73 100644
--- a/admin_customers.php
+++ b/admin_customers.php
@@ -22,6 +22,7 @@ require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Customers as Customers;
+use Froxlor\UI\Panel\UI;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
@@ -283,11 +284,6 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
's' => $s
));
} else {
- $language_options = '';
-
- foreach ($languages as $language_file => $language_name) {
- $language_options .= \Froxlor\UI\HTML::makeoption($language_name, $language_file, Settings::Get('panel.standardlanguage'), true);
- }
$diskspace_ul = \Froxlor\UI\HTML::makecheckbox('diskspace_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$traffic_ul = \Froxlor\UI\HTML::makecheckbox('traffic_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
@@ -299,10 +295,6 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
$ftps_ul = \Froxlor\UI\HTML::makecheckbox('ftps_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
$mysqls_ul = \Froxlor\UI\HTML::makecheckbox('mysqls_ul', $lng['customer']['unlimited'], '-1', false, '0', true, true);
- $gender_options = \Froxlor\UI\HTML::makeoption($lng['gender']['undef'], 0, true, true, true);
- $gender_options .= \Froxlor\UI\HTML::makeoption($lng['gender']['male'], 1, null, true, true);
- $gender_options .= \Froxlor\UI\HTML::makeoption($lng['gender']['female'], 2, null, true, true);
-
$phpconfigs = array();
$configs = Database::query("
SELECT c.*, fc.description as interpreter
@@ -312,38 +304,37 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
while ($row = $configs->fetch(PDO::FETCH_ASSOC)) {
if ((int) Settings::Get('phpfpm.enabled') == 1) {
$phpconfigs[] = array(
- 'label' => $row['description'] . " [" . $row['interpreter'] . "]
",
+ 'label' => $row['description'] . " [" . $row['interpreter'] . "]",
'value' => $row['id']
);
} else {
$phpconfigs[] = array(
- 'label' => $row['description'] . "
",
+ 'label' => $row['description'],
'value' => $row['id']
);
}
}
// hosting plans
- $hosting_plans = "";
+ $hosting_plans = [];
$plans = Database::query("
SELECT *
FROM `" . TABLE_PANEL_PLANS . "`
ORDER BY name ASC
");
- if (Database::num_rows() > 0) {
- $hosting_plans .= \Froxlor\UI\HTML::makeoption("---", 0, 0, true, true);
- }
+ $hosting_plans = [
+ 0 => "---"
+ ];
while ($row = $plans->fetch(PDO::FETCH_ASSOC)) {
- $hosting_plans .= \Froxlor\UI\HTML::makeoption($row['name'], $row['id'], 0, true, true);
+ $hosting_plans[$row['id']] = $row['name'];
}
$customer_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_add.php';
- $customer_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($customer_add_data);
- $title = $customer_add_data['customer_add']['title'];
- $image = $customer_add_data['customer_add']['image'];
-
- eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers_add") . "\";");
+ UI::TwigBuffer('user/form.html.twig', [
+ 'formdata' => $customer_add_data['customer_add']
+ ]);
+ UI::TwigOutputBuffer();
}
} elseif ($action == 'edit' && $id != 0) {
diff --git a/lib/formfields/admin/customer/formfield.customer_add.php b/lib/formfields/admin/customer/formfield.customer_add.php
index 3fe58af5..2cd7c562 100644
--- a/lib/formfields/admin/customer/formfield.customer_add.php
+++ b/lib/formfields/admin/customer/formfield.customer_add.php
@@ -17,7 +17,7 @@
return array(
'customer_add' => array(
'title' => $lng['admin']['customer_add'],
- 'image' => 'icons/user_add.png',
+ 'image' => 'fa-solid fa-user-plus',
'sections' => array(
'section_a' => array(
'title' => $lng['admin']['accountdata'],
@@ -25,33 +25,20 @@ return array(
'fields' => array(
'new_loginname' => array(
'label' => $lng['login']['username'],
- 'type' => 'text'
+ 'type' => 'text',
+ 'placeholder' => 'Leave empty for autogenerated value'
),
'createstdsubdomain' => array(
'label' => $lng['admin']['stdsubdomain_add'] . '?',
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- ),
- 'value' => array(
- \Froxlor\Settings::Get('system.createstdsubdom_default')
- )
+ 'value' => '1',
+ 'checked' => \Froxlor\Settings::Get('system.createstdsubdom_default')
),
'store_defaultindex' => array(
'label' => $lng['admin']['store_defaultindex'] . '?',
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- ),
- 'value' => array(
- '1'
- )
+ 'value' => '1',
+ 'checked' => true
),
'new_customer_password' => array(
'label' => $lng['login']['password'],
@@ -62,39 +49,27 @@ return array(
'label' => $lng['customer']['generated_pwd'],
'type' => 'text',
'visible' => (\Froxlor\Settings::Get('panel.password_regex') == ''),
- 'value' => \Froxlor\System\Crypt::generatePassword()
+ 'value' => \Froxlor\System\Crypt::generatePassword(),
+ 'readonly' => true
),
'sendpassword' => array(
'label' => $lng['admin']['sendpassword'],
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- ),
- 'value' => array(
- '1'
- )
+ 'value' => '1',
+ 'checked' => true
),
'def_language' => array(
'label' => $lng['login']['language'],
'type' => 'select',
- 'select_var' => $language_options
+ 'select_var' => $languages,
+ 'selected' => \Froxlor\Settings::Get('panel.standardlanguage')
),
'api_allowed' => array(
'label' => $lng['usersettings']['api_allowed']['title'],
'desc' => $lng['usersettings']['api_allowed']['description'],
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- ),
- 'value' => array(
- (\Froxlor\Settings::Get('api.enabled') == '1' ? '1' : '0')
- ),
+ 'value' => '1',
+ 'checked' => (\Froxlor\Settings::Get('api.enabled') == '1' ? true : false),
'visible' => (\Froxlor\Settings::Get('api.enabled') == '1' ? true : false)
)
)
@@ -116,7 +91,11 @@ return array(
'gender' => array(
'label' => $lng['gender']['title'],
'type' => 'select',
- 'select_var' => $gender_options
+ 'select_var' => [
+ 0 => $lng['gender']['undef'],
+ 1 => $lng['gender']['male'],
+ 2 => $lng['gender']['female']
+ ]
),
'company' => array(
'label' => $lng['customer']['company'],
@@ -163,13 +142,8 @@ return array(
'custom_notes_show' => array(
'label' => $lng['usersettings']['custom_notes']['show'],
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- ),
- 'value' => array()
+ 'value' => '1',
+ 'checked' => false
)
)
),
@@ -249,29 +223,15 @@ return array(
'email_imap' => array(
'label' => $lng['customer']['email_imap'],
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- ),
- 'value' => array(
- '1'
- ),
+ 'value' => '1',
+ 'checked' => true,
'mandatory' => true
),
'email_pop3' => array(
'label' => $lng['customer']['email_pop3'],
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- ),
- 'value' => array(
- '1'
- ),
+ 'value' => '1',
+ 'checked' => true,
'mandatory' => true
),
'ftps' => array(
@@ -292,58 +252,39 @@ return array(
'phpenabled' => array(
'label' => $lng['admin']['phpenabled'] . '?',
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- ),
- 'value' => array(
- '1'
- )
+ 'value' => '1',
+ 'checked' => true
),
'allowed_phpconfigs' => array(
'visible' => (((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 || (int) \Froxlor\Settings::Get('phpfpm.enabled') == 1) ? true : false),
'label' => $lng['admin']['phpsettings']['title'],
'type' => 'checkbox',
'values' => $phpconfigs,
- 'value' => ((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 ? array(
+ 'value' => ((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 ?
\Froxlor\Settings::Get('system.mod_fcgid_defaultini')
- ) : ((int) \Froxlor\Settings::Get('phpfpm.enabled') == 1 ? array(
+ : ((int) \Froxlor\Settings::Get('phpfpm.enabled') == 1 ?
\Froxlor\Settings::Get('phpfpm.defaultini')
- ) : array())),
+ : null)),
'is_array' => 1
),
'perlenabled' => array(
'label' => $lng['admin']['perlenabled'] . '?',
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- )
+ 'value' => '1',
+ 'checked' => false
),
'dnsenabled' => array(
'label' => $lng['admin']['dnsenabled'] . '?',
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- ),
+ 'value' => '1',
+ 'checked' => (\Froxlor\Settings::Get('system.dnsenabled') == '1' ? true : false),
'visible' => (\Froxlor\Settings::Get('system.dnsenabled') == '1' ? true : false)
),
'logviewenabled' => array(
'label' => $lng['admin']['logviewenabled'] . '?',
'type' => 'checkbox',
- 'values' => array(
- array(
- 'label' => $lng['panel']['yes'],
- 'value' => '1'
- )
- )
+ 'value' => '1',
+ 'checked' => true
)
)
)
diff --git a/templates/Froxlor/form/form.html.twig b/templates/Froxlor/form/form.html.twig
new file mode 100644
index 00000000..93da2836
--- /dev/null
+++ b/templates/Froxlor/form/form.html.twig
@@ -0,0 +1,48 @@
+{% macro form(form_data, action, title = "") %}
+
+ {% import "Froxlor/form/formfields.html.twig" as formfields %}
+
+