Example #1
0
 public function unhandleEntity(array $metadata = array())
 {
     if (!empty($metadata['sitemap_definition'])) {
         // Unresolve the sitemap information.
         $unresolver = new Unresolver($this->original_entity, false);
         $unresolver->unresolveDependencies($metadata['sitemap_definition'], 'xmlsitemap');
         $new_sitemap = (array) $unresolver->unresolvedDefinition();
         unset($new_sitemap['id']);
         unset($new_sitemap['changefreq']);
         unset($new_sitemap['changecount']);
         unset($new_sitemap['lastmod']);
         // Get the existing sitemap link.
         $existing = xmlsitemap_link_load($this->original_entity->type(), $this->original_entity->id());
         // Overwrite the values in the existing if one already exists.
         if ($existing) {
             xmlsitemap_link_save(array_replace($existing, $new_sitemap));
         } else {
             xmlsitemap_link_save($new_sitemap);
         }
     }
 }
Example #2
0
 /**
  * Generate XML sitemap links
  *
  * @return void
  */
 public function generateXMLSitemapLinks()
 {
     $iterator = new \XLite\Module\CDev\XMLSitemap\Logic\SitemapIterator();
     $i = 0;
     $options = xmlsitemap_get_changefreq_options();
     $hash = array_flip($options);
     foreach ($iterator as $record) {
         $target = $record['loc']['target'];
         unset($record['loc']['target']);
         $record['loc'] = \XLite\Core\Converter::buildDrupalPath($target, '', $record['loc']);
         $i++;
         $record['type'] = 'lc_connector';
         $record['subtype'] = '';
         $record['id'] = $i;
         if (isset($hash[$record['changefreq']])) {
             $record['changefreq'] = $hash[$record['changefreq']];
         } else {
             unset($record['changefreq']);
         }
         xmlsitemap_link_save($record);
     }
 }