Skip to content
Snippets Groups Projects
Commit fee27f4f authored by Georgi's avatar Georgi
Browse files

[TASK] Show info about Vimeo restricting channels to EU and UK

parent 84423dca
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ use SGalinski\SgVimeo\Event\AfterFilterVideosEvent;
use SGalinski\SgVimeo\Event\AfterMapCustomThumbnailsEvent;
use SGalinski\SgVimeo\Event\AfterVimeoCallEvent;
use SGalinski\SgVimeo\Event\BeforeVimeoCallEvent;
use SGalinski\SgVimeo\Exception\RegionRestrictedException;
use SGalinski\SgVimeo\Filter\FilterParameterBag;
use SGalinski\SgVimeo\Service\CachedImageService;
use SGalinski\SgVimeo\Service\VimeoService;
......@@ -122,7 +123,15 @@ class VimeoController extends ActionController {
$this->eventDispatcher->dispatch($beforeVimeoCallEvent);
// Use the possibly modified parameters
$response = $vimeoService->getVimeoData($filterParameterBag);
try {
$response = $vimeoService->getVimeoData($filterParameterBag);
} catch (RegionRestrictedException $exception) {
$response = [];
$response['items'] = [];
$response['kind'] = 'channel';
$this->view->assign('regionRestricted', true);
}
if (count($response['items']) < 1) {
$this->view->assignMultiple([
'notFound' => TRUE,
......
<?php
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace SGalinski\SgVimeo\Exception;
use RuntimeException;
/**
* Class JsonImportException
*
* @package SGalinski\SgCookieOptin\Exception
*/
class RegionRestrictedException extends RuntimeException {
}
<?php
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
namespace SGalinski\SgVimeo\Form\Element;
use TYPO3\CMS\Backend\Form\Element\AbstractFormElement;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
/**
* Licence Status Field
*/
class ChannelWarning extends AbstractFormElement {
public function render(): array {
$errorMessage = LocalizationUtility::translate(
'flexform.channelsRestricted',
'sg_vimeo'
);
$message = '<div class="alert alert-warning" role="warning">' . $errorMessage . '</div>';
$resultArray['html'] = $message;
return $resultArray;
}
}
......@@ -58,6 +58,16 @@ class LicenceStatus extends AbstractFormElement {
return $resultArray;
}
/**
* Checks the license key and retrieves license check response data.
*
* This function verifies if the current TYPO3 version is supported,
* updates the last AJAX notification check timestamp, and retrieves
* the license check response data.
*
* @return array An array containing license check response data,
* or an empty array if the TYPO3 version is not supported.
*/
private function checkLicenceKey() {
if (!LicenceCheckService::isTYPO3VersionSupported()
) {
......
......@@ -28,6 +28,7 @@ namespace SGalinski\SgVimeo\Service;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use SGalinski\SgVimeo\Exception\RegionRestrictedException;
use SGalinski\SgVimeo\Filter\FilterParameterBag;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
......@@ -321,6 +322,9 @@ class VimeoService implements LoggerAwareInterface {
$response = $this->vimeoApiClient->request(
self::API_CHANNEL . $channelIdentifier . self::API_VIDEO . '?' . $query
);
if ($response['status'] === 404 && ($response['body']['error'] ?? '') === 'This resource is restricted in your region.') {
throw new RegionRestrictedException($response['body']['error']);
}
} catch (VimeoRequestException $e) {
throw $e;
}
......
......@@ -28,6 +28,13 @@
<eval>trim,required</eval>
</config>
</settings.id>
<settings.channelWarning>
<label></label>
<config>
<type>user</type>
<renderType>SgVimeoChannelWarning</renderType>
</config>
</settings.channelWarning>
<settings.filterId>
<exclude>0</exclude>
<label>LLL:EXT:sg_vimeo/Resources/Private/Language/locallang.xlf:flexform.filterIds</label>
......
......@@ -289,6 +289,14 @@
<source>No videos found</source>
<target>Keine Videos gefunden</target>
</trans-unit>
<trans-unit id="response.regionRestricted">
<source>This resource has been restricted in your region by Vimeo.</source>
<target>Diese Ressource wurde in Ihrer Region von Vimeo gesperrt.</target>
</trans-unit>
<trans-unit id="flexform.channelsRestricted">
<source>Vimeo has restricted the use of channels for visitors from the EU and UK area!</source>
<target>Vimeo hat die Nutzung der Kanäle für Besucher aus der EU und dem Vereinigten Königreich gesperrt!</target>
</trans-unit>
<trans-unit id="flexform.queryString" resname="flexform.queryString" approved="yes">
<source><![CDATA[Query String]]></source>
<target><![CDATA[Abfragetext]]></target>
......
......@@ -218,6 +218,12 @@
<trans-unit id="response.noItemsFound">
<source>No videos found</source>
</trans-unit>
<trans-unit id="response.regionRestricted">
<source>This resource has been restricted in your region by Vimeo.</source>
</trans-unit>
<trans-unit id="flexform.channelsRestricted">
<source>Vimeo has restricted the use of channels for visitors from the EU and UK area!</source>
</trans-unit>
<trans-unit id="flexform.queryString" resname="flexform.queryString" approved="yes">
<source><![CDATA[Query String]]></source>
</trans-unit>
......
<div style="color: red;">
{f:translate(key: 'response.noItemsFound')}
{f:translate(key: message)}
</div>
......@@ -36,7 +36,14 @@
<f:if condition="{notFound}">
<f:then>
<f:render partial="NotFound" arguments="{name: filter.name, label: filter.label}" />
<f:if condition="{regionRestricted}">
<f:then>
<f:render partial="Error" arguments="{name: filter.name, label: filter.label, message: 'response.regionRestricted'}" />
</f:then>
<f:else>
<f:render partial="Error" arguments="{name: filter.name, label: filter.label, message: 'response.noItemsFound'}" />
</f:else>
</f:if>
</f:then>
<f:else>
<f:if condition="{feedCount} < 2">
......
......@@ -57,7 +57,14 @@
<f:if condition="{notFound}">
<f:then>
<f:render partial="NotFound" arguments="{name: filter.name, label: filter.label}" />
<f:if condition="{regionRestricted}">
<f:then>
<f:render partial="Error" arguments="{name: filter.name, label: filter.label, message: 'response.regionRestricted'}" />
</f:then>
<f:else>
<f:render partial="Error" arguments="{name: filter.name, label: filter.label, message: 'response.noItemsFound'}" />
</f:else>
</f:if>
</f:then>
<f:else>
......
<?php
use SGalinski\SgVimeo\Controller\VimeoController;
use SGalinski\SgVimeo\Form\Element\ChannelWarning;
use SGalinski\SgVimeo\Form\Element\LicenceStatus;
use SGalinski\SgVimeo\Hooks\LicenceCheckHook;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
......@@ -43,3 +44,10 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][] = [
'priority' => 40,
'class' => LicenceStatus::class,
];
// Add Channel Warning render type
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][] = [
'nodeName' => 'SgVimeoChannelWarning',
'priority' => 40,
'class' => ChannelWarning::class,
];
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