/** * @test * @dataProvider flvFileIsRecognizedDataProvider * @return void */ public function flvFileIsRecognized($expected, $expectedOutput) { $mediaElement = new Tx_News_Domain_Model_Media(); $mediaElement->setMultimedia($expected); $renderer = new Tx_News_MediaRenderer_Video_File(); $this->assertEquals($expectedOutput, $renderer->enabled($mediaElement)); }
/** * @test * @dataProvider fileIsRecognizedDataProvider * @return void */ public function fileIsRecognized($expected, $expectedOutput) { $mediaElement = new Tx_News_Domain_Model_Media(); $mediaElement->setMultimedia($expected); $mediaElement->setType(Tx_News_Domain_Model_Media::MEDIA_TYPE_MULTIMEDIA); $renderer = new Tx_News_MediaRenderer_Audio_Mp3(); $this->assertEquals($expectedOutput, $renderer->enabled($mediaElement)); }
/** * Videosites implementation is always enabled if any file given, * the check is done in tslib_mediaWizardManager * * @param Tx_News_Domain_Model_Media $element * @return boolean */ public function enabled(Tx_News_Domain_Model_Media $element) { $result = TRUE; $file = $element->getContent(); if (empty($file)) { $result = FALSE; } return $result; }
/** * Files with extension flv|mp4 are handled within this implementation * * @param Tx_News_Domain_Model_Media $element * @return boolean */ public function enabled(Tx_News_Domain_Model_Media $element) { $url = Tx_News_Service_FileService::getFalFilename($element->getMultimedia()); $fileEnding = strtolower(substr($url, -3)); $enabled = FALSE; if ($fileEnding === 'flv' || $fileEnding === 'mp4') { $enabled = TRUE; } return $enabled; }
/** * @param Tx_News_Domain_Model_Media $element * @return null|string */ public function getYoutubeUrl(Tx_News_Domain_Model_Media $element) { $videoId = NULL; $youtubeUrl = NULL; if (preg_match('/(v=|v\\/|.be\\/)([^(\\&|$)]*)/', $element->getContent(), $matches)) { $videoId = $matches[2]; } if ($videoId) { $youtubeUrl = 'http://www.youtube.com/embed/' . $videoId . '?fs=1&wmode=opaque'; } return $youtubeUrl; }
/** * Get Vimeo url * * @param Tx_News_Domain_Model_Media $element * @return null|string */ public function getVimeoUrl(Tx_News_Domain_Model_Media $element) { $videoId = NULL; $vimeoUrl = NULL; if (preg_match('/vimeo.com\\/([0-9]+)/', $element->getContent(), $matches)) { $videoId = $matches[1]; } if ($videoId) { $vimeoUrl = '//player.vimeo.com/video/' . $videoId . ''; } return $vimeoUrl; }
/** * 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 = tslib_mediaWizardManager::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' . md5($element->getUid() . uniqid()); $content .= '<div id="' . $uniqueDivId . '"></div> <script type="text/javascript"> var params = { allowScriptAccess: "always" }; var atts = { id: "' . $uniqueDivId . '" }; swfobject.embedSWF("' . htmlspecialchars($finalUrl) . '", "' . $uniqueDivId . '", "' . (int) $width . '", "' . (int) $height . '", "8", null, null, params, atts); </script>'; } return $content; }
/** * Test if media can be set * * @test * @return void */ public function mediaCanBeSet() { $media = new Tx_News_Domain_Model_Media(); $media->setTitle('fo'); $mediaElements = new Tx_Extbase_Persistence_ObjectStorage(); $mediaElements->attach($media); $this->newsDomainModelInstance->setMedia($mediaElements); $this->assertEquals($mediaElements, $this->newsDomainModelInstance->getMedia()); }
/** * Test if description can be set * * @test * @return void */ public function descriptionCanBeSet() { $description = 'Some words'; $this->mediaDomainModelInstance->setDescription($description); $this->assertEquals($description, $this->mediaDomainModelInstance->getDescription()); }
/** * Implementation is used if file extension is mov * * @param Tx_News_Domain_Model_Media $element * @return boolean */ public function enabled(Tx_News_Domain_Model_Media $element) { $url = $element->getMultimedia(); $fileEnding = strtolower(substr($url, -3)); return $fileEnding === 'mov'; }
/** * Get a unique container id * * @param Tx_News_Domain_Model_Media $element * @return string */ public static function getUniqueId(Tx_News_Domain_Model_Media $element) { return 'mediaelement-' . md5($element->getUid() . uniqid()); }
/** * Test if correct sub selection is returned * * @test * @return void */ public function correctMediaSelectionIsReturned() { $imageElement1 = new Tx_News_Domain_Model_Media(); $imageElement1->setType(Tx_News_Domain_Model_Media::MEDIA_TYPE_IMAGE); $imageElement2 = new Tx_News_Domain_Model_Media(); $imageElement2->setType(Tx_News_Domain_Model_Media::MEDIA_TYPE_IMAGE); $imageElement3 = new Tx_News_Domain_Model_Media(); $imageElement3->setType(Tx_News_Domain_Model_Media::MEDIA_TYPE_IMAGE); $multimediaElement1 = new Tx_News_Domain_Model_Media(); $multimediaElement1->setType(Tx_News_Domain_Model_Media::MEDIA_TYPE_MULTIMEDIA); $news = new Tx_News_Domain_Model_News(); $news->addMedia($imageElement1); $news->addMedia($imageElement2); $news->addMedia($imageElement3); $news->addMedia($imageElement3); $news->addMedia($multimediaElement1); $this->assertEquals(3, count($news->getMediaTypeImage())); $this->assertEquals(1, count($news->getMediaTypeMultimedia())); $this->assertEquals(4, count($news->getMedia())); }
/** * Implementation is only used if file ending is mp3 * * @param Tx_News_Domain_Model_Media $element media element * @return boolean */ public function enabled(Tx_News_Domain_Model_Media $element) { $url = Tx_News_Service_FileService::getFalFilename($element->getContent()); $fileEnding = strtolower(substr($url, -3)); return $fileEnding === 'mp3'; }