You are here

paging_xmlsitemap.install in Paging 5

Install file for Paging: XML Sitemap

File

contrib/paging_xmlsitemap/paging_xmlsitemap.install
View source
<?php

/**
 * @file
 * Install file for Paging: XML Sitemap
 */

/**
 * Implementation of hook_install().
 */
function paging_xmlsitemap_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {paging_xmlsitemap} (\n        nid int(10) unsigned NOT NULL default 0,\n        pages int(10) unsigned NOT NULL default 0,\n        PRIMARY KEY (nid)\n      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {paging_xmlsitemap} (\n        nid int NOT NULL default 0,\n        pages int NOT NULL default 0,\n        PRIMARY KEY (nid)\n      );");
      break;
  }
  _paging_xmlsitemap_paging_gsitemap_replace();
}

/**
 * Transfer data from Paging: Google Sitemap if it was installed.
 */
function _paging_xmlsitemap_paging_gsitemap_replace() {
  if (db_result(db_query("\n    SELECT 1 FROM {system}\n    WHERE type = 'module' AND name = 'paging_gsitemap' AND (status = 1 OR schema_version >= 0)\n  "))) {
    db_query("INSERT INTO {paging_xmlsitemap} SELECT * FROM {paging}");
    db_query("UPDATE {system} SET status = 0, throttle = 0 WHERE type = 'module' AND name = 'paging_gsitemap'");
    db_query("DROP TABLE {paging}");
    drupal_set_installed_schema_version('paging_gsitemap', SCHEMA_UNINSTALLED);
  }
}

/**
 * Implementation of hook_enable().
 */
function paging_xmlsitemap_enable() {
  $result = db_query("SELECT n.nid FROM {node} n INNER JOIN {paging_xmlsitemap} px ON n.nid = px.nid");
  while ($node = db_fetch_object($result)) {
    $node = node_load($node->nid);
    paging_xmlsitemap_nodeapi($node, 'update');
  }
  $result = db_query("SELECT n.nid FROM {node} n LEFT JOIN {paging_xmlsitemap} px ON px.nid = n.nid WHERE px.nid IS NULL");
  while ($node = db_fetch_object($result)) {
    $node = node_load($node->nid);
    paging_xmlsitemap_nodeapi($node, 'insert');
  }
  xmlsitemap_update_sitemap();
}

/**
 * Implementation of hook_disable().
 */
function paging_xmlsitemap_disable() {
  xmlsitemap_update_sitemap();
}

/**
 * Implementation of hook_uninstall().
 */
function paging_xmlsitemap_uninstall() {
  db_query("DROP TABLE {paging_xmlsitemap}");
}

Functions

Namesort descending Description
paging_xmlsitemap_disable Implementation of hook_disable().
paging_xmlsitemap_enable Implementation of hook_enable().
paging_xmlsitemap_install Implementation of hook_install().
paging_xmlsitemap_uninstall Implementation of hook_uninstall().
_paging_xmlsitemap_paging_gsitemap_replace Transfer data from Paging: Google Sitemap if it was installed.