You are here

themekey.install in ThemeKey 6

File

themekey.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function themekey_schema() {
  $schema = array();
  $schema['themekey_paths'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'path' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'fit' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'wildcards' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'serialize' => TRUE,
      ),
      'conditions' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'serialize' => TRUE,
      ),
      'custom' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'theme' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'callbacks' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'path' => array(
        'path',
      ),
      'fit' => array(
        'fit',
      ),
      'weight' => array(
        'weight',
      ),
      'custom' => array(
        'custom',
      ),
    ),
  );
  $schema['themekey_properties'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'property' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'value' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'conditions' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'serialize' => TRUE,
      ),
      'theme' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'callbacks' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'property' => array(
        'property',
      ),
      'weight' => array(
        'weight',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function themekey_install() {
  drupal_install_schema('themekey');
  db_query("UPDATE {system} SET weight = -10 WHERE name = 'themekey'");
}

/**
 * Implementation of hook_uninstall().
 */
function themekey_uninstall() {

  // Drop tables
  drupal_uninstall_schema('themekey');

  // Remove variables
  db_query("DELETE FROM {variable} WHERE name LIKE 'themekey_%'");
  cache_clear_all('variables', 'cache');
}

/**
 * Implementation of hook_update_N().
 * (Update property 'nid' to 'node:nid')
 */
function themekey_update_6001() {
  $ret = array();

  //
  $result = db_query('SELECT * FROM {themekey_properties} WHERE property = \'nid\'');
  while ($item = db_fetch_array($result)) {
    if (db_result(db_query('SELECT COUNT(id) FROM {themekey_properties} WHERE property = \'node:nid\' AND value = \'%s\'', $item['value'])) > 0) {
      $ret[] = update_sql('DELETE FROM {themekey_properties} WHERE id = ' . $item['id']);
    }
    else {
      $ret[] = update_sql('UPDATE {themekey_properties} SET property = \'node:nid\' WHERE id = ' . $item['id']);
    }
  }
  return $ret;
}

Functions

Namesort descending Description
themekey_install Implementation of hook_install().
themekey_schema Implementation of hook_schema().
themekey_uninstall Implementation of hook_uninstall().
themekey_update_6001 Implementation of hook_update_N(). (Update property 'nid' to 'node:nid')