Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 protected function get_xml_item_body(array $item)
 {
     $sitemap = BWP_Sitemaps_Sitemap_Tag::create_compound_tag('sitemap');
     $sitemap->add_tag(BWP_Sitemaps_Sitemap_Tag::create_single_tag('loc', $item['location']));
     if (!empty($item['lastmod'])) {
         $sitemap->add_tag(BWP_Sitemaps_Sitemap_Tag::create_single_tag('lastmod', $item['lastmod']));
     }
     return $sitemap->get_xml();
 }
Exemplo n.º 2
0
 /**
  * Create single tags from a sitemap item
  *
  * @param array $item
  * @param array $tag_names a map from tag's name to item's array key
  * @param array BWP_Sitemaps_Sitemap_Sanitizer[] $sanitizers default to null
  *
  * @return array
  */
 protected function create_tags_from_sitemap_item(array $item, array $tag_names, array $sanitizers = array())
 {
     $tags = array();
     foreach ($tag_names as $tag_name => $item_key) {
         if (!isset($item[$item_key])) {
             continue;
         }
         $tags[] = BWP_Sitemaps_Sitemap_Tag::create_single_tag($tag_name, $item[$item_key], isset($sanitizers[$tag_name]) ? $sanitizers[$tag_name] : null);
     }
     return $tags;
 }
Exemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 protected function get_xml_item_body(array $item)
 {
     // allow overriding publication name via item data
     $item['name'] = !empty($item['name']) ? $item['name'] : $this->news_name;
     $url = BWP_Sitemaps_Sitemap_Tag::create_compound_tag('url');
     $location = BWP_Sitemaps_Sitemap_Tag::create_single_tag('loc', $item['location']);
     $news = BWP_Sitemaps_Sitemap_Tag::create_compound_tag('news:news');
     $news_publication = BWP_Sitemaps_Sitemap_Tag::create_compound_tag('news:publication');
     $news_publication_tags = $this->create_tags_from_sitemap_item($item, array('news:name' => 'name', 'news:language' => 'language'));
     $news_tags = $this->create_tags_from_sitemap_item($item, array('news:genres' => 'genres', 'news:publication_date' => 'pub_date', 'news:title' => 'title', 'news:keywords' => 'keywords'));
     $url->add_tags(array($location, $news->add_tag($news_publication->add_tags($news_publication_tags))->add_tags($news_tags)));
     if ($image = $this->create_image_tag_from_sitemap_item($item)) {
         $url->add_tag($image);
     }
     return $url->get_xml();
 }