Skip to content
Code-Schnipsel Gruppen Projekte
Commit 20a9e22c erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: support of new video quiqqer class

Übergeordneter 08163142
No related branches found
No related tags found
2 Merge Requests!7Next,!6Dev
Pipeline #5180 fehlgeschlagen mit Phase
in 12 Sekunden
<?php
/**
* Smarty plugin
*
* @package com.pcsg.pms.smarty
* @subpackage plugins
*/
use QUI\Projects\Media\Image;
use QUI\Projects\Media\Video;
/**
* Smarty {image} function plugin
*
......@@ -7,17 +17,19 @@
* Name: image<br>
*
* @param array $params
* @param Smarty $smarty
* @param Smarty_Internal_Template $smarty
*
* @return string
*
* @throws Exception
*
* @event onSmartyImageBegin [array &$params]
* @event onSmartyImageEnd [string &$imageString]
* @event onSmartyImageBeforeSource [string &$src]
* @author www.pcsg.de (Henning Leutz)
*
* @author www.pcsg.de (Henning Leutz)
*/
function smarty_function_image($params, $smarty)
function smarty_function_image(array $params, Smarty_Internal_Template $smarty): string
{
// defaults
if (!isset($params['type'])) {
......@@ -70,8 +82,12 @@ function smarty_function_image($params, $smarty)
// Image Params
if (strpos($params['src'], 'image.php') === false) {
if ((isset($params['onlyicon']) || !isset($params['onlyicon']) && !isset($params['onlysrc']) ||
isset($params['onlysrc']) && !$params['onlysrc'])
$onlySrcCheck = (isset($params['onlyicon'])
|| !isset($params['onlyicon']) && !isset($params['onlysrc'])
|| isset($params['onlysrc']) && !$params['onlysrc']);
if (
$onlySrcCheck
&& QUI\Icons\Handler::getInstance()->isIcon($params['src'])
) {
return smarty_plugin_image_assign(
......@@ -90,7 +106,7 @@ function smarty_function_image($params, $smarty)
QUI\System\Log::LEVEL_WARNING,
[
'smarty' => '{image}',
'image' => $params['src']
'image' => $params['src']
]
);
......@@ -101,7 +117,7 @@ function smarty_function_image($params, $smarty)
return smarty_plugin_image_assign($params, '', $smarty);
}
$src = str_replace('&amp;', '&', $params['src']);
$src = str_replace('&amp;', '&', $params['src']);
$attributes = QUI\Utils\StringHelper::getUrlAttributes($src);
if (!isset($attributes['id']) || !isset($attributes['project'])) {
......@@ -118,9 +134,9 @@ function smarty_function_image($params, $smarty)
try {
$Project = QUI::getProject($attributes['project']);
$Media = $Project->getMedia();
$Media = $Project->getMedia();
/* @param $Image \QUI\Projects\Media\Image */
/* @param $Image Image */
$Image = $Media->get((int)$attributes['id']);
} catch (Exception $Exception) {
QUI\System\Log::addNotice(
......@@ -155,8 +171,7 @@ function smarty_function_image($params, $smarty)
return smarty_plugin_image_assign($params, '', $smarty);
}
/* @var $Image \QUI\Projects\Media\Image */
/* @var $Image Image */
// Falls das Objekt gewünscht ist
if (isset($params['assign']) && isset($params['object'])) {
$smarty->assign($params['assign'], $Image);
......@@ -164,18 +179,17 @@ function smarty_function_image($params, $smarty)
return '';
}
if ($Image->getType() != 'QUI\Projects\Media\Image') {
// @todo video type einführen
if ($Image->getType() !== Image::class || $Image->getType() === Video::class) {
$mimeType = $Image->getAttribute('mime_type');
$html = '';
$html = '';
if (strpos($mimeType, 'video/') === 0) {
$width = '';
$height = '';
$controls = '';
$autoplay = '';
$loop = '';
$muted = '';
$width = '';
$height = '';
$controls = '';
$autoplay = '';
$loop = '';
$muted = '';
$playsinline = '';
$style = '';
......@@ -208,10 +222,10 @@ function smarty_function_image($params, $smarty)
}
if (!empty($params['style'])) {
$style = 'style="' . $params['style'] .'"';
$style = 'style="' . $params['style'] . '"';
}
$src = $Image->getUrl(true);
$src = $Image->getUrl(true);
$type = '';
if (strpos($src, '.mp4')) {
......@@ -223,8 +237,8 @@ function smarty_function_image($params, $smarty)
}
$html = '
<video width="'.$width.'" height="'.$height.'" '.$controls.' '.$autoplay.' '.$loop.' '.$muted.' '.$playsinline.' '.$style.' >
<source src="'.$src.'" type="'.$type.'" />
<video width="' . $width . '" height="' . $height . '" ' . $controls . ' ' . $autoplay . ' ' . $loop . ' ' . $muted . ' ' . $playsinline . ' ' . $style . ' >
<source src="' . $src . '" type="' . $type . '" />
Your browser does not support the video tag.
</video>
';
......@@ -241,12 +255,12 @@ function smarty_function_image($params, $smarty)
$params['width'] = false;
}
$maxWidth = '';
$maxWidth = '';
$maxHeight = '';
$ratio = false;
try {
$maxWidth = $Image->getWidth();
$maxWidth = $Image->getWidth();
$maxHeight = $Image->getHeight();
if ($maxWidth && $maxHeight) {
......@@ -279,7 +293,7 @@ function smarty_function_image($params, $smarty)
default:
case 'resize':
try {
$src = $Image->createResizeCache($params['width'], $params['height']);
$src = $Image->createResizeCache($params['width'], $params['height']);
$resizeData = $Image->getResizeSize($params['width'], $params['height']);
if ($resizeData['width'] < $params['width']) {
......@@ -355,12 +369,12 @@ function smarty_function_image($params, $smarty)
return smarty_plugin_image_assign($params, $src, $smarty);
}
$src = str_replace(CMS_DIR, URL_DIR, $src);
$src = str_replace(CMS_DIR, URL_DIR, $src);
$host = false;
if (isset($params['host']) && $params['host'] == 1) {
$host = $Image->getMedia()->getProject()->getVHost(true, true);
$src = $host . $src;
$src = $host . $src;
}
if (isset($params['onlysrc'])) {
......@@ -379,7 +393,7 @@ function smarty_function_image($params, $smarty)
}
$attributes = [];
$filter = \array_flip([
$filter = array_flip([
'src',
'type',
'reflection',
......@@ -425,11 +439,11 @@ function smarty_function_image($params, $smarty)
*
* @param array $params
* @param string $str
* @param Smarty $smarty
* @param Smarty_Internal_Template $smarty
*
* @return string
*/
function smarty_plugin_image_assign($params, $str, $smarty)
function smarty_plugin_image_assign(array $params, string $str, Smarty_Internal_Template $smarty): string
{
if (!isset($params['assign'])) {
return $str;
......
......@@ -16,7 +16,7 @@
"require": {
"php": "5.*|7.*|8.*",
"smarty\/smarty": "3.*",
"quiqqer\/quiqqer": "^1.4.3|dev-master|dev-dev",
"quiqqer\/quiqqer": "^1.9|dev-master|dev-dev",
"quiqqer\/utils": "^1.4|dev-master|dev-dev",
"quiqqer\/bricks": "^1.3|*@dev"
},
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren