/[drupal]/contributions/modules/dhtml_menu/dhtml_menu.install
ViewVC logotype

Contents of /contributions/modules/dhtml_menu/dhtml_menu.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


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

  ViewVC Help
Powered by ViewVC 1.1.2