Ejemplo n.º 1
0
    /**
     * Render videos from various video portals
     *
     * @param Tx_News_Domain_Model_Media $element
     * @param integer $width
     * @param integer $height
     * @return string
     */
    public function render(Tx_News_Domain_Model_Media $element, $width, $height)
    {
        $content = $finalUrl = '';
        $url = Tx_News_Service_FileService::getCorrectUrl($element->getContent());
        // get the correct rewritten url
        $mediaWizard = \TYPO3\CMS\Frontend\MediaWizard\MediaWizardProviderManager::getValidMediaWizardProvider($url);
        if ($mediaWizard !== NULL) {
            $finalUrl = $mediaWizard->rewriteUrl($url);
        }
        // override width & height if both are set
        if ($element->getWidth() > 0 && $element->getHeight() > 0) {
            $width = $element->getWidth();
            $height = $element->getHeight();
        }
        if (!empty($finalUrl)) {
            $GLOBALS['TSFE']->getPageRenderer()->addJsFile('typo3conf/ext/news/Resources/Public/JavaScript/Contrib/swfobject-2-2.js');
            $uniqueDivId = 'mediaelement' . Tx_News_Service_FileService::getUniqueId($element);
            $content .= '<div id="' . htmlspecialchars($uniqueDivId) . '"></div>
						<script type="text/javascript">
							var params = { allowScriptAccess: "always", allowfullscreen : "true" };
							var atts = { id: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($uniqueDivId) . ' };
							swfobject.embedSWF(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($finalUrl) . ',
							' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($uniqueDivId) . ', "' . (int) $width . '", "' . (int) $height . '", "8", null, null, params, atts);
						</script>';
        }
        return $content;
    }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * 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\Frontend\MediaWizard\MediaWizardProviderInterface */
     $mediaWizard = \TYPO3\CMS\Frontend\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) {
         $returnValue = $this->cObj->typoLink_URL(array('parameter' => $mediaWizard->rewriteUrl($fileParts[0])));
     } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($fileParts[0])) {
         $returnValue = $fileParts[0];
     }
     return $returnValue;
 }
Ejemplo n.º 4
0
 /**
  * Resolves the URL of an file
  *
  * @param string $file
  * @return string|NULL
  */
 protected function retrieveMediaUrl($file)
 {
     $returnValue = NULL;
     /** @var $mediaWizard \TYPO3\CMS\Frontend\MediaWizard\MediaWizardProviderInterface */
     $mediaWizard = \TYPO3\CMS\Frontend\MediaWizard\MediaWizardProviderManager::getValidMediaWizardProvider($file);
     // Get the path relative to the page currently outputted
     if (is_file(PATH_site . $file)) {
         $returnValue = $GLOBALS['TSFE']->tmpl->getFileName($file);
     } elseif ($mediaWizard !== NULL) {
         $returnValue = $this->cObj->typoLink_URL(array('parameter' => $mediaWizard->rewriteUrl($file)));
     } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($file)) {
         $returnValue = $file;
     }
     return $returnValue;
 }