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"; }