1
|
<?php
|
2
|
|
3
|
|
4
|
/**
|
5
|
* @file dhtml_menu.install
|
6
|
* Installation and update functions for the DHTML Menu module.
|
7
|
*/
|
8
|
|
9
|
/**
|
10
|
* Default settings storage.
|
11
|
*/
|
12
|
function _dhtml_menu_defaults() {
|
13
|
return array(
|
14
|
'nav' => 'open',
|
15
|
'animation' => array(
|
16
|
'effects' => array(
|
17
|
'height' => 'height',
|
18
|
'opacity' => 'opacity',
|
19
|
),
|
20
|
'speed' => 500,
|
21
|
),
|
22
|
'effects' => array(
|
23
|
'siblings' => 'close-same-tree',
|
24
|
'children' => 'none',
|
25
|
'remember' => 0,
|
26
|
),
|
27
|
'filter' => array(
|
28
|
'type' => 'blacklist',
|
29
|
'list' => array(),
|
30
|
),
|
31
|
);
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
* Implementation of hook_enable().
|
36
|
*/
|
37
|
function dhtml_menu_enable() {
|
38
|
drupal_set_message(t('<em>DHTML Menu</em> offers a wide range of customization options. If you wish to change them, please visit the <a href="@url">configuration page</a>.', array('@url' => url('admin/config/user-interface/dhtml_menu'))), 'warning');
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
* Implementation of hook_install().
|
43
|
* This will create our system variable defaults.
|
44
|
* The benefit is that we do not need to pass defaults
|
45
|
* to variable_get(), which allows centralization of defaults.
|
46
|
*/
|
47
|
function dhtml_menu_install() {
|
48
|
variable_set('dhtml_menu_settings', _dhtml_menu_defaults());
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* Implementation of hook_uninstall().
|
53
|
* Only clears our variables, so a fresh installation can repopulate them.
|
54
|
*/
|
55
|
function dhtml_menu_uninstall() {
|
56
|
// Settings.
|
57
|
variable_del('dhtml_menu_settings');
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* #6000: 6.x-2.x upgrade. Custom blocks are gone, using preprocess instead.
|
62
|
* - Fixing a variable typo in dhtml_menus_menus.
|
63
|
* - Restore normal menu blocks.
|
64
|
* - Setting dhtml_menu_menus to its initial settings.
|
65
|
*/
|
66
|
function dhtml_menu_update_6000() {
|
67
|
variable_del('dhtml_menus_menus');
|
68
|
|
69
|
$res = db_query("SELECT delta, theme, weight, region, custom, throttle, visibility, pages, title FROM {blocks} WHERE status AND module = '%s'", 'dhtml_menu');
|
70
|
while ($row = db_fetch_array($res)) {
|
71
|
if ($row['delta'] == 1) {
|
72
|
$module = 'user';
|
73
|
}
|
74
|
else {
|
75
|
$module = 'menu';
|
76
|
}
|
77
|
db_query("UPDATE {blocks} SET status = 1, weight = %d, region = '%s', custom = %d, throttle = %d, visibility = %d, pages = '%s', title = '%s' WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $row['weight'], $row['region'], $row['custom'], $row['throttle'], $row['visibility'], $row['pages'], $row['title'], $module, $row['delta'], $row['theme']);
|
78
|
}
|
79
|
|
80
|
variable_set('dhtml_menu_menus', array('navigation' => 1, 'primary-links' => 1, 'secondary-links' => 1));
|
81
|
return array();
|
82
|
}
|
83
|
|
84
|
/**
|
85
|
* #6001: 6.x-2.1 upgrade. A two-dimensional array is now used for these settings, indexing by module and block delta.
|
86
|
*/
|
87
|
function dhtml_menu_update_6001() {
|
88
|
variable_set('dhtml_menu_menus', array('user' => array(1 => TRUE), 'menu' => array('primary-links' => TRUE, 'secondary-links' => TRUE)));
|
89
|
return array();
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* #6002: 6.x-3.x upgrade. All existing variables are obsolete.
|
94
|
*/
|
95
|
function dhtml_menu_update_6002() {
|
96
|
$s['slide'] = variable_get('dhtml_menu_use_effects', FALSE);
|
97
|
$s['siblings'] = variable_get('dhtml_menu_hide_siblings', FALSE);
|
98
|
// don't confuse people by removing this functionality.
|
99
|
$s['doubleclick'] = TRUE;
|
100
|
// add this new functionality.
|
101
|
$s['clone'] = TRUE;
|
102
|
|
103
|
// These settings are no longer needed.
|
104
|
variable_del('dhtml_menu_use_effects');
|
105
|
variable_del('dhtml_menu_hide_siblings');
|
106
|
variable_del('dhtml_menu_duplicated');
|
107
|
variable_del('dhtml_menu_menus');
|
108
|
|
109
|
$var = array();
|
110
|
foreach ($s as $setting => $value) {
|
111
|
if ($value) {
|
112
|
$var[] = $setting;
|
113
|
}
|
114
|
}
|
115
|
|
116
|
// Store new settings.
|
117
|
variable_set('dhtml_menu_effects', $var);
|
118
|
|
119
|
// Rebuild theme registry now that our theme functions got added.
|
120
|
drupal_rebuild_theme_registry();
|
121
|
return array();
|
122
|
}
|
123
|
|
124
|
/**
|
125
|
* #7101: 7.x-1.x-dev upgrade (duplicated in 6.x-3.x). Remove two obsolete variables and rebuild all themes.
|
126
|
*/
|
127
|
function dhtml_menu_update_7101() {
|
128
|
variable_del('dhtml_menu_theme_menu_item');
|
129
|
variable_del('dhtml_menu_theme_menu_item_link');
|
130
|
|
131
|
drupal_theme_rebuild();
|
132
|
return array();
|
133
|
}
|
134
|
|
135
|
/**
|
136
|
* #7102: Consolidate variables into one settings array.
|
137
|
*/
|
138
|
function dhtml_menu_update_7102() {
|
139
|
$defaults = _dhtml_menu_defaults();
|
140
|
|
141
|
// As the settings have moved, read them individually.
|
142
|
$settings['nav'] = variable_get('dhtml_menu_nav', $defaults['nav']);
|
143
|
$settings['animation'] = array(
|
144
|
'effects' => variable_get('dhtml_menu_animations', $defaults['animation']['effects']),
|
145
|
'speed' => variable_get('dhtml_menu_speed', $defaults['animation']['speed']),
|
146
|
);
|
147
|
$settings['effects'] = array(
|
148
|
'siblings' => variable_get('dhtml_menu_siblings', $defaults['effects']['siblings']),
|
149
|
'children' => variable_get('dhtml_menu_children', $defaults['effects']['children']),
|
150
|
// Entirely new setting.
|
151
|
'remember' => $defaults['effects']['remember'],
|
152
|
);
|
153
|
|
154
|
$settings['filter']['list'] = variable_get('dhtml_menu_disabled', array());
|
155
|
|
156
|
// Write the consolidated settings.
|
157
|
variable_set("dhtml_menu_settings", $settings);
|
158
|
|
159
|
// Clear the old settings.
|
160
|
foreach (array('nav', 'siblings', 'children', 'animations', 'speed', 'disabled') as $key) {
|
161
|
variable_del("dhtml_menu_$key");
|
162
|
}
|
163
|
return array();
|
164
|
}
|
165
|
|
166
|
/**
|
167
|
* #7103: Rename "pseudo-child" to "clone".
|
168
|
*/
|
169
|
function dhtml_menu_update_7103() {
|
170
|
$settings = variable_get('dhtml_menu_settings');
|
171
|
if ($settings['nav'] == 'pseudo-child') {
|
172
|
$settings['nav'] = 'clone';
|
173
|
variable_set('dhtml_menu_settings', $settings);
|
174
|
}
|
175
|
return array();
|
176
|
}
|
177
|
|
178
|
/**
|
179
|
* #7104: Theme registry interceptor is dead.
|
180
|
*/
|
181
|
function dhtml_menu_update_7104() {
|
182
|
variable_del('dhtml_menu_theme');
|
183
|
}
|
184
|
|
185
|
/**
|
186
|
* #7105: Ensure that 'Filter type' is set.
|
187
|
*/
|
188
|
function dhtml_menu_update_7105() {
|
189
|
$settings = variable_get('dhtml_menu_settings');
|
190
|
if (!isset($settings['filter']['type'])) {
|
191
|
$settings['filter']['type'] = 'blacklist';
|
192
|
variable_set('dhtml_menu_settings', $settings);
|
193
|
}
|
194
|
}
|
195
|
|