public function populate(Sitemap $sitemap)
 {
     $url = new Url();
     $url->setLoc('http://www.google.fr');
     $url->setChangefreq(Url::CHANGEFREQ_NEVER);
     $url->setLastmod('2012-12-19 02:28');
     $video = new Video();
     $video->setThumbnailLoc('http://www.example.com/thumbs/123.jpg');
     $video->setTitle('Grilling steaks for summer');
     $video->setDescription('Alkis shows you how to get perfectly done steaks every time');
     $url->addVideo($video);
     $sitemap->add($url);
     $url = new Url();
     $url->setLoc('http://github.com');
     $url->setChangefreq(Url::CHANGEFREQ_ALWAYS);
     $url->setPriority(0.2);
     $sitemap->add($url);
 }
 protected function formatVideo(Video $video)
 {
     $buffer = "\t" . '<video:video>' . "\n";
     $buffer .= "\t\t" . '<video:title>' . $this->escape($video->getTitle()) . '</video:title>' . "\n";
     $buffer .= "\t\t" . '<video:description>' . $this->escape($video->getDescription()) . '</video:description>' . "\n";
     $buffer .= "\t\t" . '<video:thumbnail_loc>' . $this->escape($video->getThumbnailLoc()) . '</video:thumbnail_loc>' . "\n";
     if ($video->getContentLoc() !== null) {
         $buffer .= "\t\t" . '<video:content_loc>' . $this->escape($video->getContentLoc()) . '</video:content_loc>' . "\n";
     }
     if ($video->getPlayerLoc() !== null) {
         $playerLoc = $video->getPlayerLoc();
         $allowEmbed = $playerLoc['allow_embed'] ? 'yes' : 'no';
         $autoplay = $playerLoc['autoplay'] !== null ? sprintf(' autoplay="%s"', $this->escape($playerLoc['autoplay'])) : '';
         $buffer .= "\t\t" . sprintf('<video:player_loc allow_embed="%s"%s>', $allowEmbed, $autoplay) . $this->escape($playerLoc['loc']) . '</video:player_loc>' . "\n";
     }
     if ($video->getDuration() !== null) {
         $buffer .= "\t\t" . '<video:duration>' . $this->escape($video->getDuration()) . '</video:duration>' . "\n";
     }
     if ($video->getExpirationDate() !== null) {
         $buffer .= "\t\t" . '<video:expiration_date>' . $this->escape($video->getExpirationDate()) . '</video:expiration_date>' . "\n";
     }
     if ($video->getRating() !== null) {
         $buffer .= "\t\t" . '<video:rating>' . $this->escape($video->getRating()) . '</video:rating>' . "\n";
     }
     if ($video->getViewCount() !== null) {
         $buffer .= "\t\t" . '<video:view_count>' . $this->escape($video->getViewCount()) . '</video:view_count>' . "\n";
     }
     if ($video->getPublicationDate() !== null) {
         $buffer .= "\t\t" . '<video:publication_date>' . $this->escape($video->getPublicationDate()) . '</video:publication_date>' . "\n";
     }
     if ($video->getFamilyFriendly() === false) {
         $buffer .= "\t\t" . '<video:family_friendly>no</video:family_friendly>' . "\n";
     }
     if ($video->getTags() !== null) {
         foreach ($video->getTags() as $tag) {
             $buffer .= "\t\t" . '<video:tag>' . $this->escape($tag) . '</video:tag>' . "\n";
         }
     }
     if ($video->getCategory() !== null) {
         $buffer .= "\t\t" . '<video:category>' . $this->escape($video->getCategory()) . '</video:category>' . "\n";
     }
     if ($video->getRestrictions() !== null) {
         $restrictions = $video->getRestrictions();
         $relationship = $this->escape($restrictions['relationship']);
         $buffer .= "\t\t" . '<video:restriction relationship="' . $relationship . '">' . $this->escape(implode(' ', $restrictions['countries'])) . '</video:restriction>' . "\n";
     }
     if ($video->getGalleryLoc() !== null) {
         $galleryLoc = $video->getGalleryLoc();
         $title = $galleryLoc['title'] !== null ? sprintf(' title="%s"', $this->escape($galleryLoc['title'])) : '';
         $buffer .= "\t\t" . sprintf('<video:gallery_loc%s>', $title) . $this->escape($galleryLoc['loc']) . '</video:gallery_loc>' . "\n";
     }
     if ($video->getRequiresSubscription() !== null) {
         $buffer .= "\t\t" . '<video:requires_subscription>' . ($video->getRequiresSubscription() ? 'yes' : 'no') . '</video:requires_subscription>' . "\n";
     }
     if ($video->getUploader() !== null) {
         $uploader = $video->getUploader();
         $info = $uploader['info'] !== null ? sprintf(' info="%s"', $this->escape($uploader['info'])) : '';
         $buffer .= "\t\t" . sprintf('<video:uploader%s>', $info) . $this->escape($uploader['name']) . '</video:uploader>' . "\n";
     }
     if ($video->getPlatforms() !== null) {
         foreach ($video->getPlatforms() as $platform => $relationship) {
             $buffer .= "\t\t" . '<video:platform relationship="' . $this->escape($relationship) . '">' . $this->escape($platform) . '</video:platform>' . "\n";
         }
     }
     if ($video->getLive() !== null) {
         $buffer .= "\t\t" . '<video:live>' . ($video->getLive() ? 'yes' : 'no') . '</video:live>' . "\n";
     }
     return $buffer . "\t" . '</video:video>' . "\n";
 }
 public function testAddUrlBaseHostToVideos()
 {
     $dumper = new TestableMemoryDumper();
     $sitemap = new TestableSitemap($dumper, new TextFormatter(), 'http://www.google.fr');
     $url = new Url();
     $url->setLoc('http://www.joe.fr/search');
     $video = new Video();
     $video->setThumbnailLoc('/thumbs/123.jpg');
     $video->setContentLoc('/content/123.avi');
     $video->setPlayerLoc('/player/123.swf');
     $video->setGalleryLoc('/gallery/123');
     $url->addVideo($video);
     $sitemap->add($url);
     $this->assertEquals('http://www.google.fr/thumbs/123.jpg', $video->getThumbnailLoc());
     $this->assertEquals('http://www.google.fr/content/123.avi', $video->getContentLoc());
     $player = $video->getPlayerLoc();
     $this->assertEquals('http://www.google.fr/player/123.swf', $player['loc']);
     $gallery = $video->getGalleryLoc();
     $this->assertEquals('http://www.google.fr/gallery/123', $gallery['loc']);
 }
 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidPlatformRelationship()
 {
     $video = new Video();
     $video->setPlatforms(array(Video::PLATFORM_TV => Video::RESTRICTION_DENY, Video::PLATFORM_MOBILE => 'foo'));
 }
 public function testFormatFullVideo()
 {
     $formatter = new TestableXmlFormatter();
     $video = new Video();
     $video->setThumbnailLoc('http://www.example.com/thumbs/123.jpg');
     $video->setTitle('Grilling steaks for summer');
     $video->setDescription('Alkis shows you how to get perfectly done steaks every time');
     $video->setContentLoc('http://www.example.com/video123.flv');
     $video->setPlayerLoc('http://www.example.com/videoplayer.swf?video=123', true, 'ap=1');
     $video->setDuration(600);
     $video->setExpirationDate('2012-12-23');
     $video->setRating(2.2);
     $video->setViewCount(42);
     $video->setFamilyFriendly(false);
     $video->setTags(array('test', 'video'));
     $video->setCategory('test category');
     $video->setRestrictions(array('fr', 'us'), Video::RESTRICTION_DENY);
     $video->setGalleryLoc('http://www.example.com/gallery/foo', 'Foo gallery');
     $video->setRequiresSubscription(true);
     $video->setUploader('K-Phoen', 'http://www.kevingomez.fr');
     $video->setPlatforms(array(Video::PLATFORM_TV => Video::RESTRICTION_ALLOW, Video::PLATFORM_WEB => Video::RESTRICTION_ALLOW));
     $video->setLive(false);
     $this->assertEquals("\t<video:video>\n" . "\t\t<video:title>Grilling steaks for summer</video:title>\n" . "\t\t<video:description>Alkis shows you how to get perfectly done steaks every time</video:description>\n" . "\t\t<video:thumbnail_loc>http://www.example.com/thumbs/123.jpg</video:thumbnail_loc>\n" . "\t\t<video:content_loc>http://www.example.com/video123.flv</video:content_loc>\n" . "\t\t<video:player_loc allow_embed=\"yes\" autoplay=\"ap=1\">http://www.example.com/videoplayer.swf?video=123</video:player_loc>\n" . "\t\t<video:duration>600</video:duration>\n" . sprintf("\t\t<video:expiration_date>%s</video:expiration_date>\n", $this->dateFormatW3C('2012-12-23')) . "\t\t<video:rating>2.2</video:rating>\n" . "\t\t<video:view_count>42</video:view_count>\n" . "\t\t<video:family_friendly>no</video:family_friendly>\n" . "\t\t<video:tag>test</video:tag>\n" . "\t\t<video:tag>video</video:tag>\n" . "\t\t<video:category>test category</video:category>\n" . "\t\t<video:restriction relationship=\"deny\">fr us</video:restriction>\n" . "\t\t<video:gallery_loc title=\"Foo gallery\">http://www.example.com/gallery/foo</video:gallery_loc>\n" . "\t\t<video:requires_subscription>yes</video:requires_subscription>\n" . "\t\t<video:uploader info=\"http://www.kevingomez.fr\">K-Phoen</video:uploader>\n" . "\t\t<video:platform relationship=\"allow\">tv</video:platform>\n" . "\t\t<video:platform relationship=\"allow\">web</video:platform>\n" . "\t\t<video:live>no</video:live>\n" . "\t</video:video>\n", $formatter->testFormatVideo($video));
 }