Skip to content
Snippets Groups Projects
Commit 2710f984 authored by Michael Kessler's avatar Michael Kessler
Browse files

[FEATURE] Add filter setting

parent d1b6fa26
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ class VimeoController extends ActionController {
*/
public function indexAction(): void {
$id = $this->settings['id'];
$filterIds = $this->settings['filterId'] ?? '';
$maxResults = (int) $this->settings['maxResults'];
$clientId = $this->settings['clientId'];
$clientSecret = $this->settings['clientSecret'];
......@@ -48,6 +49,14 @@ class VimeoController extends ActionController {
$this->view->assign('error', 'Please configure a client id and a client secret for sg_vimeo.');
return;
}
$filterIds = explode(',', $filterIds);
foreach ($filterIds as &$filterId) {
$filterId = trim($filterId, " ");
}
$maxResultsWithFilters = (string) ($maxResults + count($filterIds));
/** @var VimeoService $vimeoService */
$vimeoService = GeneralUtility::makeInstance(
VimeoService::class,
......@@ -55,13 +64,30 @@ class VimeoController extends ActionController {
$clientSecret,
$personalAccessToken
);
$response = $vimeoService->getVimeoData($id, $maxResults);
$response = $vimeoService->getVimeoData($id, $maxResultsWithFilters);
$response = $this->mapVimeoApiResponseWithPossibleCustomThumbnails($response);
if ($response === NULL) {
return;
}
if (is_array($response['items'])) {
$response['items'] = array_filter($response['items'], function ($item) use ($filterIds) {
$videoId = (string) $item['videoId'];
foreach ($filterIds as $filterId) {
if ($videoId === $filterId) {
return false;
}
}
return true;
});
// Fix the array indexes from previous filtering
$response['items'] = array_values($response['items']);
while (count($response['items']) > $maxResults) {
array_pop($response['items']);
}
foreach ($response['items'] as &$item) {
/*
......
......@@ -25,6 +25,17 @@
</config>
</TCEforms>
</settings.id>
<settings.filterId>
<TCEforms>
<exclude>0</exclude>
<label>LLL:EXT:sg_vimeo/Resources/Private/Language/locallang.xlf:flexform.filterIds</label>
<description>LLL:EXT:sg_vimeo/Resources/Private/Language/locallang.xlf:flexform.filterIds.description</description>
<config>
<type>input</type>
<eval>trim</eval>
</config>
</TCEforms>
</settings.filterId>
<settings.maxResults>
<TCEforms>
<exclude>0</exclude>
......
......@@ -105,6 +105,14 @@
<source><![CDATA[Example inputs - Single video: 123456789 | Channel: channel/channelname | Showcase: showcase/987645]]></source>
<target><![CDATA[Beispieleingaben - Einzelnes Video: 123456789 | Kanal: channel/kanalname | Showcase: showcase/987645]]></target>
</trans-unit>
<trans-unit id="flexform.filterIds" approved="yes">
<source><![CDATA[IDs of the videos to exclude]]></source>
<target><![CDATA[Auszuschließende Video-IDs]]></target>
</trans-unit>
<trans-unit id="flexform.filterIds.description" approved="yes">
<source><![CDATA[Insert as a comma seperated list. (12345, 67890)]]></source>
<target><![CDATA[Als ein List getrennt durch Kommas angeben. (12345, 67890)]]></target>
</trans-unit>
<trans-unit id="flexform.layout" approved="yes">
<source><![CDATA[Layout Style]]></source>
<target><![CDATA[Layout-Art]]></target>
......
......@@ -32,6 +32,12 @@
<trans-unit id="flexform.id">
<source><![CDATA[Video ID (https://vimeo.com/%VIDEO_ID%), channel name (https://vimeo.com/channels/%CHANNEL_NAME%) or showcase (https://vimeo.com/showcase/%SHOWCASE_ID%)]]></source>
</trans-unit>
<trans-unit id="flexform.filterIds">
<source><![CDATA[IDs of the videos to exclude]]></source>
</trans-unit>
<trans-unit id="flexform.filterIds.description">
<source><![CDATA[Insert as a comma seperated list. (12345, 67890)]]></source>
</trans-unit>
<trans-unit id="flexform.layout">
<source><![CDATA[Layout Style]]></source>
</trans-unit>
......
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