You are here

xmlsitemap.install in XML sitemap 5.2

Install file for XML sitemap

File

xmlsitemap/xmlsitemap.install
View source
<?php

/**
 * @file
 * Install file for XML sitemap
 */

/*****************************************************************************
 * Drupal hooks.
 ****************************************************************************/

/**
 * Implementation of hook_enable().
 */
function xmlsitemap_enable() {
  xmlsitemap_flag_sitemap();
}

/**
 * Implementation of hook_install().
 */
function xmlsitemap_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {xmlsitemap} (\n        loc varchar(255) NOT NULL default '',\n        lastmod int(11),\n        changefreq int(11),\n        priority float\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {xmlsitemap} (\n        loc varchar(255) NOT NULL default '',\n        lastmod integer,\n        changefreq integer,\n        priority real\n      );");
      db_query('CREATE OR REPLACE FUNCTION first(anyelement, anyelement) RETURNS anyelement AS \'SELECT COALESCE($1, $2);\' LANGUAGE \'sql\';');
      @db_query("DROP AGGREGATE first(anyelement)");
      db_query("CREATE AGGREGATE first(\n        sfunc = first,\n        basetype = anyelement,\n        stype = anyelement\n      );");
      break;
  }
  db_query("DELETE FROM {url_alias} WHERE dst LIKE 'sitemap%.xml'");
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_1() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE {xmlsitemap} (\n        loc varchar(128) NOT NULL default '',\n        lastmod int(11),\n        changefreq int(11),\n        priority float\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
  }
  return $ret;
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_2() {
  $ret = array();
  $result = array();
  if ($GLOBALS['db_type'] == 'pgsql') {
    $ret[] = update_sql('CREATE OR REPLACE FUNCTION first(anyelement, anyelement) RETURNS anyelement AS \'SELECT COALESCE($1, $2);\' LANGUAGE \'sql\';');
    $result = @update_sql("DROP AGGREGATE first(anyelement)");
    if ($result['success']) {
      $ret[] = $result;
    }
    $ret[] = update_sql("CREATE AGGREGATE first(\n      sfunc = first,\n      basetype = anyelement,\n      stype = anyelement\n    );");
  }
  return $ret;
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_3() {
  return array();
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_4() {
  return array();
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_5() {
  return array();
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_6() {
  return array();
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_7() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {xmlsitemap} CHANGE loc loc varchar(255) NOT NULL default ''");
      break;
    case 'pgsql':
      db_change_column($ret, 'xmlsitemap', 'loc', 'loc', 'varchar(255)', array(
        'not null' => TRUE,
        'default' => "''",
      ));
      break;
  }
  $ret[] = update_sql("DELETE FROM {cache_page}\n    WHERE cid LIKE '%%gss.xsl' OR cid LIKE '%%sitemap%%.xml'");
  return $ret;
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_8() {
  return array();
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_9() {
  return array();
}

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_update_10() {
  $ret[] = update_sql("DELETE FROM {system} WHERE name = 'xmlsitemap_file' AND type = 'module'");
  menu_rebuild();
  $ret[] = array(
    'success' => TRUE,
    'query' => 'REBUILD DRUPAL MENU',
  );
  return $ret;
}

/**
 * Implementation of hook_uninstall().
 */
function xmlsitemap_uninstall() {
  db_query("DROP TABLE {xmlsitemap}");
  db_query("DELETE FROM {variable} WHERE name LIKE 'xmlsitemap\\_%'");
}

Functions

Namesort descending Description
xmlsitemap_enable Implementation of hook_enable().
xmlsitemap_install Implementation of hook_install().
xmlsitemap_uninstall Implementation of hook_uninstall().
xmlsitemap_update_1 Implementation of hook_update_N().
xmlsitemap_update_10 Implementation of hook_update_N().
xmlsitemap_update_2 Implementation of hook_update_N().
xmlsitemap_update_3 Implementation of hook_update_N().
xmlsitemap_update_4 Implementation of hook_update_N().
xmlsitemap_update_5 Implementation of hook_update_N().
xmlsitemap_update_6 Implementation of hook_update_N().
xmlsitemap_update_7 Implementation of hook_update_N().
xmlsitemap_update_8 Implementation of hook_update_N().
xmlsitemap_update_9 Implementation of hook_update_N().