This repository has been archived by the owner on Mar 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
choropleth.install
92 lines (85 loc) · 3.31 KB
/
choropleth.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* @file
* Installation file for choropleth module.
*/
/**
* Implements hook_install().
*/
function choropleth_install() {
choropleth_udpate_existing_fields();
}
/**
* Checks for current implementations of recline and adds additional columns.
*/
function choropleth_udpate_existing_fields() {
$fields = field_info_fields();
foreach ($fields as $field_name => $field) {
if ($field['type'] == 'recline_field' && $field['storage']['type'] == 'field_sql_storage') {
foreach ($field['storage']['details']['sql'] as $type => $table_info) {
foreach ($table_info as $table_name => $columns) {
$column_name = _field_sql_storage_columnname($field_name, 'choropleth_data_column');
$schema = choropleth_custom_db_field_schema();
// Adding choropleth_data_column.
if (!(db_field_exists($table_name, $column_name))) {
// _drupal_schema_initialize() expects a fields array from the
// schema.
db_add_field($table_name, $column_name, $schema['choropleth_data_column'] + array('fields' => array()));
}
// Adding choropleth_unit_of_measure.
$column_name = _field_sql_storage_columnname($field_name, 'choropleth_unit_of_measure');
if (!(db_field_exists($table_name, $column_name))) {
// _drupal_schema_initialize() expects a fields array from the
// schema.
db_add_field($table_name, $column_name, $schema['choropleth_unit_of_measure'] + array('fields' => array()));
}
// Adding choropleth_breakpoints.
$column_name = _field_sql_storage_columnname($field_name, 'choropleth_breakpoints');
if (!(db_field_exists($table_name, $column_name))) {
// _drupal_schema_initialize() expects a fields array from the
// schema.
db_add_field($table_name, $column_name, $schema['choropleth_breakpoints'] + array('fields' => array()));
}
// Adding choropleth_color_scale.
$column_name = _field_sql_storage_columnname($field_name, 'choropleth_color_scale');
if (!(db_field_exists($table_name, $column_name))) {
// _drupal_schema_initialize() expects a fields array from the
// schema.
db_add_field($table_name, $column_name, $schema['choropleth_color_scale'] + array('fields' => array()));
}
// Adding choropleth view.
$column_name = _field_sql_storage_columnname($field_name, 'choropleth');
$schema = recline_field_schema();
if (!(db_field_exists($table_name, $column_name))) {
db_add_field($table_name, $column_name, $schema['columns']['choropleth']);
}
field_cache_clear();
}
}
}
}
}
/**
* Add cholorpleth columns to existing recline field storage.
*/
function choropleth_update_7001(&$sandbox) {
$ret = array();
choropleth_udpate_existing_fields();
return $ret;
}
/**
* Add cholorpleth color scale column to existing recline field storage.
*/
function choropleth_update_7002(&$sandbox) {
$ret = array();
choropleth_udpate_existing_fields();
return $ret;
}
/**
* Add choropleth units of measure to existing recline field storage.
*/
function choropleth_update_7003(&$sandbox) {
$ret = array();
choropleth_udpate_existing_fields();
return $ret;
}