123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <?php
- /**
- * Implementation of hook_schema().
- */
- function panels_mini_schema() {
- // This should always point to our 'current' schema. This makes it relatively easy
- // to keep a record of schema as we make changes to it.
- return panels_mini_schema_1();
- }
- /**
- * Schema version 1 for Panels in D6.
- */
- function panels_mini_schema_1() {
- $schema = array();
- $schema['panels_mini'] = array(
- 'export' => array(
- 'identifier' => 'mini',
- 'load callback' => 'panels_mini_load',
- 'load all callback' => 'panels_mini_load_all',
- 'save callback' => 'panels_mini_save',
- 'delete callback' => 'panels_mini_delete',
- 'export callback' => 'panels_mini_export',
- 'api' => array(
- 'owner' => 'panels_mini',
- 'api' => 'panels_default',
- 'minimum_version' => 1,
- 'current_version' => 1,
- ),
- ),
- 'fields' => array(
- 'pid' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- 'no export' => TRUE,
- 'description' => 'The primary key for uniqueness.',
- ),
- 'name' => array(
- 'type' => 'varchar',
- 'length' => '255',
- 'description' => 'The unique name of the mini panel.',
- ),
- 'category' => array(
- 'type' => 'varchar',
- 'length' => '64',
- 'description' => 'The category this mini panel appears in on the add content pane.',
- ),
- 'did' => array(
- 'type' => 'int',
- 'no export' => TRUE,
- 'description' => 'The display ID of the panel.',
- ),
- 'admin_title' => array(
- 'type' => 'varchar',
- 'length' => '128',
- 'description' => 'The administrative title of the mini panel.',
- ),
- 'admin_description' => array(
- 'type' => 'text',
- 'size' => 'big',
- 'description' => 'Administrative title of this mini panel.',
- 'object default' => '',
- ),
- 'requiredcontexts' => array(
- 'type' => 'text',
- 'size' => 'big',
- 'serialize' => TRUE,
- 'object default' => array(),
- 'description' => 'An array of required contexts.',
- ),
- 'contexts' => array(
- 'type' => 'text',
- 'size' => 'big',
- 'serialize' => TRUE,
- 'object default' => array(),
- 'description' => 'An array of contexts embedded into the panel.',
- ),
- 'relationships' => array(
- 'type' => 'text',
- 'size' => 'big',
- 'serialize' => TRUE,
- 'object default' => array(),
- 'description' => 'An array of relationships embedded into the panel.',
- ),
- ),
- 'primary key' => array('pid'),
- 'unique keys' => array(
- 'name' => array('name'),
- ),
- );
- return $schema;
- }
- /**
- * Implementation of hook_uninstall().
- */
- function panels_mini_uninstall() {
- $panels_exists = db_table_exists('panels_display');
- $result = db_query("SELECT * FROM {panels_mini}");
- $deltas = array();
- foreach ($result as $panel_mini) {
- // Delete all associated displays.
- if (!function_exists('panels_delete_display')) {
- require_once drupal_get_path('module', 'panels') .'/panels.module';
- }
- if ($panels_exists) {
- panels_delete_display($panel_mini->did);
- }
- $deltas[] = $panel_mini->pid;
- }
- if (db_table_exists('block') && $deltas) {
- // Delete all configured blocks.
- db_delete('block')
- ->condition('module', 'panels_mini')
- ->condition('delta', $deltas)
- ->execute();
- }
- }
- /**
- * Implements hook_update_dependencies().
- */
- function panels_mini_update_dependencies() {
- // Update 7301 requires panels storage support
- $dependencies['panels_mini'][7301] = array(
- 'panels' => 7305,
- );
- return $dependencies;
- }
- /**
- * Set the storage type and id on existing mini panels.
- */
- function panels_mini_update_7301() {
- if (!isset($sandbox['progress'])) {
- // Initialize batch update information.
- $sandbox['progress'] = (float)0;
- $sandbox['current_did'] = -1;
- $sandbox['max'] = db_query("SELECT COUNT(pd.did)
- FROM {panels_display} pd
- JOIN {panels_mini} pm ON pm.did = pd.did
- WHERE pd.storage_type = ''")->fetchField();
- }
- // Set a limit of how many rows to process per batch.
- $limit = 1000;
- // Run the query
- $result = db_query_range("SELECT pd.did, pm.name
- FROM {panels_display} pd
- JOIN {panels_mini} pm ON pm.did = pd.did
- WHERE pd.storage_type = '' AND pd.did > :current_did", 0, $limit, array(':current_did' => $sandbox['current_did']));
- foreach ($result as $row) {
- db_update('panels_display')
- ->fields(array(
- 'storage_type' => 'panels_mini',
- 'storage_id' => $row->name,
- ))
- ->condition('did', $row->did)
- ->execute();
- // Update our progress information.
- $sandbox['progress']++;
- $sandbox['current_did'] = $row->did;
- }
- // Set the "finished" status, to tell batch engine whether this function
- // needs to run again.
- $sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
- if ($sandbox['#finished']) {
- return t('Added the storage type for panels_mini to relevant panels displays');
- }
- }
|