1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Install and uninstall all required databases. Also do incremental database updates.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_uninstall().
|
10 |
|
|
*/
|
11 |
|
|
function taxonomy_menu_uninstall() {
|
12 |
|
|
|
13 |
|
|
//remove menu items
|
14 |
|
|
db_delete('menu_links')->condition('module', 'taxonomy_menu', '=')->execute();
|
15 |
|
|
|
16 |
|
|
//rebuild the menus
|
17 |
|
|
variable_set('menu_rebuild_needed', TRUE);
|
18 |
|
|
|
19 |
|
|
// Delete variables
|
20 |
|
|
$query = db_select('variable', 'v')->fields('v')->execute();
|
21 |
|
|
$variables = $query->fetchAll();
|
22 |
|
|
foreach ($variables as $variable) {
|
23 |
|
|
if (strpos($variable->name, 'taxonomy_menu') !== FALSE) {
|
24 |
|
|
variable_del($variable->name);
|
25 |
|
|
}
|
26 |
|
|
}
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
/**
|
30 |
|
|
* Implements hook_install().
|
31 |
|
|
*/
|
32 |
|
|
function taxonomy_menu_install() {
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
/**
|
36 |
|
|
* Implements hook_schema().
|
37 |
|
|
*/
|
38 |
|
|
function taxonomy_menu_schema() {
|
39 |
|
|
|
40 |
|
|
$schema['taxonomy_menu'] = array(
|
41 |
|
|
'description' => 'Links a taxonomy term to a menu item.',
|
42 |
|
|
'fields' => array(
|
43 |
|
|
'mlid' => array(
|
44 |
|
|
'type' => 'int',
|
45 |
|
|
'unsigned' => TRUE,
|
46 |
|
|
'not null' => TRUE,
|
47 |
|
|
'default' => 0,
|
48 |
|
|
'description' => 'The taxonomy terms {menu_link}.mlid.',
|
49 |
|
|
),
|
50 |
|
|
'tid' => array(
|
51 |
|
|
'type' => 'int',
|
52 |
|
|
'unsigned' => TRUE,
|
53 |
|
|
'not null' => TRUE,
|
54 |
|
|
'default' => 0,
|
55 |
|
|
'description' => 'Tid that is linked to the mlid.',
|
56 |
|
|
),
|
57 |
|
|
'vid' => array(
|
58 |
|
|
'type' => 'int',
|
59 |
|
|
'unsigned' => TRUE,
|
60 |
|
|
'not null' => TRUE,
|
61 |
|
|
'default' => 0,
|
62 |
|
|
'description' => 'Vid for the tid.',
|
63 |
|
|
),
|
64 |
|
|
),
|
65 |
|
|
'primary key' => array('mlid', 'tid'),
|
66 |
|
|
'indexes' => array(
|
67 |
|
|
'vid' => array('vid'),
|
68 |
|
|
),
|
69 |
|
|
);
|
70 |
|
|
|
71 |
|
|
return $schema;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
/**
|
75 |
|
|
* Convert vocabulary ids into vocabulary machine names.
|
76 |
|
|
*/
|
77 |
|
|
function taxonomy_menu_update_7000() {
|
78 |
|
|
$variable_prefixes = array(
|
79 |
|
|
'vocab_menu',
|
80 |
|
|
'vocab_parent',
|
81 |
|
|
'voc_item',
|
82 |
|
|
'display_num',
|
83 |
|
|
'hide_empty_terms',
|
84 |
|
|
'expanded',
|
85 |
|
|
'rebuild',
|
86 |
|
|
'path',
|
87 |
|
|
'menu_end_all',
|
88 |
|
|
'display_descendants',
|
89 |
|
|
'voc_name',
|
90 |
|
|
'sync',
|
91 |
|
|
);
|
92 |
|
|
|
93 |
|
|
$vocabularies = taxonomy_get_vocabularies();
|
94 |
|
|
foreach ($vocabularies as $vocabulary) {
|
95 |
|
|
foreach ($variable_prefixes as $prefix) {
|
96 |
|
|
$old_name = 'taxonomy_menu_' . $prefix . '_' . $vocabulary->vid;
|
97 |
|
|
$new_name = 'taxonomy_menu_' . $prefix . '_' . $vocabulary->machine_name;
|
98 |
|
|
if (($value = variable_get($old_name)) !== NULL) {
|
99 |
|
|
variable_set($new_name, $value);
|
100 |
|
|
variable_del($old_name);
|
101 |
|
|
}
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
} |