[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/skinr/ -> skinr.install (source)

   1  <?php
   2  // $Id: skinr.install,v 1.3.2.2.2.4 2010/04/08 01:59:47 moonray Exp $
   3  
   4  /**
   5   * @file skinr.install
   6   * Contains install, update, and uninstall functions for Skinr.
   7   */
   8  
   9  /**
  10   * Implementation of hook_schema.
  11   */
  12  function skinr_schema() {
  13    $schema['skinr'] = array(
  14      'description' => 'Stores skinr data.',
  15      'fields' => array(
  16        'theme' => array(
  17          'description' => 'The system name of the theme.',
  18          'type' => 'varchar',
  19          'length' => 64,
  20          'not null' => TRUE,
  21          'default' => '',
  22        ),
  23        'module' => array(
  24          'description' => 'The module this skinr settings is for.',
  25          'type' => 'varchar',
  26          'length' => 64,
  27          'not null' => TRUE,
  28          'default' => '',
  29        ),
  30        'sid' => array(
  31          'description' => 'A unique identifier for this skinr datum.',
  32          'type' => 'varchar',
  33          'length' => 128,
  34          'not null' => TRUE,
  35          'default' => '',
  36        ),
  37        'skins' => array(
  38          'description' => 'The skins set for this datum.',
  39          'type' => 'text',
  40          'size' => 'big',
  41          'not null' => TRUE,
  42          'serialize' => TRUE,
  43        ),
  44        'settings' => array(
  45          'description' => 'Custom settings for this id.',
  46          'type' => 'text',
  47          'size' => 'big',
  48          'not null' => TRUE,
  49          'serialize' => TRUE,
  50        ),
  51      ),
  52      'primary key' => array('theme', 'module', 'sid'),
  53      'indexes' => array(
  54        'theme' => array('theme'),
  55        'module' => array('module'),
  56        'sid' => array('sid'),
  57      ),
  58    );
  59  
  60    $schema['skinr_rules'] = array(
  61      'description' => 'Stores skinr page rule data.',
  62      'fields' => array(
  63        'rid' => array(
  64          'type' => 'serial',
  65          'not null' => TRUE,
  66          'description' => 'Primary Key: Unique skinr page rule ID.',
  67        ),
  68        'title' => array(
  69          'description' => 'The administrative title for this rule.',
  70          'type' => 'varchar',
  71          'length' => 128,
  72          'not null' => TRUE,
  73          'default' => '',
  74        ),
  75        'roles' => array(
  76          'type' => 'text',
  77          'size' => 'normal',
  78          'not null' => FALSE,
  79          'serialize' => TRUE,
  80          'description' => 'A serialized array of roles for this record.',
  81        ),
  82        'visibility' => array(
  83          'type' => 'int',
  84          'not null' => TRUE,
  85          'default' => 0,
  86          'size' => 'tiny',
  87          'description' => 'Flag to indicate how to show on pages. (0 = Show on all pages except listed pages, 1 = Show only on listed pages, 2 = Use custom PHP code to determine visibility.)',
  88        ),
  89        'pages' => array(
  90          'type' => 'text',
  91          'not null' => TRUE,
  92          'description' => 'Contents of the "Pages" block; contains either a list of paths on which to include/exclude the region or PHP code, depending on the visibility setting.',
  93        ),
  94      ),
  95      'primary key' => array('rid'),
  96    );
  97  
  98    $schema['skinr_skinsets'] = array(
  99      'description' => "A list of all non-theme skinsets that are or have been installed in Drupal's file system.",
 100      'fields' => array(
 101        'filename' => array(
 102          'description' => 'The path of the primary file for this item, relative to the Drupal root; e.g. skins/skinset/skinset.info.',
 103          'type' => 'varchar',
 104          'length' => 255,
 105          'not null' => TRUE,
 106          'default' => ''),
 107        'name' => array(
 108          'description' => 'The name of the item; e.g. skinset.',
 109          'type' => 'varchar',
 110          'length' => 255,
 111          'not null' => TRUE,
 112          'default' => ''),
 113        'status' => array(
 114          'description' => 'Boolean indicating whether or not this item is enabled.',
 115          'type' => 'int',
 116          'not null' => TRUE,
 117          'default' => 0),
 118        'info' => array(
 119          'description' => "A serialized array containing information from the skinset's .info file; keys can include name, description, package, version, core, and skinr.",
 120          'type' => 'text',
 121          'not null' => FALSE),
 122      ),
 123      'primary key' => array('filename'),
 124      'indexes' => array(
 125        'name' => array('name'),
 126      ),
 127    );
 128  
 129    $schema['skinr_skins'] = array(
 130      'description' => 'Keeps track of the whether a skin is enabled for a specific skinset and theme.',
 131      'fields' => array(
 132        'name' => array(
 133          'description' => 'The name of the skinset or theme that this skin belongs to.',
 134          'type' => 'varchar',
 135          'length' => 64,
 136          'not null' => TRUE,
 137          'default' => '',
 138        ),
 139        'type' => array(
 140          'description' => 'The type of this item; skinset or theme.',
 141          'type' => 'varchar',
 142          'length' => 16,
 143          'not null' => TRUE,
 144          'default' => '',
 145        ),
 146        'skin' => array(
 147          'description' => 'The name of the skin which you are saving settings for.',
 148          'type' => 'varchar',
 149          'length' => 128,
 150          'not null' => TRUE,
 151          'default' => '',
 152        ),
 153        'status' => array(
 154          'description' => 'A serialized array of values for each theme indicating whether or not the skin is enabled.',
 155          'type' => 'text',
 156          'size' => 'big',
 157          'not null' => TRUE,
 158          'serialize' => TRUE,
 159          ),
 160      ),
 161      'primary key' => array('name', 'skin'),
 162      'indexes' => array(
 163        'name' => array('name'),
 164        'skin' => array('skin'),
 165      ),
 166    );
 167  
 168    return $schema;
 169  }
 170  
 171  /**
 172   * Implementation of hook_install().
 173   */
 174  function skinr_install() {
 175    // Install tables.
 176    drupal_install_schema('skinr');
 177  }
 178  
 179  /**
 180   * Implementation of hook_uninstall().
 181   */
 182  function skinr_uninstall() {
 183    // Uninstall table.
 184    drupal_uninstall_schema('skinr');
 185  
 186    // Remove all skinr variables.
 187    $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'skinr_%'");
 188    while ($variable = db_fetch_object($result)) {
 189      variable_del($variable->name);
 190    }
 191  }
 192  
 193  /**
 194   * Install new skinr table and convert old variables to the new db system.
 195   */
 196  function skinr_update_6000() {
 197    $ret = array();
 198  
 199    // Install skinr table.
 200    if (!db_table_exists('skinr')) {
 201      $schema = drupal_get_schema_unprocessed('skinr');
 202      _drupal_initialize_schema('skinr', $schema);
 203      db_create_table($ret, 'skinr', $schema['skinr']);
 204  
 205      // Exclude variables that aren't theme settings.
 206      $exclude = array('skinr_overlay_width', 'skinr_overlay_height', 'skinr_overlay_autofit', 'skinr_overlay_draggable');
 207  
 208      $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'skinr_%'");
 209      while ($variable = db_fetch_object($result)) {
 210        if (!in_array($variable->name, $exclude)) {
 211          // Convert from variable to db.
 212          $theme = substr($variable->name, 6);
 213          $skinr = variable_get($variable->name, array());
 214          foreach ($skinr as $module => $sids) {
 215            foreach ($sids as $sid => $skins) {
 216              db_query("INSERT INTO {skinr} (theme, module, sid, skins, settings) VALUES ('%s', '%s', '%s', '%s', '%s')", $theme, $module, $sid, serialize($skins), serialize(array()));
 217            }
 218          }
 219  
 220          // Delete the old variable.
 221          variable_del($variable->name);
 222        }
 223      }
 224    }
 225  
 226    return $ret;
 227  }
 228  
 229  /**
 230   * Install new rule table and add some additional fields to the skinr table.
 231   */
 232  function skinr_update_6001() {
 233    $ret = array();
 234  
 235    db_change_field($ret, 'skinr', 'skins', 'skins', array('description' => 'The skins set for this datum.', 'type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE));
 236    db_change_field($ret, 'skinr', 'settings', 'settings', array('description' => 'Custom settings for this id.', 'type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE, 'default' => ''));
 237  
 238    // Add new table for page rules.
 239    if (!db_table_exists('skinr_rules')) {
 240      $schema = drupal_get_schema_unprocessed('skinr');
 241      _drupal_initialize_schema('skinr', $schema);
 242      db_create_table($ret, 'skinr_rules', $schema['skinr_rules']);
 243    }
 244  
 245    return $ret;
 246  }
 247  
 248  /**
 249   * Install new skinsets table to allow enabling and disabling of skinsets.
 250   */
 251  function skinr_update_6002() {
 252    $ret = array();
 253  
 254    // Install skinr table.
 255    if (!db_table_exists('skinr_skinsets')) {
 256      $schema = drupal_get_schema_unprocessed('skinr');
 257      _drupal_initialize_schema('skinr', $schema);
 258      db_create_table($ret, 'skinr_skinsets', $schema['skinr_skinsets']);
 259    }
 260  
 261    return $ret;
 262  }
 263  
 264  /**
 265   * Install new skinsets table to allow enabling and disabling of skinsets.
 266   */
 267  function skinr_update_6003() {
 268    $ret = array();
 269  
 270    // Install skinr table.
 271    if (!db_table_exists('skinr_skins')) {
 272      $schema = drupal_get_schema_unprocessed('skinr');
 273      _drupal_initialize_schema('skinr', $schema);
 274      db_create_table($ret, 'skinr_skins', $schema['skinr_skins']);
 275    }
 276  
 277    return $ret;
 278  }
 279  
 280  /**
 281   * Change all panels regions to the new format.
 282   */
 283  function skinr_update_6004() {
 284    $ret = array();
 285    $ret[] = update_sql("UPDATE {skinr} SET sid = REPLACE(sid, '-panel-', '-region-') WHERE module = 'panels' && sid LIKE '%-panel-%'");
 286  
 287    return $ret;
 288  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7