From 40e68c1222e7d2bb2d7559779ed146d42cdc4f5f Mon Sep 17 00:00:00 2001 From: christophboecker Date: Sun, 1 Sep 2024 14:20:14 +0200 Subject: [PATCH 1/4] TODO und FIXME eingetragen --- install.php | 1 + lib/Entry.php | 1 + package.yml | 1 + uninstall.php | 1 + 4 files changed, 4 insertions(+) diff --git a/install.php b/install.php index 74112a4..ece2732 100644 --- a/install.php +++ b/install.php @@ -40,6 +40,7 @@ if (null === rex_media::get($fallbackImage)) { rex_file::copy(__DIR__ . '/install/' . $fallbackImage, rex_path::media($fallbackImage)); $data = []; + // TODO: Text nach *.lang verlagern $data['title'] = 'Aktuelles - Fallback-Image'; $data['category_id'] = 0; $data['file'] = [ diff --git a/lib/Entry.php b/lib/Entry.php index f8f5327..647709e 100644 --- a/lib/Entry.php +++ b/lib/Entry.php @@ -549,6 +549,7 @@ public static function findByCategoryIds(string|array|null $category_ids = null, } // whereInList anwenden + // FIXME: whereInList gibt es nicht! Ist $query->whereListContains() gemeint? $query->whereInList('category_ids', $category_ids); } diff --git a/package.yml b/package.yml index bcf55d3..641cc79 100644 --- a/package.yml +++ b/package.yml @@ -57,6 +57,7 @@ pages: default_config: default_author: "Redaktion" default_thumbnail: "neues_entry_fallback_image.png" + # TODO: Text nach *.lang verlagern external_url_label: "Zur Website" editor: 'class="form-control redactor-editor--default"' url_profile: false diff --git a/uninstall.php b/uninstall.php index 5a16990..1b18ed1 100644 --- a/uninstall.php +++ b/uninstall.php @@ -26,6 +26,7 @@ $scope = rex_request::get('nscope', 'int', 0); if (!in_array($scope, [1, 2], true)) { $context = rex_context::fromGet(); + // TODO: Texte nach *.lang verlagern $msg = '### Bitte den De-Installations-Umfang auswählen' . PHP_EOL; $msg .= '- **Minimal** (YForm-Tablesets entfernen) ⇒ **[Start](' . $context->getUrl(['nscope' => 1], false) . ')**' . PHP_EOL; $msg .= '- **Vollständig** (Tabellen, Tablesets, Cronjobs etc. entfernen) ⇒ **[Start](' . $context->getUrl(['nscope' => 2], false) . ')**' . PHP_EOL; From 6cdad5ccebec7443a4a0ed2d1c7a1c3c6e984c7b Mon Sep 17 00:00:00 2001 From: christophboecker Date: Mon, 2 Sep 2024 10:02:29 +0200 Subject: [PATCH 2/4] =?UTF-8?q?Tabellenseiten=20=C3=BCber=20nur=20eine=20D?= =?UTF-8?q?atei=20yform.php=20anzeigen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.yml | 14 +++++++ pages/neues.author.php | 34 ----------------- pages/neues.category.php | 33 ----------------- pages/neues.entry.php | 33 ----------------- pages/neues.lang.php | 33 ----------------- pages/neues.php | 12 ++++++ pages/neues.settings.php | 2 - pages/yform.php | 80 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 106 insertions(+), 135 deletions(-) delete mode 100644 pages/neues.author.php delete mode 100644 pages/neues.category.php delete mode 100644 pages/neues.entry.php delete mode 100644 pages/neues.lang.php create mode 100644 pages/yform.php diff --git a/package.yml b/package.yml index 641cc79..eb42baf 100644 --- a/package.yml +++ b/package.yml @@ -31,18 +31,22 @@ pages: title: translate:neues_entry icon: rex-icon fa-bullhorn perm: neues[date] + subPath: pages\yform.php category: title: translate:neues_category icon: rex-icon fa-folder perm: neues[category] + subPath: pages\yform.php author: title: translate:neues_author icon: rex-icon fa-user perm: neues[author] + subPath: pages\yform.php lang: title: translate:neues_lang perm: neues[lang] icon: rex-icon fa-flag + subPath: pages\yform.php settings: title: translate:neues_settings icon: rex-icon fa-gear @@ -54,6 +58,16 @@ pages: itemClass: pull-right perm: neues[docs] +yform: + neues/entry: + table_name: FriendsOfRedaxo\Neues\Entry + neues/category: + table_name: FriendsOfRedaxo\Neues\Category + neues/author: + table_name: FriendsOfRedaxo\Neues\Author + neues/lang: + table_name: FriendsOfRedaxo\Neues\EntryLang + default_config: default_author: "Redaktion" default_thumbnail: "neues_entry_fallback_image.png" diff --git a/pages/neues.author.php b/pages/neues.author.php deleted file mode 100644 index 44288c1..0000000 --- a/pages/neues.author.php +++ /dev/null @@ -1,34 +0,0 @@ -getProperty('page')['title']); - -$currentPage = rex_be_controller::getCurrentPageObject(); -$wrapper = ''; - -$table_name = Author::table()->getTableName(); - -if (!rex_request('table_name', 'string', '')) { - /* @phpstan-ignore-next-line */ - $_REQUEST['table_name'] = $table_name; -} - -if (true !== $currentPage->getItemAttr('show_title', '')) { - rex_extension::register('YFORM_MANAGER_DATA_PAGE_HEADER', static function ($ep) { - if ($ep->getParam('yform')->table->getTableName() !== $ep->getParam('table_name')) { - return; - } - return ''; - }, rex_extension::EARLY, ['table_name' => $table_name]); -} - -if ($wrapper = $currentPage->getItemAttr('wrapper_class', '')) { - echo "
"; -} - -include rex_path::plugin('yform', 'manager', 'pages/data_edit.php'); - -if ($wrapper) { - echo '
'; -} diff --git a/pages/neues.category.php b/pages/neues.category.php deleted file mode 100644 index 3618ca6..0000000 --- a/pages/neues.category.php +++ /dev/null @@ -1,33 +0,0 @@ -getProperty('page')['title']); - -$currentPage = rex_be_controller::getCurrentPageObject(); -$wrapper = ''; - -$table_name = Category::table()->getTableName(); -if (!rex_request('table_name', 'string', '')) { - /* @phpstan-ignore-next-line */ - $_REQUEST['table_name'] = $table_name; -} - -if (true !== $currentPage->getItemAttr('show_title', '')) { - rex_extension::register('YFORM_MANAGER_DATA_PAGE_HEADER', static function ($ep) { - if ($ep->getParam('yform')->table->getTableName() !== $ep->getParam('table_name')) { - return; - } - return ''; - }, rex_extension::EARLY, ['table_name' => $table_name]); -} - -if ($wrapper = $currentPage->getItemAttr('wrapper_class', '')) { - echo "
"; -} - -include rex_path::plugin('yform', 'manager', 'pages/data_edit.php'); - -if ($wrapper) { - echo '
'; -} diff --git a/pages/neues.entry.php b/pages/neues.entry.php deleted file mode 100644 index 05bc2c2..0000000 --- a/pages/neues.entry.php +++ /dev/null @@ -1,33 +0,0 @@ -getProperty('page')['title']); - -$currentPage = rex_be_controller::getCurrentPageObject(); -$wrapper = ''; - -$table_name = Entry::table()->getTableName(); -if (!rex_request('table_name', 'string', '')) { - /* @phpstan-ignore-next-line */ - $_REQUEST['table_name'] = $table_name; -} - -if (true !== $currentPage->getItemAttr('show_title', '')) { - rex_extension::register('YFORM_MANAGER_DATA_PAGE_HEADER', static function ($ep) { - if ($ep->getParam('yform')->table->getTableName() !== $ep->getParam('table_name')) { - return; - } - return ''; - }, rex_extension::EARLY, ['table_name' => $table_name]); -} - -if ($wrapper = $currentPage->getItemAttr('wrapper_class', '')) { - echo "
"; -} - -include rex_path::plugin('yform', 'manager', 'pages/data_edit.php'); - -if ($wrapper) { - echo '
'; -} diff --git a/pages/neues.lang.php b/pages/neues.lang.php deleted file mode 100644 index f78a6d0..0000000 --- a/pages/neues.lang.php +++ /dev/null @@ -1,33 +0,0 @@ -getProperty('page')['title']); - -$currentPage = rex_be_controller::getCurrentPageObject(); -$wrapper = ''; - -$table_name = EntryLang::table()->getTableName(); -if (!rex_request('table_name', 'string', '')) { - /* @phpstan-ignore-next-line */ - $_REQUEST['table_name'] = $table_name; -} - -if (true !== $currentPage->getItemAttr('show_title', '')) { - rex_extension::register('YFORM_MANAGER_DATA_PAGE_HEADER', static function ($ep) { - if ($ep->getParam('yform')->table->getTableName() !== $ep->getParam('table_name')) { - return; - } - return ''; - }, rex_extension::EARLY, ['table_name' => $table_name]); -} - -if ($wrapper = $currentPage->getItemAttr('wrapper_class', '')) { - echo "
"; -} - -include rex_path::plugin('yform', 'manager', 'pages/data_edit.php'); - -if ($wrapper) { - echo '
'; -} diff --git a/pages/neues.php b/pages/neues.php index f75e4b3..345bc9d 100644 --- a/pages/neues.php +++ b/pages/neues.php @@ -1,3 +1,15 @@ includeFile(__DIR__ . '/neues.docs.php'); + return; +} + +echo rex_view::title(rex_addon::get('neues')->getProperty('page')['title']); rex_be_controller::includeCurrentPageSubPath(); diff --git a/pages/neues.settings.php b/pages/neues.settings.php index c78cc4f..5d16be3 100644 --- a/pages/neues.settings.php +++ b/pages/neues.settings.php @@ -1,7 +1,5 @@ getProperty('page')['title']); - $addon = rex_addon::get('neues'); $form = rex_config_form::factory($addon->getName()); diff --git a/pages/yform.php b/pages/yform.php new file mode 100644 index 0000000..97fe337 --- /dev/null +++ b/pages/yform.php @@ -0,0 +1,80 @@ +getTableName() zu rex_tabelle + * + * @see https://friendsofredaxo.github.io/tricks/addons/yform/im-addon + * @var \rex_addon $this + */ + +$yform = $this->getProperty('yform', []); +$yform = $yform[\rex_be_controller::getCurrentPage()] ?? []; + +if( isset($yform['table_name']) ) { + $table_name = $yform['table_name']; + if( is_subclass_of($table_name,rex_yform_manager_dataset::class)) { + // table_name ist eine Dataset-Klasse + $table_name = $table_name::table()->getTableName(); + } else { + // table_name ist ein Tabellenname + $table_name = rex::getTable($table_name); + } +} else { + $table_name = ''; +} + +$table_name = rex_request('table_name', 'string', $table_name); +$show_title = true === ($yform['show_title'] ?? false); +$wrapper_class = $yform['wrapper_class'] ?? ''; + +if ('' !== $table_name) { + /** + * STAN: Using $_REQUEST is forbidden, use rex_request::request() or rex_request() instead. + * Hierfür gibt es keinen Ersatz durch eine REX-Methode/Funktion. + * @phpstan-ignore-next-line + */ + $_REQUEST['table_name'] = $table_name; +} + +if (!$show_title) { + \rex_extension::register( + 'YFORM_MANAGER_DATA_PAGE_HEADER', + static function (rex_extension_point $ep) { + if ($ep->getParam('yform')->table->getTableName() === $ep->getParam('table_name')) { + return ''; + } + }, + \rex_extension::EARLY, ['table_name' => $table_name] + ); +} + +if ('' !== $wrapper_class) { + echo '
'; +} + +include \rex_path::plugin('yform', 'manager', 'pages/data_edit.php'); + +if ('' !== $wrapper_class) { + echo '
'; +} From 364860e763e749a8ab114910abdbb157e85c6988 Mon Sep 17 00:00:00 2001 From: christophboecker Date: Mon, 2 Sep 2024 08:16:29 +0000 Subject: [PATCH 3/4] Apply php-cs-fixer changes --- pages/neues.php | 2 +- pages/yform.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pages/neues.php b/pages/neues.php index 345bc9d..5827553 100644 --- a/pages/neues.php +++ b/pages/neues.php @@ -6,7 +6,7 @@ * für docs gilt: es sind Vorarbeiten notwendig, damit das Menü korrekt angezeigt * wird. Daher abweichender Ablauf. */ -if('neues/docs' === rex_be_controller::getCurrentPage()) { +if ('neues/docs' === rex_be_controller::getCurrentPage()) { $this->includeFile(__DIR__ . '/neues.docs.php'); return; } diff --git a/pages/yform.php b/pages/yform.php index 97fe337..a33365f 100644 --- a/pages/yform.php +++ b/pages/yform.php @@ -23,17 +23,17 @@ * als Model-Class/Dataset-Class: * tabelle: wird über rex::getTable($table_name) zu rex_tabelle * Namespace\Tabelle: wird über $table_name::table()->getTableName() zu rex_tabelle - * + * * @see https://friendsofredaxo.github.io/tricks/addons/yform/im-addon - * @var \rex_addon $this + * @var rex_addon $this */ $yform = $this->getProperty('yform', []); -$yform = $yform[\rex_be_controller::getCurrentPage()] ?? []; +$yform = $yform[rex_be_controller::getCurrentPage()] ?? []; -if( isset($yform['table_name']) ) { +if (isset($yform['table_name'])) { $table_name = $yform['table_name']; - if( is_subclass_of($table_name,rex_yform_manager_dataset::class)) { + if (is_subclass_of($table_name, rex_yform_manager_dataset::class)) { // table_name ist eine Dataset-Klasse $table_name = $table_name::table()->getTableName(); } else { @@ -58,14 +58,14 @@ } if (!$show_title) { - \rex_extension::register( + rex_extension::register( 'YFORM_MANAGER_DATA_PAGE_HEADER', static function (rex_extension_point $ep) { if ($ep->getParam('yform')->table->getTableName() === $ep->getParam('table_name')) { return ''; } }, - \rex_extension::EARLY, ['table_name' => $table_name] + rex_extension::EARLY, ['table_name' => $table_name], ); } @@ -73,7 +73,7 @@ static function (rex_extension_point $ep) { echo '
'; } -include \rex_path::plugin('yform', 'manager', 'pages/data_edit.php'); +include rex_path::plugin('yform', 'manager', 'pages/data_edit.php'); if ('' !== $wrapper_class) { echo '
'; From 0d663f4e2ec76dde291452780367ca6ff963d567 Mon Sep 17 00:00:00 2001 From: christophboecker Date: Mon, 2 Sep 2024 11:19:17 +0200 Subject: [PATCH 4/4] Update package.yml Co-authored-by: Alexander Walther --- package.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/package.yml b/package.yml index eb42baf..b2ecd56 100644 --- a/package.yml +++ b/package.yml @@ -71,7 +71,6 @@ yform: default_config: default_author: "Redaktion" default_thumbnail: "neues_entry_fallback_image.png" - # TODO: Text nach *.lang verlagern external_url_label: "Zur Website" editor: 'class="form-control redactor-editor--default"' url_profile: false