Projet

Général

Profil

Paste
Télécharger (5,53 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / dhtml_menu / dhtml_menu.install @ 87dbc3bf

1
<?php
2
// $Id: dhtml_menu.install,v 1.17 2010/08/16 10:39:57 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
  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');
40
}
41

    
42
/**
43
 * Implementation of hook_install().
44
 * This will create our system variable defaults.
45
 * The benefit is that we do not need to pass defaults
46
 * to variable_get(), which allows centralization of defaults.
47
 */
48
function dhtml_menu_install() {
49
  variable_set('dhtml_menu_settings', _dhtml_menu_defaults());
50
}
51

    
52
/**
53
 * Implementation of hook_uninstall().
54
 * Only clears our variables, so a fresh installation can repopulate them.
55
 */
56
function dhtml_menu_uninstall() {
57
  // Settings.
58
  variable_del('dhtml_menu_settings');
59
}
60

    
61
/**
62
 * #6000: 6.x-2.x upgrade. Custom blocks are gone, using preprocess instead.
63
 * - Fixing a variable typo in dhtml_menus_menus.
64
 * - Restore normal menu blocks.
65
 * - Setting dhtml_menu_menus to its initial settings.
66
 */
67
function dhtml_menu_update_6000() {
68
  variable_del('dhtml_menus_menus');
69

    
70
  $res = db_query("SELECT delta, theme, weight, region, custom, throttle, visibility, pages, title FROM {blocks} WHERE status AND module = '%s'", 'dhtml_menu');
71
  while ($row = db_fetch_array($res)) {
72
    if ($row['delta'] == 1) {
73
      $module = 'user';
74
    }
75
    else {
76
      $module = 'menu';
77
    }
78
    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']);
79
  }
80

    
81
  variable_set('dhtml_menu_menus', array('navigation' => 1, 'primary-links' => 1, 'secondary-links' => 1));
82
  return array();
83
}
84

    
85
/**
86
 * #6001: 6.x-2.1 upgrade. A two-dimensional array is now used for these settings, indexing by module and block delta.
87
 */
88
function dhtml_menu_update_6001() {
89
  variable_set('dhtml_menu_menus', array('user' => array(1 => TRUE), 'menu' => array('primary-links' => TRUE, 'secondary-links' => TRUE)));
90
  return array();
91
}
92

    
93
/**
94
 * #6002: 6.x-3.x upgrade. All existing variables are obsolete.
95
 */
96
function dhtml_menu_update_6002() {
97
  $s['slide'] = variable_get('dhtml_menu_use_effects', FALSE);
98
  $s['siblings'] = variable_get('dhtml_menu_hide_siblings', FALSE);
99
  // don't confuse people by removing this functionality.
100
  $s['doubleclick'] = TRUE;
101
  // add this new functionality.
102
  $s['clone'] = TRUE;
103

    
104
  // These settings are no longer needed.
105
  variable_del('dhtml_menu_use_effects');
106
  variable_del('dhtml_menu_hide_siblings');
107
  variable_del('dhtml_menu_duplicated');
108
  variable_del('dhtml_menu_menus');
109

    
110
  $var = array();
111
  foreach ($s as $setting => $value) {
112
    if ($value) {
113
      $var[] = $setting;
114
    }
115
  }
116

    
117
  // Store new settings.
118
  variable_set('dhtml_menu_effects', $var);
119

    
120
  // Rebuild theme registry now that our theme functions got added.
121
  drupal_rebuild_theme_registry();
122
  return array();
123
}
124

    
125
/**
126
 * #7101: 7.x-1.x-dev upgrade (duplicated in 6.x-3.x). Remove two obsolete variables and rebuild all themes.
127
 */
128
function dhtml_menu_update_7101() {
129
  variable_del('dhtml_menu_theme_menu_item');
130
  variable_del('dhtml_menu_theme_menu_item_link');
131

    
132
  drupal_theme_rebuild();
133
  return array();
134
}
135

    
136
/**
137
 * #7102: Consolidate variables into one settings array.
138
 */
139
function dhtml_menu_update_7102() {
140
  $defaults = _dhtml_menu_defaults();
141

    
142
  // As the settings have moved, read them individually.
143
  $settings['nav'] = variable_get('dhtml_menu_nav', $defaults['nav']);
144
  $settings['animation'] = array(
145
    'effects' => variable_get('dhtml_menu_animations', $defaults['animation']['effects']),
146
    'speed' => variable_get('dhtml_menu_speed', $defaults['animation']['speed']),
147
  );
148
  $settings['effects'] = array(
149
    'siblings' => variable_get('dhtml_menu_siblings', $defaults['effects']['siblings']),
150
    'children' => variable_get('dhtml_menu_children', $defaults['effects']['children']),
151
    // Entirely new setting.
152
    'remember' => $defaults['effects']['remember'],
153
  );
154

    
155
  $settings['filter']['list'] = variable_get('dhtml_menu_disabled', array());
156

    
157
  // Write the consolidated settings.
158
  variable_set("dhtml_menu_settings", $settings);
159

    
160
  // Clear the old settings.
161
  foreach (array('nav', 'siblings', 'children', 'animations', 'speed', 'disabled') as $key) {
162
    variable_del("dhtml_menu_$key");
163
  }
164
  return array();
165
}
166

    
167
/**
168
 * #7103: Rename "pseudo-child" to "clone".
169
 */
170
function dhtml_menu_update_7103() {
171
  $settings = variable_get('dhtml_menu_settings');
172
  if ($settings['nav'] == 'pseudo-child') {
173
    $settings['nav'] = 'clone';
174
    variable_set('dhtml_menu_settings', $settings);
175
  }
176
  return array();
177
}
178

    
179
/**
180
 * #7104: Theme registry interceptor is dead.
181
 */
182
function dhtml_menu_update_7104() {
183
  variable_del('dhtml_menu_theme');
184
}
185