You are here

function xmlsitemap_engines_submit_sitemap in XML sitemap 6

Same name and namespace in other branches
  1. 5.2 xmlsitemap_engines/xmlsitemap_engines.module \xmlsitemap_engines_submit_sitemap()

Helper function for xmlsitemap_engines_ping_sitemap(). Submit the sitemap to the engine passed as argument, and write a message in Drupal log.

Parameters

$engine: The identifier for the search engine.

$url_var: The variable name containing the submission URL used by the search engine.

$default_url: The default submission URL.

1 call to xmlsitemap_engines_submit_sitemap()
xmlsitemap_engines_ping_sitemap in xmlsitemap_engines/xmlsitemap_engines.module
Submit the sitemap to the selected engines.

File

xmlsitemap_engines/xmlsitemap_engines.module, line 157
Define actions for Google, Yahoo!, Ask, and Bing.

Code

function xmlsitemap_engines_submit_sitemap($engine, $url_var, $default_url, $language = null) {
  $url_options = array(
    'absolute' => TRUE,
  );
  if (!is_null($language)) {
    $url_options['language'] = $language;
  }
  $url = url('sitemap.xml', $url_options);
  $url = strtr(variable_get($url_var, $default_url), array(
    '[sitemap]' => $url,
  ));
  $result = drupal_http_request($url);
  if ($result->code == 200) {
    watchdog('xmlsitemap', 'Sitemap successfully submitted to @engine.<br />Request: @url', array(
      '@engine' => $engine,
      '@url' => $url,
    ));
  }
  else {
    watchdog('xmlsitemap', 'Error occurred submitting sitemap to @engine: @code.<br />Request: @url', array(
      '@engine' => $engine,
      '@code' => 0 + $result->code,
      '@url' => $url,
    ), WATCHDOG_ERROR);
  }
}