Commit da3d1d85 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen Committed by Thomas Löffler
Browse files

[FEATURE] Add version badges to single view

parent 076a91c8
......@@ -14,6 +14,9 @@ namespace T3o\TerFe2\Domain\Model;
* The TYPO3 project - inspiring people to share!
*/
use T3o\TerFe2\Utility\VersionUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
......@@ -706,4 +709,37 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
$this->crowdinKey = $crowdinKey;
}
public function getSupportedVersion(): array
{
$supportMaintainedVersions = [];
$supportDevVersion = [];
$supportELTSVersions = [];
$supportOlderVersions = [];
$ltsVersionService = GeneralUtility::makeInstance(\T3o\TerFe2\Service\LTSVersionService::class);
foreach ($ltsVersionService->getCurrentStableVersions(true) as $versionNumber) {
if (VersionUtility::doesExtensionSupportTypo3Version($this, $versionNumber)) {
$supportMaintainedVersions[] = ['label' => $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS', 'badgeClass' => 'success'];
}
}
if ($ltsVersionService->getLatestDevelopmentVersion(true) > VersionNumberUtility::convertVersionNumberToInteger($ltsVersionService->coreData['latest_lts'])
&& VersionUtility::doesExtensionSupportTypo3Version($this, $ltsVersionService->getLatestDevelopmentVersion(true))) {
$supportDevVersion[] = ['label' => $ltsVersionService->getLatestDevelopmentVersion() . '-dev', 'badgeClass' => 'primary'];
}
foreach ($ltsVersionService->getELTSVersions() as $versionNumber) {
if (VersionUtility::doesExtensionSupportTypo3Version($this, $versionNumber)) {
$supportELTSVersions[] = ['label' => $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS', 'badgeClass' => 'warning'];
}
}
foreach ($ltsVersionService->getOldLTSVersions() as $versionNumber) {
if (VersionUtility::doesExtensionSupportTypo3Version($this, $versionNumber)) {
$supportOlderVersions[] = ['label' => $ltsVersionService->getVersionLabelOfRelease($versionNumber) . ' LTS', 'badgeClass' => 'danger'];
}
}
return array_merge($supportOlderVersions, $supportELTSVersions, $supportMaintainedVersions, $supportDevVersion);
}
}
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:if condition="{version.typo3Dependency}">
<h4>This version supports TYPO3</h4>
<p>
<f:for each="{version.matrixOfSupportedTypo3Versions}" as="version">
<f:for each="{supportedVersion}" as="version">
<button class="btn btn-{version.badgeClass} btn-sm mr-2" disabled title="{f:translate(key:'title_{version.badgeClass}', arguments: {0: version.label})}">{version.label}</button>
</f:for>
</p>
</f:if>
</html>
......@@ -92,7 +92,7 @@
<div class="row mb-3">
<div class="col-md-8">
<p itemprop="description">{extension.lastVersion.description}</p>
<f:render partial="VersionSupportForTypo3" arguments="{version: extension.lastVersion}" />
<f:render partial="VersionSupportForTypo3" arguments="{supportedVersion: extension.supportedVersion}" />
<f:if condition="{extension.composerName}">
<p class="mb-3">
<h4>Composer support</h4>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment