You are here

function _xmlsitemap_update in XML sitemap 5.2

Update the sitemap if content has changed.

3 calls to _xmlsitemap_update()
xmlsitemap_cron in xmlsitemap/xmlsitemap.module
Implementation of hook_cron().
xmlsitemap_exit in xmlsitemap/xmlsitemap.module
Implementation of hook_exit().
xmlsitemap_output in xmlsitemap/xmlsitemap.module
Menu callback; display the sitemap.

File

xmlsitemap/xmlsitemap.module, line 639
Creates a sitemap compatible with the sitemaps.org schema.

Code

function _xmlsitemap_update() {
  db_query("DELETE FROM {xmlsitemap}");
  $fp_priority = variable_get('xmlsitemap_front_page_priority', 1);
  global $user;
  $current_user = $user;
  $user = user_load(array(
    'uid' => 0,
  ));
  if (module_exists('i18n')) {
    $language = i18n_get_lang();
    i18n_selection_mode('strict');
    $languages = locale_supported_languages();
    unset($languages['name'][$language]);
    foreach ($languages['name'] as $key => $lang) {
      i18n_get_lang($key);
      $key = $key == i18n_default_language() ? NULL : $key;
      db_query("INSERT INTO {xmlsitemap} (loc, lastmod, changefreq, priority) VALUES ('%s', %d, %d, %f)", xmlsitemap_url($key, NULL, NULL, NULL, TRUE), REQUEST_TIME - 1, 1, $fp_priority);
      module_invoke_all('xmlsitemap_links');
    }
    i18n_get_lang($language);
    $language = $language == i18n_default_language() ? NULL : $language;
    db_query("INSERT INTO {xmlsitemap} (loc, lastmod, changefreq, priority) VALUES ('%s', %d, %d, %f)", xmlsitemap_url($language, NULL, NULL, NULL, TRUE), REQUEST_TIME - 1, 1, $fp_priority);
    i18n_selection_mode('simple');
    module_invoke_all('xmlsitemap_links');
    i18n_selection_mode('reset');
  }
  else {
    db_query("INSERT INTO {xmlsitemap} (loc, lastmod, changefreq, priority) VALUES ('%s', %d, %d, %f)", xmlsitemap_url(NULL, NULL, NULL, NULL, TRUE), REQUEST_TIME - 1, 1, $fp_priority);
    module_invoke_all('xmlsitemap_links');
  }
  $user = $current_user;
  cache_clear_all(xmlsitemap_url('sitemap.xml', NULL, NULL, NULL, TRUE), 'cache_page', TRUE);
  variable_set('xmlsitemap_update', FALSE);
}