[TASK] Isolate content element previews for page module 54/38154/5
authorPatrick Broens <patrick@patrickbroens.nl>
Wed, 25 Mar 2015 11:12:34 +0000 (12:12 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Mon, 13 Apr 2015 10:13:23 +0000 (12:13 +0200)
With the new strong defaults some content elements have moved to
the extensions mediace, css_styled_content and compatibility6.
The previews for the page module have not been moved.

This patch moves some previews to the corresponding extensions.

Resolves: #65952
Related: #65922
Releases: master
Change-Id: Idecf1b92b685237f7957e60a902afebd1010ba23
Reviewed-on: http://review.typo3.org/38154
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/compatibility6/Classes/Hooks/PageLayoutView/ScriptPreviewRenderer.php [new file with mode: 0644]
typo3/sysext/compatibility6/ext_localconf.php
typo3/sysext/css_styled_content/Classes/Hooks/PageLayoutView/ImagePreviewRenderer.php [new file with mode: 0644]
typo3/sysext/css_styled_content/Classes/Hooks/PageLayoutView/TextPreviewRenderer.php [new file with mode: 0644]
typo3/sysext/css_styled_content/Classes/Hooks/PageLayoutView/TextpicPreviewRenderer.php [new file with mode: 0644]
typo3/sysext/css_styled_content/ext_localconf.php
typo3/sysext/mediace/Classes/Hooks/PageLayoutView/MultimediaPreviewRenderer.php [new file with mode: 0644]
typo3/sysext/mediace/ext_localconf.php

index 0ed9f04..4f9527f 100644 (file)
@@ -1468,31 +1468,6 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                                $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
                                        }
                                        break;
-                               case 'text':
-
-                               case 'textpic':
-
-                               case 'image':
-                                       if ($row['CType'] == 'text' || $row['CType'] == 'textpic') {
-                                               if ($row['bodytext']) {
-                                                       $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
-                                               }
-                                       }
-                                       if ($row['CType'] == 'textpic' || $row['CType'] == 'image') {
-                                               if ($row['image']) {
-                                                       $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />';
-                                                       $fileReferences = BackendUtility::resolveFileReferences('tt_content', 'image', $row);
-                                                       if (!empty($fileReferences)) {
-                                                               $linkedContent = '';
-                                                               foreach ($fileReferences as $fileReference) {
-                                                                       $linkedContent .= htmlspecialchars($fileReference->getDescription()) . '<br />';
-                                                               }
-                                                               $out .= $this->linkEditContent($linkedContent, $row);
-                                                               unset($linkedContent);
-                                                       }
-                                               }
-                                       }
-                                       break;
                                case 'bullets':
                                case 'table':
                                        if ($row['bodytext']) {
@@ -1504,12 +1479,6 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                                $out .= $this->thumbCode($row, 'tt_content', 'media') . '<br />';
                                        }
                                        break;
-                               case 'multimedia':
-                                       if ($row['multimedia']) {
-                                               $out .= $this->renderText($row['multimedia']) . '<br />';
-                                               $out .= $this->renderText($row['parameters']) . '<br />';
-                                       }
-                                       break;
                                case 'menu':
                                        $contentType = $this->CType_labels[$row['CType']];
                                        $out .= '<strong>' . htmlspecialchars($contentType) . '</strong><br />';
@@ -1582,12 +1551,6 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                                        TRUE
                                                ) . '<br />';
                                        break;
-                               case 'script':
-                                       $out .= $this->getLanguageService()->sL(BackendUtility::getItemLabel('tt_content', 'select_key'), TRUE)
-                                               . ' ' . $row['select_key'] . '<br />';
-                                       $out .= '<br />' . $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
-                                       $out .= '<br />' . $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />';
-                                       break;
                                default:
                                        $contentType = $this->CType_labels[$row['CType']];
 
diff --git a/typo3/sysext/compatibility6/Classes/Hooks/PageLayoutView/ScriptPreviewRenderer.php b/typo3/sysext/compatibility6/Classes/Hooks/PageLayoutView/ScriptPreviewRenderer.php
new file mode 100644 (file)
index 0000000..6b444d9
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+namespace TYPO3\CMS\Compatibility6\Hooks\PageLayoutView;
+
+/*
+ * 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!
+ */
+
+/**
+ * Contains a preview rendering for the page module of CType="script"
+ */
+class ScriptPreviewRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
+
+       /**
+        * Preprocesses the preview rendering of a content element of type "script"
+        *
+        * @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
+        * @param bool $drawItem Whether to draw the item using the default functionality
+        * @param string $headerContent Header content
+        * @param string $itemContent Item content
+        * @param array $row Record row of tt_content
+        *
+        * @return void
+        */
+       public function preProcess(
+               \TYPO3\CMS\Backend\View\PageLayoutView &$parentObject,
+               &$drawItem,
+               &$headerContent,
+               &$itemContent,
+               array &$row
+       ) {
+               if ($row['CType'] === 'script') {
+                       $itemContent .= $parentObject->getLanguageService()->sL(
+                               \TYPO3\CMS\Backend\Utility\BackendUtility::getItemLabel('tt_content', 'select_key'),
+                               TRUE
+                       ) . ' ' . $row['select_key'] . '<br />';
+                       $itemContent .= '<br />' . $parentObject->linkEditContent(
+                               $parentObject->renderText($row['bodytext']),
+                               $row
+                       ) . '<br />';
+                       $itemContent .= '<br />' . $parentObject->linkEditContent(
+                               $parentObject->renderText($row['imagecaption']),
+                               $row
+                       ) . '<br />';
+
+                       $drawItem = FALSE;
+               }
+       }
+}
index 4a03e5b..0b9021c 100644 (file)
@@ -58,9 +58,11 @@ mod.wizards.newContentElement.wizardItems.forms {
 }
 ');
 
