widgets.install in Widgets 6
Same filename and directory in other branches
Install, update and uninstall functions for the Widgets module.
File
widgets.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Widgets module.
*/
/**
* Implementation of hook_schema().
*/
function widgets_schema() {
$schema = array();
// Definition for {widgets}.
$schema['widgets'] = array(
'description' => 'Base table for the Widgets module.',
'fields' => array(
'nid' => array(
'description' => 'Node ID.',
'type' => 'int',
'not null' => TRUE,
),
'widget_nid' => array(
'description' => 'Widget node ID.',
'type' => 'varchar',
'length' => 45,
'not null' => TRUE,
),
'region' => array(
'description' => 'Region. This will be implemented in later releases.',
'type' => 'varchar',
'length' => 45,
),
'weight' => array(
'description' => '',
'type' => 'int',
'default' => 0,
),
),
'primary key' => array(
'nid',
'widget_nid',
),
);
// Definition for {widgets_disabled}.
$schema['widgets_status'] = array(
'description' => 'Stores information on widget node status.',
'fields' => array(
'nid' => array(
'description' => 'Node ID.',
'type' => 'int',
'not null' => TRUE,
),
'disabled' => array(
'description' => 'Widgets disabled for this node.',
'type' => 'int',
'size' => 'tiny',
'default' => 0,
),
'use_default' => array(
'description' => 'Use default widgets for this node.',
'type' => 'int',
'size' => 'tiny',
'default' => 1,
),
),
'primary key' => array(
'nid',
),
);
return $schema;
}
/**
* Implementation of hook_requirements().
*/
function widgets_requirements($phase) {
$requirements = array();
$t = get_t();
// Installation requirements.
if ($phase == 'installation') {
$requirements['widgets']['title'] = $t('jQuery UI Multiselect');
if (!file_exists(drupal_get_path('module', 'widgets') . '/js/multiselect/ui.multiselect.js')) {
// File missing.
$requirements['widgets']['value'] = $t('Not found');
$requirements['widgets']['description'] = $t('The <em>jQuery UI Multiselect</em> plugin is missing. Please <a href="@download">download</a> it and extract it to your <em>widgets</em> module directory. See <a href="@readme">README.txt</a> for more information.', array(
'@download' => 'http://github.com/michael/multiselect/',
'@readme' => url(drupal_get_path('module', 'widgets') . '/README.txt'),
));
$requirements['widgets']['severity'] = REQUIREMENT_ERROR;
}
else {
// All ok.
$requirements['widgets']['value'] = $jquery_ui_version;
$requirements['widgets']['severity'] = REQUIREMENT_OK;
}
}
return $requirements;
}
/**
* Implementation of hook_install().
*/
function widgets_install() {
// Create tables.
drupal_install_schema('widgets');
}
/**
* Implementation of hook_uninstall().
*/
function widgets_uninstall() {
// Drop tables.
drupal_uninstall_schema('widgets');
// Delete module variables.
db_query("DELETE FROM {variable} WHERE name LIKE 'widgets_%'");
}
/**
* Implementation of hook_enable().
*/
function widgets_enable() {
// Clear cache.
cache_clear_all();
}
Functions
Name![]() |
Description |
---|---|
widgets_enable | Implementation of hook_enable(). |
widgets_install | Implementation of hook_install(). |
widgets_requirements | Implementation of hook_requirements(). |
widgets_schema | Implementation of hook_schema(). |
widgets_uninstall | Implementation of hook_uninstall(). |