[FEATURE] Show only distributions for current version 83/42283/8
authorDaniel Maier <dani-maier@gmx.de>
Wed, 5 Aug 2015 16:41:43 +0000 (18:41 +0200)
committerAndreas Wolf <andreas.wolf@typo3.org>
Wed, 5 Aug 2015 20:33:24 +0000 (22:33 +0200)
As the list of distributions gets longer, it is filtered now to
those distributions that suite the current TYPO3 version.

Distributions that do not comply with version constraints are not
shown anymore. A button can be pressed to get the full list again,
for people who know what they’re doing.

Resolves: #68724
Releases: master
Change-Id: I11c6846e706ba18c130677c65ec568f80e502ed8
Reviewed-on: http://review.typo3.org/42283
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Sascha Wilking <sascha.wilking@hmmh.de>
Tested-by: Sascha Wilking <sascha.wilking@hmmh.de>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
typo3/sysext/core/Documentation/Changelog/master/Feature-68724-EMShowsOnlyDistributionsThatSuiteTheCurrentTYPO3Version.rst [new file with mode: 0644]
typo3/sysext/extensionmanager/Classes/Controller/ListController.php
typo3/sysext/extensionmanager/Classes/Utility/DependencyUtility.php
typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf
typo3/sysext/extensionmanager/Resources/Private/Templates/List/Distributions.html

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-68724-EMShowsOnlyDistributionsThatSuiteTheCurrentTYPO3Version.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-68724-EMShowsOnlyDistributionsThatSuiteTheCurrentTYPO3Version.rst
new file mode 100644 (file)
index 0000000..501740f
--- /dev/null
@@ -0,0 +1,14 @@
+====================================================================================================================
+Feature: #68724 - EM: "Get preconfigured distribution" shows only distributions that suite the current TYPO3 version
+====================================================================================================================
+
+Description
+===========
+
+As the list of distributions gets longer, it is filtered now to those distributions that suite the current TYPO3 version.
+
+
+Impact
+======
+
+Distributions that require different TYPO3 versions are not shown anymore.
\ No newline at end of file
index 9d372bc..5cb1e5e 100644 (file)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
+use TYPO3\CMS\Extensionmanager\Domain\Model\Dependency;
 use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
 use TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility;
 use TYPO3\CMS\Extensionmanager\Utility\Repository\Helper;
@@ -147,9 +148,10 @@ class ListController extends AbstractController {
        /**
         * Action for listing all possible distributions
         *
+        * @param bool $showUnsuitableDistributions
         * @return void
         */
-       public function distributionsAction() {
+       public function distributionsAction($showUnsuitableDistributions = FALSE) {
                $this->addComposerModeNotification();
                $importExportInstalled = ExtensionManagementUtility::isLoaded('impexp');
                if ($importExportInstalled) {
@@ -167,12 +169,23 @@ class ListController extends AbstractController {
                        }
 
                        $officialDistributions = $this->extensionRepository->findAllOfficialDistributions();
-                       $this->view->assign('officialDistributions', $officialDistributions);
+                       if (!$showUnsuitableDistributions) {
+                               $suitableOfficialDistributions = $this->dependencyUtility->getExtensionsSuitableForTypo3Version($officialDistributions->toArray());
+                               $this->view->assign('officialDistributions', $suitableOfficialDistributions);
+                       } else {
+                               $this->view->assign('officialDistributions', $officialDistributions);
+                       }
 
                        $communityDistributions = $this->extensionRepository->findAllCommunityDistributions();
-                       $this->view->assign('communityDistributions', $communityDistributions);
+                       if (!$showUnsuitableDistributions) {
+                               $suitableCommunityDistributions = $this->dependencyUtility->getExtensionsSuitableForTypo3Version($communityDistributions->toArray());
+                               $this->view->assign('communityDistributions', $suitableCommunityDistributions);
+                       } else {
+                               $this->view->assign('communityDistributions', $communityDistributions);
+                       }
                }
                $this->view->assign('enableDistributionsView', $importExportInstalled);
+               $this->view->assign('showUnsuitableDistributions', $showUnsuitableDistributions);
        }
 
        /**
index 7e42e17..fcf4611 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Extensionmanager\Utility;
  */
 
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+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;
@@ -524,4 +525,37 @@ class DependencyUtility implements \TYPO3\CMS\Core\SingletonInterface {
                return $dependentExtensions;
        }
 
+       /**
+        * Get extensions (out of a given list) that are suitable for the current TYPO3 version
+        *
+        * @param array $extensions List of extensions to check
+        * @return array List of extensions suitable for current TYPO3 version
+        */
+       public function getExtensionsSuitableForTypo3Version(array $extensions) {
+               $suitableExtensions = array();
+               /** @var Extension $extension */
+               foreach ($extensions as $extension) {
+                       /** @var Dependency $dependency */
+                       foreach ($extension->getDependencies() as $dependency) {
+                               if ($dependency->getIdentifier() === 'typo3' && $this->isDependencySatisfiedByTypo3Version($dependency)) {
+                                       array_push($suitableExtensions, $extension);
+                               }
+                       }
+               }
+               return $suitableExtensions;
+       }
+
+       /**
+        * Checks if given dependency is satisfied by current TYPO3 version
+        *
+        * @param Dependency $dependency
+        * @return bool
+        */
+       protected function isDependencySatisfiedByTypo3Version(Dependency $dependency) {
+               $numericTypo3Version = VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version());
+               $numericLowestVersion = VersionNumberUtility::convertVersionNumberToInteger($dependency->getLowestVersion());
+               $numericHighestVersion = VersionNumberUtility::convertVersionNumberToInteger($dependency->getHighestVersion());
+               return MathUtility::isIntegerInRange($numericTypo3Version, $numericLowestVersion, $numericHighestVersion);
+       }
+
 }
index 31e62c1..6579040 100644 (file)
                        <trans-unit id="extensionList.distribution.lastUpdated">
                                <source>Last Update:</source>
                        </trans-unit>
+                       <trans-unit id="extensionList.showUnsuitableDistributions">
+                               <source>Show also distributions that are not suitable for this TYPO3 version</source>
+                       </trans-unit>
                        <trans-unit id="extensionList.officialDistribution">
                                <source>Official distribution</source>
                        </trans-unit>
index d85293c..73d89d5 100644 (file)
        <f:flashMessages />
        <f:if condition="{enableDistributionsView}">
                <f:then>
+                       <f:if condition="{showUnsuitableDistributions} == 0">
+                               <div class="row">
+                                       <div class="col-sm-6">
+                                               <f:form class="typo3-extensionmanager-unsuitable-dist" action="distributions" arguments="{showUnsuitableDistributions: 1}" >
+                                                       <div class="input-group">
+                                                               <span class="input-group-btn">
+                                                                       <f:form.submit class="btn btn-default" value="{f:translate(key:'extensionList.showUnsuitableDistributions')}"/>
+                                                               </span>
+                                                       </div>
+                                               </f:form>
+                                       </div>
+                               </div>
+                       </f:if>
                        <div class="distribution-holder">
                                <f:for each="{officialDistributions}" as="distribution">
                                        <f:render partial="List/Distribution" arguments="{distribution: distribution, official: 1}" />