[TASK] Remove unused ViewHelpers of EXT:install 54/53454/2
authorGeorg Ringer <georg.ringer@gmail.com>
Wed, 12 Jul 2017 13:33:59 +0000 (15:33 +0200)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Thu, 13 Jul 2017 11:02:48 +0000 (13:02 +0200)
The following ViewHelpers are not used and can be removed:

- file.size
- file.imageDimension

The ViewHelper format.crop of EXT:install can be replace by the one of
fluid.

Resolves: #81842
Releases: master
Change-Id: I094c96ff44f010304e59d9b6940a111067ffbfb7
Reviewed-on: https://review.typo3.org/53454
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/install/Classes/ViewHelpers/File/ImageDimensionViewHelper.php [deleted file]
typo3/sysext/install/Classes/ViewHelpers/File/SizeViewHelper.php [deleted file]
typo3/sysext/install/Classes/ViewHelpers/Format/CropViewHelper.php [deleted file]
typo3/sysext/install/Resources/Private/Partials/Action/Tool/AllConfiguration/SubSection.html

diff --git a/typo3/sysext/install/Classes/ViewHelpers/File/ImageDimensionViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/File/ImageDimensionViewHelper.php
deleted file mode 100644 (file)
index 5b38537..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\ViewHelpers\File;
-
-/*
- * 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!
- */
-
-use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
-use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
-use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
-
-/**
- * Get width or height from image file
- *
- * = Examples =
- *
- * <code title="Defaults">
- * <f:file.imageDimension>/var/www/typo3/instance/typo3temp/foo.jpg</f:file.size>
- * </code>
- * <output>
- * 170
- * </output>
- *
- * @internal
- */
-class ImageDimensionViewHelper extends AbstractViewHelper
-{
-    use CompileWithRenderStatic;
-
-    /**
-     * Output is escaped already. We must not escape children, to avoid double encoding.
-     *
-     * @var bool
-     */
-    protected $escapeChildren = false;
-
-    /**
-     * Initialize arguments
-     */
-    public function initializeArguments()
-    {
-        parent::initializeArguments();
-        $this->registerArgument('dimension', 'string', '', false, 'width');
-    }
-
-    /**
-     * Get width / height from image file
-     *
-     * @throws \TYPO3\CMS\Install\ViewHelpers\Exception
-     * @param array $arguments
-     * @param \Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
-     * @throws \TYPO3\CMS\Install\ViewHelpers\Exception
-     *
-     * @return int width or height
-     */
-    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
-    {
-        $dimension = $arguments['dimension'];
-        if ($dimension !== 'width' && $dimension !== 'height') {
-            throw new \TYPO3\CMS\Install\ViewHelpers\Exception(
-                'Dimension must be either \'width\' or \'height\'',
-                1369563247
-            );
-        }
-        $absolutePathToFile = $renderChildrenClosure();
-        if (!is_file($absolutePathToFile)) {
-            throw new \TYPO3\CMS\Install\ViewHelpers\Exception(
-                'File not found',
-                1369563248
-            );
-        }
-        $actualDimension = getimagesize($absolutePathToFile);
-        if ($dimension === 'width') {
-            $size = $actualDimension[0];
-        } else {
-            $size = $actualDimension[1];
-        }
-        return $size;
-    }
-}
diff --git a/typo3/sysext/install/Classes/ViewHelpers/File/SizeViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/File/SizeViewHelper.php
deleted file mode 100644 (file)
index f55af40..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\ViewHelpers\File;
-
-/*
- * 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!
- */
-
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
-use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
-use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
-
-/**
- * Get file size from file
- *
- * = Examples =
- *
- * <code title="Defaults">
- * <f:file.size>/var/www/typo3/instance/typo3temp/foo.jpg</f:file.size>
- * </code>
- * <output>
- * 1,2k
- * </output>
- *
- * @internal
- */
-class SizeViewHelper extends AbstractViewHelper
-{
-    use CompileWithRenderStatic;
-
-    /**
-     * Output is escaped already. We must not escape children, to avoid double encoding.
-     *
-     * @var bool
-     */
-    protected $escapeChildren = false;
-
-    /**
-     * Initialize arguments
-     */
-    public function initializeArguments()
-    {
-        parent::initializeArguments();
-        $this->registerArgument('format', 'bool', 'If true, file size will be formatted', false, true);
-    }
-
-    /**
-     * Get size from file
-     *
-     * @param array $arguments
-     * @param \Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
-     * @throws \TYPO3\CMS\Install\ViewHelpers\Exception
-     *
-     * @return int File size
-     */
-    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
-    {
-        $format = $arguments['format'];
-
-        $absolutePathToFile = $renderChildrenClosure();
-        if (!is_file($absolutePathToFile)) {
-            throw new \TYPO3\CMS\Install\ViewHelpers\Exception(
-                'File not found',
-                1369563246
-            );
-        }
-        $size = filesize($absolutePathToFile);
-        if ($format) {
-            $size = GeneralUtility::formatSize($size);
-        }
-        return $size;
-    }
-}
diff --git a/typo3/sysext/install/Classes/ViewHelpers/Format/CropViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/Format/CropViewHelper.php
deleted file mode 100644 (file)
index 94790c1..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-namespace TYPO3\CMS\Install\ViewHelpers\Format;
-
-/*
- * 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!
- */
-
-use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
-use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
-use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
-
-/**
- * Simplified crop view helper that does not need a frontend environment
- *
- * = Examples =
- *
- * <code title="Defaults">
- * <f:format.crop maxCharacters="10">This is some very long text</f:format.crop>
- * </code>
- * <output>
- * This is...
- * </output>
- *
- * <code title="Inline notation">
- * {someLongText -> f:format.crop(maxCharacters: 10)}
- * </code>
- * <output>
- * someLongText cropped after 10 characters...
- * (depending on the value of {someLongText})
- * </output>
- *
- * @internal
- */
-class CropViewHelper extends AbstractViewHelper
-{
-    use CompileWithRenderStatic;
-
-    /**
-     * Output is escaped already. We must not escape children, to avoid double encoding.
-     *
-     * @var bool
-     */
-    protected $escapeChildren = false;
-
-    /**
-     * Initialize arguments
-     */
-    public function initializeArguments()
-    {
-        parent::initializeArguments();
-        $this->registerArgument('maxCharacters', 'int', '', true);
-    }
-
-    /**
-     * Render the cropped text
-     *
-     * @param array $arguments
-     * @param \Closure $renderChildrenClosure
-     * @param RenderingContextInterface $renderingContext
-     * @throws \TYPO3\CMS\Install\ViewHelpers\Exception
-     * @return string cropped text
-     */
-    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
-    {
-        $maxCharacters = $arguments['maxCharacters'];
-        if (empty($maxCharacters) || $maxCharacters < 1) {
-            throw new \TYPO3\CMS\Install\ViewHelpers\Exception(
-                'maxCharacters must be a positive integer',
-                1371410113
-            );
-        }
-        $stringToTruncate = $renderChildrenClosure();
-        return substr($stringToTruncate, 0, $maxCharacters);
-    }
-}
index eaf3356..6b02cb7 100644 (file)
@@ -21,7 +21,7 @@
                                                </f:then>
                                                <f:else>
                                                        <f:if condition="{item.value}">
-                                                               = {item.value -> i:format.crop(maxCharacters: 40)}
+                                                               = {item.value -> f:format.crop(maxCharacters: 40, respectWordBoundaries:0, respectHtml:0)}
                                                        </f:if>
                                                </f:else>
                                        </f:if>