From 2bf78b9f5d0e48308259aeefd253780a8331a5e3 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 23 Sep 2025 14:35:40 +0200 Subject: [PATCH 1/5] InlineFormView: split off from TabularData template --- templates/InlineFormView.php | 100 +++++++++++++++++++++++++++++++++++ templates/TabularData.php | 94 +------------------------------- 2 files changed, 102 insertions(+), 92 deletions(-) create mode 100644 templates/InlineFormView.php diff --git a/templates/InlineFormView.php b/templates/InlineFormView.php new file mode 100644 index 00000000..b047b6b1 --- /dev/null +++ b/templates/InlineFormView.php @@ -0,0 +1,100 @@ +'; + else + echo ' +
'; + + if (!empty($form['is_group'])) + echo ' +
'; + + if (!empty($form['fields'])) + { + foreach ($form['fields'] as $name => $field) + { + if ($field['type'] === 'select') + { + echo ' + '; + } + else + echo ' + '; + + if (isset($field['html_after'])) + echo $field['html_after']; + } + } + + echo ' + '; + + if (!empty($form['buttons'])) + foreach ($form['buttons'] as $name => $button) + { + echo ' + '; + + if (isset($button['html_after'])) + echo $button['html_after']; + } + + if (!empty($form['is_group'])) + echo ' +
'; + + if (!isset($form['is_embed'])) + echo ' + '; + else + echo ' +
'; + } +} diff --git a/templates/TabularData.php b/templates/TabularData.php index b6df151a..099ae4c8 100644 --- a/templates/TabularData.php +++ b/templates/TabularData.php @@ -3,7 +3,7 @@ * TabularData.php * Contains the template that displays tabular data. * - * Kabuki CMS (C) 2013-2023, Aaron van Geffen + * Kabuki CMS (C) 2013-2025, Aaron van Geffen *****************************************************************************/ class TabularData extends SubTemplate @@ -79,7 +79,7 @@ class TabularData extends SubTemplate // Form controls? if (isset($form)) - $this->renderInlineForm($form); + InlineFormView::renderInlineForm($form); echo ' '; @@ -146,94 +146,4 @@ class TabularData extends SubTemplate echo ' '; } - - protected function renderInlineForm($form) - { - if (!isset($form['is_embed'])) - echo ' -
'; - else - echo ' -
'; - - if (!empty($form['is_group'])) - echo ' -
'; - - if (!empty($form['fields'])) - { - foreach ($form['fields'] as $name => $field) - { - if ($field['type'] === 'select') - { - echo ' - '; - } - else - echo ' - '; - - if (isset($field['html_after'])) - echo $field['html_after']; - } - } - - echo ' - '; - - if (!empty($form['buttons'])) - foreach ($form['buttons'] as $name => $button) - { - echo ' - '; - - if (isset($button['html_after'])) - echo $button['html_after']; - } - - if (!empty($form['is_group'])) - echo ' -
'; - - if (!isset($form['is_embed'])) - echo ' - '; - else - echo ' -
'; - } } From 2dea80b58e732d7dd57e2e9e030bec5a970b0753 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 23 Sep 2025 14:42:47 +0200 Subject: [PATCH 2/5] InlineFormView: split rendering into smaller methods --- templates/InlineFormView.php | 102 ++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/templates/InlineFormView.php b/templates/InlineFormView.php index b047b6b1..b3f7368d 100644 --- a/templates/InlineFormView.php +++ b/templates/InlineFormView.php @@ -26,42 +26,9 @@ class InlineFormView foreach ($form['fields'] as $name => $field) { if ($field['type'] === 'select') - { - echo ' - '; - } + self::renderSelectBox($field, $name); else - echo ' - '; + self::renderInputBox($field, $name); if (isset($field['html_after'])) echo $field['html_after']; @@ -74,13 +41,7 @@ class InlineFormView if (!empty($form['buttons'])) foreach ($form['buttons'] as $name => $button) { - echo ' - '; + self::renderSubmitButton($button, $name); if (isset($button['html_after'])) echo $button['html_after']; @@ -97,4 +58,61 @@ class InlineFormView echo ' '; } + + private static function renderInputBox(array $field, $name) + { + echo ' + '; + } + + private static function renderSelectBox(array $field, $name) + { + echo ' + '; + } + + private static function renderSubmitButton(array $button, $name) + { + echo ' + '; + } } From 0274ff5bf46bcbc41a273d3d2c36abee86707154 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 23 Sep 2025 14:44:07 +0200 Subject: [PATCH 3/5] InlineFormView: remove support for unused 'html_after' property --- templates/InlineFormView.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/templates/InlineFormView.php b/templates/InlineFormView.php index b3f7368d..c6f17367 100644 --- a/templates/InlineFormView.php +++ b/templates/InlineFormView.php @@ -29,9 +29,6 @@ class InlineFormView self::renderSelectBox($field, $name); else self::renderInputBox($field, $name); - - if (isset($field['html_after'])) - echo $field['html_after']; } } @@ -42,9 +39,6 @@ class InlineFormView foreach ($form['buttons'] as $name => $button) { self::renderSubmitButton($button, $name); - - if (isset($button['html_after'])) - echo $button['html_after']; } if (!empty($form['is_group'])) From 77fa33730a6e21937f6430cd0ad1cc7b50d00064 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 23 Sep 2025 14:48:08 +0200 Subject: [PATCH 4/5] InlineFormView: combine fields and buttons into one 'controls' array --- controllers/ManageAssets.php | 2 +- controllers/ManageErrors.php | 2 +- controllers/ManageTags.php | 2 +- controllers/ManageUsers.php | 2 +- templates/InlineFormView.php | 21 +++++++-------------- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/controllers/ManageAssets.php b/controllers/ManageAssets.php index 59895fff..1d732001 100644 --- a/controllers/ManageAssets.php +++ b/controllers/ManageAssets.php @@ -25,7 +25,7 @@ class ManageAssets extends HTMLController 'method' => 'post', 'class' => 'col-md-6 text-end', 'is_embed' => true, - 'buttons' => [ + 'controls' => [ 'deleteChecked' => [ 'type' => 'submit', 'caption' => 'Delete checked', diff --git a/controllers/ManageErrors.php b/controllers/ManageErrors.php index 75186aa1..b8f608c2 100644 --- a/controllers/ManageErrors.php +++ b/controllers/ManageErrors.php @@ -30,7 +30,7 @@ class ManageErrors extends HTMLController 'action' => BASEURL . '/manageerrors/?' . Session::getSessionTokenKey() . '=' . Session::getSessionToken(), 'method' => 'post', 'class' => 'col-md-6 text-end', - 'buttons' => [ + 'controls' => [ 'clear' => [ 'type' => 'submit', 'caption' => 'Delete all', diff --git a/controllers/ManageTags.php b/controllers/ManageTags.php index 9dc653b2..6f79df7f 100644 --- a/controllers/ManageTags.php +++ b/controllers/ManageTags.php @@ -21,7 +21,7 @@ class ManageTags extends HTMLController 'action' => BASEURL . '/edittag/', 'method' => 'get', 'class' => 'col-md-6 text-end', - 'buttons' => [ + 'controls' => [ 'add' => [ 'type' => 'submit', 'caption' => 'Add new tag', diff --git a/controllers/ManageUsers.php b/controllers/ManageUsers.php index 9e80cb95..a8c35ee2 100644 --- a/controllers/ManageUsers.php +++ b/controllers/ManageUsers.php @@ -21,7 +21,7 @@ class ManageUsers extends HTMLController 'action' => BASEURL . '/edituser/', 'method' => 'get', 'class' => 'col-md-6 text-end', - 'buttons' => [ + 'controls' => [ 'add' => [ 'type' => 'submit', 'caption' => 'Add new user', diff --git a/templates/InlineFormView.php b/templates/InlineFormView.php index c6f17367..779146ec 100644 --- a/templates/InlineFormView.php +++ b/templates/InlineFormView.php @@ -21,26 +21,19 @@ class InlineFormView echo '
'; - if (!empty($form['fields'])) + foreach ($form['controls'] as $name => $control) { - foreach ($form['fields'] as $name => $field) - { - if ($field['type'] === 'select') - self::renderSelectBox($field, $name); - else - self::renderInputBox($field, $name); - } + if ($control['type'] === 'select') + self::renderSelectBox($control, $name); + elseif ($control['type'] === 'submit') + self::renderSubmitButton($control, $name); + else + self::renderInputBox($control, $name); } echo ' '; - if (!empty($form['buttons'])) - foreach ($form['buttons'] as $name => $button) - { - self::renderSubmitButton($button, $name); - } - if (!empty($form['is_group'])) echo '
'; From 2af4e865e0e4b9036b9f6af28019739c689942c3 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 23 Sep 2025 15:04:57 +0200 Subject: [PATCH 5/5] TabularData: take control of juxtapositing pager and form --- controllers/ManageAlbums.php | 4 +--- controllers/ManageAssets.php | 2 -- controllers/ManageErrors.php | 2 -- controllers/ManageTags.php | 4 +--- controllers/ManageUsers.php | 2 -- templates/InlineFormView.php | 4 ++-- templates/TabularData.php | 20 ++++++++++++++++++-- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/controllers/ManageAlbums.php b/controllers/ManageAlbums.php index 248e3694..d5176e29 100644 --- a/controllers/ManageAlbums.php +++ b/controllers/ManageAlbums.php @@ -18,8 +18,7 @@ class ManageAlbums extends HTMLController 'form' => [ 'action' => BASEURL . '/editalbum/', 'method' => 'get', - 'class' => 'col-md-6 text-end', - 'buttons' => [ + 'controls' => [ 'add' => [ 'type' => 'submit', 'caption' => 'Add new album', @@ -58,7 +57,6 @@ class ManageAlbums extends HTMLController 'title' => 'Manage albums', 'no_items_label' => 'No albums meet the requirements of the current filter.', 'items_per_page' => 9999, - 'index_class' => 'col-md-6', 'base_url' => BASEURL . '/managealbums/', 'get_data' => function($offset, $limit, $order, $direction) { return Tag::getOffset($offset, $limit, $order, $direction, true); diff --git a/controllers/ManageAssets.php b/controllers/ManageAssets.php index 1d732001..d4461e41 100644 --- a/controllers/ManageAssets.php +++ b/controllers/ManageAssets.php @@ -23,7 +23,6 @@ class ManageAssets extends HTMLController 'form' => [ 'action' => BASEURL . '/manageassets/?' . Session::getSessionTokenKey() . '=' . Session::getSessionToken(), 'method' => 'post', - 'class' => 'col-md-6 text-end', 'is_embed' => true, 'controls' => [ 'deleteChecked' => [ @@ -113,7 +112,6 @@ class ManageAssets extends HTMLController 'title' => 'Manage assets', 'no_items_label' => 'No assets meet the requirements of the current filter.', 'items_per_page' => 30, - 'index_class' => 'col-md-6', 'base_url' => BASEURL . '/manageassets/', 'get_data' => 'Asset::getOffset', 'get_count' => 'Asset::getCount', diff --git a/controllers/ManageErrors.php b/controllers/ManageErrors.php index b8f608c2..f0fbb26b 100644 --- a/controllers/ManageErrors.php +++ b/controllers/ManageErrors.php @@ -29,7 +29,6 @@ class ManageErrors extends HTMLController 'form' => [ 'action' => BASEURL . '/manageerrors/?' . Session::getSessionTokenKey() . '=' . Session::getSessionToken(), 'method' => 'post', - 'class' => 'col-md-6 text-end', 'controls' => [ 'clear' => [ 'type' => 'submit', @@ -95,7 +94,6 @@ class ManageErrors extends HTMLController 'sort_direction' => $_GET['dir'] ?? '', 'no_items_label' => "No errors to display -- we're all good!", 'items_per_page' => 20, - 'index_class' => 'col-md-6', 'base_url' => BASEURL . '/manageerrors/', 'get_count' => 'ErrorLog::getCount', 'get_data' => 'ErrorLog::getOffset', diff --git a/controllers/ManageTags.php b/controllers/ManageTags.php index 6f79df7f..ce937e5a 100644 --- a/controllers/ManageTags.php +++ b/controllers/ManageTags.php @@ -20,7 +20,6 @@ class ManageTags extends HTMLController 'form' => [ 'action' => BASEURL . '/edittag/', 'method' => 'get', - 'class' => 'col-md-6 text-end', 'controls' => [ 'add' => [ 'type' => 'submit', @@ -70,8 +69,7 @@ class ManageTags extends HTMLController 'sort_direction' => $_GET['dir'] ?? '', 'title' => 'Manage tags', 'no_items_label' => 'No tags meet the requirements of the current filter.', - 'items_per_page' => 30, - 'index_class' => 'col-md-6', + 'items_per_page' => 9999, 'base_url' => BASEURL . '/managetags/', 'get_data' => function($offset, $limit, $order, $direction) { return Tag::getOffset($offset, $limit, $order, $direction, false); diff --git a/controllers/ManageUsers.php b/controllers/ManageUsers.php index a8c35ee2..0f7f419f 100644 --- a/controllers/ManageUsers.php +++ b/controllers/ManageUsers.php @@ -20,7 +20,6 @@ class ManageUsers extends HTMLController 'form' => [ 'action' => BASEURL . '/edituser/', 'method' => 'get', - 'class' => 'col-md-6 text-end', 'controls' => [ 'add' => [ 'type' => 'submit', @@ -86,7 +85,6 @@ class ManageUsers extends HTMLController 'title' => 'Manage users', 'no_items_label' => 'No users meet the requirements of the current filter.', 'items_per_page' => 30, - 'index_class' => 'col-md-6', 'base_url' => BASEURL . '/manageusers/', 'get_data' => 'Member::getOffset', 'get_count' => 'Member::getCount', diff --git a/templates/InlineFormView.php b/templates/InlineFormView.php index 779146ec..c737ff43 100644 --- a/templates/InlineFormView.php +++ b/templates/InlineFormView.php @@ -12,10 +12,10 @@ class InlineFormView { if (!isset($form['is_embed'])) echo ' -
'; + '; else echo ' -
'; +
'; if (!empty($form['is_group'])) echo ' diff --git a/templates/TabularData.php b/templates/TabularData.php index 099ae4c8..5c558fa1 100644 --- a/templates/TabularData.php +++ b/templates/TabularData.php @@ -68,19 +68,35 @@ class TabularData extends SubTemplate } } - protected function renderPaginationForm($pager, $form, $class='row') + protected function renderPaginationForm($pager, $form) { echo ' -
'; +
'; // Page index? if (!empty($pager)) + { + echo ' +
'; + PageIndexWidget::paginate($pager); + echo ' +
'; + } + // Form controls? if (isset($form)) + { + echo ' +
'; + InlineFormView::renderInlineForm($form); + echo ' +
'; + } + echo '
'; }