-
Notifications
You must be signed in to change notification settings - Fork 1
/
header_footer_corporate.install
142 lines (129 loc) · 4.29 KB
/
header_footer_corporate.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/**
* @file
* Contains install/update/enable hooks.
*/
include_once 'header_footer_corporate.install.inc';
/**
* Implements hook_enable().
*
* Add ECL menus.
*/
function header_footer_corporate_enable() {
// Create menus saving menu group into menu_custom table (from 'menu' module).
$config_menus = array(
array(
'menu_name' => 'menu-nexteuropa-site-links',
'title' => 'European Commission',
'description' => 'European Commission menu',
),
array(
'menu_name' => 'menu-nexteuropa-social-media',
'title' => 'Follow the European Commission',
'description' => 'List of social networks links for the European Commission',
),
array(
'menu_name' => 'menu-nexteuropa-inst-links',
'title' => 'European Union',
'description' => 'DT menu',
),
array(
'menu_name' => 'menu-nexteuropa-service-links',
'title' => 'Nexteuropa service links',
'description' => 'DT links to be put in the bottom footer',
),
array(
'menu_name' => 'menu-footer-follow-us',
'title' => 'Follow us',
'description' => 'Custom Follow us menu',
),
array(
'menu_name' => 'menu-footer-right',
'title' => 'Footer Custom - Right',
'description' => 'Custom footer menu',
),
);
foreach ($config_menus as $menu) {
// Look the table first if the data does exist.
$title = db_query("SELECT title FROM {menu_custom} WHERE menu_name=:menu_name", array(':menu_name' => $menu['menu_name']))->fetchField();
// Create the menu by saving data if it does not exist.
if (empty($title)) {
menu_save($menu);
}
// Add params 'Translate and Localize' to the menu.
db_update('menu_custom')
->fields(array(
'i18n_mode' => 5,
))
->condition('menu_name', $menu)
->condition('i18n_mode', 0)
->execute();
}
// Breadcrumb: Update/Create the root link path.
_breadcrumb__main_link();
// Reset corporate menus.
_reset_menu_to_config('menu-nexteuropa-site-links');
_reset_menu_to_config('menu-nexteuropa-social-media');
_reset_menu_to_config('menu-nexteuropa-inst-links');
_reset_menu_to_config('menu-nexteuropa-service-links');
// Initialize Follow us menu items if necessary.
$menu_name = 'menu-footer-follow-us';
$mlids = db_query("SELECT mlid from {menu_links} WHERE menu_name=:menu_name", array(':menu_name' => $menu_name))->fetchAll();
if (empty($mlids)) {
_reset_menu_to_config($menu_name);
}
// Custom menu right 'menu-footer-right':
// Copy links from existing menu (used in MARE sites) into our menus.
_footer__custom_right_copy_links();
// Set all translations menu items.
foreach (_get_links_config() as $link_group) {
foreach ($link_group as $link) {
$mlids = db_query("SELECT mlid from {menu_links} WHERE link_title=:link_title AND menu_name=:menu_name", array(':link_title' => $link['link_title'], ':menu_name' => $link['menu_name']))->fetchAll();
foreach ($mlids as $menu_item) {
// Set menu_items translations.
if (!empty($link['customized'])) {
_set_translations(array(
'text_original' => $link['link_title'],
'context' => 'menu_item',
'mlid' => $menu_item->mlid,
));
}
}
}
}
// Set interface translations.
_set_translations(array('context' => 'default'));
}
/**
* Corporate footer left links: Two links relative to EC homepage become once.
*/
function header_footer_corporate_update_7001() {
_reset_menu_to_config('menu-nexteuropa-site-links');
}
/**
* Footer links: Copy links from custom menus (used in MARE sites) to our menus.
*/
function header_footer_corporate_update_7002() {
_footer__custom_right_copy_links();
}
/**
* Breadcrumb main link path.
*/
function header_footer_corporate_update_7003() {
_breadcrumb__main_link();
}
/**
* Footer corporate : Reset corporates menus.
*/
function header_footer_corporate_update_7004() {
_reset_menu_to_config('menu-nexteuropa-site-links');
_reset_menu_to_config('menu-nexteuropa-social-media');
_reset_menu_to_config('menu-nexteuropa-inst-links');
_reset_menu_to_config('menu-nexteuropa-service-links');
}
/**
* Footer custom : Unset custom classes.
*/
function header_footer_corporate_update_7005() {
_delete_menu_items_attributes('menu-footer-follow-us');
}