View source
<?php
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;
}
function themekey_install() {
drupal_install_schema('themekey');
db_query("UPDATE {system} SET weight = -10 WHERE name = 'themekey'");
}
function themekey_uninstall() {
drupal_uninstall_schema('themekey');
db_query("DELETE FROM {variable} WHERE name LIKE 'themekey_%'");
cache_clear_all('variables', 'cache');
}
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;
}