You are here

function _xmlsitemap_node_gsitemap_replace in XML sitemap 5

Transfer data from Google Sitemap if it is installed.

1 call to _xmlsitemap_node_gsitemap_replace()
xmlsitemap_node_install in xmlsitemap_node/xmlsitemap_node.install
Implementation of hook_install().

File

xmlsitemap_node/xmlsitemap_node.install, line 56

Code

function _xmlsitemap_node_gsitemap_replace() {
  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  "))) {
    switch ($GLOBALS['db_type']) {
      case 'mysql':
      case 'mysqli':
        db_query("\n          UPDATE {xmlsitemap_node} xn, {url_alias} ua SET xn.pid = ua.pid\n          WHERE xn.pid IS NULL AND ua.src = CONCAT('node/', CAST(xn.nid AS CHAR))\n        ");
        break;
      case 'pgsql':
        db_query("\n          UPDATE {xmlsitemap_node} SET pid = {url_alias}.pid FROM {url_alias}\n          WHERE {xmlsitemap_node}.pid IS NULL AND {url_alias}.src = CONCAT('node/', CAST(nid AS VARCHAR))\n        ");
        break;
    }
    db_query("\n      INSERT INTO {xmlsitemap_node} (nid, pid, last_changed, previously_changed, last_comment, previous_comment, priority_override)\n      SELECT nid, pid, last_changed, previously_changed, last_comment, previous_comment, priority_override FROM {gsitemap}\n    ");
    $settings = db_query("SELECT * FROM {variable} WHERE name LIKE 'gsitemap\\_%wt'");
    while ($variable = db_fetch_object($settings)) {
      $ts = strlen('gsitemap_');
      $tl = strlen('wt');
      $type = substr($variable->name, $ts, -$tl);
      if (node_get_types('type', $type) === FALSE) {
        variable_set("xmlsitemap_node_{$type}_priority", (double) unserialize($variable->value));
      }
      else {
        variable_set("xmlsitemap_node_type_priority_{$type}", (double) unserialize($variable->value));
      }
      variable_del($variable->name);
    }
    $variable = db_fetch_object(db_query("SELECT * FROM {variable} WHERE name = 'gsitemap_countcom'"));
    variable_set('xmlsitemap_node_count_comments', unserialize($variable->value));
    variable_del($variable->name);
  }
}