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 423116b..6119c90 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..5827553 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..a33365f --- /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 '
'; +} 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;