[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

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

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


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