Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Upgrade compact view to use video elements #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ return PhpCsFixer\Config::create()
'array_syntax' => ['syntax' => 'short'],
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
])
->setFinder($finder);
->setFinder($finder);
4 changes: 4 additions & 0 deletions Classes/Backend/ImageManipulationElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
*/
class ImageManipulationElement extends \TYPO3\CMS\Backend\Form\Element\ImageManipulationElement
{
/**
* @return array
* @throws \TYPO3\CMS\Core\Imaging\ImageManipulation\InvalidConfigurationException
*/
public function render()
{
$resultArray = $this->initializeResultArray();
Expand Down
9 changes: 7 additions & 2 deletions Classes/Backend/InlineControlContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* All code (c) Beech.it all rights reserved
*/
use BeechIt\Bynder\Resource\BynderDriver;
use BeechIt\Bynder\Utility\ConfigurationUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Resource\ResourceStorage;
Expand Down Expand Up @@ -63,11 +64,15 @@ protected function renderBynderButton(array $inlineConfiguration): string

$foreign_table = $inlineConfiguration['foreign_table'];
$allowed = $groupFieldConfiguration['allowed'];
$allowedAssetTypes = ConfigurationUtility::getAssetTypesByAllowedElements($groupFieldConfiguration['appearance']['elementBrowserAllowed']);
$currentStructureDomObjectIdPrefix = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data['inlineFirstPid']);
$objectPrefix = $currentStructureDomObjectIdPrefix . '-' . $foreign_table;
$nameObject = $currentStructureDomObjectIdPrefix;

$compactViewUrl = BackendUtility::getModuleUrl('bynder_compact_view', ['element' => 'bynder' . $this->inlineData['config'][$nameObject]['md5']]);
$compactViewUrl = BackendUtility::getModuleUrl('bynder_compact_view', [
'element' => 'bynder' . $this->inlineData['config'][$nameObject]['md5'],
'assetTypes' => implode(',', $allowedAssetTypes)
]);

$this->requireJsModules[] = 'TYPO3/CMS/Bynder/CompactView';
$buttonText = htmlspecialchars($languageService->sL('LLL:EXT:bynder/Resources/Private/Language/locallang_be.xlf:compact_view.button'));
Expand Down Expand Up @@ -105,4 +110,4 @@ protected function bynderStorageAvailable(): bool
}
return false;
}
}
}
32 changes: 22 additions & 10 deletions Classes/Controller/CompactViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
* All code (c) Beech.it all rights reserved
*/

use BeechIt\Bynder\Utility\ConfigurationUtility;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use BeechIt\Bynder\Service\BynderService;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\Index\Indexer;
use TYPO3\CMS\Core\Resource\ResourceStorage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -22,6 +23,7 @@
*/
class CompactViewController
{

/**
* Fluid Standalone View
*
Expand Down Expand Up @@ -50,22 +52,21 @@ class CompactViewController
*/
protected $layoutRootPaths = ['EXT:bynder/Resources/Private/Layouts/CompactView'];


/**
* @var BynderService
* CompactViewController constructor.
*/
protected $bynderService;

public function __construct()
{
$this->bynderService = GeneralUtility::makeInstance(BynderService::class);

$this->view = GeneralUtility::makeInstance(StandaloneView::class);
$this->view->setPartialRootPaths($this->partialRootPaths);
$this->view->setTemplateRootPaths($this->templateRootPaths);
$this->view->setLayoutRootPaths($this->layoutRootPaths);
}

/**
* Action: Display compact view
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
Expand All @@ -76,25 +77,33 @@ public function indexAction(ServerRequestInterface $request, ResponseInterface $

$this->view->assignMultiple([
'language' => $this->getBackendUserAuthentication()->uc['lang'] ?: ($this->getBackendUserAuthentication()->user['lang'] ?: 'en_EN'),
'apiBaseUrl' => $this->bynderService->getApiBaseUrl(),
'apiBaseUrl' => ConfigurationUtility::getApiBaseUrl(),
'element' => $request->getQueryParams()['element'],
'assetTypes' => $request->getQueryParams()['assetTypes']
]);

$response->getBody()->write($this->view->render());

return $response;
}

/**
* Action: Retrieve file from storage
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function getFilesAction(ServerRequestInterface $request, ResponseInterface $response)
{
$files = [];
$error = '';
$fileStorage = $this->getBynderStorage();
foreach ($request->getParsedBody()['files'] ?? [] as $fileIdentifier) {
$file = $fileStorage->getFile($fileIdentifier);
if ($file) {
if ($file instanceof File) {
// (Re)Fetch metadata
$this->getIndexer($file->getStorage())->extractMetaData($file);
$this->getIndexer($fileStorage)->extractMetaData($file);
$files[] = $file->getUid();
}
}
Expand All @@ -107,6 +116,9 @@ public function getFilesAction(ServerRequestInterface $request, ResponseInterfac
return $response;
}

/**
* @return ResourceStorage
*/
protected function getBynderStorage(): ResourceStorage
{
/** @var ResourceStorage $fileStorage */
Expand Down Expand Up @@ -137,4 +149,4 @@ protected function getIndexer(ResourceStorage $storage)
{
return GeneralUtility::makeInstance(Indexer::class, $storage);
}
}
}
2 changes: 1 addition & 1 deletion Classes/Exception/BynderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

abstract class BynderException extends \Exception
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

class InvalidExtensionConfigurationException extends BynderException
{
}
}
2 changes: 1 addition & 1 deletion Classes/Exception/NotImplementedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

class NotImplementedException extends BynderException
{
}
}
2 changes: 1 addition & 1 deletion Classes/Hook/DataHandlerHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ protected function getUsageReference(string $table, int $uid): string
return $table;
}
}
}
}
Loading