[TASK] Show suited TYPO3 versions at distributions 90/37790/7
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 12 Mar 2015 14:17:41 +0000 (15:17 +0100)
committerFrank Nägler <typo3@naegler.net>
Sun, 15 Mar 2015 16:19:50 +0000 (17:19 +0100)
Show the suited TYPO3 version of each distribution. If a distribution
does matches the used TYPO3 version, show the version numbers in a
"success" label.

Resolves: #65680
Releases: master, 6.2
Change-Id: Ib65834c1856b5d0cdde7e7bb477743b4d95e2dc4
Reviewed-on: http://review.typo3.org/37790
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
typo3/sysext/extensionmanager/Classes/ViewHelpers/Typo3DependencyViewHelper.php [new file with mode: 0644]
typo3/sysext/extensionmanager/Resources/Private/Partials/List/Distribution.html
typo3/sysext/t3skin/Resources/Private/Styles/TYPO3/_module_extensionmanager.less
typo3/sysext/t3skin/Resources/Public/Css/visual/t3skin.css

diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/Typo3DependencyViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/Typo3DependencyViewHelper.php
new file mode 100644 (file)
index 0000000..c74163a
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
+
+/*
+ * 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\MathUtility;
+use TYPO3\CMS\Core\Utility\VersionNumberUtility;
+use TYPO3\CMS\Extensionmanager\Domain\Model\Dependency;
+use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
+
+/**
+ * Shows the version numbers of the TYPO3 dependency, if any
+ *
+ * @internal
+ */
+class Typo3DependencyViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+
+       /**
+        * Finds and returns the suitable TYPO3 versions of an extension
+        *
+        * @param Extension $extension
+        * @return string
+        */
+       public function render(Extension $extension) {
+               /** @var Dependency $dependency */
+               foreach ($extension->getDependencies() as $dependency) {
+                       if ($dependency->getIdentifier() === 'typo3') {
+                               $lowestVersion = $dependency->getLowestVersion();
+                               $highestVersion = $dependency->getHighestVersion();
+                               $cssClass = $this->isVersionSuitable($lowestVersion, $highestVersion) ? 'success' : 'default';
+                               return
+                                       '<span class="label label-' . $cssClass . '">'
+                                               . htmlspecialchars($lowestVersion) . ' - ' . htmlspecialchars($highestVersion)
+                                       . '</span>';
+                       }
+               }
+               return '';
+       }
+
+       /**
+        * Check if current TYPO3 version is suitable for the extension
+        *
+        * @param string $lowestVersion
+        * @param string $highestVersion
+        * @return bool
+        */
+       protected function isVersionSuitable($lowestVersion, $highestVersion) {
+               $numericTypo3Version = VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version());
+               $numericLowestVersion = VersionNumberUtility::convertVersionNumberToInteger($lowestVersion);
+               $numericHighestVersion = VersionNumberUtility::convertVersionNumberToInteger($highestVersion);
+               return MathUtility::isIntegerInRange($numericTypo3Version, $numericLowestVersion, $numericHighestVersion);
+       }
+}
index 9046a8e..32db7cf 100644 (file)
@@ -1,6 +1,11 @@
 {namespace em=TYPO3\CMS\Extensionmanager\ViewHelpers}
 <div class="distribution">
        <div class="distribution-image">
+               <f:if condition="{distribution.dependencies}">
+                       <div class="typo3-dependency-version">
+                               <em:typo3Dependency extension="{distribution}" />
+                       </div>
+               </f:if>
                <em:image
                                src="EXT:{distribution.extensionKey}/Resources/Public/Images/Distribution.png" alt="{distribution.title}"
                                fallbackImage="EXT:extensionmanager/Resources/Public/Images/Distribution.png"
@@ -10,7 +15,7 @@
                <div class="distribution-hover">
                        <div class="distribution-hover-inner">
                                <dl class="dl-horizontal">
-                                        <dt><f:translate key="extensionList.distribution.title" /></dt>
+                                       <dt><f:translate key="extensionList.distribution.title" /></dt>
                                        <dd>{distribution.title}</dd>
                                        <dt><f:translate key="extensionList.distribution.key" /></dt>
                                        <dd>{distribution.extensionKey}</dd>
index 879919b..4f93f50 100644 (file)
                        text-decoration: underline;
                }
        }
+       .typo3-dependency-version {
+               position: absolute;
+               right: 0px;
+       }
 }
 .distribution-holder {
        .clearfix();
index 7dbebf9..c9de946 100644 (file)
@@ -11051,6 +11051,10 @@ fieldset[disabled] .live-search-list .x-btn button.active {
 .distribution:hover .distribution-more {
   text-decoration: underline;
 }
+.distribution .typo3-dependency-version {
+  position: absolute;
+  right: 0px;
+}
 .distribution-holder {
   top: 0px;
   bottom: 0px;