From: Steffen Kamper Date: Wed, 16 Sep 2009 10:30:52 +0000 (+0000) Subject: Fixed bug #11902: [MediaCE] works only with absRefPrefix and doesn't support flowplayer X-Git-Tag: TYPO3_4-3-0beta1~139 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/ff37c81b0751b352cba4db5287eeb7c9e5bf73b6 Fixed bug #11902: [MediaCE] works only with absRefPrefix and doesn't support flowplayer git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5939 709f56b5-9817-0410-a4d7-c38de5d9e867 --- diff --git a/ChangeLog b/ChangeLog index 522b9acbc5d4..f0c6d3c0b59b 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-16 Steffen Kamper + + * Fixed bug #11902: [MediaCE] works only with absRefPrefix and doesn't support flowplayer + 2009-09-15 Francois Suter * Feature #11555: Integrated extension "gabriel" into TYPO3 Core as sysext "scheduler" diff --git a/typo3/sysext/cms/tslib/class.tslib_content.php b/typo3/sysext/cms/tslib/class.tslib_content.php index 81f22d0587c7..c50f08cd518c 100644 --- a/typo3/sysext/cms/tslib/class.tslib_content.php +++ b/typo3/sysext/cms/tslib/class.tslib_content.php @@ -2740,7 +2740,7 @@ class tslib_cObj { } } - // render MEDIA + // render MEDIA if ($mode == 'url' && $url != '') { // url is called direct, not with player $conf = array_merge($conf['mimeConf.']['swfobject.'], $conf); @@ -2758,7 +2758,7 @@ class tslib_cObj { if (in_array($fileinfo['fileext'], $handler)) { $renderType = strtolower($conf['fileExtHandler.'][$fileinfo['fileext']]); } - } + } switch ($renderType) { case 'swf': $conf[$conf['type'] . '.'] = array_merge($conf['mimeConf.']['swfobject.'][$conf['type'] . '.'], $typeConf); @@ -2788,7 +2788,7 @@ class tslib_cObj { $hookObj = &t3lib_div::getUserObj($classRef); $conf['file'] = $url; $conf['mode'] = $mode; - $content = $hookObj->customMediaRender($renderType, $conf); + $content = $hookObj->customMediaRender($renderType, $conf, $this); } } } @@ -2806,47 +2806,66 @@ class tslib_cObj { public function SWFOBJECT($conf) { $content = ''; $flashvars = $params = $attributes = ''; - - $filename = $this->stdWrap($conf['file'], $conf['file.']); + $prefix = ''; + if ($GLOBALS['TSFE']->baseUrl) { + $prefix = $GLOBALS['TSFE']->baseUrl; + } + if ($GLOBALS['TSFE']->absRefPrefix) { + $prefix = $GLOBALS['TSFE']->absRefPrefix; + }; $typeConf = $conf[$conf['type'] . '.']; - //add SWFobject js-file - $GLOBALS['TSFE']->additionalHeaderData['SWFobject'] = ''; - + //add SWFobject js-file + $GLOBALS['TSFE']->addJsFile('typo3/contrib/flashmedia/swfobject/swfobject.js'); + + $player = $this->stdWrap($conf[$conf['type'] . '.']['player'], $conf[$conf['type'] . '.']['player.']); + $installUrl = $conf['installUrl'] ? $conf['installUrl'] : $prefix . 'typo3/contrib/flashmedia/swfobject/expressInstall.swf'; + $filename = $this->stdWrap($conf['file'], $conf['file.']); if ($filename) { - $conf['flashvars.']['file'] = strpos($filename, '://') !== FALSE ? $filename : $GLOBALS['TSFE']->absRefPrefix . $filename; + if (strpos($filename, '://') !== FALSE) { + $conf['flashvars.']['file'] = $filename; + } else { + if ($prefix) { + $conf['flashvars.']['file'] = $prefix . $filename; + } else { + $conf['flashvars.']['file'] = str_repeat('../', substr_count($player, '/')) . $filename; + } + + } } + // Write calculated values in conf for the hook + $conf['player'] = $player; + $conf['installUrl'] = $installUrl; + $conf['filename'] = $filename; + $conf['prefix'] = $prefix; - // merge with default parameters + // merge with default parameters $conf['flashvars.'] = array_merge((array) $typeConf['default.']['flashvars.'], (array) $conf['flashvars.']); $conf['params.'] = array_merge((array) $typeConf['default.']['params.'], (array) $conf['params.']); $conf['attributes.'] = array_merge((array) $typeConf['default.']['attributes.'], (array) $conf['attributes.']); + $conf['embedParams'] = 'flashvars, params, attributes'; + // Hook for manipulating the conf array, it's needed for some players like flowplayer + if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['swfParamTransform'])) { + foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['swfParamTransform'] as $classRef) { + t3lib_div::callUserFunction($classRef, $conf, $this); + } + } if (is_array($conf['flashvars.'])) { t3lib_div::remapArrayKeys($conf['flashvars.'], $typeConf['mapping.']['flashvars.']); - foreach ($conf['flashvars.'] as $key => $value) { - $flashvars .= $key . ': "' . $value . '",'; - } } - $flashvars = 'var flashvars = {' . ($flashvars ? (substr($flashvars, -1) == ',' ? substr(trim($flashvars), 0, -1) : $flashvars) : '') . '};'; + $flashvars = 'var flashvars = ' . (count($conf['flashvars.']) ? json_encode($conf['flashvars.']) : '{}') . ';'; if (is_array($conf['params.'])) { t3lib_div::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']); - foreach ($conf['params.'] as $key => $value) { - $params .= $key . ': "' . $value . '",'; - } - $params = substr(trim($params), 0, -1); } - $params = 'var params = {' . ($params ? $params : '') . '};'; + $params = 'var params = ' . (count($conf['params.']) ? json_encode($conf['params.']) : '{}') . ';'; if (is_array($conf['attributes.'])) { t3lib_div::remapArrayKeys($conf['attributes.'], $typeConf['attributes.']['params.']); - foreach ($conf['attributes.'] as $key => $value) { - $attributes .= $key . ': "' . $value . '",'; - } } - $attributes = 'var attributes = {' . ($attributes ? (substr($attributes, -1 === ',' ? substr($attributes, 0, -1) : $attributes)) : '') . '};'; + $attributes = 'var attributes = ' . (count($conf['attributes.']) ? json_encode($conf['attributes.']) : '{}') . ';'; $flashVersion = $this->stdWrap($conf['flashVersion'], $conf['flashVersion.']); if (!$flashVersion) { @@ -2868,11 +2887,9 @@ class tslib_cObj { $width = $width ? $width : $conf[$conf['type'] . '.']['defaultWidth']; $height = $height ? $height : $conf[$conf['type'] . '.']['defaultHeight']; - $player = $this->stdWrap($conf[$conf['type'] . '.']['player'], $conf[$conf['type'] . '.']['player.']); - $installUrl = $conf['installUrl'] ? $conf['installUrl'] : $GLOBALS['TSFE']->absRefPrefix . 'typo3/contrib/flashmedia/swfobject/expressInstall.swf'; - $embed = 'swfobject.embedSWF("' . $player . '", "' . $replaceElementIdString . '", "' . $width . '", "' . $height . '", - "' . $flashVersion . '", "' . $installUrl . '", flashvars, params, attributes);'; + $embed = 'swfobject.embedSWF("' . $conf['player'] . '", "' . $replaceElementIdString . '", "' . $width . '", "' . $height . '", + "' . $flashVersion . '", "' . $installUrl . '", ' . $conf['embedParams'] . ');'; $content = $layout . ' '; + + //add QTobject js-file + $GLOBALS['TSFE']->addJsFile('typo3/contrib/flashmedia/qtobject/qtobject.js'); $replaceElementIdString = uniqid('mmqt'); $GLOBALS['TSFE']->register['MMQTID'] = $replaceElementIdString; $qtObject = 'QTObject' . $replaceElementIdString; - // merge with default parameters + // merge with default parameters $conf['params.'] = array_merge((array) $typeConf['default.']['params.'], (array) $conf['params.']); if (is_array($conf['params.'])) { @@ -2931,7 +2951,7 @@ class tslib_cObj { $width = $width ? $width : $conf[$conf['type'] . '.']['defaultWidth']; $height = $height ? $height : $conf[$conf['type'] . '.']['defaultHeight']; - $embed = 'var ' . $qtObject . ' = new QTObject("' . $GLOBALS['TSFE']->absRefPrefix . $filename . '", "' . $replaceElementIdString . '", "' . $width . '", "' . $height . '");'; + $embed = 'var ' . $qtObject . ' = new QTObject("' . $prefix . $filename . '", "' . $replaceElementIdString . '", "' . $width . '", "' . $height . '");'; $content = $layout . '