123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <?php
- function menu_schema() {
- $schema['menu_custom'] = array(
- 'description' => 'Holds definitions for top-level custom menus (for example, Main 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;
- }
- function menu_install() {
- $system_menus = menu_list_system_menus();
- $t = get_t();
- $descriptions = array(
- 'navigation' => $t('The <em>Navigation</em> menu contains links intended for site visitors. Links are added to the <em>Navigation</em> menu automatically by some modules.'),
- 'user-menu' => $t("The <em>User</em> menu contains links related to the user's account, as well as the 'Log out' link."),
- 'management' => $t('The <em>Management</em> menu contains links for administrative tasks.'),
- 'main-menu' => $t('The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.'),
- );
- foreach ($system_menus as $menu_name => $title) {
- $menu = array(
- 'menu_name' => $menu_name,
- 'title' => $t($title),
- 'description' => $descriptions[$menu_name],
- );
- menu_save($menu);
- }
- }
- function menu_uninstall() {
- menu_rebuild();
- }
- function menu_update_7000() {
-
-
- $default_node_menu = variable_get('menu_default_node_menu');
- if (isset($default_node_menu)) {
-
- variable_del('menu_default_node_menu');
-
- $defined_menus = db_query('SELECT * FROM {menu_custom}')->fetchAllAssoc('menu_name', PDO::FETCH_ASSOC);
-
-
- if (!isset($defined_menus[$default_node_menu])) {
- return;
- }
-
- foreach (_update_7000_node_get_types() as $type => $type_object) {
- $type_menus = variable_get('menu_options_' . $type);
-
-
- if (!isset($type_menus)) {
-
-
- variable_set('menu_options_' . $type, array($default_node_menu));
- variable_set('menu_parent_' . $type, $default_node_menu . ':0');
- }
- }
- }
- }
- function menu_update_7001() {
-
-
- if (variable_get('menu_primary_links_source') !== NULL) {
- variable_set('menu_main_links_source', variable_get('menu_primary_links_source'));
- variable_del('menu_primary_links_source');
- }
-
-
-
- $rename = array(
- 'primary-links' => array('main-menu', 'Main menu'),
- 'secondary-links' => array('secondary-menu', 'Secondary menu'),
- );
- foreach ($rename as $from_menu => $to) {
- list($to_menu, $to_title) = $to;
-
- db_update('menu_custom')
- ->fields(array('menu_name' => $to_menu, 'title' => $to_title))
- ->condition('menu_name', $from_menu)
- ->execute();
- db_update('menu_links')
- ->fields(array('menu_name' => $to_menu))
- ->condition('menu_name', $from_menu)
- ->execute();
-
-
-
- foreach (_update_7000_node_get_types() as $type => $type_object) {
- $menu_options = variable_get('menu_options_' . $type);
- if ($menu_options !== NULL) {
- variable_set('menu_options_' . $type, str_replace($from_menu, $to_menu, $menu_options));
- if (variable_get('menu_parent_' . $type) == $from_menu . ':0') {
- variable_set('menu_parent_' . $type, $to_menu . ':0');
- }
- }
- }
-
-
- if (variable_get('menu_main_links_source') == $from_menu) {
- variable_set('menu_main_links_source', $to_menu);
- }
- if (variable_get('menu_secondary_links_source') == $from_menu) {
- variable_set('menu_secondary_links_source', $to_menu);
- }
- }
- }
- function menu_update_7002(&$sandbox) {
-
- if (db_table_exists('blocks') || db_table_exists('block')) {
- $renamed_deltas = array(
- 'menu' => array(
- 'primary-links' => 'main-menu',
- 'secondary-links' => 'secondary-menu',
- ),
- );
- $moved_deltas = array(
- 'menu' => array('main-menu' => 'system'),
- );
- update_fix_d7_block_deltas($sandbox, $renamed_deltas, $moved_deltas);
- }
- }
- function menu_update_7003(&$sandbox) {
-
-
-
- $active_menus = variable_get('menu_default_active_menus', array_keys(menu_list_system_menus()));
- $update_variable = FALSE;
- foreach (menu_get_names() as $menu_name) {
- if (!in_array($menu_name, $active_menus) && (strpos($menu_name, 'menu-') === 0)) {
- $active_menus[] = $menu_name;
- $update_variable = TRUE;
- }
- }
- if ($update_variable) {
- variable_set('menu_default_active_menus', $active_menus);
- }
-
- cache_clear_all(NULL, 'cache_menu');
- }
|