Commit 641c4801 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

Merge branch '539-verified-extension-state-for-extensions-typo3-org' into 'develop'

[FEATURE] Add verified extensions in list and detail view

Closes #539

See merge request !687
parents daf50d09 378ba853
Pipeline #20154 passed with stages
in 6 minutes and 35 seconds
......@@ -162,6 +162,11 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implement
*/
protected $nominations = 0;
/**
* @var string
*/
protected $verified = '';
public function injectDownloadRepository(DownloadRepository $downloadRepository)
{
$this->downloadRepository = $downloadRepository;
......@@ -503,6 +508,14 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implement
$this->nominations = $nominations;
}
/**
* @return string
*/
public function getVerified(): array
{
return explode(',', $this->verified);
}
/**
* Returns all votes for the extension
*
......
......@@ -890,4 +890,23 @@ class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
return $this->getReviewState() >= 0;
}
public function isVerified(): bool
{
if ($this->getTypo3Dependency() === null) {
return false;
}
$extensionVerifiedFor = $this->getExtension()->getVerified();
$typo3Dependency = $this->getTypo3Dependency();
foreach ($extensionVerifiedFor as $majorVersion) {
$minimumVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($majorVersion . '.0');
$maximumVersion = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($majorVersion . '.999');
if ($typo3Dependency->getMinimumVersion() <= $maximumVersion && $typo3Dependency->getMaximumVersion() >= $minimumVersion) {
return true;
}
}
return false;
}
}
<?php
declare(strict_types = 1);
namespace T3o\TerFe2\Service;
class Typo3VersionService
{
const BASE_API_URL = 'https://get.typo3.org/';
const BASE_API_VERSION = 'v1';
public static function getAllMajorVersions(): array
{
$data = self::fetchDataFromPath('/major');
return $data;
}
protected static function fetchDataFromPath(string $path): array
{
$result = file_get_contents(self::buildApiUrl($path));
return json_decode($result, true);
}
protected static function buildApiUrl(string $path): string
{
return self::BASE_API_URL . self::BASE_API_VERSION . '/api' . $path;
}
}
......@@ -195,6 +195,9 @@ class TerIndexer extends \ApacheSolrForTypo3\Solr\IndexQueue\Indexer
}
}
$document->setField('author_textWstM', $authors);
// is latest version verified
$document->setField('verified_boolS', $extension->getLastVersion()->isVerified());
}
return $document;
......
<?php
declare(strict_types = 1);
namespace T3o\TerFe2\Tca;
use T3o\TerFe2\Service\Typo3VersionService;
class FetchVerifiedVersions
{
public function getMajorTypo3VersionsForSelect(array &$config)
{
foreach (Typo3VersionService::getAllMajorVersions() as $version) {
$config['items'][] = [$version['title'], $version['lts']];
}
}
}
......@@ -16,7 +16,7 @@ return [
'showRecordFieldList' => 'ext_key,forge_link,last_update,last_maintained,tags,versions,last_version,frontend_user,downloads,composer_name,repository_url,paypal_url,external_manual,expire,security_team_notice,localization_status,crowdin_key,last_download_sync',
],
'types' => [
'1' => ['showitem' => 'ext_key,forge_link,last_update,last_maintained,tags,versions,last_version,frontend_user,downloads,composer_name,repository_url,paypal_url,external_manual,security_team_notice,expire,localization_status,crowdin_key,last_download_sync'],
'1' => ['showitem' => '--div--;General,ext_key,frontend_user,composer_name,verified,--div--;Links,forge_link,repository_url,paypal_url,external_manual,--div--;Localization,localization_status,crowdin_key,--div--;Other,security_team_notice,last_update,last_maintained,tags,versions,last_version,downloads,expire,last_download_sync'],
],
'palettes' => [
'1' => ['showitem' => ''],
......@@ -249,5 +249,14 @@ return [
'MM' => 'tx_terfe2_extension_feuser_nomination_mm',
],
],
'verified' => [
'exclude' => 1,
'label' => 'Verified for TYPO3 version(s)',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'itemsProcFunc' => \T3o\TerFe2\Tca\FetchVerifiedVersions::class . '->getMajorTypo3VersionsForSelect'
],
],
],
];
......@@ -58,6 +58,10 @@
<td class="align-middle">
<strong>{version.versionString}</strong> /
<span class="ter-ext-state-{version.state}">{version.state}</span>
<f:if condition="{version.verified}">
/
<f:render partial="Verified/Badge" arguments="{height: 25, withText: 0}" />
</f:if>
<br />
<small>
<f:format.date format="F d, Y">{version.uploadDate}</f:format.date>
......
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:spaceless>
<a target="_blank" href="https://typo3.com/typo3-cms/extensions-integrations/what-are-verified-extensions-integrations" title="Verified Extension">
<img height="{height}" src="/typo3conf/ext/ter_fe2/Resources/Public/Icons/icon_verified_extension.svg" alt="verified logo" style="vertical-align: text-top;" />
<f:if condition="{withText}">
<span class="verified">verified</span>
</f:if>
</a>
</f:spaceless>
</html>
......@@ -81,6 +81,9 @@
<small class="text-muted">
<span itemprop="name" title="Extension key: {extension.extKey}">{extension.extKey}</span> /
<span title="Stability: {extension.lastVersion.state}" class="ter-ext-state-{extension.lastVersion.state}">{extension.lastVersion.state}</span>
<f:if condition="{extension.lastVersion.verified}"> /
<f:render partial="Verified/Badge" arguments="{height: 28, withText: 1}" />
</f:if>
</small>
<f:render partial="Like" arguments="{hasLiked: hasLiked, extension: extension}" />
</h2>
......
<svg id="Ebene_51" data-name="Ebene 51" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14"><defs><style>.cls-1{fill:#f08300;}</style></defs><path class="cls-1" d="M15,2.71c0-.74-.77-1.17-1.86-1.4h0a8.83,8.83,0,0,0-.94-.14A19.12,19.12,0,0,0,3.44,2h0A5.12,5.12,0,0,0,1.29,3.28,2,2,0,0,0,1,4.44a12.16,12.16,0,0,0,.92,4h0v0c1.6,4.38,3.66,5.94,3.66,5.94h0A2.24,2.24,0,0,0,7,15a1.9,1.9,0,0,0,.93-.3,6.32,6.32,0,0,0,1.24-.95l0,0a1.85,1.85,0,0,0,.14-.14c.05-.05.11-.1.17-.17h0A22.42,22.42,0,0,0,14.28,6a10.24,10.24,0,0,0,.59-2V4h0A7.66,7.66,0,0,0,15,2.71ZM12,5.15,7.26,9.89a.35.35,0,0,1-.51,0L4.11,7.22a.36.36,0,0,1,0-.52l.44-.51a.35.35,0,0,1,.51,0L6.89,8.11l4-4a.36.36,0,0,1,.52,0l.51.52A.44.44,0,0,1,12,5.15Z" transform="translate(-1 -1)"/></svg>
\ No newline at end of file
<?php
declare(strict_types = 1);
namespace T3o\TerFe2\Tests\Service;
/*
* This file is part of TYPO3 CMS-extension "ter_fe2".
*
* 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.
*/
use Nimut\TestingFramework\TestCase\AbstractTestCase;
use T3o\TerFe2\Service\Typo3VersionService;
class Typo3VersionServiceTest extends AbstractTestCase
{
/**
* @test
*/
public function getAllMajorVersionsReturnsArrayWithMultipleMajorVersions()
{
$majorVersions = Typo3VersionService::getAllMajorVersions();
self::assertNotEmpty(
$majorVersions
);
self::assertIsArray(
$majorVersions
);
self::assertArrayHasKey(
0,
$majorVersions
);
self::assertIsArray(
$majorVersions[0]
);
}
}
......@@ -33,6 +33,7 @@ CREATE TABLE tx_terfe2_domain_model_extension (
localization_status mediumtext,
last_download_sync int(11) unsigned DEFAULT '0' NOT NULL,
nominations int(11) unsigned DEFAULT '0' NOT NULL,
verified varchar(255) DEFAULT '' NOT NULL,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
crdate int(11) unsigned DEFAULT '0' NOT NULL,
......
......@@ -26,6 +26,22 @@ plugin.tx_solr {
manualSortOrder = 10 LTS, 9 LTS, 8 LTS, 7 LTS, 6.2 LTS
}
verified {
label = Verified Extension
field = verified_boolS
partialName = OptionsComposer
itemClass = primary
excludeValues = 0
renderingInstruction = CASE
renderingInstruction {
key.field = optionValue
1 = TEXT
1.value = Verified
}
}
distribution {
label = Distribution
field = distribution_boolS
......
......@@ -4,7 +4,7 @@
<f:section name="DocumentWrap">
<f:if condition="{exactMatchFound}">
<f:if condition="{exactMatchFound} || {document.verified_boolS}">
<f:then>
<div class="card card-size-medium mb-3 bg-light">
<f:render section="Document" arguments="{_all}" />
......@@ -40,6 +40,14 @@
<h4 class="card-subtitle text-muted mb-2">
{document.extensionKey_stringS} /
<span class="ter-ext-state ter-ext-state-{document.extensionState_stringS}">{document.extensionState_stringS}</span>
<f:if condition="{document.verified_boolS}"> /
<f:spaceless>
<a target="_blank" href="https://typo3.com/typo3-cms/extensions-integrations/what-are-verified-extensions-integrations" title="Verified Extension">
<img height="28" src="/typo3conf/ext/ter_fe2/Resources/Public/Icons/icon_verified_extension.svg" alt="verified logo" style="vertical-align: text-top;" />
<span class="verified">verified</span>
</a>
</f:spaceless>
</f:if>
</h4>
<p>
<small>
......
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