From 0b70aa28350be682e1adc7b8c7d692fd1d3568e9 Mon Sep 17 00:00:00 2001 From: Alexander Walther Date: Thu, 18 Jan 2024 14:26:03 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Rekursives=20Sortieren=20aller=20JSON-Table?= =?UTF-8?q?set-Export-Schl=C3=BCssel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Einfachere Nachverfolgung von Ă„nderungen, wenn das Tableset in einem GitHub-Repository aktualisiert wird (z.B. YForm-basierte Addons) --- plugins/manager/lib/yform/manager/table/api.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/manager/lib/yform/manager/table/api.php b/plugins/manager/lib/yform/manager/table/api.php index 26c27fe2..9b4580ef 100644 --- a/plugins/manager/lib/yform/manager/table/api.php +++ b/plugins/manager/lib/yform/manager/table/api.php @@ -130,7 +130,17 @@ public static function exportTablesets(array $table_names) ]; } - return json_encode($export, JSON_PRETTY_PRINT); + return json_encode(self::recursive_ksort($export), JSON_PRETTY_PRINT); + } + /** + * @param array $array + * @return array + */ + public static function recursive_ksort(&$array) { + foreach ($array as &$value) { + if (is_array($value)) recursive_ksort($value); + } + return ksort($array); } /** From 1f176c52a85bc2a7bffc05ed2b86f8f294a81bd0 Mon Sep 17 00:00:00 2001 From: Alexander Walther Date: Fri, 21 Jun 2024 15:20:12 +0200 Subject: [PATCH 2/4] Update api.php --- .../manager/lib/yform/manager/table/api.php | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plugins/manager/lib/yform/manager/table/api.php b/plugins/manager/lib/yform/manager/table/api.php index 9b4580ef..bcd0d1b2 100644 --- a/plugins/manager/lib/yform/manager/table/api.php +++ b/plugins/manager/lib/yform/manager/table/api.php @@ -117,6 +117,13 @@ public static function importTablesets(string $tableset_content): bool */ public static function exportTablesets(array $table_names) { + $recursiveKsort = function(&$array) use (&$recursiveKsort) { + foreach ($array as &$value) { + if (is_array($value)) $recursiveKsort($value); + } + ksort($array); + }; + $export = []; foreach ($table_names as $table_name) { $export_table = rex_yform_manager_table::get($table_name); @@ -130,17 +137,8 @@ public static function exportTablesets(array $table_names) ]; } - return json_encode(self::recursive_ksort($export), JSON_PRETTY_PRINT); - } - /** - * @param array $array - * @return array - */ - public static function recursive_ksort(&$array) { - foreach ($array as &$value) { - if (is_array($value)) recursive_ksort($value); - } - return ksort($array); + $recursiveKsort($export); + return json_encode($export, JSON_PRETTY_PRINT); } /** From 5f3f35f8acdc893039e8330f5ab0b30ebe099af4 Mon Sep 17 00:00:00 2001 From: Alexander Walther Date: Fri, 30 Aug 2024 14:09:31 +0200 Subject: [PATCH 3/4] Update api.php --- plugins/manager/lib/yform/manager/table/api.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/manager/lib/yform/manager/table/api.php b/plugins/manager/lib/yform/manager/table/api.php index bcd0d1b2..2934c4b4 100644 --- a/plugins/manager/lib/yform/manager/table/api.php +++ b/plugins/manager/lib/yform/manager/table/api.php @@ -131,13 +131,12 @@ public static function exportTablesets(array $table_names) foreach ($export_table->getFields() as $field) { $export_fields[] = array_diff_key($field->toArray(), ['id' => 0]); } - $export[$export_table['table_name']] = [ + $export[$export_table['table_name']] = $recursiveKsort([ 'table' => array_diff_key($export_table->toArray(), ['id' => 0, 'prio' => 0]), 'fields' => $export_fields, - ]; + ](; } - $recursiveKsort($export); return json_encode($export, JSON_PRETTY_PRINT); } From 754eb85f1760a68d89333ffeec803a6353d7e482 Mon Sep 17 00:00:00 2001 From: Alexander Walther Date: Fri, 30 Aug 2024 14:09:53 +0200 Subject: [PATCH 4/4] Update api.php --- plugins/manager/lib/yform/manager/table/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/manager/lib/yform/manager/table/api.php b/plugins/manager/lib/yform/manager/table/api.php index 2934c4b4..c253945d 100644 --- a/plugins/manager/lib/yform/manager/table/api.php +++ b/plugins/manager/lib/yform/manager/table/api.php @@ -134,7 +134,7 @@ public static function exportTablesets(array $table_names) $export[$export_table['table_name']] = $recursiveKsort([ 'table' => array_diff_key($export_table->toArray(), ['id' => 0, 'prio' => 0]), 'fields' => $export_fields, - ](; + ]); } return json_encode($export, JSON_PRETTY_PRINT);