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

Contents of /contributions/modules/openlayers/openlayers.install

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


Revision 1.14 - (show annotations) (download) (as text)
Thu Sep 24 17:40:46 2009 UTC (2 months ago) by tmcw
Branch: MAIN
CVS Tags: DRUPAL-6--0-1-ALPHA2, DRUPAL-6--0-1-ALPHA3, DRUPAL-6--0-1-ALPHA1, DRUPAL-6--0-1-ALPHA6, DRUPAL-6--0-1-ALPHA4, DRUPAL-6--0-1-ALPHA5, HEAD
Changes since 1.13: +155 -15 lines
File MIME type: text/x-php
Adding new code for 0.x tags
1 <?php
2 // $Id: openlayers.install,v 1.10.2.1 2009/07/13 05:08:15 binarybill Exp $
3
4 /**
5 * @file
6 * This file holds the functions for the installing
7 * and enabling of the openlayers module.
8 *
9 * @ingroup openlayers
10 */
11
12 /**
13 * Implementation of hook_install().
14 */
15 function openlayers_install() {
16 // Create tables
17 drupal_install_schema('openlayers');
18 }
19
20 /**
21 * Implementation of hook_uninstall().
22 */
23 function openlayers_uninstall() {
24 // Remove tables
25 drupal_uninstall_schema('openlayers');
26
27 // Get module variables
28 $results = db_query("SELECT v.name FROM {variable} AS v WHERE v.name LIKE '%s%%'", 'openlayers_');
29 // Remove variables
30 while ($row = db_fetch_array($results)) {
31 variable_del($row['name']);
32 }
33 }
34
35 /**
36 * Implementation of hook_schema.
37 */
38 function openlayers_schema() {
39 $schema = array();
40 $schema['openlayers_layers'] = array(
41 'description' => 'Storage for user defined OpenLayers layers.',
42 'export' => array(
43 'key' => 'name',
44 'identifier' => 'openlayers_layers',
45 'default hook' => 'openlayers_layers_info',
46 'api' => array(
47 'owner' => 'openlayers',
48 'api' => 'openlayers_layers',
49 'minimum_version' => 1,
50 'current_version' => 1,
51 ),
52 ),
53 'fields' => array(
54 'name' => array(
55 'type' => 'varchar',
56 'length' => '255',
57 'not null' => TRUE,
58 'default' => '',
59 'description' => 'Layer name.',
60 ),
61 'title' => array(
62 'type' => 'varchar',
63 'length' => '255',
64 'not null' => TRUE,
65 'default' => '',
66 'description' => 'Layer title.',
67 ),
68 'description' => array(
69 'type' => 'text',
70 'not null' => TRUE,
71 'default' => '',
72 'description' => 'Layer description.',
73 ),
74 'data' => array(
75 'type' => 'text',
76 'not null' => FALSE,
77 'description' => 'Layer data serialized.',
78 'serialize' => TRUE,
79 ),
80 ),
81 'primary key' => array('name'),
82 'indexes' => array(
83 'name' => array('name'),
84 ),
85 );
86 $schema['openlayers_map_presets'] = array(
87 'description' => 'Storage for User defined OpenLayers map presets.',
88 'export' => array(
89 'key' => 'name',
90 'identifier' => 'openlayers_presets',
91 'default hook' => 'openlayers_presets',
92 'api' => array(
93 'owner' => 'openlayers',
94 'api' => 'openlayers_presets',
95 'minimum_version' => 1,
96 'current_version' => 1,
97 ),
98 ),
99 'fields' => array(
100 'name' => array(
101 'description' => t('The primary identifier for the preset.'),
102 'type' => 'varchar',
103 'length' => 255,
104 'not null' => TRUE,
105 ),
106 'title' => array(
107 'description' => t('The title of the preset.'),
108 'type' => 'varchar',
109 'length' => 255,
110 'not null' => TRUE,
111 ),
112 'description' => array(
113 'description' => t('The description of the preset.'),
114 'type' => 'text',
115 'not null' => TRUE,
116 ),
117 'data' => array(
118 'description' => t('The serialized map.'),
119 'type' => 'text',
120 'not null' => TRUE,
121 'serialize' => TRUE,
122 ),
123 ),
124 'primary key' => array('name'),
125 );
126 $schema['openlayers_styles'] = array(
127 'description' => 'Storage for user defined OpenLayers styles.',
128 'export' => array(
129 'key' => 'name',
130 'identifier' => 'openlayers_styles',
131 'default hook' => 'openlayers_styles_info',
132 'api' => array(
133 'owner' => 'openlayers',
134 'api' => 'openlayers_styles',
135 'minimum_version' => 1,
136 'current_version' => 1,
137 ),
138 ),
139 'fields' => array(
140 'name' => array(
141 'type' => 'varchar',
142 'length' => '255',
143 'not null' => TRUE,
144 'default' => '',
145 'description' => 'Style name.',
146 ),
147 'title' => array(
148 'type' => 'varchar',
149 'length' => '255',
150 'not null' => TRUE,
151 'default' => '',
152 'description' => 'Style title.',
153 ),
154 'description' => array(
155 'type' => 'text',
156 'not null' => TRUE,
157 'default' => '',
158 'description' => 'Style description.',
159 ),
160 'data' => array(
161 'type' => 'text',
162 'not null' => FALSE,
163 'description' => 'Style data serialized.',
164 'serialize' => TRUE,
165 ),
166 ),
167 'primary key' => array('name'),
168 'indexes' => array(
169 'name' => array('name'),
170 ),
171 );
172 return $schema;
173 }
174
175 /**
176 * 6001: Adjust presets table.
177 */
178 function openlayers_update_6001() {
179 $ret = array();
180
181 // Alter presets table.
182 db_drop_field($ret, 'openlayers_map_presets', 'preset_id');
183 db_change_field($ret, 'openlayers_map_presets', 'preset_name', 'name',
184 array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
185 array('primary key' => array('name'))
186 );
187 db_change_field($ret, 'openlayers_map_presets', 'preset_title', 'title',
188 array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
189 array()
190 );
191 db_change_field($ret, 'openlayers_map_presets', 'preset_description', 'description',
192 array('type' => 'text', 'not null' => TRUE),
193 array()
194 );
195 db_change_field($ret, 'openlayers_map_presets', 'preset_data', 'data',
196 array('type' => 'text', 'not null' => TRUE),
197 array()
198 );
199 return $ret;
200 }
201
202 /**
203 * 6002: Add any new tables.
204 */
205 function openlayers_update_6002() {
206 $ret = array();
207
208 $schema = drupal_get_schema_unprocessed('openlayers');
209 foreach ($schema as $name => $table) {
210 if (!db_table_exists($name)) {
211 db_create_table($ret, $name, $table);
212 }
213 }
214 return $ret;
215 }

  ViewVC Help
Powered by ViewVC 1.1.2