first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<?php
use KupShop\CDNBundle\CDN;
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
/**
* Smarty {url} plugin.
*
* Type: function<br>
* Name: get_video<br>
* Purpose: return array describing video
*
* @param array $params parameters
* @param Smarty_Internal_Template $smarty template object
*
* @return array
*/
function smarty_function_get_video($params, &$smarty)
{
if (!isset($params['id'])) {
throw new InvalidArgumentException("Missing parameter 'id' in smarty function 'get_video'!");
}
$id = $params['id'];
$resolution = $params['resolution'] ?? '240p';
$autoplay = $params['autoplay'] ?? true;
$cdn = ServiceContainer::getService(CDN::class);
$result = [
'mp4' => $cdn->getMP4Video($id, $resolution),
'hls' => $cdn->getHLSPlaylist($id),
'direct' => $cdn->getIframeUrl($id, $autoplay),
];
if (!empty($params['assign'])) {
$smarty->assign($params['assign'], $result);
} else {
return $result;
}
}