power_menu.install in Power Menu 6
Same filename and directory in other branches
just containing the stuff for install and uninstall
File
power_menu.installView source
<?php
/**
* @file
* just containing the stuff for install and uninstall
*/
/**
* Implementation of hook_uninstall().
*/
function power_menu_uninstall() {
variable_del('power_menu_taxonomy_navigation');
variable_del('power_menu_menu');
drupal_uninstall_schema('power_menu');
}
/**
* Implementation of hook_install().
*/
function power_menu_install() {
drupal_install_schema('power_menu');
}
/**
* Implementation of hook_schema().
*/
function power_menu_schema() {
$schema['power_menu'] = array(
'description' => t('Save the relation between menu and taxonomy term'),
'fields' => array(
'mid' => array(
'description' => t('Just a key'),
'type' => 'varchar',
'length' => 40,
'not null' => TRUE,
),
'mlid' => array(
'description' => t('Menu item id'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'tid' => array(
'description' => t('Termid'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'nodetype' => array(
'description' => t('Nodetype'),
'type' => 'varchar',
'length' => 50,
'not null' => FALSE,
),
'path' => array(
'description' => t('Path, this is redundant, but better performance'),
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'menu_name' => array(
'description' => 'The menu which was selected',
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array(
'mid',
),
'indexes' => array(
'tid' => array(
'tid',
),
'path' => array(
'path',
),
'nodetype' => array(
'nodetype',
),
'menu_name' => array(
'menu_name',
),
),
);
$schema['power_menu_properties'] = array(
'fields' => array(
'mlid' => array(
'description' => t('Menu item id'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'property_name' => array(
'description' => 'Name of the property',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'value' => array(
'description' => 'The value of the property',
'type' => 'text',
'not null' => TRUE,
),
),
'primary key' => array(
'mlid',
'property_name',
),
);
return $schema;
}
/**
* Updating and adding an additional language field to the table
*/
function power_menu_update_6001() {
$ret = array();
$field = array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
);
$current_menu = variable_get('power_menu_menu', '');
db_add_field($ret, 'power_menu', 'menu_name', $field);
db_add_index($ret, 'power_menu', 'menu_name', array(
'menu_name',
));
$ret[] = update_sql("UPDATE {power_menu} SET menu_name='%s'", $current_menu);
return $ret;
}
function power_menu_update_6002() {
$ret = array();
$ret[] = array(
'success' => TRUE,
'query' => t('Make sure to update your power-menu tokens!'),
);
return $ret;
}
/**
* update. Add the properties table
*/
function power_menu_update_6003() {
$ret = array();
$schema = power_menu_schema();
$table = drupal_get_schema_unprocessed('system', 'cache');
db_create_table($ret, 'power_menu_properties', $schema['power_menu_properties']);
return $ret;
}
Functions
Name![]() |
Description |
---|---|
power_menu_install | Implementation of hook_install(). |
power_menu_schema | Implementation of hook_schema(). |
power_menu_uninstall | Implementation of hook_uninstall(). |
power_menu_update_6001 | Updating and adding an additional language field to the table |
power_menu_update_6002 | |
power_menu_update_6003 | update. Add the properties table |