118 lines
2.9 KiB
Plaintext
118 lines
2.9 KiB
Plaintext
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Install, update and uninstall functions for the menu module.
|
|
*/
|
|
|
|
/**
|
|
* Implements hook_schema().
|
|
*/
|
|
function menu_schema() {
|
|
$schema['menu_custom'] = array(
|
|
'description' => 'Holds definitions for top-level custom menus (for example, Main navigation menu).',
|
|
'fields' => array(
|
|
'menu_name' => array(
|
|
'type' => 'varchar',
|
|
'length' => 32,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
'description' => 'Primary Key: Unique key for menu. This is used as a block delta so length is 32.',
|
|
),
|
|
'title' => array(
|
|
'type' => 'varchar',
|
|
'length' => 255,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
'description' => 'Menu title; displayed at top of block.',
|
|
'translatable' => TRUE,
|
|
),
|
|
'description' => array(
|
|
'type' => 'text',
|
|
'not null' => FALSE,
|
|
'description' => 'Menu description.',
|
|
'translatable' => TRUE,
|
|
),
|
|
),
|
|
'primary key' => array('menu_name'),
|
|
);
|
|
|
|
return $schema;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_install().
|
|
*/
|
|
function menu_install() {
|
|
$system_menus = menu_list_system_menus();
|
|
$t = get_t();
|
|
$descriptions = array(
|
|
'tools' => $t('Contains links for site visitors. Some modules add their links here.'),
|
|
'account' => $t('Links related to the user account.'),
|
|
'admin' => $t('Contains links to administrative tasks.'),
|
|
'main' => $t('Use this for linking to the main site sections.'),
|
|
'footer' => $t('Use this for linking to site information.'),
|
|
);
|
|
foreach ($system_menus as $menu_name => $title) {
|
|
$menu = array(
|
|
'menu_name' => $menu_name,
|
|
'title' => $t($title),
|
|
'description' => $descriptions[$menu_name],
|
|
);
|
|
menu_save($menu);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements hook_uninstall().
|
|
*/
|
|
function menu_uninstall() {
|
|
menu_router_rebuild();
|
|
}
|
|
|
|
/**
|
|
* Moves menu settings from variables to config.
|
|
*
|
|
* @ingroup config_upgrade
|
|
*/
|
|
function menu_update_8000() {
|
|
update_variables_to_config('menu.settings', array(
|
|
'menu_main_links_source' => 'main_links',
|
|
'menu_secondary_links_source' => 'secondary_links',
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Rename default menu names.
|
|
*/
|
|
function menu_update_8001() {
|
|
// Only the internal identifiers are updated; the labels and descriptions
|
|
// might have been customized and do not have to be renamed.
|
|
$map = array(
|
|
'navigation' => 'tools',
|
|
'management' => 'admin',
|
|
'user-menu' => 'account',
|
|
'main-menu' => 'main',
|
|
);
|
|
foreach ($map as $old => $new) {
|
|
db_update('menu_custom')
|
|
->condition('menu_name', $old)
|
|
->fields(array('menu_name' => $new))
|
|
->execute();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Adds the footer menu to custom menus.
|
|
*/
|
|
function menu_update_8002() {
|
|
db_insert('menu_custom')
|
|
->fields(array(
|
|
'menu_name' => 'footer',
|
|
'title' => 'Footer menu',
|
|
'description' => 'Use this for linking to site information.',
|
|
))
|
|
->execute();
|
|
}
|
|
|