[BUGFIX] Media element not working with FAL 02/19002/2
authorAndreas Schütte <a.schuette@bitmotion.de>
Wed, 13 Feb 2013 08:45:44 +0000 (09:45 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 17 Mar 2013 23:13:47 +0000 (00:13 +0100)
With FAL the path to a file is no longer used,
instead the UID to the specific file is used,
prefixed with "file:"

This patch just adds a check if the filename
starts with "file:" and if so load the specific FileObject
to retrive the url. This check is done before all others,
because FAL should be the default file handler.
Additionally use explode() first to get the filename
if an editor adds (non used)
link parameters: file:740 _blank media-title

This fixes also the problem with audio files mentioned in #39416,
using the same patch.

Resolves: #41280
Related: #39416
Releases: 6.0, 6.1
Change-Id: Ibec6cefda54b6e136c0d5ae43c67ef2eea3b1bb8
Reviewed-on: https://review.typo3.org/19002
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/frontend/Classes/ContentObject/MediaContentObject.php
typo3/sysext/frontend/Classes/ContentObject/QuicktimeObjectContentObject.php
typo3/sysext/frontend/Classes/ContentObject/ShockwaveFlashObjectContentObject.php

index 7207e81..16e41fd 100644 (file)
@@ -69,6 +69,7 @@ class MediaContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConte
                }
                // Video fallback and backward compatibility file
                $videoFallback = $this->doFlexFormOverlay($conf, 'file');
+
                // Backward compatibility file
                if ($videoFallback !== NULL) {
                        $conf['file'] = $this->retrieveMediaUrl($videoFallback);
@@ -251,18 +252,33 @@ class MediaContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConte
         */
        protected function retrieveMediaUrl($file) {
                $returnValue = NULL;
+
+               // because the file value can possibly have link parameters, use explode to split all values
+               $fileParts = explode(' ', $file);
+
                /** @var $mediaWizard \TYPO3\CMS\Frontend\MediaWizard\MediaWizardProviderInterface */
-               $mediaWizard = \TYPO3\CMS\Frontend\MediaWizard\MediaWizardProviderManager::getValidMediaWizardProvider($file);
+               $mediaWizard = \TYPO3\CMS\Frontend\MediaWizard\MediaWizardProviderManager::getValidMediaWizardProvider($fileParts[0]);
                // Get the path relative to the page currently outputted
-               if (is_file(PATH_site . $file)) {
-                       $returnValue = $GLOBALS['TSFE']->tmpl->getFileName($file);
+               if (substr($fileParts[0], 0, 5) === "file:") {
+                       $fileUid = substr($fileParts[0], 5);
+
+                       if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($fileUid)) {
+                               $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileUid);
+
+                               if ($fileObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
+                                       $returnValue = $fileObject->getPublicUrl();
+                               }
+                       }
+               } elseif (is_file(PATH_site . $fileParts[0])) {
+                       $returnValue = $GLOBALS['TSFE']->tmpl->getFileName($fileParts[0]);
                } elseif ($mediaWizard !== NULL) {
                        $returnValue = $this->cObj->typoLink_URL(array(
-                               'parameter' => $mediaWizard->rewriteUrl($file)
+                               'parameter' => $mediaWizard->rewriteUrl($fileParts[0])
                        ));
-               } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($file)) {
-                       $returnValue = $file;
+               } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($fileParts[0])) {
+                       $returnValue = $fileParts[0];
                }
+
                return $returnValue;
        }
 
index 76c647c..84ea62e 100644 (file)
@@ -49,8 +49,17 @@ class QuicktimeObjectContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abs
                if ($GLOBALS['TSFE']->absRefPrefix) {
                        $prefix = $GLOBALS['TSFE']->absRefPrefix;
                }
-               $filename = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
                $type = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
+
+               // If file is audio and an explicit path has not been set,
+               // take path from audio fallback property
+               if ($type == 'audio' && empty($conf['file'])) {
+                       $conf['file'] = $conf['audioFallback'];
+               }
+               $filename = isset( $conf['file.'])
+                       ? $this->cObj->stdWrap($conf['file'], $conf['file.'])
+                       : $conf['file'];
+
                $typeConf = $conf[$type . '.'];
                // Add QTobject js-file
                $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . 'contrib/flashmedia/qtobject/qtobject.js');
index 4326a02..7d061cb 100644 (file)
@@ -58,6 +58,11 @@ class ShockwaveFlashObjectContentObject extends \TYPO3\CMS\Frontend\ContentObjec
                if (!$installUrl) {
                        $installUrl = $prefix . TYPO3_mainDir . 'contrib/flashmedia/swfobject/expressInstall.swf';
                }
+               // If file is audio and an explicit path has not been set,
+               // take path from audio fallback property
+               if ($type == 'audio' && empty($conf['file'])) {
+                       $conf['file'] = $conf['audioFallback'];
+               }
                $filename = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
                $forcePlayer = isset($conf['forcePlayer.']) ? $this->cObj->stdWrap($conf['forcePlayer'], $conf['forcePlayer.']) : $conf['forcePlayer'];
                if ($filename && $forcePlayer) {