Initial commit - Typo3 11.5.41

This commit is contained in:
Matteo Gallo
2026-07-03 17:53:31 +02:00
commit 5ca4743197
6811 changed files with 568848 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
<?php
namespace Brightside\Youtubevideo\DataProcessing;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\DataProcessing\FilesProcessor;
use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry;
use Brightside\Paginatedprocessors\Processing\DataToPaginatedData;
class YoutubevideoFilesProcessor extends FilesProcessor
{
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
$allProcessedData = parent::process($cObj, $contentObjectConfiguration, $processorConfiguration, $processedData);
// Get youtube files from content element
$fileRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
if (isset($cObj->data['_LOCALIZED_UID'])) {
$youtubeObjects = $fileRepository->findByRelation('tt_content', 'tx_youtubevideo_assets', $cObj->data['_LOCALIZED_UID']);
} else {
$youtubeObjects = $fileRepository->findByRelation('tt_content', 'tx_youtubevideo_assets', $cObj->data['uid']);
}
// Loop throguh files to get data and vover image relations
foreach ($youtubeObjects as $video) {
$previewImageObjects = $fileRepository->findByRelation('sys_file_reference', 'tx_youtubevideo_coverimage', $video->getUid());
// Get the original cover image and title
$originalvideo = $video->getOriginalFile();
$helper = OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($originalvideo);
$previewFileName = $helper->getPreviewImage($originalvideo);
$original = array(
'title' => $originalvideo->getProperty('title'),
'preview' => $helper->getPreviewImage($originalvideo),
);
// Get start and end time and convert it to seconds
if($video->getProperty('tx_youtubevideo_starttime')) {
$starttime = explode(':', strval($video->getProperty('tx_youtubevideo_starttime')));
$start = ((int)$starttime[0] * 3600) + ((int)$starttime[1] * 60) + (int)$starttime[2];
} else {
$start = 0;
}
if($video->getProperty('tx_youtubevideo_endtime')) {
$endtime = explode(':', strval($video->getProperty('tx_youtubevideo_endtime')));
$end = ((int)$endtime[0] * 3600) + ((int)$endtime[1] * 60) + (int)$endtime[2];
} else {
$end = 0;
}
// Get video settings
$settings = array(
'loop' => $video->getProperty('tx_youtubevideo_loop'),
'mute' => $video->getProperty('tx_youtubevideo_mute'),
'start' => $start,
'end' => $end,
'fullscreen' => $video->getProperty('tx_youtubevideo_fullscreen'),
'ratio' => $video->getProperty('tx_youtubevideo_ratio'),
'rel' => $video->getProperty('tx_youtubevideo_rel'),
);
// Get custom cover image
$coverImages = array();
foreach ($previewImageObjects as $image) {
$coverImages[] = $image;
}
// Create video array
$youtubeVideos[] = array(
'video' => $video,
'original' => $original,
'settings' => $settings,
'coverimages' => $coverImages
);
}
$allProcessedData['youtubevideos'] = $youtubeVideos;
// Paginate with 'paginatedprocessors' extension
$paginationSettings = $processorConfiguration['pagination.'];
if ((int)($cObj->stdWrapValue('isActive', $paginationSettings ?? []))) {
$paginatedData = new DataToPaginatedData();
$allProcessedData = $paginatedData->getPaginatedData(
$cObj,
$contentObjectConfiguration,
$processorConfiguration,
$allProcessedData,
$allProcessedData['youtubevideos'],
'youtubevideos'
);
return $allProcessedData;
} else {
return $allProcessedData;
}
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Brightside\Youtubevideo\Evaluation;
/**
* Class for field value validation/evaluation to be used in 'eval' of TCA
*/
class HoursMinutesSeconds
{
/**
* JavaScript code for client side validation/evaluation
*
* @return string JavaScript code for client side validation/evaluation
*/
public function returnFieldJS()
{
return "
var value = value.replace(/[-|_|,|.||']+/g,':');
var value = value.replace(/[^\d:]+/g,'');
var value = value.replace(/^:|:$/g, '');
var p = value.split(':'),
s = 0, m = 1;
while (p.length > 0) {
s += m * parseInt(p.pop(), 10);
m *= 60;
}
if (s > 0) {
var date = new Date(0);
date.setSeconds(s);
var value = date.toISOString().substr(11, 8);
return value;
} else {
return '';
}
";
}
}

View File

@@ -0,0 +1,109 @@
<?php
namespace Brightside\Youtubevideo\Hooks\PageLayoutView;
use \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use \TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry;
use TYPO3\CMS\Core\Core\Environment;
class YoutubevideoContentElementPreviewRenderer implements PageLayoutViewDrawItemHookInterface {
/**
* Preprocesses the preview rendering of a content element of type "youtubemedia_pi1"
*
* @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
* @param bool $drawItem Whether to draw the item using the default functionality
* @param string $headerContent Header content
* @param string $itemContent Item content
* @param array $row Record row of tt_content
*
* @return void
*/
public function preProcess(
PageLayoutView &$parentObject,
&$drawItem,
&$headerContent,
&$itemContent,
array &$row
) {
// Get extension configuration
$extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
);
$extensionConfiguration = $extensionConfiguration->get('youtubevideo');
if ($row['CType'] === 'youtubevideo_pi1') {
$videoRelations = $parentObject->renderText($row['uid']);
$youtubeObjects = \TYPO3\CMS\Backend\Utility\BackendUtility::resolveFileReferences('tt_content', 'tx_youtubevideo_assets', $row);
$itemContent .= '<div class="youtubevideo-container">';
foreach ($youtubeObjects as $video) {
$original = $video->getOriginalFile();
$code = $video->getContents();
$onlineMediaHelper = OnlineMediaHelperRegistry::getInstance()->getOnlineMediaHelper($original);
$previewUrl = str_replace(Environment::getPublicPath(), '', $onlineMediaHelper->getPreviewImage($original));
if (!$video->getProperty('hidden')){
$itemContent .= '<div class="youtubevideo-item">';
if ($extensionConfiguration['youtubevideoEnableBePlayer']) {
$itemContent .= '<div class="youtubevideo-wrapper"><iframe src="https://www.youtube.com/embed/';
$itemContent .= $code;
$itemContent .= '?showinfo=0&amp;rel=0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>';
} else {
$itemContent .= $parentObject->linkEditContent('<img src="' . $previewUrl . '" />', $row);
}
if ($video->getProperty('title')){
$itemContent .= '<b class="title">' . $parentObject->linkEditContent($parentObject->renderText($video->getProperty('title')), $row) . '</b>';
}
$itemContent .= '<ul>';
if ($video->getProperty('tx_youtubevideo_mute')){
$itemContent .= '<li>' . $parentObject->linkEditContent('Mute: on', $row) . '</li>';
}
if ($video->getProperty('tx_youtubevideo_loop')){
$itemContent .= '<li>' . $parentObject->linkEditContent('Loop: on', $row) . '</li>';
}
if (!$video->getProperty('tx_youtubevideo_fullscreen')){
$itemContent .= '<li>' . $parentObject->linkEditContent('Fullscreen: off', $row) . '</li>';
}
if (!$video->getProperty('tx_youtubevideo_rel')){
$itemContent .= '<li>' . $parentObject->linkEditContent('Related: off', $row) . '</li>';
}
if ($video->getProperty('tx_youtubevideo_starttime')){
$itemContent .= '<li>' . $parentObject->linkEditContent('Start: ' . $video->getProperty('tx_youtubevideo_starttime') , $row) . '</li>';
}
if ($video->getProperty('tx_youtubevideo_endtime')){
$itemContent .= '<li>' . $parentObject->linkEditContent('End: ' . $video->getProperty('tx_youtubevideo_endtime') , $row) . '</li>';
}
$itemContent .= '</ul></div>';
}
}
$itemContent .= '</div>';
if (
$row['tx_youtubevideo_colcount'] ||
$row['tx_paginatedprocessors_paginationenabled'] ||
$row['tx_paginatedprocessors_itemsperpage'] ||
$row['tx_paginatedprocessors_pagelinksshown'] ||
$row['tx_paginatedprocessors_pagelinksshown']
) {
$itemContent .= '<div class="settings">';
if ($row['tx_youtubevideo_colcount']) {
$itemContent .= '<br /><b>Layout:</b> columns:' . $parentObject->linkEditContent($parentObject->renderText($row['tx_youtubevideo_colcount']), $row) . '';
}
if ($row['tx_paginatedprocessors_paginationenabled']) {
$itemContent .= '<br /><b> Pagination:</b> active ';
if ($row['tx_paginatedprocessors_itemsperpage']) {
$itemContent .= ' &bull; items per page: ' . $row['tx_paginatedprocessors_itemsperpage'];
}
if ($row['tx_paginatedprocessors_pagelinksshown']) {
$itemContent .= ' &bull; links shown: ' . $row['tx_paginatedprocessors_pagelinksshown'];
}
if ($row['tx_paginatedprocessors_urlsegment']) {
$itemContent .= ' &bull; url segment: ' . $row['tx_paginatedprocessors_urlsegment'];
}
}
$itemContent .= '</div>';
}
$drawItem = FALSE;
}
}
}