The GPL headers named dreipunktnull and an old address and no longer match the license of the code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace EP\EpTheme\ViewHelpers\Uri;
|
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
|
|
|
class VideoViewHelper extends AbstractViewHelper
|
|
{
|
|
/**
|
|
* @var bool
|
|
*/
|
|
protected $escapeOutput = false;
|
|
|
|
public function initializeArguments()
|
|
{
|
|
parent::initializeArguments();
|
|
|
|
$this->registerArgument('value', 'string', 'The video url', true);
|
|
$this->registerArgument('layout', 'int', 'The layout', false, 1);
|
|
}
|
|
|
|
/**
|
|
* @param array $arguments
|
|
* @param \Closure $renderChildrenClosure
|
|
* @param RenderingContextInterface $renderingContext
|
|
* @return mixed
|
|
*/
|
|
public function render()
|
|
{
|
|
// YouTube
|
|
if ((int) $this->arguments['layout'] === 0) {
|
|
return $this->arguments['value'] . '?rel=0&controls=0&showinfo=0';
|
|
}
|
|
// Vimeo
|
|
if ((int) $this->arguments['layout'] === 1) {
|
|
return sprintf('https://player.vimeo.com/video/%d?html5=1', $this->arguments['value']);
|
|
}
|
|
return '';
|
|
}
|
|
|
|
}
|