-// Add a for previewing tt_content elements of CType="mailform"
+// Register for hook to show preview of tt_content element of CType="mailform" in page module
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['mailform'] = \TYPO3\CMS\Compatibility6\Hooks\PageLayoutView\MailformPreviewRenderer::class;
 
+// Register for hook to show preview of tt_content element of CType="script" in page module
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['script'] = \TYPO3\CMS\Compatibility6\Hooks\PageLayoutView\ScriptPreviewRenderer::class;
 
 /**
  * CType "search"
diff --git a/typo3/sysext/css_styled_content/Classes/Hooks/PageLayoutView/ImagePreviewRenderer.php b/typo3/sysext/css_styled_content/Classes/Hooks/PageLayoutView/ImagePreviewRenderer.php
new file mode 100644 (file)
index 0000000..9b2781a
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+namespace TYPO3\CMS\CssStyledContent\Hooks\PageLayoutView;
+
+/*
+ * 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!
+ */
+
+/**
+ * Contains a preview rendering for the page module of CType="image"
+ */
+class ImagePreviewRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
+
+       /**
+        * Preprocesses the preview rendering of the content element "image".
+        *
+        * @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
+        * @param bool $drawItem Whether to draw the item using the default functionalities
+        * @param string $headerContent Header content
+        * @param string $itemContent Item content
+        * @param array $row Record row of tt_content
+        * @return void
+        */
+       public function preProcess(
+               \TYPO3\CMS\Backend\View\PageLayoutView &$parentObject,
+               &$drawItem,
+               &$headerContent,
+               &$itemContent,
+               array &$row
+       ) {
+               if ($row['CType'] === 'image') {
+                       if ($row['image']) {
+                               $itemContent .= $parentObject->thumbCode($row, 'tt_content', 'image') . '<br />';
+
+                               $fileReferences = \TYPO3\CMS\Backend\Utility\BackendUtility::resolveFileReferences('tt_content', 'image', $row);
+
+                               if (!empty($fileReferences)) {
+                                       $linkedContent = '';
+
+                                       foreach ($fileReferences as $fileReference) {
+                                               $linkedContent .= htmlspecialchars($fileReference->getDescription()) . '<br />';
+                                       }
+
+                                       $itemContent .= $parentObject->linkEditContent($linkedContent, $row);
+
+                                       unset($linkedContent);
+                               }
+                       }
+
+                       $drawItem = FALSE;
+               }
+       }
+}
\ No newline at end of file
diff --git a/typo3/sysext/css_styled_content/Classes/Hooks/PageLayoutView/TextPreviewRenderer.php b/typo3/sysext/css_styled_content/Classes/Hooks/PageLayoutView/TextPreviewRenderer.php
new file mode 100644 (file)
index 0000000..85c4a4d
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+namespace TYPO3\CMS\CssStyledContent\Hooks\PageLayoutView;
+
+/*
+ * 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!
+ */
+
+/**
+ * Contains a preview rendering for the page module of CType="text"
+ */
+class TextPreviewRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
+
+       /**
+        * Preprocesses the preview rendering of the content element "text".
+        *
+        * @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
+        * @param bool $drawItem Whether to draw the item using the default functionalities
+        * @param string $headerContent Header content
+        * @param string $itemContent Item content
+        * @param array $row Record row of tt_content
+        * @return void
+        */
+       public function preProcess(
+               \TYPO3\CMS\Backend\View\PageLayoutView &$parentObject,
+               &$drawItem,
+               &$headerContent,
+               &$itemContent,
+               array &$row
+       ) {
+               if ($row['CType'] === 'text') {
+                       if ($row['bodytext']) {
+                               $itemContent .= $parentObject->linkEditContent($parentObject->renderText($row['bodytext']), $row) . '<br />';
+                       }
+
+                       $drawItem = FALSE;
+               }
+       }
+}
\ No newline at end of file
diff --git a/typo3/sysext/css_styled_content/Classes/Hooks/PageLayoutView/TextpicPreviewRenderer.php b/typo3/sysext/css_styled_content/Classes/Hooks/PageLayoutView/TextpicPreviewRenderer.php
new file mode 100644 (file)
index 0000000..2e45582
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+namespace TYPO3\CMS\CssStyledContent\Hooks\PageLayoutView;
+
+/*
+ * 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!
+ */
+
+/**
+ * Contains a preview rendering for the page module of CType="textpic"
+ */
+class TextpicPreviewRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
+
+       /**
+        * Preprocesses the preview rendering of the content element "textpic".
+        *
+        * @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
+        * @param bool $drawItem Whether to draw the item using the default functionalities
+        * @param string $headerContent Header content
+        * @param string $itemContent Item content
+        * @param array $row Record row of tt_content
+        * @return void
+        */
+       public function preProcess(
+               \TYPO3\CMS\Backend\View\PageLayoutView &$parentObject,
+               &$drawItem,
+               &$headerContent,
+               &$itemContent,
+               array &$row
+       ) {
+               if ($row['CType'] === 'textpic') {
+                       if ($row['bodytext']) {
+                               $itemContent .= $parentObject->linkEditContent($parentObject->renderText($row['bodytext']), $row) . '<br />';
+                       }
+
+                       if ($row['image']) {
+                               $itemContent .= $parentObject->thumbCode($row, 'tt_content', 'image') . '<br />';
+
+                               $fileReferences = \TYPO3\CMS\Backend\Utility\BackendUtility::resolveFileReferences('tt_content', 'image', $row);
+
+                               if (!empty($fileReferences)) {
+                                       $linkedContent = '';
+
+                                       foreach ($fileReferences as $fileReference) {
+                                               $linkedContent .= htmlspecialchars($fileReference->getDescription()) . '<br />';
+                                       }
+
+                                       $itemContent .= $parentObject->linkEditContent($linkedContent, $row);
+
+                                       unset($linkedContent);
+                               }
+                       }
+
+                       $drawItem = FALSE;
+               }
+       }
+}
\ No newline at end of file
index f5bb9e3..f3e7e34 100644 (file)
@@ -18,3 +18,15 @@ if (!$_EXTCONF || $_EXTCONF['removePositionTypes']) {
 // Mark the delivered TypoScript templates as "content rendering template" (providing the hooks of "static template 43" = content (default))
 $GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'][] = 'cssstyledcontent/static/';
 $GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'][] = 'cssstyledcontent/static/v6.2/';
+
+// Register for hook to show preview of tt_content element of CType="image" in page module
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['image'] =
+       \TYPO3\CMS\CssStyledContent\Hooks\PageLayoutView\ImagePreviewRenderer::class;
+
+// Register for hook to show preview of tt_content element of CType="textpic" in page module
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['textpic'] =
+       \TYPO3\CMS\CssStyledContent\Hooks\PageLayoutView\TextpicPreviewRenderer::class;
+
+// Register for hook to show preview of tt_content element of CType="text" in page module
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['text'] =
+       \TYPO3\CMS\CssStyledContent\Hooks\PageLayoutView\TextPreviewRenderer::class;
diff --git a/typo3/sysext/mediace/Classes/Hooks/PageLayoutView/MultimediaPreviewRenderer.php b/typo3/sysext/mediace/Classes/Hooks/PageLayoutView/MultimediaPreviewRenderer.php
new file mode 100644 (file)
index 0000000..20333b0
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+namespace TYPO3\CMS\Mediace\Hooks\PageLayoutView;
+
+/*
+ * 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!
+ */
+
+/**
+ * Contains a preview rendering for the page module of
+ * CType="multimedia"
+ */
+class MultimediaPreviewRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
+
+       /**
+        * Preprocesses the preview rendering of a content element of type "multimedia"
+        *
+        * @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
+        * @param bool $drawItem Whether to draw the item using the default functionality
+        * @param string $headerContent Header content
+        * @param string $itemContent Item content
+        * @param array $row Record row of tt_content
+        *
+        * @return void
+        */
+       public function preProcess(
+               \TYPO3\CMS\Backend\View\PageLayoutView &$parentObject,
+               &$drawItem,
+               &$headerContent,
+               &$itemContent,
+               array &$row
+       ) {
+               if ($row['CType'] === 'multimedia' && $row['multimedia']) {
+                       $itemContent .= $parentObject->renderText($row['multimedia']) . '<br />';
+                       $itemContent .= $parentObject->renderText($row['parameters']) . '<br />';
+
+                       $drawItem = FALSE;
+               }
+       }
+}
index 7dfe09c..fa3fb9a 100644 (file)
@@ -29,3 +29,9 @@ if (TYPO3_MODE === 'FE') {
        // Register the basic media wizard provider
        \TYPO3\CMS\Mediace\MediaWizard\MediaWizardProviderManager::registerMediaWizardProvider(\TYPO3\CMS\Mediace\MediaWizard\MediaWizardProvider::class);
 }
+
+if (TYPO3_MODE === 'BE') {
+       // Register for hook to show preview of tt_content element of CType="multimedia" in page module
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['multimedia'] =
+               \TYPO3\CMS\Mediace\Hooks\PageLayoutView\MultimediaPreviewRenderer::class;
+}
\ No newline at end of file