aggregator.install 7.3 KB
Newer Older
1
<?php
2
// $Id$
3

4
5
6
/**
 * Implementation of hook_install().
 */
7
function aggregator_install() {
8
9
  // Create tables.
  drupal_install_schema('aggregator');
10
}
11
12
13
14
15

/**
 * Implementation of hook_uninstall().
 */
function aggregator_uninstall() {
16
17
18
  // Remove tables.
  drupal_uninstall_schema('aggregator');

19
20
21
22
23
  variable_del('aggregator_allowed_html_tags');
  variable_del('aggregator_summary_items');
  variable_del('aggregator_clear');
  variable_del('aggregator_category_selector');
}
24
25
26
27
28
29

/**
 * Implementation of hook_schema().
 */
function aggregator_schema() {
  $schema['aggregator_category'] = array(
30
    'description' => 'Stores categories for aggregator feeds and feed items.',
31
    'fields' => array(
32
33
34
      'cid'  => array(
        'type' => 'serial',
        'not null' => TRUE,
35
        'description' => 'Primary Key: Unique aggregator category ID.',
36
37
38
39
40
41
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
42
        'description' => 'Title of the category.',
43
44
45
46
47
      ),
      'description' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
48
        'description' => 'Description of the category',
49
50
51
52
53
54
      ),
      'block' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
55
        'description' => 'The number of recent items to show within the category block.',
56
      )
57
58
    ),
    'primary key' => array('cid'),
59
60
61
    'unique keys' => array(
      'title' => array('title'),
    ),
62
63
64
  );

  $schema['aggregator_category_feed'] = array(
65
    'description' => 'Bridge table; maps feeds to categories.',
66
    'fields' => array(
67
68
69
70
      'fid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
71
        'description' => "The feed's {aggregator_feed}.fid.",
72
73
74
75
76
      ),
      'cid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
77
        'description' => 'The {aggregator_category}.cid to which the feed is being assigned.',
78
      )
79
    ),
80
    'primary key' => array('cid', 'fid'),
81
82
83
    'indexes' => array(
      'fid' => array('fid'),
    ),
84
85
86
  );

  $schema['aggregator_category_item'] = array(
87
    'description' => 'Bridge table; maps feed items to categories.',
88
    'fields' => array(
89
90
91
92
      'iid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
93
        'description' => "The feed item's {aggregator_item}.iid.",
94
95
96
97
98
      ),
      'cid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
99
        'description' => 'The {aggregator_category}.cid to which the feed item is being assigned.',
100
      )
101
    ),
102
    'primary key' => array('cid', 'iid'),
103
104
105
    'indexes' => array(
      'iid' => array('iid'),
    ),
106
107
108
  );

  $schema['aggregator_feed'] = array(
109
    'description' => 'Stores feeds to be parsed by the aggregator.',
110
    'fields' => array(
111
112
113
      'fid' => array(
        'type' => 'serial',
        'not null' => TRUE,
114
        'description' => 'Primary Key: Unique feed ID.',
115
116
117
118
119
120
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
121
        'description' => 'Title of the feed.',
122
123
124
125
126
127
      ),
      'url' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
128
        'description' => 'URL to the feed.',
129
130
131
132
133
      ),
      'refresh' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
134
        'description' => 'How often to check for new feed items, in seconds.',
135
136
137
138
139
      ),
      'checked' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
140
        'description' => 'Last time feed was checked for new items, as Unix timestamp.',
141
142
143
144
145
146
      ),
      'link' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
147
        'description' => 'The parent website of the feed; comes from the &lt;link&gt; element in the feed.',
148
149
150
151
152
      ),
      'description' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
153
        'description' => "The parent website's description; comes from the &lt;description&gt; element in the feed.",
154
155
156
157
158
      ),
      'image' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
159
        'description' => 'An image representing the feed.',
160
      ),
161
162
163
164
165
      'hash' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
166
        'description' => 'Calculated md5 hash of the feed data, used for validating cache.',
167
      ),
168
169
170
171
172
      'etag' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
173
        'description' => 'Entity tag HTTP response header, used for validating cache.',
174
175
176
177
178
      ),
      'modified' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
179
        'description' => 'When the feed was last modified, as a Unix timestamp.',
180
181
182
183
184
185
      ),
      'block' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
186
        'description' => "Number of items to display in the feed's block.",
187
      )
188
    ),
189
    'primary key' => array('fid'),
190
191
    'unique keys' => array(
      'url'  => array('url'),
192
      'title' => array('title'),
193
194
195
196
    ),
  );

  $schema['aggregator_item'] = array(
197
    'description' => 'Stores the individual items imported from feeds.',
198
    'fields' => array(
199
200
201
      'iid'  => array(
        'type' => 'serial',
        'not null' => TRUE,
202
        'description' => 'Primary Key: Unique ID for feed item.',
203
204
205
206
207
      ),
      'fid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
208
        'description' => 'The {aggregator_feed}.fid to which this item belongs.',
209
210
211
212
213
214
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
215
        'description' => 'Title of the feed item.',
216
217
218
219
220
221
      ),
      'link' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
222
        'description' => 'Link to the feed item.',
223
224
225
226
227
228
      ),
      'author' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
229
        'description' => 'Author of the feed item.',
230
231
232
233
234
      ),
      'description' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
235
        'description' => 'Body of the feed item.',
236
237
238
239
      ),
      'timestamp' => array(
        'type' => 'int',
        'not null' => FALSE,
240
        'description' => 'Posted date of the feed item, as a Unix timestamp.',
241
242
243
244
245
      ),
      'guid' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
246
        'description' => 'Unique identifier for the feed item.',
247
      )
248
249
    ),
    'primary key' => array('iid'),
250
251
252
    'indexes' => array(
      'fid' => array('fid'),
    ),
253
254
255
256
  );

  return $schema;
}
257
258
259
260
261
262
263
264
265

/**
 * Add hash column to aggregator_feed table.
 */
function aggregator_update_7000() {
  $ret = array();
  db_add_field($ret, 'aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''));
  return $ret;
}