From fe75f1d7246eedff4628fc5b2174a1ead28afb42 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Wed, 11 Jan 2023 07:06:28 +0900 Subject: [PATCH] Add missing table arrays and name fix schim missed two table arrays as class EditVisibleGroup and EditAccess also fix wrong name for EditSchemas (wrong: EditSchemes) with a shim lookup. edit_schemes.php file will stay the same for now. --- www/lib/CoreLibs/Output/Form/Generate.php | 12 +- .../Output/Form/TableArrays/EditAccess.php | 140 ++++++++++++++++++ .../Form/TableArrays/EditVisibleGroup.php | 61 ++++++++ www/vendor/composer/autoload_classmap.php | 2 + www/vendor/composer/autoload_static.php | 2 + 5 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 www/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php create mode 100644 www/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php diff --git a/www/lib/CoreLibs/Output/Form/Generate.php b/www/lib/CoreLibs/Output/Form/Generate.php index 7ba1f1b7..d560e6fb 100644 --- a/www/lib/CoreLibs/Output/Form/Generate.php +++ b/www/lib/CoreLibs/Output/Form/Generate.php @@ -472,12 +472,22 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO */ private function loadTableArray() { + // note: it schould be Schemas but an original type made it to this + // this file is kept for the old usage, new one should be EditSchemas + $table_array_shim = [ + 'EditSchemes' => 'EditSchemas' + ]; // camel case $this->my_page_name from foo_bar_note to FooBarNote $page_name_camel_case = ''; foreach (explode('_', $this->my_page_name) as $part) { $page_name_camel_case .= ucfirst($part); } - $class_string = __NAMESPACE__ . "\\TableArrays\\" . $page_name_camel_case; + $class_string = __NAMESPACE__ . "\\TableArrays\\" + . ( + // shim lookup + $table_array_shim[$page_name_camel_case] ?? + $page_name_camel_case + ); try { /** @var \CoreLibs\Output\Form\TableArraysInterface|false $class */ $class = new $class_string($this); diff --git a/www/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php b/www/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php new file mode 100644 index 00000000..84b2bf9a --- /dev/null +++ b/www/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php @@ -0,0 +1,140 @@ +form = $form; + $this->form->log->debug('CLASS LOAD', __NAMESPACE__ . __CLASS__); + } + + /** + * return the table array + * + * @return array + */ + public function setTableArray(): array + { + return [ + 'table_array' => [ + 'edit_access_id' => [ + 'value' => $_POST['edit_access_id'] ?? '', + 'type' => 'hidden', + 'pk' => 1 + ], + 'name' => [ + 'value' => $_POST['name'] ?? '', + 'output_name' => 'Access Group Name', + 'mandatory' => 1, + 'type' => 'text', + 'error_check' => 'alphanumericspace|unique' + ], + 'description' => [ + 'value' => $_POST['description'] ?? '', + 'output_name' => 'Description', + 'type' => 'textarea' + ], + 'color' => [ + 'value' => $_POST['color'] ?? '', + 'output_name' => 'Color', + 'mandatory' => 0, + 'type' => 'text', + 'size' => 10, + 'length' => 9, + 'error_check' => 'custom', + // FIXME: update regex check for hex/rgb/hsl with color check class + 'error_regex' => '/^#([\dA-Fa-f]{6}|[\dA-Fa-f]{8})$/', + 'error_example' => '#F6A544' + ], + 'enabled' => [ + 'value' => $_POST['enabled'] ?? 0, + 'output_name' => 'Enabled', + 'type' => 'binary', + 'int' => 1, // OR 'bool' => 1 + 'element_list' => [ + '1' => 'Yes', + '0' => 'No' + ], + ], + 'protected' => [ + 'value' => $_POST['protected'] ?? 0, + 'output_name' => 'Protected', + 'type' => 'binary', + 'int' => 1, + 'element_list' => [ + '1' => 'Yes', + '0' => 'No' + ], + ], + 'additional_acl' => [ + 'value' => $_POST['additional_acl'] ?? '', + 'output_name' => 'Additional ACL (as JSON)', + 'type' => 'textarea', + 'error_check' => 'json', + 'rows' => 10, + 'cols' => 60 + ], + ], + 'table_name' => 'edit_access', + "load_query" => "SELECT edit_access_id, name FROM edit_access ORDER BY name", + 'show_fields' => [ + [ + 'name' => 'name' + ], + ], + 'element_list' => [ + 'edit_access_data' => [ + 'output_name' => 'Edit Access Data', + 'delete_name' => 'remove_edit_access_data', + // is not a sub table read and connect, but only a sub table with data + // 'type' => 'reference_data', + // maxium visible if no data is set, if filled add this number to visible + 'max_empty' => 5, + 'prefix' => 'ead', + 'elements' => [ + 'name' => [ + 'type' => 'text', + 'error_check' => 'alphanumeric|unique', + 'output_name' => 'Name', + 'mandatory' => 1 + ], + 'value' => [ + 'type' => 'text', + 'output_name' => 'Value' + ], + 'enabled' => [ + 'type' => 'checkbox', + 'output_name' => 'Activate', + 'int' => 1, + 'element_list' => [1] + ], + /*'edit_access_id' => [ + 'int' => 1, + 'type' => 'hidden', + // reference main key from master table above + 'fk_id' => 1 + ],*/ + 'edit_access_data_id' => [ + 'type' => 'hidden', + 'int' => 1, + 'pk_id' => 1 + ], + ], + ], + ], + ]; + } +} + +// __END__ diff --git a/www/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php b/www/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php new file mode 100644 index 00000000..9c82caab --- /dev/null +++ b/www/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php @@ -0,0 +1,61 @@ +form = $form; + $this->form->log->debug('CLASS LOAD', __NAMESPACE__ . __CLASS__); + } + + /** + * return the table array + * + * @return array + */ + public function setTableArray(): array + { + return [ + 'table_array' => [ + 'edit_visible_group_id' => [ + 'value' => $_POST['edit_visible_group_id'] ?? '', + 'type' => 'hidden', + 'pk' => 1 + ], + 'name' => [ + 'value' => $_POST['name'] ?? '', + 'output_name' => 'Group name', + 'mandatory' => 1, + 'type' => 'text' + ], + 'flag' => [ + 'value' => $_POST['flag'] ?? '', + 'output_name' => 'Flag', + 'mandatory' => 1, + 'type' => 'text', + 'error_check' => 'alphanumeric|unique' + ], + ], + 'table_name' => 'edit_visible_group', + 'load_query' => "SELECT edit_visible_group_id, name FROM edit_visible_group ORDER BY name", + 'show_fields' => [ + [ + 'name' => 'name' + ], + ], + ]; + } +} + +// __END__ diff --git a/www/vendor/composer/autoload_classmap.php b/www/vendor/composer/autoload_classmap.php index 5eb762bd..4408f1f4 100644 --- a/www/vendor/composer/autoload_classmap.php +++ b/www/vendor/composer/autoload_classmap.php @@ -58,12 +58,14 @@ return array( 'CoreLibs\\Output\\Form\\Elements' => $baseDir . '/lib/CoreLibs/Output/Form/Elements.php', 'CoreLibs\\Output\\Form\\Generate' => $baseDir . '/lib/CoreLibs/Output/Form/Generate.php', 'CoreLibs\\Output\\Form\\TableArraysInterface' => $baseDir . '/lib/CoreLibs/Output/TableArraysInterface.php', + 'CoreLibs\\Output\\Form\\TableArrays\\EditAccess' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditGroups' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditGroups.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditLanguages' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditLanguages.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditMenuGroup' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditMenuGroup.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditPages' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditPages.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditSchemas' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditSchemas.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditUsers' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditUsers.php', + 'CoreLibs\\Output\\Form\\TableArrays\\EditVisibleGroup' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php', 'CoreLibs\\Output\\Form\\Token' => $baseDir . '/lib/CoreLibs/Output/Form/Token.php', 'CoreLibs\\Output\\Image' => $baseDir . '/lib/CoreLibs/Output/Image.php', 'CoreLibs\\Output\\ProgressBar' => $baseDir . '/lib/CoreLibs/Output/ProgressBar.php', diff --git a/www/vendor/composer/autoload_static.php b/www/vendor/composer/autoload_static.php index a2faf519..9661276c 100644 --- a/www/vendor/composer/autoload_static.php +++ b/www/vendor/composer/autoload_static.php @@ -91,12 +91,14 @@ class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9 'CoreLibs\\Output\\Form\\Elements' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/Elements.php', 'CoreLibs\\Output\\Form\\Generate' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/Generate.php', 'CoreLibs\\Output\\Form\\TableArraysInterface' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/TableArraysInterface.php', + 'CoreLibs\\Output\\Form\\TableArrays\\EditAccess' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditGroups' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditGroups.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditLanguages' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditLanguages.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditMenuGroup' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditMenuGroup.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditPages' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditPages.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditSchemas' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditSchemas.php', 'CoreLibs\\Output\\Form\\TableArrays\\EditUsers' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditUsers.php', + 'CoreLibs\\Output\\Form\\TableArrays\\EditVisibleGroup' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php', 'CoreLibs\\Output\\Form\\Token' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/Token.php', 'CoreLibs\\Output\\Image' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Image.php', 'CoreLibs\\Output\\ProgressBar' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/ProgressBar.php',