/**
  * Return the xml representation for the image
  *
  * @return string
  */
 public function toXML()
 {
     $xml = '<image:image><image:loc>' . Utils::encode($this->getLoc()) . '</image:loc>';
     if ($this->getCaption()) {
         $xml .= '<image:caption>' . Utils::render($this->getCaption()) . '</image:caption>';
     }
     if ($this->getGeoLocation()) {
         $xml .= '<image:geo_location>' . Utils::render($this->getGeoLocation()) . '</image:geo_location>';
     }
     if ($this->getTitle()) {
         $xml .= '<image:title>' . Utils::render($this->getTitle()) . '</image:title>';
     }
     if ($this->getLicense()) {
         $xml .= '<image:license>' . Utils::render($this->getLicense()) . '</image:license>';
     }
     $xml .= '</image:image>';
     return $xml;
 }
 public function testCamelize()
 {
     $actual = Utils::camelize('data to_camelize');
     $this->assertEquals('DataToCamelize', $actual);
 }
 /**
  * decorate w/ the video element before the closing tag
  *
  * @return string
  */
 public function toXml()
 {
     $videoXml = '<video:video>';
     //----------------------
     // required fields
     $videoXml .= '<video:thumbnail_loc>' . Utils::encode($this->getThumbnailLoc()) . '</video:thumbnail_loc>';
     foreach (array('title', 'description') as $paramName) {
         $videoXml .= '<video:' . $paramName . '>' . Utils::render($this->{Utils::getGetMethod($this, $paramName)}()) . '</video:' . $paramName . '>';
     }
     //----------------------
     //----------------------
     // simple optionnal fields
     if ($this->getCategory()) {
         $videoXml .= '<video:category>' . Utils::render($this->getCategory()) . '</video:category>';
     }
     if ($this->getContentLoc()) {
         $videoXml .= '<video:content_loc>' . Utils::encode($this->getContentLoc()) . '</video:content_loc>';
     }
     foreach (array('duration', 'rating', 'view_count', 'family_friendly', 'requires_subscription', 'live') as $paramName) {
         $getMethod = Utils::getGetMethod($this, $paramName);
         if ($this->{$getMethod}()) {
             $videoXml .= '<video:' . $paramName . '>' . $this->{$getMethod}() . '</video:' . $paramName . '>';
         }
     }
     //----------------------
     //----------------------
     // date based optionnal fields
     foreach (array('expiration_date', 'publication_date') as $paramName) {
         $getMethod = Utils::getGetMethod($this, $paramName);
         if ($this->{$getMethod}()) {
             $videoXml .= '<video:' . $paramName . '>' . $this->{$getMethod}()->format('c') . '</video:' . $paramName . '>';
         }
     }
     //----------------------
     //----------------------
     // moar complexe optionnal fields
     if ($this->getPlayerLoc()) {
         $allow_embed = $this->getPlayerLocAllowEmbed() ? ' allow_embed="' . $this->getPlayerLocAllowEmbed() . '"' : '';
         $autoplay = $this->getPlayerLocAutoplay() ? ' autoplay="' . $this->getPlayerLocAutoplay() . '"' : '';
         $videoXml .= '<video:player_loc' . $allow_embed . $autoplay . '>' . Utils::encode($this->getPlayerLoc()) . '</video:player_loc>';
     }
     if ($this->getRestrictionAllow()) {
         $videoXml .= '<video:restriction relationship="allow">' . implode(' ', $this->getRestrictionAllow()) . '</video:restriction>';
     }
     if ($this->getRestrictionDeny()) {
         $videoXml .= '<video:restriction relationship="deny">' . implode(' ', $this->getRestrictionDeny()) . '</video:restriction>';
     }
     if ($this->getGalleryLoc()) {
         $title = $this->getGalleryLocTitle() ? ' title="' . Utils::encode($this->getGalleryLocTitle()) . '"' : '';
         $videoXml .= '<video:gallery_loc' . $title . '>' . Utils::encode($this->getGalleryLoc()) . '</video:gallery_loc>';
     }
     foreach ($this->getTags() as $tag) {
         $videoXml .= '<video:tag>' . Utils::render($tag) . '</video:tag>';
     }
     foreach ($this->getPrices() as $price) {
         $type = $price['type'] ? ' type="' . $price['type'] . '"' : '';
         $resolution = $price['resolution'] ? ' resolution="' . $price['resolution'] . '"' : '';
         $videoXml .= '<video:price currency="' . $price['currency'] . '"' . $type . $resolution . '>' . $price['amount'] . '</video:price>';
     }
     if ($this->getUploader()) {
         $info = $this->getUploaderInfo() ? ' info="' . $this->getUploaderInfo() . '"' : '';
         $videoXml .= '<video:uploader' . $info . '>' . $this->getUploader() . '</video:uploader>';
     }
     if (count($this->getPlatforms())) {
         $relationship = $this->getPlatformRelationship();
         $videoXml .= '<video:platform relationship="' . $relationship . '">' . implode(' ', $this->getPlatforms()) . '</video:platform>';
     }
     //----------------------
     $videoXml .= '</video:video>';
     $baseXml = $this->urlDecorated->toXml();
     return str_replace('</url>', $videoXml . '</url>', $baseXml);
 }
 /**
  * @return string
  */
 public function toXml()
 {
     $xml = '<url><loc>' . Utils::encode($this->getLoc()) . '</loc>';
     if ($this->getLastmod()) {
         $xml .= '<lastmod>' . $this->getLastmod()->format('c') . '</lastmod>';
     }
     if ($this->getChangefreq()) {
         $xml .= '<changefreq>' . $this->getChangefreq() . '</changefreq>';
     }
     if ($this->getPriority()) {
         $xml .= '<priority>' . $this->getPriority() . '</priority>';
     }
     $xml .= '</url>';
     return $xml;
 }
 /**
  * {@inheritdoc}
  */
 public function toXml()
 {
     $newsXml = '<news:news>';
     $newsXml .= '<news:publication>';
     $newsXml .= '<news:name>' . Utils::render($this->getPublicationName()) . '</news:name>';
     $newsXml .= '<news:language>' . $this->getPublicationLanguage() . '</news:language>';
     $newsXml .= '</news:publication>';
     if ($this->getAccess()) {
         $newsXml .= '<news:access>' . $this->getAccess() . '</news:access>';
     }
     if ($this->getGenres() && count($this->getGenres()) > 0) {
         $newsXml .= '<news:genres>' . implode(', ', $this->getGenres()) . '</news:genres>';
     }
     $newsXml .= '<news:publication_date>' . $this->getPublicationDate()->format($this->getPublicationDateFormat()) . '</news:publication_date>';
     $newsXml .= '<news:title>' . Utils::render($this->getTitle()) . '</news:title>';
     if ($this->getGeoLocations()) {
         $newsXml .= '<news:geo_locations>' . $this->getGeoLocations() . '</news:geo_locations>';
     }
     if ($this->getKeywords() && count($this->getKeywords()) > 0) {
         $newsXml .= '<news:keywords>' . implode(', ', $this->getKeywords()) . '</news:keywords>';
     }
     if ($this->getStockTickers() && count($this->getStockTickers()) > 0) {
         $newsXml .= '<news:stock_tickers>' . implode(', ', $this->getStockTickers()) . '</news:stock_tickers>';
     }
     $newsXml .= '</news:news>';
     $baseXml = $this->urlDecorated->toXml();
     return str_replace('</url>', $newsXml . '</url>', $baseXml);
 }