home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (panels_mini.install)

This example Drupal source code file (panels_mini.install) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, callback, default, description, function, mini, object, of, panel, php, size, the, true, type

The panels_mini.install Drupal example source code

<?php

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

/**
 * Schema version 1 for Panels in D6.
 */
function panels_mini_schema_1() {
  $schema = array();

  $schema['panels_mini'] = array(
    'export' => array(
      'identifier' => 'mini',
      'load callback' => 'panels_mini_load',
      'load all callback' => 'panels_mini_load_all',
      'save callback' => 'panels_mini_save',
      'delete callback' => 'panels_mini_delete',
      'export callback' => 'panels_mini_export',
      'api' => array(
        'owner' => 'panels_mini',
        'api' => 'panels_default',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'fields' => array(
      'pid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'no export' => TRUE,
        'description' => 'The primary key for uniqueness.',
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => '255',
        'description' => 'The unique name of the mini panel.',
      ),
      'category' => array(
        'type' => 'varchar',
        'length' => '64',
        'description' => 'The category this mini panel appears in on the add content pane.',
      ),
      'did' => array(
        'type' => 'int',
        'no export' => TRUE,
        'description' => 'The display ID of the panel.',
      ),
      'admin_title' => array(
        'type' => 'varchar',
        'length' => '128',
        'description' => 'The administrative title of the mini panel.',
      ),
      'admin_description' => array(
        'type' => 'text',
        'size' => 'big',
        'description' => 'Administrative title of this mini panel.',
        'object default' => '',
      ),
      'requiredcontexts' => array(
        'type' => 'text',
        'size' => 'big',
        'serialize' => TRUE,
        'object default' => array(),
        'description' => 'An array of required contexts.',
      ),
      'contexts' => array(
        'type' => 'text',
        'size' => 'big',
        'serialize' => TRUE,
        'object default' => array(),
        'description' => 'An array of contexts embedded into the panel.',
      ),
      'relationships' => array(
        'type' => 'text',
        'size' => 'big',
        'serialize' => TRUE,
        'object default' => array(),
        'description' => 'An array of relationships embedded into the panel.',
      ),
    ),
    'primary key' => array('pid'),
    'unique keys' => array(
      'name' => array('name'),
    ),
  );

  return $schema;
}

/**
 * Implementation of hook_uninstall().
 */
function panels_mini_uninstall() {
  $panels_exists = db_table_exists('panels_display');

  $result = db_query("SELECT * FROM {panels_mini}");
  $deltas = array();
  foreach ($result as $panel_mini) {
    // Delete all associated displays.
    if (!function_exists('panels_delete_display')) {
      require_once drupal_get_path('module', 'panels') .'/panels.module';
    }
    if ($panels_exists) {
      panels_delete_display($panel_mini->did);
    }

    $deltas[] = $panel_mini->pid;
  }

  if ($deltas) {
    // Delete all configured blocks.
    db_delete('block')
      ->condition('module', 'panels_mini')
      ->condition('delta', $deltas)
      ->execute();
  }
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal panels_mini.install source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.