You are here

panelizer.install in Panelizer 6

File

panelizer.install
View source
<?php

/**
 * Implementation of hook_requirements().
 */
function panelizer_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $node_view = page_manager_get_task('node_view');
    if ($node_view['disabled']) {
      $requirements['panelizer'] = array(
        'title' => t('Panelizer'),
        'value' => t('You must enable the %node_view page template in <a href="@url">page manager</a> to use panelizer.', array(
          '%node_view' => 'node_view',
          '@url' => url('admin/build/pages'),
        )),
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}

/**
 * Implementation of hook_schema().
 */
function panelizer_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 panelizer_schema_1();
}

/**
 * Schema version 1 for Panels in D6.
 */
function panelizer_schema_1() {
  $schema = array();
  $common_fields = array(
    'no_blocks' => array(
      'type' => 'int',
      'size' => 'tiny',
      'description' => 'Whether or not the node disable sidebar blocks.',
      'default' => 0,
    ),
    'css_id' => array(
      'type' => 'varchar',
      'length' => '255',
      'description' => 'The CSS ID this panel should use.',
      'default' => '',
    ),
    'css' => array(
      'type' => 'text',
      'size' => 'big',
      'description' => 'Any CSS the author provided for the panel.',
      'default' => '',
    ),
    'pipeline' => array(
      'type' => 'varchar',
      'length' => '255',
      'description' => 'The render pipeline this panel uses.',
      'default' => 'standard',
    ),
    'contexts' => array(
      'type' => 'text',
      'size' => 'big',
      'description' => 'The contexts configured by the node author.',
      'serialize' => TRUE,
      'object default' => array(),
    ),
    'relationships' => array(
      'type' => 'text',
      'size' => 'big',
      'description' => 'The relationship contexts configured by the node author.',
      'serialize' => TRUE,
      'object default' => array(),
    ),
    'did' => array(
      'type' => 'int',
      'not null' => TRUE,
      'description' => 'The display ID of the panel.',
    ),
  );
  $schema['panelizer_node'] = array(
    'export' => array(
      'bulk export' => FALSE,
      'can disable' => FALSE,
      'identifier' => 'panelizer_node',
    ),
    'description' => 'Node panelizer references.',
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The node ID this panel is attached to.',
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => '255',
        'description' => 'The name of the default being used if there is one.',
      ),
    ) + $common_fields,
    'primary key' => array(
      'nid',
    ),
  );
  $schema['panelizer_defaults'] = array(
    'description' => 'Node type panelizer references.',
    'export' => array(
      'primary key' => 'pnid',
      'key' => 'name',
      'key name' => 'Name',
      'identifier' => 'panelizer',
      'default hook' => 'panelizer_defaults',
      'api' => array(
        'owner' => 'panelizer',
        'api' => 'panelizer',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
      //      'create callback' => 'panelizer_export_create_callback',
      'save callback' => 'panelizer_export_save_callback',
      'export callback' => 'panelizer_export_export_callback',
      'delete callback' => 'panelizer_export_delete_callback',
    ),
    'fields' => array(
      'pnid' => array(
        'type' => 'serial',
        'description' => 'The database primary key.',
        'no export' => TRUE,
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => '255',
        'description' => 'The unique name of this default.',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => '255',
        'description' => 'The human readable title of this default.',
      ),
      'panelizer_type' => array(
        'type' => 'varchar',
        'length' => '32',
        'description' => 'The panelizer type, such as node or user.',
      ),
      'panelizer_key' => array(
        'type' => 'varchar',
        'length' => '128',
        'description' => 'The panelizer key, such as node type or user role.',
      ),
    ) + $common_fields,
    'primary key' => array(
      'pnid',
    ),
    'indexes' => array(
      'name' => array(
        'name',
      ),
      'type_key' => array(
        'panelizer_type',
        'panelizer_key',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function panelizer_install() {
  db_query("UPDATE {system} SET weight = 21 WHERE name = 'panelizer'");
  drupal_install_schema('panelizer');
}

/**
 * Implementation of hook_uninstall().
 */
function panelizer_uninstall() {
  drupal_uninstall_schema('panelizer');
  db_query("DELETE FROM {variable} WHERE name like 'panelizer%%'");
}

Functions

Namesort descending Description
panelizer_install Implementation of hook_install().
panelizer_requirements Implementation of hook_requirements().
panelizer_schema Implementation of hook_schema().
panelizer_schema_1 Schema version 1 for Panels in D6.
panelizer_uninstall Implementation of hook_uninstall().