'Stores skinr data.', 'fields' => array( 'theme' => array( 'description' => 'The system name of the theme.', 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '', ), 'module' => array( 'description' => 'The module this skinr settings is for.', 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '', ), 'sid' => array( 'description' => 'A unique identifier for this skinr datum.', 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ), 'skins' => array( 'description' => 'The skins set for this datum.', 'type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE, ), 'settings' => array( 'description' => 'Custom settings for this id.', 'type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE, ), ), 'primary key' => array('theme', 'module', 'sid'), 'indexes' => array( 'theme' => array('theme'), 'module' => array('module'), 'sid' => array('sid'), ), ); $schema['skinr_rules'] = array( 'description' => 'Stores skinr page rule data.', 'fields' => array( 'rid' => array( 'type' => 'serial', 'not null' => TRUE, 'description' => 'Primary Key: Unique skinr page rule ID.', ), 'title' => array( 'description' => 'The administrative title for this rule.', 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ), 'roles' => array( 'type' => 'text', 'size' => 'normal', 'not null' => FALSE, 'serialize' => TRUE, 'description' => 'A serialized array of roles for this record.', ), 'visibility' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny', '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.)', ), 'pages' => array( 'type' => 'text', 'not null' => TRUE, '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.', ), ), 'primary key' => array('rid'), ); $schema['skinr_skinsets'] = array( 'description' => "A list of all non-theme skinsets that are or have been installed in Drupal's file system.", 'fields' => array( 'filename' => array( 'description' => 'The path of the primary file for this item, relative to the Drupal root; e.g. skins/skinset/skinset.info.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'name' => array( 'description' => 'The name of the item; e.g. skinset.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'status' => array( 'description' => 'Boolean indicating whether or not this item is enabled.', 'type' => 'int', 'not null' => TRUE, 'default' => 0), 'info' => array( 'description' => "A serialized array containing information from the skinset's .info file; keys can include name, description, package, version, core, and skinr.", 'type' => 'text', 'not null' => FALSE), ), 'primary key' => array('filename'), 'indexes' => array( 'name' => array('name'), ), ); $schema['skinr_skins'] = array( 'description' => 'Keeps track of the whether a skin is enabled for a specific skinset and theme.', 'fields' => array( 'name' => array( 'description' => 'The name of the skinset or theme that this skin belongs to.', 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '', ), 'type' => array( 'description' => 'The type of this item; skinset or theme.', 'type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => '', ), 'skin' => array( 'description' => 'The name of the skin which you are saving settings for.', 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ), 'status' => array( 'description' => 'A serialized array of values for each theme indicating whether or not the skin is enabled.', 'type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE, ), ), 'primary key' => array('name', 'skin'), 'indexes' => array( 'name' => array('name'), 'skin' => array('skin'), ), ); return $schema; } /** * Implementation of hook_install(). */ function skinr_install() { // Install tables. drupal_install_schema('skinr'); } /** * Implementation of hook_uninstall(). */ function skinr_uninstall() { // Uninstall table. drupal_uninstall_schema('skinr'); // Remove all skinr variables. $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'skinr_%'"); while ($variable = db_fetch_object($result)) { variable_del($variable->name); } } /** * Install new skinr table and convert old variables to the new db system. */ function skinr_update_6000() { $ret = array(); // Install skinr table. if (!db_table_exists('skinr')) { $schema = drupal_get_schema_unprocessed('skinr'); _drupal_initialize_schema('skinr', $schema); db_create_table($ret, 'skinr', $schema['skinr']); // Exclude variables that aren't theme settings. $exclude = array('skinr_overlay_width', 'skinr_overlay_height', 'skinr_overlay_autofit', 'skinr_overlay_draggable'); $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'skinr_%'"); while ($variable = db_fetch_object($result)) { if (!in_array($variable->name, $exclude)) { // Convert from variable to db. $theme = substr($variable->name, 6); $skinr = variable_get($variable->name, array()); foreach ($skinr as $module => $sids) { foreach ($sids as $sid => $skins) { db_query("INSERT INTO {skinr} (theme, module, sid, skins, settings) VALUES ('%s', '%s', '%s', '%s', '%s')", $theme, $module, $sid, serialize($skins), serialize(array())); } } // Delete the old variable. variable_del($variable->name); } } } return $ret; } /** * Install new rule table and add some additional fields to the skinr table. */ function skinr_update_6001() { $ret = array(); db_change_field($ret, 'skinr', 'skins', 'skins', array('description' => 'The skins set for this datum.', 'type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE)); db_change_field($ret, 'skinr', 'settings', 'settings', array('description' => 'Custom settings for this id.', 'type' => 'text', 'size' => 'big', 'not null' => TRUE, 'serialize' => TRUE, 'default' => '')); // Add new table for page rules. if (!db_table_exists('skinr_rules')) { $schema = drupal_get_schema_unprocessed('skinr'); _drupal_initialize_schema('skinr', $schema); db_create_table($ret, 'skinr_rules', $schema['skinr_rules']); } return $ret; } /** * Install new skinsets table to allow enabling and disabling of skinsets. */ function skinr_update_6002() { $ret = array(); // Install skinr table. if (!db_table_exists('skinr_skinsets')) { $schema = drupal_get_schema_unprocessed('skinr'); _drupal_initialize_schema('skinr', $schema); db_create_table($ret, 'skinr_skinsets', $schema['skinr_skinsets']); } return $ret; } /** * Install new skinsets table to allow enabling and disabling of skinsets. */ function skinr_update_6003() { $ret = array(); // Install skinr table. if (!db_table_exists('skinr_skins')) { $schema = drupal_get_schema_unprocessed('skinr'); _drupal_initialize_schema('skinr', $schema); db_create_table($ret, 'skinr_skins', $schema['skinr_skins']); } return $ret; } /** * Change all panels regions to the new format. */ function skinr_update_6004() { $ret = array(); $ret[] = update_sql("UPDATE {skinr} SET sid = REPLACE(sid, '-panel-', '-region-') WHERE module = 'panels' && sid LIKE '%-panel-%'"); return $ret; }