[FEATURE] Add hook for content element footer in Page module 09/31309/4
authorLeon de Rijke <leon@cmsworks.nl>
Thu, 3 Jul 2014 09:54:52 +0000 (11:54 +0200)
committerFrank Nägler <typo3@naegler.net>
Tue, 23 Dec 2014 18:11:52 +0000 (19:11 +0100)
Currently, there is only a hook for the `tt_content_drawItem` function
in the PageLayoutView. Since 6.0 the info fields for a tt_content element
(hidden,starttime,endtime,fe_group,spaceBefore,spaceAfter) are rendered
in a footer, so there is no way to alter the rendering of the info
fields or add information to the footer.

This change adds a hook to the `tt_content_drawFooter` function
responsible for rendering the footer.

Resolves: #58929
Releases: master
Change-Id: I23c54eefd3a511fddd480b4bf08d6a3977757973
Reviewed-on: http://review.typo3.org/31309
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/backend/Classes/View/PageLayoutViewDrawFooterHookInterface.php [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Feature-58929-FooterHookInPageLayoutView [new file with mode: 0644]

index 5cbb67a..10019fb 100644 (file)
@@ -1284,6 +1284,19 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                // Get processed values:
                $info = array();
                $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info);
+
+               // Call drawFooter hooks
+               $drawFooterHooks = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'];
+               if (is_array($drawFooterHooks)) {
+                       foreach ($drawFooterHooks as $hookClass) {
+                               $hookObject = GeneralUtility::getUserObj($hookClass);
+                               if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) {
+                                       throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\View\\PageLayoutViewDrawFooterHookInterface', 1404378171);
+                               }
+                               $hookObject->preProcess($this, $info, $row);
+                       }
+               }
+
                // Display info from records fields:
                if (count($info)) {
                        $content = '<div class="t3-page-ce-info">
diff --git a/typo3/sysext/backend/Classes/View/PageLayoutViewDrawFooterHookInterface.php b/typo3/sysext/backend/Classes/View/PageLayoutViewDrawFooterHookInterface.php
new file mode 100644 (file)
index 0000000..ef5fc0a
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+namespace TYPO3\CMS\Backend\View;
+
+/**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Interface for classes which hook into PageLayoutView and do additional
+ * tt_content_drawFooter processing.
+ *
+ */
+interface PageLayoutViewDrawFooterHookInterface {
+
+       /**
+        * Preprocesses the preview footer rendering of a content element.
+        *
+        * @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
+        * @param string $info Processed values
+        * @param array $row Record row of tt_content
+        * @return void
+        */
+       public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$info, array &$row);
+
+}
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-58929-FooterHookInPageLayoutView b/typo3/sysext/core/Documentation/Changelog/master/Feature-58929-FooterHookInPageLayoutView
new file mode 100644 (file)
index 0000000..9c79bc9
--- /dev/null
@@ -0,0 +1,9 @@
+====================================================================
+Feature: #58929 - PageLayoutView: Add hook for tt_content_drawFooter
+====================================================================
+
+Description
+===========
+
+A hook is added to the PageLayoutView to manipulate the rendering of
+the footer of a content element.
\ No newline at end of file