[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/ctools/page_manager/ -> page_manager.install (source)

   1  <?php
   2  // $Id: page_manager.install,v 1.7.2.1 2010/06/16 15:42:28 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   * Installation routines for page manager module.
   7   */
   8  
   9  /**
  10   * Implementation of hook_schema().
  11   */
  12  function page_manager_schema() {
  13    // This should always point to our 'current' schema. This makes it relatively easy
  14    // to keep a record of schema as we make changes to it.
  15    return page_manager_schema_1();
  16  }
  17  
  18  /**
  19   * Schema version 1 for Panels in D6.
  20   */
  21  function page_manager_schema_1() {
  22    $schema = array();
  23  
  24    $schema['page_manager_handlers'] = array(
  25      'export' => array(
  26        'identifier' => 'handler',
  27        'bulk export' => TRUE,
  28        'export callback' => 'page_manager_export_task_handler',
  29        'primary key' => 'did',
  30        'api' => array(
  31          'owner' => 'page_manager',
  32          'api' => 'pages_default',
  33          'minimum_version' => 1,
  34          'current_version' => 1,
  35        ),
  36      ),
  37      'fields' => array(
  38        'did' => array(
  39          'type' => 'serial',
  40          'not null' => TRUE,
  41          'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
  42          'no export' => TRUE,
  43        ),
  44        'name' => array(
  45          'type' => 'varchar',
  46          'length' => '255',
  47          'description' => 'Unique ID for this task handler. Used to identify it programmatically.',
  48        ),
  49        'task' => array(
  50          'type' => 'varchar',
  51          'length' => '64',
  52          'description' => 'ID of the task this handler is for.',
  53        ),
  54        'subtask' => array(
  55          'type' => 'varchar',
  56          'length' => '64',
  57          'description' => 'ID of the subtask this handler is for.',
  58          'not null' => TRUE,
  59          'default' => '',
  60        ),
  61        'handler' => array(
  62          'type' => 'varchar',
  63          'length' => '64',
  64          'description' => 'ID of the task handler being used.',
  65        ),
  66        'weight' => array(
  67          'type' => 'int',
  68          'description' => 'The order in which this handler appears. Lower numbers go first.',
  69        ),
  70        'conf' => array(
  71          'type' => 'text',
  72          'size' => 'big',
  73          'description' => 'Serialized configuration of the handler, if needed.',
  74          'not null' => TRUE,
  75          'serialize' => TRUE,
  76          'object default' => array(),
  77        ),
  78      ),
  79      'primary key' => array('did'),
  80      'unique keys' => array(
  81        'name' => array('name'),
  82      ),
  83      'indexes' => array('fulltask' => array('task', 'subtask', 'weight')),
  84    );
  85  
  86    $schema['page_manager_weights'] = array(
  87      'description' => 'Contains override weights for page_manager handlers that are in code.',
  88      'fields' => array(
  89        'name' => array(
  90          'type' => 'varchar',
  91          'length' => '255',
  92          'description' => 'Unique ID for this task handler. Used to identify it programmatically.',
  93          'not null' => TRUE,
  94          'default' => '',
  95        ),
  96        'weight' => array(
  97          'type' => 'int',
  98          'description' => 'The order in which this handler appears. Lower numbers go first.',
  99        ),
 100      ),
 101      'primary key' => array('name'),
 102      'indexes' => array(
 103        'weights' => array('name', 'weight'),
 104      ),
 105    );
 106  
 107    $schema['page_manager_pages'] = array(
 108      'description' => 'Contains page subtasks for implementing pages with arbitrary tasks.',
 109      'export' => array(
 110        'identifier' => 'page',
 111        'bulk export' => TRUE,
 112        'export callback' => 'page_manager_page_export',
 113        'api' => array(
 114          'owner' => 'page_manager',
 115          'api' => 'pages_default',
 116          'minimum_version' => 1,
 117          'current_version' => 1,
 118        ),
 119      ),
 120      'fields' => array(
 121        'pid' => array(
 122          'type' => 'serial',
 123          'not null' => TRUE,
 124          'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
 125          'no export' => TRUE,
 126        ),
 127        'name' => array(
 128          'type' => 'varchar',
 129          'length' => '255',
 130          'description' => 'Unique ID for this subtask. Used to identify it programmatically.',
 131        ),
 132        'task' => array(
 133          'type' => 'varchar',
 134          'length' => '64',
 135          'description' => 'What type of page this is, so that we can use the same mechanism for creating tighter UIs for targeted pages.',
 136          'default' => 'page',
 137        ),
 138        'admin_title' => array(
 139          'type' => 'varchar',
 140          'length' => '255',
 141          'description' => 'Human readable title for this page subtask.',
 142        ),
 143        'admin_description' => array(
 144          'type' => 'text',
 145          'size' => 'big',
 146          'description' => 'Administrative description of this item.',
 147          'object default' => '',
 148        ),
 149        'path' => array(
 150          'type' => 'varchar',
 151          'length' => '255',
 152          'description' => 'The menu path that will invoke this task.',
 153        ),
 154        'access' => array(
 155          'type' => 'text',
 156          'size' => 'big',
 157          'description' => 'Access configuration for this path.',
 158          'not null' => TRUE,
 159          'serialize' => TRUE,
 160          'object default' => array(),
 161        ),
 162        'menu' => array(
 163          'type' => 'text',
 164          'size' => 'big',
 165          'description' => 'Serialized configuration of Drupal menu visibility settings for this item.',
 166          'not null' => TRUE,
 167          'serialize' => TRUE,
 168          'object default' => array(),
 169        ),
 170        'arguments' => array(
 171          'type' => 'text',
 172          'size' => 'big',
 173          'description' => 'Configuration of arguments for this menu item.',
 174          'not null' => TRUE,
 175          'serialize' => TRUE,
 176          'object default' => array(),
 177        ),
 178        'conf' => array(
 179          'type' => 'text',
 180          'size' => 'big',
 181          'description' => 'Serialized configuration of the page, if needed.',
 182          'not null' => TRUE,
 183          'serialize' => TRUE,
 184          'object default' => array(),
 185        ),
 186      ),
 187      'primary key' => array('pid'),
 188      'unique keys' => array(
 189        'name' => array('name'),
 190      ),
 191      'indexes' => array('task' => array('task')),
 192    );
 193  
 194    return $schema;
 195  }
 196  
 197  /**
 198   * Implementation of hook_install().
 199   */
 200  function page_manager_install() {
 201    drupal_install_schema('page_manager');
 202  
 203    // If we're swapping over from delegator module, take away its tables.
 204    // Take THAT, delegator!
 205    if (db_table_exists('{delegator_pages}')) {
 206      db_query("INSERT INTO {page_manager_pages} (pid, name, task, admin_title, path, access, menu, arguments, conf) (SELECT pid, name, task, admin_title, path, access, menu, arguments, conf FROM {delegator_pages})");
 207      db_query("INSERT INTO {page_manager_handlers} (SELECT did, name, task, subtask, handler, weight, conf FROM {delegator_handlers})");
 208      db_query("INSERT INTO {page_manager_weights} (SELECT name, weight FROM {delegator_weights})");
 209  
 210      // Update all of the 'panel_page' type pages appropriately:
 211      $result = db_query("SELECT * FROM {page_manager_pages} WHERE task = 'panel_page'");
 212      while ($page = db_fetch_object($result)) {
 213        $page->conf = unserialize($page->conf);
 214        $handler = new stdClass();
 215        $handler->name = 'page_' . $page->name . '_panel_context';
 216        $handler->task = 'page';
 217        $handler->subtask = $page->name;
 218        $handler->handler = 'panel_context';
 219        $handler->weight = 0;
 220        $handler->conf = array();
 221  
 222        $default_conf = array(
 223          'title' => t('Panel'),
 224          'no_blocks' => FALSE,
 225          'css_id' => '',
 226          'css' => '',
 227          'contexts' => array(),
 228          'relationships' => array(),
 229          'did' => NULL,
 230          'css_cache' => NULL,
 231        );
 232  
 233        foreach($default_conf as $key => $default) {
 234          if (isset($page->conf[$key])) {
 235            $handler->conf[$key] = $page->conf[$key];
 236            unset($page->conf[$key]);
 237          }
 238          else {
 239            $handler->conf[$key] = $default;
 240          }
 241        }
 242  
 243        $handler->conf = serialize($handler->conf);
 244        $page->conf = serialize($page->conf);
 245        db_query("UPDATE {page_manager_pages} SET conf = '%s', task = 'page' WHERE pid = %d", $page->conf, $page->pid);
 246        db_query("INSERT INTO {page_manager_handlers} (name, task, subtask, handler, weight, conf) VALUES ('%s', '%s', '%s', '%s', %d, '%s')", $handler->name, $handler->task, $handler->subtask, $handler->handler, $handler->weight, $handler->conf);
 247      }
 248  
 249      $ret = array();
 250      db_drop_table($ret, 'delegator_pages');
 251      db_drop_table($ret, 'delegator_handlers');
 252      db_drop_table($ret, 'delegator_weights');
 253  
 254      // And take delegator's variables:
 255      variable_set('page_manager_term_view_type', variable_get('delegator_term_view_type', 'multiple'));
 256      variable_del('delegator_term_view_type');
 257  
 258      variable_set('page_manager_override_anyway', variable_get('delegator_override_anyway', FALSE));
 259      variable_del('delegator_override_anyway');
 260    }
 261  
 262    db_query("UPDATE {system} SET weight = 99 WHERE name = 'page_manager'");
 263  }
 264  
 265  /**
 266   * Implementation of hook_uninstall().
 267   */
 268  function page_manager_uninstall() {
 269    drupal_uninstall_schema('page_manager');
 270  }
 271  
 272  function page_manager_update_6101() {
 273    $ret = array();
 274    return $ret;
 275  }


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