From 5f75dd8e92c965b4fc037798e53b2586f5950622 Mon Sep 17 00:00:00 2001 From: Ayke Halder Date: Tue, 20 Oct 2020 19:41:21 +0200 Subject: [PATCH 1/4] Show page-tree in backend for luxletter submodule --- ext_tables.php | 1 + 1 file changed, 1 insertion(+) diff --git a/ext_tables.php b/ext_tables.php index 892d57e4..73c98de9 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -69,6 +69,7 @@ function () { 'access' => 'user,group', 'icon' => 'EXT:luxletter/Resources/Public/Icons/lux_module_newsletter.svg', 'labels' => 'LLL:EXT:luxletter/Resources/Private/Language/locallang_mod_newsletter.xlf', + 'navigationComponentId' => 'TYPO3/CMS/Backend/PageTree/PageTreeElement', ] ); From f684efc5011b24965183564c0e4ae8a2f8c38031 Mon Sep 17 00:00:00 2001 From: Ayke Halder Date: Tue, 20 Oct 2020 20:05:53 +0200 Subject: [PATCH 2/4] Newsletter mailing: prefill page id from page-tree --- .../ViewHelpers/Backend/PageIdViewHelper.php | 80 +++++++++++++++++++ .../Partials/Newsletter/FormFields.html | 1 + 2 files changed, 81 insertions(+) create mode 100644 Classes/ViewHelpers/Backend/PageIdViewHelper.php diff --git a/Classes/ViewHelpers/Backend/PageIdViewHelper.php b/Classes/ViewHelpers/Backend/PageIdViewHelper.php new file mode 100644 index 00000000..68bf9d22 --- /dev/null +++ b/Classes/ViewHelpers/Backend/PageIdViewHelper.php @@ -0,0 +1,80 @@ + + * + * Page id + */ +class PageIdViewHelper extends AbstractBackendViewHelper +{ + + /** + * This ViewHelper renders no HTML + * + * @var bool + */ + protected $escapeOutput = true; + + /** + * Output page id + * + * @return string the page id + */ + public function render(): string + { + return static::renderStatic( + [], + $this->buildRenderChildrenClosure(), + $this->renderingContext + ); + } + + /** + * @param array $arguments + * @param \Closure $renderChildrenClosure + * @param RenderingContextInterface $renderingContext + * + * @return string + */ + public static function renderStatic( + array $arguments, + \Closure $renderChildrenClosure, + RenderingContextInterface $renderingContext + ): string { + $id = (int)GeneralUtility::_GP('id'); + if ($id > 0) { + return '' . $id; + } + + return ''; + } +} diff --git a/Resources/Private/Partials/Newsletter/FormFields.html b/Resources/Private/Partials/Newsletter/FormFields.html index f2aa8d03..d7c6acc4 100644 --- a/Resources/Private/Partials/Newsletter/FormFields.html +++ b/Resources/Private/Partials/Newsletter/FormFields.html @@ -93,6 +93,7 @@ From 6eebb34ee1059a2bb84e8ba6a5a506113720ba53 Mon Sep 17 00:00:00 2001 From: Ayke Halder Date: Tue, 20 Oct 2020 20:07:01 +0200 Subject: [PATCH 3/4] Newsletter mailing: load newsletter preview for prefilled page id --- Resources/Private/JavaScript/Module.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Resources/Private/JavaScript/Module.js b/Resources/Private/JavaScript/Module.js index b58a423a..f0c0f6cc 100644 --- a/Resources/Private/JavaScript/Module.js +++ b/Resources/Private/JavaScript/Module.js @@ -124,6 +124,9 @@ define(['jquery'], function($) { showIfNewsletterIsReady(); } }); + if (input.value.length !== 0) { + input.dispatchEvent(new Event('blur')); + } } }; From 3950cd7854ac1d23d9e4343023a8ca5f64f1c420 Mon Sep 17 00:00:00 2001 From: Ayke Halder Date: Tue, 20 Oct 2020 20:14:53 +0200 Subject: [PATCH 4/4] Newsletter mailing: prefill newsletter title and subject with page title from page-tree --- .../Backend/PageTitleViewHelper.php | 88 +++++++++++++++++++ .../Partials/Newsletter/FormFields.html | 2 + 2 files changed, 90 insertions(+) create mode 100644 Classes/ViewHelpers/Backend/PageTitleViewHelper.php diff --git a/Classes/ViewHelpers/Backend/PageTitleViewHelper.php b/Classes/ViewHelpers/Backend/PageTitleViewHelper.php new file mode 100644 index 00000000..5f01ccae --- /dev/null +++ b/Classes/ViewHelpers/Backend/PageTitleViewHelper.php @@ -0,0 +1,88 @@ + + * + * Page title + */ +class PageTitleViewHelper extends AbstractBackendViewHelper +{ + + /** + * This ViewHelper renders no HTML + * + * @var bool + */ + protected $escapeOutput = true; + + /** + * Output page title + * + * @return string the page title + */ + public function render(): string + { + return static::renderStatic( + [], + $this->buildRenderChildrenClosure(), + $this->renderingContext + ); + } + + /** + * @param array $arguments + * @param \Closure $renderChildrenClosure + * @param RenderingContextInterface $renderingContext + * + * @return string + */ + public static function renderStatic( + array $arguments, + \Closure $renderChildrenClosure, + RenderingContextInterface $renderingContext + ): string { + $id = (int)GeneralUtility::_GP('id'); + if ($id > 0) { + $pageRecord = BackendUtility::readPageAccess( + $id, + $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW) + ); + if ($pageRecord['title']) { + return $pageRecord['title']; + } + } + + return ''; + } +} diff --git a/Resources/Private/Partials/Newsletter/FormFields.html b/Resources/Private/Partials/Newsletter/FormFields.html index d7c6acc4..2ca42a54 100644 --- a/Resources/Private/Partials/Newsletter/FormFields.html +++ b/Resources/Private/Partials/Newsletter/FormFields.html @@ -6,6 +6,7 @@ @@ -60,6 +61,7 @@