...
  View open merge request
Commits (1)
......@@ -116,6 +116,17 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $composerName = '';
/**
* @todo: Get these versions automatically
*
* @var array
*/
private $typo3Versions = [
'7 LTS' => 7006000,
'8 LTS' => 8007000,
'9 LTS' => 9005000,
];
/**
* @var int
*/
......@@ -600,4 +611,67 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
$this->likes--;
}
}
/**
* @param ObjectStorage $versions
* @param int $mainVersion
* @return bool
*/
public function isSupportingTypo3Version(ObjectStorage $versions, int $mainVersion): bool
{
foreach ($versions as $version) {
/* @var Version $version */
$supportsTypo3Version = $version->isSupportingTypo3Version($mainVersion);
if ($supportsTypo3Version) {
return true;
}
}
return false;
}
/**
* @return array
*/
public function getSupportedTypo3VersionsForLastVersion()
{
if ($this->getVersionCount() === 0) {
return [];
}
$lastVersion = $this->getLastVersion();
$versionObjectStorage = new ObjectStorage();
$versionObjectStorage->attach($lastVersion);
$supportedTypo3Versions = [];
foreach ($this->typo3Versions as $label => $mainVersion) {
$hasSupport = $this->isSupportingTypo3Version($versionObjectStorage, $mainVersion);
if ($hasSupport) {
$supportedTypo3Versions[$label] = $hasSupport;
}
}
return $supportedTypo3Versions;
}
/**
* @return array
*/
public function getSupportedTypo3VersionsForOlderVersions()
{
if ($this->getVersionCount() === 0) {
return [];
}
$lastVersion = $this->getLastVersion();
$versionObjectStorage = $this->getVersions();
$versionObjectStorage->detach($lastVersion);
$supportedTypo3Versions = [];
foreach ($this->typo3Versions as $label => $mainVersion) {
$hasSupport = $this->isSupportingTypo3Version($versionObjectStorage, $mainVersion);
if ($hasSupport) {
$supportedTypo3Versions[$label] = $hasSupport;
}
}
return $supportedTypo3Versions;
}
}
......@@ -15,7 +15,7 @@ namespace T3o\TerFe2\Domain\Model;
* The TYPO3 project - inspiring people to share!
*/
use T3o\TerFe2\Utility\VersionUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* Any type of relation of an extension
......@@ -173,11 +173,11 @@ class Relation extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
$version = [];
if (!empty($this->minimumVersion)) {
$version[] = VersionUtility::versionFromInteger($this->minimumVersion);
$version[] = VersionNumberUtility::convertIntegerToVersionNumber($this->minimumVersion);
}
if (!empty($this->maximumVersion)) {
$version[] = VersionUtility::versionFromInteger($this->maximumVersion);
$version[] = VersionNumberUtility::convertIntegerToVersionNumber($this->maximumVersion);
}
return !empty($version) ? implode(' - ', $version) : '';
......
......@@ -1151,31 +1151,28 @@ class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
}
/**
* @return array
* @return bool
*/
public function getMatrixOfSupportedTypo3Versions(): array
public function hasTypo3Dependency()
{
// @todo: Get these versions automatically
$typo3Versions = [
'7 LTS' => 7006000,
'8 LTS' => 8007000,
'9 LTS' => 9005000
];
$supportedTypo3Versions = [];
foreach ($typo3Versions as $label => $mainVersion) {
$supportedTypo3Versions[$label] = \T3o\TerFe2\Utility\VersionUtility::doesExtensionSupportTypo3Version($this->getExtension(), $mainVersion);
}
return $supportedTypo3Versions;
return $this->getTypo3Dependency() !== null;
}
/**
* @param int $mainVersion
* @return bool
*/
public function hasTypo3Dependency()
public function isSupportingTypo3Version(int $mainVersion): bool
{
return $this->getTypo3Dependency() !== null;
if ($this->hasTypo3Dependency() === false || $this->isLive() === false) {
return false;
}
$typo3Dependency = $this->getTypo3Dependency();
// reset from e.g. 7.6.21 to 7.6.0 for valid check
$resetMinimumVersion = (int)($typo3Dependency->getMinimumVersion() / 1000) * 1000;
$supportsTypo3Version = $resetMinimumVersion <= $mainVersion && $typo3Dependency->getMaximumVersion() >= $mainVersion;
return $supportsTypo3Version;
}
/**
......
......@@ -15,7 +15,6 @@ namespace T3o\TerFe2\Solr\IndexQueue;
*/
use ApacheSolrForTypo3\Solr\IndexQueue\Item;
use T3o\TerFe2\Utility\VersionUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
......@@ -113,15 +112,16 @@ class TerIndexer extends \ApacheSolrForTypo3\Solr\IndexQueue\Indexer
$document->setField('supports8_boolS', false);
$document->setField('supports9_boolS', false);
$typo3Support = [];
if (VersionUtility::doesExtensionSupportTypo3Version($extension, 7006000)) {
$versions = $extension->getVersions();
if ($extension->isSupportingTypo3Version($versions, 7006000)) {
$typo3Support[] = '7 LTS';
$document->setField('supports7_boolS', true);
}
if (VersionUtility::doesExtensionSupportTypo3Version($extension, 8007000)) {
if ($extension->isSupportingTypo3Version($versions, 8007000)) {
$typo3Support[] = '8 LTS';
$document->setField('supports8_boolS', true);
}
if (VersionUtility::doesExtensionSupportTypo3Version($extension, 9005000)) {
if ($extension->isSupportingTypo3Version($versions, 9005000)) {
$typo3Support[] = '9 LTS';
$document->setField('supports9_boolS', true);
}
......
<?php
namespace T3o\TerFe2\Utility;
/*
* 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!
*/
/**
* Utilities to manage versions
*/
class VersionUtility
{
/**
* Build version from integer
*
* @param int $version The numeric version
* @return string Version string
*/
public static function versionFromInteger($version)
{
if (empty($version)) {
return '';
}
$versionString = str_pad($version, 9, '0', STR_PAD_LEFT);
$parts = [
substr($versionString, 0, 3),
substr($versionString, 3, 3),
substr($versionString, 6, 3)
];
return intval($parts[0]) . '.' . intval($parts[1]) . '.' . intval($parts[2]);
}
/**
* @param \T3o\TerFe2\Domain\Model\Extension $extension
* @param int $mainVersion
* @return bool
*/
public static function doesExtensionSupportTypo3Version(\T3o\TerFe2\Domain\Model\Extension $extension, int $mainVersion): bool
{
foreach ($extension->getVersions() as $version) {
if ($version->hasTypo3Dependency() === false || $version->isLive() === false) {
continue;
}
// reset from e.g. 7.6.21 to 7.6.0 for valid check
$resetMinimumVersion = (int)($version->getTypo3Dependency()->getMinimumVersion() / 1000) * 1000;
$supportsTypo3Version = $resetMinimumVersion <= $mainVersion && $version->getTypo3Dependency()->getMaximumVersion() >= $mainVersion;
if ($supportsTypo3Version) {
return true;
}
}
return false;
}
}
{namespace terfe2=T3o\TerFe2\ViewHelpers}
<dl class="dl-horizontal">
<f:if condition="{extension.lastVersion.author}">
<dt>
Current version supports
</dt>
<dd>
<f:render partial="VersionSupportForTypo3" arguments="{supportedTypo3Versions: extension.supportedTypo3VersionsForLastVersion}" />
</dd>
<f:if condition="{extension.supportedTypo3VersionsForOlderVersions -> f:count()} > 0">
<dt>
Older versions support
</dt>
<dd>
<f:render partial="VersionSupportForTypo3" arguments="{supportedTypo3Versions: extension.supportedTypo3VersionsForOlderVersions}" />
</dd>
</f:if>
</f:if>
</dl>
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:if condition="{version.matrixOfSupportedTypo3Versions}">
<f:if condition="{supportedTypo3Versions -> f:count()} > 0">
<ul class="list-inline">
<f:for each="{version.matrixOfSupportedTypo3Versions}" key="label" as="supported">
<f:for each="{supportedTypo3Versions}" key="label" as="supported">
<f:if condition="{supported}">
<li class="list-inline-item badge badge-success">{label}</li>
</f:if>
......
......@@ -135,6 +135,9 @@
</f:if>
</div>
<div class="col-md-4">
<div class="alert alert-secondary">
<f:render partial="ExtensionVersionSupportsTypo3" arguments="{extension:extension, settings:settings, owner:owner, flattrUrl:flattrUrl, documentationLink:documentationLink, qualityLinkNotBroken:qualityLinkNotBroken, urlToQualityServer:urlToQualityServer}" />
</div>
<f:if condition="{extension.lastVersion.reviewState} != -1">
<f:link.action class="btn btn-primary btn-block btn-lg" controller="Extension" action="download" arguments="{extension : extension, versionString : extension.lastVersion.versionString, format : 'zip'}">
<strong>Download
......