diff --git a/Classes/Hooks/View/PageLayoutView.php b/Classes/Hooks/View/PageLayoutView.php new file mode 100644 index 0000000..5e6d52d --- /dev/null +++ b/Classes/Hooks/View/PageLayoutView.php @@ -0,0 +1,86 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use TYPO3\CMS\Backend\View\PageLayoutView as Typo3PageLayoutView; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Fluid\View\StandaloneView; + +/** + * Holds all TYPO3 Hooks for PageLayoutView class. + */ +class PageLayoutView +{ + /** + * @var Typo3PageLayoutView + */ + private $layoutView; + + public function processColPosGrid( + Typo3PageLayoutView $layoutView, + array $columnConfig + ): string { + $this->layoutView = $layoutView; + if (isset($columnConfig['colPos']) && trim($columnConfig['colPos']) !== '') { + return ''; + } + + if (isset($columnConfig['name']) && $columnConfig['name'] === 'Meta Info') { + return $this->renderMetaInfo(); + } + } + + private function renderMetaInfo(): string + { + $view = $this->getView(); + $view->assignMultiple([ + 'record' => $this->layoutView->pageRecord, + 'metaInfo' => [ + [ + 'label' => 'introduction', + 'value' => $this->layoutView->pageRecord['abstract'], + 'field' => 'abstract', + 'type' => 'string', + ], + [ + 'label' => 'published', + 'value' => $this->layoutView->pageRecord['lastUpdated'], + 'field' => 'lastUpdated', + 'type' => 'date', + ], + [ + 'label' => 'updated', + 'value' => $this->layoutView->pageRecord['SYS_LASTCHANGED'], + 'type' => 'date', + ], + ], + ]); + $view->setTemplatePathAndFilename('EXT:ds_site/Resources/Private/Templates/Backend/Page/MetaInfo.html'); + + return $view->render(); + } + + private function getView(): StandaloneView + { + return GeneralUtility::makeInstance(StandaloneView::class); + } +} diff --git a/Classes/ViewHelpers/Uri/EditRecordViewHelper.php b/Classes/ViewHelpers/Uri/EditRecordViewHelper.php new file mode 100644 index 0000000..521b6d1 --- /dev/null +++ b/Classes/ViewHelpers/Uri/EditRecordViewHelper.php @@ -0,0 +1,82 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use TYPO3\CMS\Backend\Routing\UriBuilder; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; + +/** + * Use this ViewHelper to provide edit links (only the uri) to records. The ViewHelper will + * pass the uid and table to FormEngine. + * + * The uid must be given as a positive integer. + * For new records, use the :ref:` `. + * + * Examples + * ======== + * + * URI to the record-edit action passed to FormEngine:: + * + * + * + * ``/typo3/index.php?route=/record/edit&edit[a_table][42]=edit&returnUrl=foo/bar`` + */ +class EditRecordViewHelper extends AbstractViewHelper +{ + use CompileWithRenderStatic; + + public function initializeArguments() + { + $this->registerArgument('uid', 'int', 'uid of record to be edited, 0 for creation', true); + $this->registerArgument('table', 'string', 'target database table', true); + $this->registerArgument('returnUrl', 'string', '', false, ''); + $this->registerArgument('columns', 'string', 'columns to show', false, ''); + } + + /** + * @param array $arguments + * @param \Closure $renderChildrenClosure + * @param RenderingContextInterface $renderingContext + * + * @return string + * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException + */ + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string + { + if ($arguments['uid'] < 1) { + throw new \InvalidArgumentException('Uid must be a positive integer, ' . $arguments['uid'] . ' given.', 1526128259); + } + if (empty($arguments['returnUrl'])) { + $arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI'); + } + + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + return (string)$uriBuilder->buildUriFromRoute('record_edit', [ + 'edit' => [$arguments['table'] => [$arguments['uid'] => 'edit']], + 'columnsOnly' => $arguments['columns'], + 'returnUrl' => $arguments['returnUrl'] + ]); + } +} diff --git a/Configuration/PageTSconfig/Mod/WebLayout/BackendLayouts/BlogPost.tsconfig b/Configuration/PageTSconfig/Mod/WebLayout/BackendLayouts/BlogPost.tsconfig index 0f32ec5..9876557 100644 --- a/Configuration/PageTSconfig/Mod/WebLayout/BackendLayouts/BlogPost.tsconfig +++ b/Configuration/PageTSconfig/Mod/WebLayout/BackendLayouts/BlogPost.tsconfig @@ -5,9 +5,17 @@ mod.web_layout.BackendLayouts { config { backend_layout { colCount = 1 - rowCount = 4 + rowCount = 5 rows { 1 { + columns { + 1 { + name = Meta Info + colPos = + } + } + } + 2 { columns { 1 { name = Introduction @@ -15,7 +23,7 @@ mod.web_layout.BackendLayouts { } } } - 2 { + 3 { columns { 1 { name = Content @@ -23,7 +31,7 @@ mod.web_layout.BackendLayouts { } } } - 3 { + 4 { columns { 1 { name = Acknowledgements @@ -31,7 +39,7 @@ mod.web_layout.BackendLayouts { } } } - 4 { + 5 { columns { 1 { name = Further reading diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf new file mode 100644 index 0000000..4fc2da2 --- /dev/null +++ b/Resources/Private/Language/locallang.xlf @@ -0,0 +1,20 @@ + + + +
+ + + not set + + + Introduction (Abstract) + + + Published (Last Updated) + + + Updated (SYS_LASTCHANGED) + + + + diff --git a/Resources/Private/Templates/Backend/Page/MetaInfo.html b/Resources/Private/Templates/Backend/Page/MetaInfo.html new file mode 100644 index 0000000..6429324 --- /dev/null +++ b/Resources/Private/Templates/Backend/Page/MetaInfo.html @@ -0,0 +1,45 @@ + + + + + + + {value} + + + {f:translate(id: 'backend.page.metainfo.notSet', extensionName: 'DsSite')} + + + + + + + + {f:translate(id: 'backend.page.metainfo.notSet', extensionName: 'DsSite')} + + + {value -> f:format.date(format: 'd.m.Y')} + + + + + + {f:uri.editRecord( + uid: recordUid, + table: 'pages', + columns: field + )} + + diff --git a/ext_localconf.php b/ext_localconf.php index cb93c49..b05afec 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,6 +1,30 @@ [ + 'Presets' => [ + 'default' => 'EXT:ds_site/Configuration/RTE/Default.yaml', + ], + ], + 'SC_OPTIONS' => [ + 'cms/layout/class.tx_cms_layout.php' => [ + 'colpos_content' => [ + $extKey => \DanielSiepmann\DsSite\Hooks\View\PageLayoutView::class, + ], + ], + ], + 'SYS' => [ + 'fluid' => [ + 'namespaces' => [ + 'f' => [ + $extKey => 'DanielSiepmann\DsSite\ViewHelpers', + ], + ], + ], + ], + ]); + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig( + "@import 'EXT:ds_site/Configuration/UserTSconfig/*.tsconfig'" + ); +})('ds_site');