-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata_snapshots.install
137 lines (125 loc) · 3.91 KB
/
data_snapshots.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
include_once 'data_snapshots.fields.data_snapshot_data_source.inc';
include_once 'data_snapshots.fields.data_snapshot.inc';
include_once 'data_snapshots.field_groups.inc';
function data_snapshots_install() {
$vocab = array(
'name' => 'Data Snapshot Data Set Frequency',
'machine_name' => 'data_snapshot_data_set_frequency',
'description' => 'Image frequency for a Data Snapshot Data set.',
'hierarchy' => '0',
'module' => 'taxonomy',
'weight' => '0',
'rdf_mapping' => array(
'rdftype' => array(
0 => 'skos:ConceptScheme',
),
'name' => array(
'predicates' => array(
0 => 'dc:title',
),
),
'description' => array(
'predicates' => array(
0 => 'rdfs:comment',
),
),
),
);
taxonomy_vocabulary_save((object)$vocab);
$vocab = array(
'name' => 'Data Snapshots Themes',
'machine_name' => 'data_snapshots_themes',
'description' => 'The available Themes for Data Snapshots',
'hierarchy' => '0',
'module' => 'taxonomy',
'weight' => '0',
'rdf_mapping' => array(
'rdftype' => array(
0 => 'skos:ConceptScheme',
),
'name' => array(
'predicates' => array(
0 => 'dc:title',
),
),
'description' => array(
'predicates' => array(
0 => 'rdfs:comment',
),
),
),
);
taxonomy_vocabulary_save((object)$vocab);
}
function data_snapshots_uninstall() {
//
// WARNING: delete (or comment out) this function before releasing this module.
// It's here during development so that the content types created by
// this module will get removed from the database when uninstalling the module,
// to make it easier to undo the effect of installing the module during testing.
// In production, however, we don't want this to happen.
//fwrite(STDERR, "uninstall at 1\n");
foreach (data_snapshots_fields_data_snapshot() as $field) {
$instance = $field['field_instance'];
$instance['entity_type'] = 'node';
$instance['bundle'] = 'data_snapshot';
field_delete_instance($instance);
field_delete_field($field['field_config']['field_name']);
}
node_type_delete('data_snapshot');
foreach (data_snapshots_fields_data_snapshot_data_source() as $field) {
$instance = $field['field_instance'];
$instance['entity_type'] = 'node';
$instance['bundle'] = 'data_snapshot_data_source';
field_delete_instance($instance);
field_delete_field($field['field_config']['field_name']);
}
node_type_delete('data_snapshot_data_source');
field_purge_batch();
}
/**
* Implements hook_schema().
*
* Defines the database tables used by this module.
*/
function data_snapshots_schema() {
$schema['data_snapshots'] = array(
'description' => 'Stores extra data needed for optimized access to data_snaphots nodes.',
'fields' => array(
'nid' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'Primary Key: nid of data_snapshot node.',
),
'guid' => array(
'type' => 'text',
'not null' => TRUE,
'description' => "Guid field from feeds_item table.",
),
'dsmn' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => "Dataset machine name for the node.",
),
'ptk' => array(
'type' => 'varchar',
'length' => 16,
'not null' => TRUE,
'default' => '',
'description' => 'The primary time key for the node, typically the year.',
),
'stk' => array(
'type' => 'varchar',
'length' => 16,
'description' => 'The secondary time key for the node, e.g. MM-DD, optional.',
)
),
'primary key' => array('nid'),
'indexes' => array(
'dsmn' => array('dsmn'),
),
);
return $schema;
}