custom_formatters.install in Custom Formatters 6
Same filename and directory in other branches
Install, update and uninstall functions for the Custom Formatters module.
File
custom_formatters.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Custom Formatters module.
*/
/**
* Implements hook_schema().
*/
function custom_formatters_schema() {
$schema['formatters'] = array(
'fields' => array(
'name' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'label' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'field_types' => array(
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
'serialize' => TRUE,
),
'multiple' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'description' => array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
'default' => '',
),
'mode' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'code' => array(
'type' => 'blob',
),
'status' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
),
'primary key' => array(
'name',
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function custom_formatters_install() {
drupal_install_schema('custom_formatters');
}
/**
* Implements hook_uninstall().
*/
function custom_formatters_uninstall() {
drupal_uninstall_schema('custom_formatters');
variable_del('custom_formatters_settings');
}
/**
* Implements hook_update_N().
*/
function custom_formatters_update_6100() {
$ret = array();
db_add_field($ret, 'formatters', 'multiple', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
db_query("INSERT INTO {formatters} (name, label, field_types, multiple, description, mode, code) VALUES ('%s', '%s', '%s', %d, '%s', '%s', %b)", 'example_basic_multiples', 'Example - Basic (multiples)', serialize(array(
'number_decimal',
'number_float',
'number_integer',
'text',
)), 1, 'An example custom formatter for an assorted group of basic field types, with support for multiple values.', 'advanced', pack('H*', '246f7574707574203d2027273b0d0a666f72656163682028656c656d656e745f6368696c6472656e2824656c656d656e742920617320246b657929207b0d0a2020246f7574707574202e3d20273c6469763e27202e2024656c656d656e745b246b65795d5b27236974656d275d5b2776616c7565275d202e20222022202e206c287428223c7375703e437573746f6d20466f726d6174746572204578616d706c653c2f7375703e22292c202761646d696e2f73657474696e67732f666f726d617474657273272c206172726179282768746d6c27203d3e20545255452929202e20273c2f6469763e273b0d0a7d0d0a72657475726e20246f75747075743b'));
return $ret;
}
function custom_formatters_update_6101() {
$ret = array();
db_add_field($ret, 'formatters', 'mode', array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
));
db_query("INSERT INTO {formatters} (name, label, field_types, multiple, description, mode, code) VALUES ('%s', '%s', '%s', %d, '%s', '%s', %b)", 'example_image', 'Example - Image (basic)', serialize(array(
'filefield',
)), 0, 'A basic example custom formatter for the "filefield" field type.', 'basic', pack('H*', '3c696d67207372633d225b736974652d75726c5d2f5b66696c656669656c642d66696c65706174685d22202f3e203c6120687265663d225b736974652d75726c5d2f61646d696e2f73657474696e67732f666f726d617474657273223e3c7375703e437573746f6d20466f726d6174746572204578616d706c653c2f7375703e3c2f613e'));
$ret[] = update_sql("UPDATE {formatters} SET mode = 'advanced' WHERE mode = ''");
return $ret;
}
function custom_formatters_update_6102() {
$ret = array();
db_change_field($ret, 'formatters', 'name', 'name', array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
));
db_change_field($ret, 'formatters', 'label', 'label', array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
));
return $ret;
}
function custom_formatters_update_6103() {
$ret = array();
db_drop_field($ret, 'formatters', 'cfid');
db_add_field($ret, 'formatters', 'status', array(
'type' => 'int',
'unsiggned' => TUE,
'not null' => TRUE,
'default' => 1,
));
return $ret;
}
Functions
Name | Description |
---|---|
custom_formatters_install | Implements hook_install(). |
custom_formatters_schema | Implements hook_schema(). |
custom_formatters_uninstall | Implements hook_uninstall(). |
custom_formatters_update_6100 | Implements hook_update_N(). |
custom_formatters_update_6101 | |
custom_formatters_update_6102 | |
custom_formatters_update_6103 |