diff --git a/.gitignore b/.gitignore index 671c7ff..7cf426f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ manifest/tmp/ symphony/ workspace/uploads/ install-log.txt +.vscode/ diff --git a/composer.json b/composer.json index 1b722cd..b4862b3 100644 --- a/composer.json +++ b/composer.json @@ -9,14 +9,13 @@ ], "type": "contao-bundle", "license": "LGPL-3.0-or-later", - "authors": [ - { + "authors": [{ "name": "Markus Nestmann", "role": "Developer" }, { - "name":"postyou", - "homepage":"http://postyou.de" + "name": "postyou", + "homepage": "http://postyou.de" } ], "support": { @@ -26,9 +25,9 @@ "php": "~7.0", "contao/core-bundle": "~4.3" }, - "autoload" : { + "autoload": { "psr-4": { - "Postyou\\ContaoABRStreamingBundle\\" : "src/" + "Postyou\\ContaoABRStreamingBundle\\": "src/" }, "classmap": [ "src/Resources/contao/" @@ -43,4 +42,4 @@ "extra": { "contao-manager-plugin": "Postyou\\ContaoABRStreamingBundle\\ContaoManager\\Plugin" } -} +} \ No newline at end of file diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index 3c1bc2b..c38f8e2 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -3,23 +3,27 @@ * * Extension for Contao Open Source CMS (contao.org) * - * Copyright (c) 2018-2018 POSTYOU + * Copyright (c) 2018-2019 POSTYOU * * @package * @author Markus Nestmann * @link http://www.postyou.de + * @license http://www.apache.org/licenses/LICENSE-2.0 */ + namespace Postyou\ContaoABRStreamingBundle\ContaoManager; + use Contao\ManagerPlugin\Bundle\BundlePluginInterface; use Contao\ManagerPlugin\Bundle\Config\BundleConfig; use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; + class Plugin implements BundlePluginInterface { - /** - * Plugin for the Contao Manager. - * - * @author Markus Nestmann - */ + /** + * Plugin for the Contao Manager. + * + * @author Markus Nestmann + */ public function getBundles(ParserInterface $parser) { return [ @@ -27,4 +31,4 @@ public function getBundles(ParserInterface $parser) ->setLoadAfter(['Contao\CoreBundle\ContaoCoreBundle']) ]; } -} \ No newline at end of file +} diff --git a/src/PostyouContaoABRStreamingBundle.php b/src/PostyouContaoABRStreamingBundle.php index 72e4cbd..9baf580 100644 --- a/src/PostyouContaoABRStreamingBundle.php +++ b/src/PostyouContaoABRStreamingBundle.php @@ -3,7 +3,7 @@ * * Extension for Contao Open Source CMS (contao.org) * - * Copyright (c) 2018-2018 POSTYOU + * Copyright (c) 2018-2019 POSTYOU * * @package * @author Markus Nestmann @@ -11,8 +11,9 @@ * @license http://www.apache.org/licenses/LICENSE-2.0 */ namespace Postyou\ContaoABRStreamingBundle; + use Symfony\Component\HttpKernel\Bundle\Bundle; class PostyouContaoABRStreamingBundle extends Bundle { -} \ No newline at end of file +} diff --git a/src/Resources/classes/dashPlayerPlugin.php b/src/Resources/classes/dashPlayerPlugin.php index b2040df..1a2bae0 100644 --- a/src/Resources/classes/dashPlayerPlugin.php +++ b/src/Resources/classes/dashPlayerPlugin.php @@ -1,14 +1,23 @@ getName() == 'js_mediaelement') - { + if ($objTemplate->getName() == 'js_mediaelement') { $objTemplate->setName('js_mediaelement_dash'); } } -} \ No newline at end of file +} diff --git a/src/Resources/classes/tl_content.php b/src/Resources/classes/tl_content.php index 89c1edb..e159f49 100644 --- a/src/Resources/classes/tl_content.php +++ b/src/Resources/classes/tl_content.php @@ -1,5 +1,15 @@ id); + $objCte = ContentModel::findByPk($dc->id); - if ($objCte === null) - { - return; + if ($objCte === null) { + return; } - if ($objCte->type == 'abrstreaming') Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplate'], 'js_mediaelement')); + if ($objCte->type == 'abrstreaming') { + Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplate'], 'js_mediaelement')); + } } -} \ No newline at end of file +} diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 41e4813..456bad4 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -3,15 +3,16 @@ * * Extension for Contao Open Source CMS (contao.org) * - * Copyright (c) 2018-2018 POSTYOU + * Copyright (c) 2018-2019 POSTYOU * * @package * @author Markus Nestmann * @link http://www.postyou.de + * @license http://www.apache.org/licenses/LICENSE-2.0 */ $GLOBALS['TL_CTE']['media']['abrstreaming'] = 'Postyou\ContaoABRStreamingBundle\ContentAbrstreaming'; $GLOBALS['TL_MIME']['mpd'] = array('application/dash+xml', 'iconMPEG.svg'); $GLOBALS['TL_MIME']['m3u8'] = array('application/x-mpegURL', 'iconMPEG.svg'); -$GLOBALS['TL_HOOKS']['parseTemplate'][] = array('Postyou\ContaoABRStreamingBundle\dashPlayerPlugin', 'myParseFrontendTemplate'); \ No newline at end of file +$GLOBALS['TL_HOOKS']['parseTemplate'][] = array('Postyou\ContaoABRStreamingBundle\dashPlayerPlugin', 'myParseFrontendTemplate'); diff --git a/src/Resources/contao/dca/tl_content.php b/src/Resources/contao/dca/tl_content.php index 4f87dd3..d30e864 100644 --- a/src/Resources/contao/dca/tl_content.php +++ b/src/Resources/contao/dca/tl_content.php @@ -1,32 +1,39 @@ &$GLOBALS['TL_LANG']['tl_content']['abrs_playerSRC'], - 'exclude' => true, - 'inputType' => 'fileTree', - 'eval' => array('filesOnly'=>true, 'multiple'=>true, 'fieldType'=>'checkbox', 'extensions' =>'mpd, m3u8, mp4, m4v, mov, wmv, webm, ogv', 'mandatory'=>true, 'tl_class'=>'clr autoheight'), - 'sql' => "blob NULL" +$GLOBALS['TL_DCA']['tl_content']['fields']['abrs_playerSRC'] = array( + 'label' => &$GLOBALS['TL_LANG']['tl_content']['abrs_playerSRC'], + 'exclude' => true, + 'inputType' => 'fileTree', + 'eval' => array('filesOnly'=>true, 'multiple'=>true, 'fieldType'=>'checkbox', 'extensions' =>'mpd, m3u8, mp4, m4v, mov, wmv, webm, ogv', 'mandatory'=>true, 'tl_class'=>'clr autoheight'), + 'sql' => "blob NULL" +); +$GLOBALS['TL_DCA']['tl_content']['fields']['abrs_playerSize'] = array( + 'label' => &$GLOBALS['TL_LANG']['tl_content']['playerSize'], + 'exclude' => true, + 'inputType' => 'text', + 'eval' => array('multiple'=>true, 'size'=>2, 'rgxp'=>'natural', 'nospace'=>true, 'tl_class'=>'w50'), + 'sql' => "varchar(64) NOT NULL default ''" ); -$GLOBALS['TL_DCA']['tl_content']['fields']['abrs_playerSize'] = array -( - 'label' => &$GLOBALS['TL_LANG']['tl_content']['playerSize'], - 'exclude' => true, - 'inputType' => 'text', - 'eval' => array('multiple'=>true, 'size'=>2, 'rgxp'=>'natural', 'nospace'=>true, 'tl_class'=>'w50'), - 'sql' => "varchar(64) NOT NULL default ''" +$GLOBALS['TL_DCA']['tl_content']['fields']['abrs_autoplay'] = array( + 'label' => &$GLOBALS['TL_LANG']['tl_content']['autoplay'], + 'exclude' => true, + 'inputType' => 'checkbox', + 'eval' => array('tl_class'=>'w50 m12'), + 'sql' => "char(1) NOT NULL default ''" ); -$GLOBALS['TL_DCA']['tl_content']['fields']['abrs_autoplay'] = array -( - 'label' => &$GLOBALS['TL_LANG']['tl_content']['autoplay'], - 'exclude' => true, - 'inputType' => 'checkbox', - 'eval' => array('tl_class'=>'w50 m12'), - 'sql' => "char(1) NOT NULL default ''" -); \ No newline at end of file diff --git a/src/Resources/contao/elements/ContentAbrstreaming.php b/src/Resources/contao/elements/ContentAbrstreaming.php index e6760e5..0ce3ade 100644 --- a/src/Resources/contao/elements/ContentAbrstreaming.php +++ b/src/Resources/contao/elements/ContentAbrstreaming.php @@ -1,128 +1,124 @@ abrs_playerSRC == '') - { - return ''; - } - $source = \StringUtil::deserialize($this->abrs_playerSRC); - - if (empty($source) || !\is_array($source)) - { - return ''; - } - - $objFiles = \FilesModel::findMultipleByUuidsAndExtensions($source, array('mpd', 'm3u8', 'mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv')); - - if ($objFiles === null) - { - return ''; - } - - // Display a list of files in the back end - if (TL_MODE == 'BE') - { - $return = ''; - } - - $this->objFiles = $objFiles; - - return parent::generate(); - } - - /** - * Generate the module - */ - protected function compile() - { - /** @var PageModel $objPage */ - global $objPage; - - $objFiles = $this->objFiles; - - /** @var FilesModel $objFirst */ - $objFirst = $objFiles->current(); - - // Pre-sort the array by preference - if (\in_array($objFirst->extension, array('mpd','m3u8', 'mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv'))) - { - $arrFiles = array('mpd'=>null, 'm3u8'=>null, 'mp4'=>null, 'm4v'=>null, 'mov'=>null, 'wmv'=>null, 'webm'=>null, 'ogv'=>null); - } - - $objFiles->reset(); - - // Convert the language to a locale (see #5678) - $strLanguage = str_replace('-', '_', $objPage->language); - - // Pass File objects to the template - while ($objFiles->next()) - { - $arrMeta = \StringUtil::deserialize($objFiles->meta); - - if (\is_array($arrMeta) && isset($arrMeta[$strLanguage])) - { - $strTitle = $arrMeta[$strLanguage]['title']; - } - else - { - $strTitle = $objFiles->name; - } - - $objFile = new \File($objFiles->path); - $objFile->title = \StringUtil::specialchars($strTitle); - - $arrFiles[$objFile->extension] = $objFile; - } - - $size = \StringUtil::deserialize($this->abrs_playerSize); - - if (!\is_array($size) || empty($size[0]) || empty($size[1])) - { - - $this->Template->size = ' width="640" height="360"'; - } - else - { - $this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"'; - } - - $this->Template->files = array_values(array_filter($arrFiles)); - $this->Template->autoplay = $this->abrs_autoplay; - } + /** + * Return if there are no files + * + * @return string + */ + public function generate() + { + if ($this->abrs_playerSRC == '') { + return ''; + } + $source = \StringUtil::deserialize($this->abrs_playerSRC); + + if (empty($source) || !\is_array($source)) { + return ''; + } + + $objFiles = \FilesModel::findMultipleByUuidsAndExtensions($source, array('mpd', 'm3u8', 'mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv')); + + if ($objFiles === null) { + return ''; + } + + // Display a list of files in the back end + if (TL_MODE == 'BE') { + $return = ''; + } + + $this->objFiles = $objFiles; + + return parent::generate(); + } + + /** + * Generate the module + */ + protected function compile() + { + /** @var PageModel $objPage */ + global $objPage; + + $objFiles = $this->objFiles; + + /** @var FilesModel $objFirst */ + $objFirst = $objFiles->current(); + + // Pre-sort the array by preference + if (\in_array($objFirst->extension, array('mpd','m3u8', 'mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv'))) { + $arrFiles = array('mpd'=>null, 'm3u8'=>null, 'mp4'=>null, 'm4v'=>null, 'mov'=>null, 'wmv'=>null, 'webm'=>null, 'ogv'=>null); + } + + $objFiles->reset(); + + // Convert the language to a locale (see #5678) + $strLanguage = str_replace('-', '_', $objPage->language); + + // Pass File objects to the template + while ($objFiles->next()) { + $arrMeta = \StringUtil::deserialize($objFiles->meta); + + if (\is_array($arrMeta) && isset($arrMeta[$strLanguage])) { + $strTitle = $arrMeta[$strLanguage]['title']; + } else { + $strTitle = $objFiles->name; + } + + $objFile = new \File($objFiles->path); + $objFile->title = \StringUtil::specialchars($strTitle); + + $arrFiles[$objFile->extension] = $objFile; + } + + $size = \StringUtil::deserialize($this->abrs_playerSize); + + if (!\is_array($size) || empty($size[0]) || empty($size[1])) { + $this->Template->size = ' width="640" height="360"'; + } else { + $this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"'; + } + + $this->Template->files = array_values(array_filter($arrFiles)); + $this->Template->autoplay = $this->abrs_autoplay; + } } diff --git a/src/Resources/contao/languages/de/default.php b/src/Resources/contao/languages/de/default.php index aa72977..169d00f 100644 --- a/src/Resources/contao/languages/de/default.php +++ b/src/Resources/contao/languages/de/default.php @@ -1,6 +1,13 @@ extend('block_unsearchable'); ?> block('content'); ?> - - headline): ?> - <hl; ?>>headline; ?>hl; ?>> - + +headline): ?> +<hl; ?>> + headline; ?> +hl; ?>> + - + -endblock(); ?> +endblock(); ?> \ No newline at end of file diff --git a/src/Resources/contao/templates/js_mediaelement_dash.html5 b/src/Resources/contao/templates/js_mediaelement_dash.html5 index 189a9be..02e9880 100644 --- a/src/Resources/contao/templates/js_mediaelement_dash.html5 +++ b/src/Resources/contao/templates/js_mediaelement_dash.html5 @@ -8,11 +8,11 @@ $GLOBALS['TL_CSS'][] = 'bundles/postyoucontaoabrstreaming/css/qualityselection.c