Skip to content
Snippets Groups Projects
Verified Commit e28ceba8 authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[TASK] Release version 8.1.1

parent 0f7836d8
No related branches found
Tags 8.1.1
No related merge requests found
Showing
with 136 additions and 67 deletions
......@@ -101,12 +101,12 @@ class YoutubeController extends ActionController {
}
}
$typo3Version = VersionNumberUtility::getCurrentTypo3Version();
if (version_compare($typo3Version, '13.0.0', '<')) {
$disableYoutubeCache = (bool) GeneralUtility::_GP('disableYoutubeCache');
} else {
$disableYoutubeCache = (bool) ($this->request->getParsedBody()['disableYoutubeCache'] ?? $this->request->getQueryParams()['disableYoutubeCache'] ?? null);
}
$typo3Version = VersionNumberUtility::getCurrentTypo3Version();
if (version_compare($typo3Version, '13.0.0', '<')) {
$disableYoutubeCache = (bool) GeneralUtility::_GP('disableYoutubeCache');
} else {
$disableYoutubeCache = (bool) ($this->request->getParsedBody()['disableYoutubeCache'] ?? $this->request->getQueryParams()['disableYoutubeCache'] ?? NULL);
}
// Add third-party filters
$filterInstances = $this->handleFrontendFilters($filterValues);
......@@ -329,7 +329,9 @@ class YoutubeController extends ActionController {
if (class_exists($filterConfig['filterClass'])) {
$specificFilterValues = $filterValues[$filterName] ?? [];
$filterInstance = GeneralUtility::makeInstance(
$filterConfig['filterClass'], $specificFilterValues, $filterConfig
$filterConfig['filterClass'],
$specificFilterValues,
$filterConfig
);
// Register filter to modify the request before API call
......
<?php
/**
*
* Copyright notice
......
<?php
/**
*
* Copyright notice
......
<?php
/**
*
* Copyright notice
......
<?php
/**
*
* Copyright notice
......@@ -32,38 +33,78 @@ namespace SGalinski\SgYoutube\Event;
final class BeforeYoutubeCallEvent {
private array $parameters;
private int $maxResultsWithFilters;
private string $queryString;
private string $apiKey;
private mixed $id;
public function __construct(array $parameters) {
$this->parameters = $parameters;
}
public function getParamters(): array {
return $this->parameters;
}
/**
* @return mixed
*/
public function getId() {
return $this->id;
}
/**
* @param $id
* @return void
*/
public function setId($id): void {
$this->id = $id;
}
public function getMaxResultsWithFilters() {
/**
* @return int
*/
public function getMaxResultsWithFilters(): int {
return $this->maxResultsWithFilters;
}
public function setMaxResultsWithFilters($maxResultsWithFilters): void {
/**
* @param int $maxResultsWithFilters
* @return void
*/
public function setMaxResultsWithFilters(int $maxResultsWithFilters): void {
$this->maxResultsWithFilters = $maxResultsWithFilters;
}
/**
* @return string
*/
public function getApiKey(): string {
return $this->apiKey;
}
/**
* @param string $apiKey
* @return void
*/
public function setApiKey(string $apiKey): void {
$this->apiKey = $apiKey;
}
/**
* @return string
*/
public function getQueryString(): string {
return $this->queryString;
}
/**
* @param string $queryString
* @return void
*/
public function setQueryString(string $queryString): void {
$this->queryString = $queryString;
}
......
<?php
/***************************************************************
* Copyright notice
*
......
<?php
/***************************************************************
* Copyright notice
*
......
<?php
/***************************************************************
* Copyright notice
*
......
<?php
/***************************************************************
* Copyright notice
*
......@@ -25,10 +26,13 @@
namespace SGalinski\SgYoutube\EventListeners;
use SGalinski\SgYoutube\Event\AfterVimeoCallEvent;
use SGalinski\SgYoutube\Event\AfterYoutubeCallEvent;
/**
* AfterYoutubeCallEventListener
*/
class AfterYoutubeCallEventListener {
public function __invoke(AfterVimeoCallEvent $event): void {
public function __invoke(AfterYoutubeCallEvent $event): void {
$jsonArray = $event->getJsonArray();
// Add custom data
$jsonArray['customData'] = 'This is some custom data';
......
<?php
/***************************************************************
* Copyright notice
*
......@@ -25,15 +26,15 @@
namespace SGalinski\SgYoutube\EventListeners;
use SGalinski\SgYoutube\Event\BeforeVimeoCallEvent;
use SGalinski\SgYoutube\Event\BeforeYoutubeCallEvent;
/**
* Called before we call the YouTube API
*/
class BeforeYoutubeCallEventListener {
public function __invoke(BeforeVimeoCallEvent $event): void {
public function __invoke(BeforeYoutubeCallEvent $event): void {
// Change the max results because we want to filter some more
$event->setMaxResultsWithFilters($event->getMaxResultsWithFilters() + 10);
// $event->setApiKey('new-api-key');
// $event->setApiKey('new-api-key');
}
}
<?php
/***************************************************************
* Copyright notice
*
......
<?php
/***************************************************************
* Copyright notice
*
......
<?php
/***************************************************************
* Copyright notice
*
......
<?php
/***************************************************************
* Copyright notice
*
......@@ -28,12 +29,12 @@ namespace SGalinski\SgYoutube\Filter;
class FilterParameterBag {
protected array $parameters;
protected array $filterInstances;
protected bool $disableCache = FALSE;
protected bool $disableCache = FALSE;
public function __construct(array $parameters = [], array $filterInstances = [], bool $disableCache = FALSE) {
$this->parameters = $parameters;
$this->filterInstances = $filterInstances;
$this->disableCache = $disableCache;
$this->disableCache = $disableCache;
}
public function get(string $key, $default = NULL) {
......@@ -64,13 +65,11 @@ class FilterParameterBag {
$this->filterInstances = $filterInstances;
}
public function getDisableCache(): bool
{
return $this->disableCache;
}
public function getDisableCache(): bool {
return $this->disableCache;
}
public function setDisableCache(bool $disableCache): void
{
$this->disableCache = $disableCache;
}
public function setDisableCache(bool $disableCache): void {
$this->disableCache = $disableCache;
}
}
<?php
/***************************************************************
* Copyright notice
*
......@@ -58,7 +59,6 @@ class QueryStringFilter implements FilterInterface {
* @param array $data
*/
public function modifyResponse(array &$data): void {
}
public function getFilterValues(): array {
......
......@@ -61,13 +61,16 @@ class PreviewService {
'isShorts' => (int) ($this->passVDefOnKeyToTemplate($settingsDef, 'settings.isShorts') ?? 1),
'showTitle' => (int) ($this->passVDefOnKeyToTemplate($settingsAppearance, 'settings.showTitle') ?? 1),
'showDescription' => (int) ($this->passVDefOnKeyToTemplate(
$settingsAppearance, 'settings.showDescription'
$settingsAppearance,
'settings.showDescription'
) ?? 1),
'disableLightbox' => (int) ($this->passVDefOnKeyToTemplate(
$settingsBehavior, 'settings.disableLightbox'
$settingsBehavior,
'settings.disableLightbox'
) ?? 1),
'disableLightboxMobile' => (int) ($this->passVDefOnKeyToTemplate(
$settingsBehavior, 'settings.disableLightboxMobile'
$settingsBehavior,
'settings.disableLightboxMobile'
) ?? 1),
'aspectRatio' => $this->passVDefOnKeyToTemplate($settingsAppearance, 'settings.aspectRatio'),
'thumbnailType' => $this->passVDefOnKeyToTemplate($settingsAppearance, 'settings.thumbnailType'),
......@@ -79,13 +82,14 @@ class PreviewService {
$view->assign('data', $templateData);
$view->assign(
'headerLabel', BackendUtility::getLabelFromItemListMerged(
$row['pid'],
'tt_content',
'list_type',
$row['list_type'],
$row
)
'headerLabel',
BackendUtility::getLabelFromItemListMerged(
$row['pid'],
'tt_content',
'list_type',
$row['list_type'],
$row
)
);
return $view;
}
......
......@@ -131,12 +131,13 @@ class LicenceCheckService {
'8.0.0' => 1729271668, // Tue, 18 Oct 2024 20:57:50 GMT+3
'8.0.1' => 1732058531, // Tue, 19 Nov 2024 23:15:50 GMT+3
'8.1.0' => 1733341275, // Wed, 04 Dez 2024 20:57:50 GMT+3
];
'8.1.1' => 1737826502, // 2025-01-25T17:35:02Z
];
/**
* The current extension version
*/
public const CURRENT_VERSION = '8.1.0';
public const CURRENT_VERSION = '8.1.1';
/**
* @param mixed $validUntil A timestamp, which says the lifetime of this key.
......
......@@ -29,8 +29,6 @@ namespace SGalinski\SgYoutube\Service;
use Exception;
use GuzzleHttp\Exception\ClientException;
use InvalidArgumentException;
use Psr\EventDispatcher\EventDispatcherInterface;
use SGalinski\SgYoutube\Event\BeforeYoutubeRESTEvent;
use SGalinski\SgYoutube\Filter\FilterParameterBag;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Context\Context;
......@@ -57,7 +55,7 @@ class YoutubeService {
/**
* @var FrontendInterface
*/
protected $cache;
protected FrontendInterface $cache;
/**
* @param FrontendInterface $cache
......@@ -68,7 +66,7 @@ class YoutubeService {
/**
* Maps the json array from the YouTube call to return some unified value. The output from YouTube is pretty
* unsteady. Also we calculate the correct thumbnail sized and so on.
* unsteady. Also, we calculate the correct thumbnail sized and so on.
*
* @param array $jsonArray
* @param string $youtubeId
......@@ -80,12 +78,12 @@ class YoutubeService {
* @throws Exception
*/
public function mapArray(
$jsonArray = [],
$youtubeId = '',
$aspectRatio = '16:9',
$thumbnailType = 'byAspectRatio',
$apiKey = '',
$isShorts = FALSE
array $jsonArray = [],
string $youtubeId = '',
string $aspectRatio = '16:9',
string $thumbnailType = 'byAspectRatio',
string $apiKey = '',
bool $isShorts = FALSE
): array {
if (count($jsonArray) <= 0) {
return $jsonArray;
......@@ -172,10 +170,10 @@ class YoutubeService {
* @param array $jsonArray
* @param string $apiKey
* @param int $currentLanguageUid
*
* @return array
* @throws Exception
*/
protected function addLocalizationData(array $jsonArray, $apiKey, $currentLanguageUid): array {
protected function addLocalizationData(array $jsonArray, string $apiKey, int $currentLanguageUid): array {
if (!$apiKey || !$currentLanguageUid || count($jsonArray) <= 0) {
return $jsonArray;
}
......@@ -186,8 +184,8 @@ class YoutubeService {
self::API_PART_LOCALIZATIONS
);
if (!isset($localizationData['items']) || (is_countable($localizationData['items']) ? count(
$localizationData['items']
) : 0) <= 0) {
$localizationData['items']
) : 0) <= 0) {
return $jsonArray;
}
......@@ -312,17 +310,13 @@ class YoutubeService {
/**
* Returns a JSON array with the video details (title, description, preview image, url)
*
* @param string $youtubeId
* @param string $maxResults
* @param string $apiKey
* @param string $url
* @param string $queryString
* @param FilterParameterBag $parameterBag
* @return array|mixed
* @throws Exception
*/
public function getJsonAsArray(
FilterParameterBag $parameterBag
) {
): mixed {
$parameters = $parameterBag->all();
// Dynamically build the API URL if not given
......@@ -330,8 +324,8 @@ class YoutubeService {
$cacheKey = 'sg_youtube' . sha1($url);
$disableYoutubeCache = $parameterBag->getDisableCache();
$disableYoutubeCache = $parameterBag->getDisableCache();
if (!$disableYoutubeCache) {
$cachedResult = $this->cache->get($cacheKey);
if ($cachedResult) {
......@@ -397,7 +391,8 @@ class YoutubeService {
* @return string
*/
public function getApiUrl(
array $params, array $filters
array $params,
array $filters
): string {
$youtubeId = $params['id'] ?? '';
$maxResults = $params['maxResults'] ?? '';
......@@ -441,7 +436,7 @@ class YoutubeService {
* @param string $youtubeId
* @return array|string
*/
protected function removeIdParameters($youtubeId = '') {
protected function removeIdParameters(string $youtubeId = ''): array|string {
if (strpos($youtubeId, '&')) {
return explode('&', $youtubeId)[0];
}
......
......@@ -27,11 +27,15 @@
namespace SGalinski\SgYoutube\Upgrades;
use Doctrine\DBAL\Exception;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* ThumbnailsUpgradeWizard
*/
#[UpgradeWizard('sgYoutube_thumbnailsUpgradeWizard')]
final class ThumbnailsUpgradeWizard implements UpgradeWizardInterface {
/**
......@@ -50,7 +54,7 @@ final class ThumbnailsUpgradeWizard implements UpgradeWizardInterface {
public function executeUpdate(): bool {
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('sys_file_reference');
?->getConnectionForTable('sys_file_reference');
$queryBuilder = $connection->createQueryBuilder();
$queryBuilder
......@@ -58,7 +62,8 @@ final class ThumbnailsUpgradeWizard implements UpgradeWizardInterface {
->set('fieldname', 'settings.thumbnailImages')
->where(
$queryBuilder->expr()->eq(
'fieldname', $queryBuilder->createNamedParameter('tx_sgyoutube_thumbnail_image')
'fieldname',
$queryBuilder->createNamedParameter('tx_sgyoutube_thumbnail_image')
)
);
......@@ -66,9 +71,12 @@ final class ThumbnailsUpgradeWizard implements UpgradeWizardInterface {
return TRUE;
}
/**
* @throws Exception
*/
public function updateNecessary(): bool {
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('sys_file_reference');
?->getConnectionForTable('sys_file_reference');
$queryBuilder = $connection->createQueryBuilder();
$queryBuilder->getRestrictions()->removeAll();
......@@ -78,7 +86,8 @@ final class ThumbnailsUpgradeWizard implements UpgradeWizardInterface {
->from('sys_file_reference')
->where(
$queryBuilder->expr()->eq(
'fieldname', $queryBuilder->createNamedParameter('tx_sgyoutube_thumbnail_image')
'fieldname',
$queryBuilder->createNamedParameter('tx_sgyoutube_thumbnail_image')
)
)
->executeQuery()
......@@ -87,7 +96,11 @@ final class ThumbnailsUpgradeWizard implements UpgradeWizardInterface {
return (int) $count > 0;
}
/**
* @return array|string[]
*/
public function getPrerequisites(): array {
// Add your logic here
return [];
}
}
......@@ -248,11 +248,11 @@ class PictureViewHelper extends AbstractViewHelper {
$fileExtension = $originalFile->getProperty('extension');
$convertToWebp = !$disableWebp && (
$fileExtension === 'png'
$fileExtension === 'png'
|| $fileExtension === 'jpg'
|| $fileExtension === 'jpeg'
|| $fileExtension === 'webp'
);
);
$imageUrl = self::getImage($image, $sizes, 'default', $convertToWebp);
// Don't add a scaled version for SVG's. This is not necessary at all
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment