You are here

xmlsitemap_engines.install in XML sitemap 5

File

xmlsitemap_engines/xmlsitemap_engines.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function xmlsitemap_engines_install() {
  if (db_result(db_query("\n    SELECT 1 FROM {system}\n    WHERE type = 'module' AND name = 'gsitemap' AND (status = 1 OR schema_version >= 0)\n  "))) {
    $settings = db_query("SELECT * FROM {variable} WHERE name LIKE 'gsitemap\\_%\\_submit'");
    while ($variable = db_fetch_object($settings)) {
      $ts = strlen('gsitemap_');
      $tl = strpos($variable->name, '_com_submit') === FALSE ? strlen('_submit') : strlen('_com_submit');
      variable_set('xmlsitemap_engines_' . substr($variable->name, $ts, -$tl) . '_submit', unserialize($variable->value));
      variable_del($variable->name);
    }
    $settings = db_query("SELECT * FROM {variable} WHERE name LIKE 'gsitemap\\_%\\_url'");
    while ($variable = db_fetch_object($settings)) {
      $ts = strlen('gsitemap_');
      $tl = strpos($variable->name, '_com_url') === FALSE ? strlen('_url') : strlen('_com_url');
      variable_set('xmlsitemap_engines_' . substr($variable->name, $ts, -$tl) . '_url', unserialize($variable->value));
      variable_del($variable->name);
    }
    $settings = db_query("SELECT * FROM {variable} WHERE name LIKE 'gsitemap\\_%verify%'");
    while ($variable = db_fetch_object($settings)) {
      $ts = strlen('gsitemap_');
      $tl = strpos($variable->name, '_verify');
      $engine = $tl === FALSE ? 'google' : substr($variable->name, $ts, $tl - $ts);
      variable_set("xmlsitemap_engines_{$engine}" . strstr($variable->name, '_verify'), unserialize($variable->value));
      variable_del($variable->name);
    }
  }
}

/**
 * Implementation of hook_uninstall().
 */
function xmlsitemap_engines_uninstall() {
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'xmlsitemap\\_engines\\_'");
  while ($variable = db_fetch_object($settings)) {
    variable_del($variable->name);
  }
}

/**
 * Replace Moreover with Windows Live.
 */
function xmlsitemap_engines_update_1() {
  $ret = array();
  $submit = db_result(db_query("SELECT value FROM {variable} WHERE name = 'xmlsitemap_engines_moreover_submit'"));
  if ($submit !== FALSE) {
    variable_set('xmlsitemap_engines_live_submit', $submit);
  }
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'xmlsitemap\\_engines\\_moreover\\_'");
  while ($variable = db_fetch_object($settings)) {
    variable_del($variable->name);
  }
  return $ret;
}

/**
 * Update variables from Live Search to Bing.
 */
function xmlsitemap_engines_update_5100() {
  $variables = array(
    'submit' => FALSE,
    'url' => 'http://www.bing.com/webmaster/ping.aspx?siteMap=' . url('sitemap.xml', NULL, NULL, TRUE),
    'verify' => '',
    'verify_string' => '',
  );
  foreach ($variables as $variable => $default) {
    $value = variable_get('xmlsitemap_engines_live_' . $variable, $default);
    if ($variable == 'url' && $value == $default) {
      $value = 'http://www.bing.com/webmaster/ping.aspx?siteMap=' . url('sitemap.xml', NULL, NULL, TRUE);
    }
    variable_set('xmlsitemap_engines_bing_' . $variable, $value);
    variable_del('xmlsitemap_engines_live_' . $variable);
  }
  return array();
}

Functions

Namesort descending Description
xmlsitemap_engines_install Implementation of hook_install().
xmlsitemap_engines_uninstall Implementation of hook_uninstall().
xmlsitemap_engines_update_1 Replace Moreover with Windows Live.
xmlsitemap_engines_update_5100 Update variables from Live Search to Bing.