word_link.install in Word Link 7.2
Same filename and directory in other branches
Install, update, and uninstall functions for the word_link module.
File
word_link.installView source
<?php
/**
* @file
* Install, update, and uninstall functions for the word_link module.
*/
/**
* Implements hook_install().
*/
function word_link_install() {
$t = get_t();
drupal_set_message($t('Word Link module successfully installed. Please configure your text format. Visit the <a href="@link">configuration page</a>.', array(
'@link' => url('admin/config/content/formats'),
)));
}
/**
* Implements hook_uninstall().
*/
function word_link_uninstall() {
variable_del('word_link_add_css');
variable_del('word_link_defaults_class');
variable_del('word_link_defaults_rel');
variable_del('word_link_defaults_case_sensitive');
variable_del('word_link_defaults_status');
}
/**
* Implements hook_schema().
*/
function word_link_schema() {
$schema['word_link'] = array(
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'text' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'case_sensitive' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
),
'url' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'url_title' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'class' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'word-link',
),
'visibility' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'except_list' => array(
'type' => 'text',
'not null' => TRUE,
),
'weight' => array(
'description' => 'Weight of the word. Lighter weights are higher up, heavier weights go down.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'rel' => array(
'type' => 'varchar',
'length' => 30,
'not null' => TRUE,
'default' => '',
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
),
),
'primary key' => array(
'id',
),
);
return $schema;
}
/**
* Adding a visibility column.
*/
function word_link_update_7001() {
if (!db_field_exists('word_link', 'visibility')) {
db_add_field('word_link', 'visibility', array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
));
}
}
/**
* Adding a weight and rel column.
*/
function word_link_update_7002() {
if (!db_field_exists('word_link', 'weight')) {
db_add_field('word_link', 'weight', array(
'description' => 'Weight of the word. Lighter weights are higher up, heavier weights go down.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
));
}
if (!db_field_exists('word_link', 'rel')) {
db_add_field('word_link', 'rel', array(
'type' => 'varchar',
'length' => 30,
'not null' => TRUE,
'default' => '',
));
}
}
/**
* Adding a status column.
*/
function word_link_update_7003() {
if (!db_field_exists('word_link', 'status')) {
db_add_field('word_link', 'status', array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
));
}
}
/**
* Rename 'except' field to 'except_list'.
*/
function word_link_update_7004() {
if (!db_field_exists('word_link', 'except_list')) {
$spec = array(
'type' => 'text',
'length' => 255,
'not null' => TRUE,
);
db_change_field('word_link', 'except', 'except_list', $spec);
}
}
Functions
Name | Description |
---|---|
word_link_install | Implements hook_install(). |
word_link_schema | Implements hook_schema(). |
word_link_uninstall | Implements hook_uninstall(). |
word_link_update_7001 | Adding a visibility column. |
word_link_update_7002 | Adding a weight and rel column. |
word_link_update_7003 | Adding a status column. |
word_link_update_7004 | Rename 'except' field to 'except_list'. |