/**
  * Resolves the URL of an file
  *
  * @param $media
  *
  * @return null|string
  */
 protected function retrieveMediaUrl($media)
 {
     $returnValue = NULL;
     if (class_exists('TYPO3\\CMS\\Mediace\\MediaWizard\\MediaWizardProviderManager')) {
         // 7.2
         $mediaWizard = \TYPO3\CMS\Mediace\MediaWizard\MediaWizardProviderManager::getValidMediaWizardProvider($media);
     } elseif (class_exists('TYPO3\\CMS\\Frontend\\MediaWizard\\MediaWizardProviderManager')) {
         // before 7.2
         $mediaWizard = \TYPO3\CMS\Frontend\MediaWizard\MediaWizardProviderManager::getValidMediaWizardProvider($media);
     } else {
         throw new \Exception('You are running TYPO3 > CMS 7.2. Please install the mediace extension', 12367238462384.0);
     }
     // Get the path relative to the page currently outputted
     if (substr($media, 0, 5) === "file:") {
         $fileUid = substr($media, 5);
         if (MathUtility::canBeInterpretedAsInteger($fileUid)) {
             $fileObject = ResourceFactory::getInstance()->getFileObject($fileUid);
             if ($fileObject instanceof FileInterface) {
                 $returnValue = $fileObject->getPublicUrl();
             }
         }
     } elseif (is_file(PATH_site . $media)) {
         $returnValue = $GLOBALS['TSFE']->tmpl->getFileName($media);
     } elseif ($mediaWizard !== NULL) {
         $cObj = new ContentObjectRenderer();
         $returnValue = $cObj->typoLink_URL(array('parameter' => $mediaWizard->rewriteUrl($media)));
     } elseif (GeneralUtility::isValidUrl($media)) {
         $returnValue = $media;
     }
     return $returnValue;
 }
 /**
  * Resolves the URL of an file
  *
  * @param string $file
  * @return string|NULL
  */
 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\Mediace\MediaWizard\MediaWizardProviderInterface */
     $mediaWizard = \TYPO3\CMS\Mediace\MediaWizard\MediaWizardProviderManager::getValidMediaWizardProvider($fileParts[0]);
     // Get the path relative to the page currently outputted
     if (substr($fileParts[0], 0, 5) === 'file:') {
         $fileUid = substr($fileParts[0], 5);
         if (!empty($fileUid) && \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) {
         $jumpUrlEnabled = $GLOBALS['TSFE']->config['config']['jumpurl_enable'];
         $GLOBALS['TSFE']->config['config']['jumpurl_enable'] = 0;
         $returnValue = $this->cObj->typoLink_URL(array('parameter' => $mediaWizard->rewriteUrl($fileParts[0])));
         $GLOBALS['TSFE']->config['config']['jumpurl_enable'] = $jumpUrlEnabled;
     } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($fileParts[0])) {
         $returnValue = $fileParts[0];
     }
     return $returnValue;
 }
Exemple #3
0
defined('TYPO3_MODE') or die;
// Register additional content objects
$GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects']['MULTIMEDIA'] = \TYPO3\CMS\Mediace\ContentObject\MultimediaContentObject::class;
$GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects']['MEDIA'] = \TYPO3\CMS\Mediace\ContentObject\MediaContentObject::class;
$GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects']['SWFOBJECT'] = \TYPO3\CMS\Mediace\ContentObject\ShockwaveFlashObjectContentObject::class;
$GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects']['FLOWPLAYER'] = \TYPO3\CMS\Mediace\ContentObject\FlowPlayerContentObject::class;
$GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects']['QTOBJECT'] = \TYPO3\CMS\Mediace\ContentObject\QuicktimeObjectContentObject::class;
// Register the "media" CType to the "New Content Element" wizard
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('
	mod.wizards.newContentElement.wizardItems {
		special.elements.media {
			icon = EXT:frontend/Resources/Public/Icons/ContentElementWizard/multimedia.gif
			title = LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:special_media_title
			description = LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:special_media_description
			tt_content_defValues.CType = media
		}
		special.show := addToList(media)
	}
');
// Add Default TypoScript for CType "media" and "multimedia" after default content rendering
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript('mediace', 'constants', '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:mediace/Configuration/TypoScript/constants.txt">', 'defaultContentRendering');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript('mediace', 'setup', '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:mediace/Configuration/TypoScript/setup.txt">', 'defaultContentRendering');
if (TYPO3_MODE === 'FE') {
    // Register the basic media wizard provider
    \TYPO3\CMS\Mediace\MediaWizard\MediaWizardProviderManager::registerMediaWizardProvider(\TYPO3\CMS\Mediace\MediaWizard\MediaWizardProvider::class);
}
if (TYPO3_MODE === 'BE') {
    // Register for hook to show preview of tt_content element of CType="multimedia" in page module
    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['multimedia'] = \TYPO3\CMS\Mediace\Hooks\PageLayoutView\MultimediaPreviewRenderer::class;
}