Change settings into a serialized array rather than individual properties.
[project/mapboxjs.git] / mapboxjs.install
1 <?php
2
3 /**
4 * Implements hook_schema().
5 */
6 function mapboxjs_schema() {
7
8 // MapBox.js map preset table.
9 $schema['mapboxjs_preset'] = array(
10 'description' => 'MapBox.js map presets',
11 'fields' => array(
12 'mapboxjs_preset_id' => array(
13 'type' => 'serial',
14 'not null' => TRUE,
15 'description' => 'Primary Key: Unique Mapbox.js preset entity ID.',
16 ),
17 'name' => array(
18 'description' => 'The machine-readable name of this mapboxjs_preset type.',
19 'type' => 'varchar',
20 'length' => 128,
21 'not null' => TRUE,
22 ),
23 'label' => array(
24 'description' => 'The human-readable name of this mapboxjs_preset type.',
25 'type' => 'varchar',
26 'length' => 128,
27 'not null' => TRUE,
28 ),
29 'settings' => array(
30 'description' => 'MapBox JS map settings as a serialized array.',
31 'type' => 'text',
32 'not null' => FALSE,
33 'size' => 'big',
34 'serialize' => TRUE,
35 ),
36 'created' => array(
37 'description' => 'The Unix timestamp when the mapboxjs_preset was created.',
38 'type' => 'int',
39 'not null' => TRUE,
40 'default' => 0,
41 ),
42 'updated' => array(
43 'description' => 'The Unix timestamp when the mapboxjs_preset was most recently saved.',
44 'type' => 'int',
45 'not null' => TRUE,
46 'default' => 0,
47 ),
48 // following fields are for supporting exportable status.
49 'locked' => array(
50 'description' => 'A boolean indicating whether the administrator may delete this preset.',
51 'type' => 'int',
52 'not null' => TRUE,
53 'default' => 0,
54 'size' => 'tiny',
55 ),
56 'status' => array(
57 'type' => 'int',
58 'not null' => TRUE,
59 // Set the default to ENTITY_CUSTOM without using the constant as it is
60 // not safe to use it at this point.
61 'default' => 0x01,
62 'size' => 'tiny',
63 'description' => 'The exportable status of the entity.',
64 ),
65 'module' => array(
66 'description' => 'The name of the providing module if the entity has been defined in code.',
67 'type' => 'varchar',
68 'length' => 255,
69 'not null' => FALSE,
70 ),
71 ),
72 'primary key' => array('mapboxjs_preset_id'),
73 'unique keys' => array(
74 'name' => array('name'),
75 ),
76 );
77
78 return $schema;
79 }
80
81 /*
82 * Implements hook_install()
83 */
84 function mapboxjs_install() {
85 // Add a locked Link field to our MapBox.js custom entity bundle.
86 // Provides storage for our base tileset(s).
87 $base_tilesets_config = array(
88 'translatable' => '0',
89 'entity_types' => array(),
90 'settings' => array(
91 'attributes' => array(
92 'target' => 'default',
93 'class' => '',
94 'rel' => '',
95 ),
96 'url' => 0,
97 'title' => 'required',
98 'title_value' => '',
99 'title_maxlength' => 128,
100 'enable_tokens' => 1,
101 'display' => array(
102 'url_cutoff' => 80,
103 ),
104 ),
105 'foreign keys' => array(),
106 'indexes' => array(),
107 'field_name' => 'field_base_tilesets',
108 'type' => 'link_field',
109 'module' => 'link',
110 'active' => '1',
111 'locked' => '1',
112 'cardinality' => '-1',
113 'deleted' => '0',
114 );
115 $base_tilesets_instance = array(
116 'label' => 'Base tileset(s)',
117 'widget' => array(
118 'weight' => '-1',
119 'type' => 'link_field',
120 'module' => 'link',
121 'active' => 0,
122 'settings' => array(),
123 ),
124 'settings' => array(
125 'validate_url' => 1,
126 'url' => 0,
127 'title' => 'required',
128 'title_value' => '',
129 'title_maxlength' => '128',
130 'enable_tokens' => 1,
131 'display' => array(
132 'url_cutoff' => '80',
133 ),
134 'attributes' => array(
135 'target' => 'default',
136 'rel' => '',
137 'class' => '',
138 'configurable_title' => 0,
139 'title' => '',
140 ),
141 'user_register_form' => FALSE,
142 ),
143 'display' => array(
144 'default' => array(
145 'label' => 'hidden',
146 'type' => 'hidden',
147 'weight' => '0',
148 'settings' => array(),
149 ),
150 ),
151 'required' => 1,
152 'description' => 'Please enter the full URL of a <a href="http://mapbox.com">MapBox</a> tileset to be added to this map as a base layer. This URL should be in the TileJSON file format, like http://a.tiles.mapbox.com/v3/tmcw.map-hehqnmda.jsonp. The "title" you enter for this URL will be used in the map\'s tile switcher.',
153 'default_value' => NULL,
154 'field_name' => 'field_base_tilesets',
155 'entity_type' => 'mapboxjs_preset',
156 'bundle' => 'mapboxjs_preset',
157 'deleted' => '0',
158 );
159 field_create_field($base_tilesets_config);
160 field_create_instance($base_tilesets_instance);
161 // Add a locked Link field to our MapBox.js custom entity bundle.
162 // Provides storage for optional tilesets place on top of base tileset(s).
163 $optional_tilesets_config = array(
164 'translatable' => '0',
165 'entity_types' => array(),
166 'settings' => array(
167 'attributes' => array(
168 'target' => 'default',
169 'class' => '',
170 'rel' => '',
171 ),
172 'url' => 0,
173 'title' => 'required',
174 'title_value' => '',
175 'title_maxlength' => 128,
176 'enable_tokens' => 1,
177 'display' => array(
178 'url_cutoff' => 80,
179 ),
180 ),
181 'foreign keys' => array(),
182 'indexes' => array(),
183 'field_name' => 'field_optional_tilesets',
184 'type' => 'link_field',
185 'module' => 'link',
186 'active' => '1',
187 'locked' => '1',
188 'cardinality' => '-1',
189 'deleted' => '0',
190 );
191 $optional_tilesets_instance = array(
192 'label' => 'Optional tileset(s)',
193 'widget' => array(
194 'weight' => '0',
195 'type' => 'link_field',
196 'module' => 'link',
197 'active' => 0,
198 'settings' => array(),
199 ),
200 'settings' => array(
201 'validate_url' => 1,
202 'url' => 0,
203 'title' => 'required',
204 'title_value' => '',
205 'title_maxlength' => '128',
206 'enable_tokens' => 1,
207 'display' => array(
208 'url_cutoff' => '80',
209 ),
210 'attributes' => array(
211 'target' => 'default',
212 'rel' => '',
213 'class' => '',
214 'configurable_title' => 0,
215 'title' => '',
216 ),
217 'user_register_form' => FALSE,
218 ),
219 'display' => array(
220 'default' => array(
221 'label' => 'hidden',
222 'type' => 'hidden',
223 'weight' => '0',
224 'settings' => array(),
225 ),
226 ),
227 'required' => 0,
228 'description' => 'Please enter the full URL of a <a href="http://mapbox.com">MapBox</a> tileset to be added to this map on top of the base tileset layers. This URL should be in the TileJSON file format, like http://a.tiles.mapbox.com/v3/tmcw.map-hehqnmda.jsonp. The "title" you enter for this URL will be used in the map\'s toggle controls for optional tileset layers, if the controls are enabled.',
229 'default_value' => NULL,
230 'field_name' => 'field_optional_tilesets',
231 'entity_type' => 'mapboxjs_preset',
232 'bundle' => 'mapboxjs_preset',
233 'deleted' => '0',
234 );
235 field_create_field($optional_tilesets_config);
236 field_create_instance($optional_tilesets_instance);
237 }
238
239 /**
240 * Implements hook_field_schema().
241 */
242 function mapboxjs_field_schema($field) {
243 $columns = array(
244 'value' => array(
245 'type' => 'varchar',
246 'length' => 128,
247 'not null' => FALSE,
248 ),
249 );
250 return array(
251 'columns' => $columns,
252 );
253 }
254
255 /**
256 * Implements hook_uninstall().
257 */
258 function mapboxjs_uninstall() {
259 // Delete locked fields when uninstalling module.
260 field_delete_instance('field_base_tilesets', TRUE);
261 field_delete_instance('field_optional_tilesets', TRUE);
262 }