You are here

override_css.install in Override css 7

File

override_css.install
View source
<?php

/**
 * Implements hook_install().
 */
function override_css_install() {
}

/**
 * Implements hook_uninstall().
 */
function override_css_uninstall() {
}

/**
 * Implements hook_schema().
 */
function override_css_schema() {
  $schema['override_css'] = array(
    'description' => 'The table that holds override css settings.',
    // CTools export definitions.
    'export' => array(
      'key' => 'name',
      'key name' => 'Name',
      'primary key' => 'name',
      'identifier' => 'override_css',
      'default hook' => 'override_css_defaults',
      'status callback' => 'override_css_crud_set_status',
      'api' => array(
        'owner' => 'override_css',
        'api' => 'override_css',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'fields' => array(
      'name' => array(
        'description' => 'The unique machine name of this setting.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'title' => array(
        'description' => 'The human readable name of this setting.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'The description of the selectors.',
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'medium',
      ),
      'bundle' => array(
        'description' => 'The name of the bundle of this css selector.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
      ),
      'selectors' => array(
        'description' => 'The selectors.',
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
      ),
      'properties' => array(
        'description' => 'The available properties for the selectors.',
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'name',
    ),
  );
  $schema['override_css_properties'] = array(
    'description' => 'The table that holds override css properties.',
    'fields' => array(
      'name' => array(
        'description' => 'The unique machine name of this setting.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'properties_values' => array(
        'description' => 'The values of the properties.',
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'name',
    ),
  );
  return $schema;
}

/**
* Move css properties to a new table.
*/
function override_css_update_7100() {

  // Create new table
  $schema = override_css_schema();
  db_create_table('override_css_properties', $schema['override_css_properties']);

  // Move fields to new table
  $query = db_select('override_css', 'o')
    ->fields('o', array(
    'name',
    'properties_values',
  ));
  db_insert('override_css_properties')
    ->fields(array(
    'name',
    'properties_values',
  ))
    ->from($query)
    ->execute();

  // Remove properties values table
  db_drop_field('override_css', 'properties_values');
}

/**
 * Add bundle column.
 */
function override_css_update_7101() {
  $spec = array(
    'description' => 'The name of the bundle of this css selector.',
    'type' => 'varchar',
    'length' => 255,
    'not null' => FALSE,
    'default' => '',
  );
  db_add_field('override_css', 'bundle', $spec);
}

Functions

Namesort descending Description
override_css_install Implements hook_install().
override_css_schema Implements hook_schema().
override_css_uninstall Implements hook_uninstall().
override_css_update_7100 Move css properties to a new table.
override_css_update_7101 Add bundle column.