[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/panels/panels_mini/ -> panels_mini.install (source)

   1  <?php
   2  
   3  /**
   4   * Implementation of hook_schema().
   5   */
   6  function panels_mini_schema() {
   7    // This should always point to our 'current' schema. This makes it relatively easy
   8    // to keep a record of schema as we make changes to it.
   9    return panels_mini_schema_1();
  10  }
  11  
  12  /**
  13   * Schema version 1 for Panels in D6.
  14   */
  15  function panels_mini_schema_1() {
  16    $schema = array();
  17  
  18    $schema['panels_mini'] = array(
  19      'export' => array(
  20        'identifier' => 'mini',
  21        'load callback' => 'panels_mini_load',
  22        'load all callback' => 'panels_mini_load_all',
  23        'save callback' => 'panels_mini_save',
  24        'delete callback' => 'panels_mini_delete',
  25        'export callback' => 'panels_mini_export',
  26        'api' => array(
  27          'owner' => 'panels_mini',
  28          'api' => 'panels_default',
  29          'minimum_version' => 1,
  30          'current_version' => 1,
  31        ),
  32      ),
  33      'fields' => array(
  34        'pid' => array(
  35          'type' => 'serial',
  36          'not null' => TRUE,
  37          'no export' => TRUE,
  38          'description' => 'The primary key for uniqueness.',
  39        ),
  40        'name' => array(
  41          'type' => 'varchar',
  42          'length' => '255',
  43          'description' => 'The unique name of the mini panel.',
  44        ),
  45        'category' => array(
  46          'type' => 'varchar',
  47          'length' => '64',
  48          'description' => 'The category this mini panel appears in on the add content pane.',
  49        ),
  50        'did' => array(
  51          'type' => 'int',
  52          'no export' => TRUE,
  53          'description' => 'The display ID of the panel.',
  54        ),
  55        'admin_title' => array(
  56          'type' => 'varchar',
  57          'length' => '128',
  58          'description' => 'The administrative title of the mini panel.',
  59        ),
  60        'admin_description' => array(
  61          'type' => 'text',
  62          'size' => 'big',
  63          'description' => 'Administrative title of this mini panel.',
  64          'object default' => '',
  65        ),
  66        'requiredcontexts' => array(
  67          'type' => 'text',
  68          'size' => 'big',
  69          'serialize' => TRUE,
  70          'object default' => array(),
  71          'description' => 'An array of required contexts.',
  72        ),
  73        'contexts' => array(
  74          'type' => 'text',
  75          'size' => 'big',
  76          'serialize' => TRUE,
  77          'object default' => array(),
  78          'description' => 'An array of contexts embedded into the panel.',
  79        ),
  80        'relationships' => array(
  81          'type' => 'text',
  82          'size' => 'big',
  83          'serialize' => TRUE,
  84          'object default' => array(),
  85          'description' => 'An array of relationships embedded into the panel.',
  86        ),
  87      ),
  88      'primary key' => array('pid'),
  89      'unique keys' => array(
  90        'name' => array('name'),
  91      ),
  92    );
  93  
  94    return $schema;
  95  }
  96  
  97  /**
  98   * Implementation of hook_install().
  99   */
 100  function panels_mini_install() {
 101    drupal_install_schema('panels_mini');
 102  }
 103  
 104  /**
 105   * Implementation of hook_uninstall().
 106   */
 107  function panels_mini_uninstall() {
 108    $result = db_query("SELECT * FROM {panels_mini}");
 109    $panels_exists = db_table_exists('panels_display');
 110    while ($panel_mini = db_fetch_object($result)) {
 111      // Delete all associated displays.
 112      if (!function_exists('panels_delete_display')) {
 113        require_once drupal_get_path('module', 'panels') .'/panels.module';
 114      }
 115      if ($panels_exists) {
 116        panels_delete_display($panel_mini->did);
 117      }
 118  
 119      // Delete all configured blocks.
 120      db_query("DELETE FROM {blocks} WHERE module = 'panels_mini' AND delta = %d", $panel_mini->pid);
 121    }
 122  
 123    // Finally, delete all mini panels.
 124    drupal_uninstall_schema('panels_mini');
 125  }
 126  
 127  /**
 128   * Update all blocks to use 'name' as delta, not 'pid'.
 129   */
 130  function panels_mini_update_6300() {
 131    $ret = array();
 132    $result = db_query("SELECT name, pid from {panels_mini}");
 133    while ($mini = db_fetch_object($result)) {
 134      db_query("UPDATE {blocks} SET delta = '%s' WHERE module = 'panels_mini' AND delta = %d", $mini->name, $mini->pid);
 135    }
 136    return $ret;
 137  }
 138  
 139  /**
 140   * Update all panel mini blocks to not use block caching.
 141   */
 142  function panels_mini_update_6301() {
 143    $ret = array();
 144    $ret[] = update_sql("UPDATE {blocks} SET cache = -1 WHERE module = 'panels_mini'");
 145    return $ret;
 146  }
 147  
 148  /**
 149   * Add the admin description field.
 150   */
 151  function panels_mini_update_6302() {
 152    $ret = array();
 153    $field = array(
 154      'type' => 'text',
 155      'size' => 'big',
 156      'description' => 'Administrative description of this mini panel.',
 157      'object default' => '',
 158    );
 159  
 160    db_add_field($ret, 'panels_mini', 'admin_description', $field);
 161    return $ret;
 162  }
 163  
 164  /**
 165   * Add the admin description field.
 166   */
 167  function panels_mini_update_6303() {
 168    $ret = array();
 169    $field = array(
 170      'type' => 'varchar',
 171      'length' => '128',
 172      'description' => 'The administrative title of the mini panel.',
 173    );
 174  
 175    db_add_field($ret, 'panels_mini', 'admin_title', $field);
 176  
 177    $result = db_query("SELECT pid, did, title FROM {panels_mini}");
 178    while ($mini = db_fetch_object($result)) {
 179      db_query("UPDATE {panels_mini} SET admin_title = '%s' WHERE pid = %d", $mini->title, $mini->pid);
 180      db_query("UPDATE {panels_display} SET title = '%s' WHERE did = %d", $mini->title, $mini->pid);
 181    }
 182  
 183    db_drop_field($ret, 'panels_mini', 'title');
 184    return $ret;
 185  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7