You are here

function page_manager_install in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 page_manager/page_manager.install \page_manager_install()

Implementation of hook_install().

File

page_manager/page_manager.install, line 199
Installation routines for page manager module.

Code

function page_manager_install() {
  drupal_install_schema('page_manager');

  // If we're swapping over from delegator module, take away its tables.
  // Take THAT, delegator!
  if (db_table_exists('{delegator_pages}')) {
    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})");
    db_query("INSERT INTO {page_manager_handlers} (SELECT did, name, task, subtask, handler, weight, conf FROM {delegator_handlers})");
    db_query("INSERT INTO {page_manager_weights} (SELECT name, weight FROM {delegator_weights})");

    // Update all of the 'panel_page' type pages appropriately:
    $result = db_query("SELECT * FROM {page_manager_pages} WHERE task = 'panel_page'");
    while ($page = db_fetch_object($result)) {
      $page->conf = unserialize($page->conf);
      $handler = new stdClass();
      $handler->name = 'page_' . $page->name . '_panel_context';
      $handler->task = 'page';
      $handler->subtask = $page->name;
      $handler->handler = 'panel_context';
      $handler->weight = 0;
      $handler->conf = array();
      $default_conf = array(
        'title' => t('Panel'),
        'no_blocks' => FALSE,
        'css_id' => '',
        'css' => '',
        'contexts' => array(),
        'relationships' => array(),
        'did' => NULL,
        'css_cache' => NULL,
      );
      foreach ($default_conf as $key => $default) {
        if (isset($page->conf[$key])) {
          $handler->conf[$key] = $page->conf[$key];
          unset($page->conf[$key]);
        }
        else {
          $handler->conf[$key] = $default;
        }
      }
      $handler->conf = serialize($handler->conf);
      $page->conf = serialize($page->conf);
      db_query("UPDATE {page_manager_pages} SET conf = '%s', task = 'page' WHERE pid = %d", $page->conf, $page->pid);
      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);
    }
    $ret = array();
    db_drop_table($ret, 'delegator_pages');
    db_drop_table($ret, 'delegator_handlers');
    db_drop_table($ret, 'delegator_weights');

    // And take delegator's variables:
    variable_set('page_manager_term_view_type', variable_get('delegator_term_view_type', 'multiple'));
    variable_del('delegator_term_view_type');
    variable_set('page_manager_override_anyway', variable_get('delegator_override_anyway', FALSE));
    variable_del('delegator_override_anyway');
  }
  db_query("UPDATE {system} SET weight = 99 WHERE name = 'page_manager'");
}