[TASK] Deprecate thumbnail functionality via thumbs.php 94/35694/5
authorBenjamin Mack <benni@typo3.org>
Wed, 31 Dec 2014 16:08:05 +0000 (17:08 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Wed, 25 Mar 2015 20:27:06 +0000 (21:27 +0100)
With FAL and the generation of preview images
in the backend via FAL, thumbs.php and its
controller are no longer in use.

The corresponding code can therefore safely
be marked for removal.

The only place still in use was filelist() in
the frontend, where FAL is now used for
rendering icon / preview images.

Resolves: #64068
Releases: master
Change-Id: Ice806fc1684fddc303468878e351866e52a5d8e4
Reviewed-on: http://review.typo3.org/35694
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Form/Element/GroupElement.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Classes/View/ThumbnailView.php
typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-64068-ThumbnailView.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/install/Resources/Private/Partials/Action/Tool/TestSetup/AboutImageHandling.html
typo3/thumbs.php

index 007b428..2f25925 100644 (file)
@@ -145,7 +145,7 @@ class GroupElement extends AbstractFormElement {
                                                                                $table,
                                                                                $field,
                                                                                '',
-                                                                               'thumbs.php',
+                                                                               '',
                                                                                $config['uploadfolder'],
                                                                                0,
                                                                                ' align="middle"'
index d1fd91c..63fd52f 100644 (file)
@@ -2230,7 +2230,7 @@ class FormEngine {
                                                                $table,
                                                                $field,
                                                                '',
-                                                               'thumbs.php',
+                                                               '',
                                                                $config['config']['uploadfolder'], 0, ' align="middle"'
                                                        ) .
                                                        ($absFilePath ? $this->getControllerDocumentTemplate()->wrapClickMenuOnIcon($fileIcon, $absFilePath, 0, 1, '', '+copy,info,edit,view') : $fileIcon) . $imgPath .
index 7db8d14..20d5921 100644 (file)
@@ -1709,8 +1709,10 @@ class BackendUtility {
         * @param string $tparams The additional attributes for the image tag
         * @param string $size The size of the thumbnail send along to thumbs.php
         * @return string Image tag
+        * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use the corresponding Resource objects and Processing functionality
         */
        static public function getThumbNail($thumbScript, $theFile, $tparams = '', $size = '') {
+               GeneralUtility::logDeprecatedFunction();
                $size = trim($size);
                $check = basename($theFile) . ':' . filemtime($theFile) . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
                $params = '&file=' . rawurlencode($theFile);
index 64d7110..e0164b8 100644 (file)
@@ -30,6 +30,7 @@ use TYPO3\CMS\Core\Utility\MathUtility;
  * Relative paths MUST BE the first two characters ONLY: eg: '../dir/file.gif', otherwise it is expect to be absolute
  *
  * @author Kasper Skårhøj    <kasperYYYY@typo3.com>
+ * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use the corresponding Resource objects and Processing functionality
  */
 class ThumbnailView {
 
@@ -87,6 +88,7 @@ class ThumbnailView {
         * @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
         */
        public function init() {
+               GeneralUtility::deprecationLog('The class ThumbnailView is deprecated since TYPO3 CMS 7 and will be removed with TYPO3 CMS 8, use the corresponding Resource objects and Processing functionality');
                // Setting GPvars:
                // Only needed for MD5 sum calculation of backwards-compatibility uploads/ files thumbnails.
                $size = GeneralUtility::_GP('size');
index 41eafe8..0b4f347 100644 (file)
@@ -368,13 +368,13 @@ class SystemEnvironmentBuilder {
         * We have two main scenarios for entry points:
         * - Directly called documentRoot/index.php (-> FE call or eiD include): index.php sets $relativePathPart to
         * empty string to hint this code that the document root is identical to the directory the script is located at.
-        * - An indirect include of typo3/init.php (-> a backend module, the install tool, or scripts like thumbs.php).
+        * - An indirect include of typo3/init.php (-> a backend module, the install tool, or scripts like ajax.php).
         * If init.php is included we distinguish two cases:
         * -- A backend module defines 'TYPO3_MOD_PATH': This is the case for "old" modules that are not called through
         * "mod.php" dispatcher, and in the install tool. The TYPO3_MOD_PATH defines the relative path to the typo3/
         * directory. This is taken as base to calculate the document root.
         * -- A script includes init.php and does not define 'TYPO3_MOD_PATH': This is the case for the mod.php dispatcher
-        * and other entry scripts like 'cli_dispatch.phpsh' or 'thumbs.php' that are located parallel to init.php. In
+        * and other entry scripts like 'cli_dispatch.phpsh' or 'ajax.php' that are located parallel to init.php. In
         * this case init.php sets 'typo3/' as $relativePathPart as base to calculate the document root.
         *
         * This basically boils down to the following code:
index 8de5061..8de3aa1 100644 (file)
@@ -22,7 +22,7 @@ return array(
        'GFX' => array(
                // Configuration of the image processing features in TYPO3. 'IM' and 'GD' are short for ImageMagick and GD library respectively.
                'image_processing' => TRUE,                                             // Boolean: Enables image processing features. Disabling this means NO image processing with either GD or IM!
-               'thumbnails' => TRUE,                                                   // Boolean: Enables the use of thumbnails in the backend interface. Thumbnails are generated by IM/partly GD in the file typo3/thumbs.php
+               'thumbnails' => TRUE,                                                   // Boolean: Enables the use of thumbnails in the backend interface.
                'thumbnails_png' => 0,                                                  // Bits. Bit0: If set, thumbnails from non-jpegs will be 'png', otherwise 'gif' (0=gif/1=png). Bit1: Even JPG's will be converted to png or gif (2=gif/3=png)
                'gif_compress' => TRUE,                                                 // Boolean: Enables the use of the \TYPO3\CMS\Core\Utility\GeneralUtility::gifCompress() workaround function for compressing giffiles made with GD or IM, which probably use only RLE or no compression at all.
                'imagefile_ext' => 'gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai',// Commalist of file extensions perceived as images by TYPO3. List should be set to 'gif,png,jpeg,jpg' if IM is not available. Lowercase and no spaces between!
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-64068-ThumbnailView.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-64068-ThumbnailView.rst
new file mode 100644 (file)
index 0000000..1382bcf
--- /dev/null
@@ -0,0 +1,29 @@
+============================================================
+Deprecation: #64068 - Deprecate thumbs.php and ThumbnailView
+============================================================
+
+Description
+===========
+
+Prior to the File Abstraction Layer (FAL) there was typo3/thumbs.php generating all preview images for the TYPO3
+Backend resources. This functionality is now marked for removal in TYPO3 CMS 8, as all functionality in the core already
+uses the File Abstraction Layer.
+
+
+Impact
+======
+
+Using ``ThumbnailView``, ``thumbs.php`` or ``BackendUtility::getThumbNail`` will throw a deprecation warning.
+
+
+Affected installations
+======================
+
+Any TYPO3 installation with custom extensions using one of the files / methods mentioned.
+
+
+Migration
+=========
+
+Use the File Abstraction Layer for any custom works. See BackendUtility::thumbCode for inspiration.
+
index 1d838df..7a9364b 100644 (file)
@@ -4476,18 +4476,36 @@ class ContentObjectRenderer {
                                        if ($conf['iconCObject']) {
                                                $icon = $this->cObjGetSingle($conf['iconCObject'], $conf['iconCObject.'], 'iconCObject');
                                        } else {
+                                               $notFoundThumb = TYPO3_mainDir . 'gfx/fileicons/notfound_thumb.gif';
                                                if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
-                                                       $thumbSize = '';
-                                                       if ($conf['icon_thumbSize'] || $conf['icon_thumbSize.']) {
-                                                               $thumbSize = '&size=' . (isset($conf['icon_thumbSize.']) ? $this->stdWrap($conf['icon_thumbSize'], $conf['icon_thumbSize.']) : $conf['icon_thumbSize']);
+                                                       // using the File Abstraction Layer to generate a preview image
+                                                       try {
+                                                               /** @var File $fileObject */
+                                                               $fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($theFile);
+                                                               if ($fileObject->isMissing()) {
+                                                                       $icon = $notFoundThumb;
+                                                               } else {
+                                                                       $fileExtension = $fileObject->getExtension();
+                                                                       if ($fileExtension === 'ttf' || GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
+                                                                               if ($conf['icon_thumbSize'] || $conf['icon_thumbSize.']) {
+                                                                                       $thumbSize = (isset($conf['icon_thumbSize.']) ? $this->stdWrap($conf['icon_thumbSize'], $conf['icon_thumbSize.']) : $conf['icon_thumbSize']);
+                                                                                       $sizeParts = explode('x', $thumbSize);
+                                                                               } else {
+                                                                                       $sizeParts = array(64, 64);
+                                                                               }
+                                                                               $icon = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array(
+                                                                                       'width' => $sizeParts[0],
+                                                                                       'height' => $sizeParts[1]
+                                                                               ))->getPublicUrl(TRUE);
+                                                                       }
+                                                               }
+                                                       } catch (ResourceDoesNotExistException $exception) {
+                                                               $icon = $notFoundThumb;
                                                        }
-                                                       $check = basename($theFile) . ':' . filemtime($theFile) . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
-                                                       $md5sum = '&md5sum=' . md5($check);
-                                                       $icon = 'typo3/thumbs.php?file=' . rawurlencode(('../' . $theFile)) . $thumbSize . $md5sum;
                                                } else {
-                                                       $icon = TYPO3_mainDir . 'gfx/fileicons/notfound_thumb.gif';
+                                                       $icon = $notFoundThumb;
                                                }
-                                               $icon = '<img src="' . htmlspecialchars(($GLOBALS['TSFE']->absRefPrefix . $icon)) . '"' . $this->getBorderAttr(' border="0"') . '' . $this->getAltParam($conf) . ' />';
+                                               $icon = '<img src="' . htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $icon) . '"' . $this->getBorderAttr(' border="0"') . '' . $this->getAltParam($conf) . ' />';
                                        }
                                } else {
                                        $conf['icon.']['widthAttribute'] = isset($conf['icon.']['widthAttribute.']) ? $this->stdWrap($conf['icon.']['widthAttribute'], $conf['icon.']['widthAttribute.']) : $conf['icon.']['widthAttribute'];
index 120fb4c..0d529b6 100644 (file)
@@ -12,7 +12,7 @@
                        </p>
                        <p>
                                In the backend interface (TBE) thumbnails are automatically generated
-                               (by ImageMagick in thumbs.php) as well as icons, menu items and pane tabs (by GDLib).
+                               as well as icons, menu items and pane tabs (by GDLib).
                                In the frontend all kinds of graphical elements are processed. Typically images are
                                scaled down to fit the pages (by ImageMagick) and menu items, graphical headers and
                                such are generated automatically (by GDLib + ImageMagick). In addition TYPO3 is able
@@ -59,4 +59,4 @@
                        </p>
                </div>
        </div>
-</div>
\ No newline at end of file
+</div>
index 071f727..7a3bad0 100644 (file)
  * Generates a thumbnail and returns an image stream, either GIF/PNG or JPG
  *
  * @author René Fritz <r.fritz@colorcube.de>
+ * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use the corresponding Resource objects and Processing functionality
  */
 
 require __DIR__ . '/init.php';
 
-// Make instance:
+\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+       'thumbs.php is no longer in use, please use the corresponding Resource objects to generate a preview functionality for thumbnails.'
+);
 $GLOBALS['SOBE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\View\ThumbnailView::class);
 $GLOBALS['SOBE']->init();
-$GLOBALS['SOBE']->main();
+$GLOBALS['SOBE']->main();
\ No newline at end of file