aggregator.install 7.38 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' => t('Stores categories for aggregator feeds and feed items.'),
31
    'fields' => array(
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
      'cid'  => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique aggregator category ID.'),
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t('Title of the category.'),
      ),
      'description' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Description of the category'),
      ),
      'block' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => t('The number of recent items to show within the category block.'),
      )
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' => t('Bridge table; maps feeds to categories.'),
66
    'fields' => array(
67
68
69
70
71
72
73
74
75
76
77
      'fid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t("The feed's {aggregator_feed}.fid."),
      ),
      'cid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('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' => t('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' => t("The feed item's {aggregator_item}.iid."),
94
95
96
97
98
99
100
      ),
      'cid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The {aggregator_category}.cid to which the feed item is being assigned.'),
      )
101
    ),
102
    'primary key' => array('cid', 'iid'),
103
104
105
    'indexes' => array(
      'iid' => array('iid'),
    ),
106
107
108
  );

  $schema['aggregator_feed'] = array(
109
    'description' => t('Stores feeds to be parsed by the aggregator.'),
110
    'fields' => array(
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
      'fid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique feed ID.'),
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t('Title of the feed.'),
      ),
      'url' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t('URL to the feed.'),
      ),
      'refresh' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('How often to check for new feed items, in seconds.'),
      ),
      'checked' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('Last time feed was checked for new items, as Unix timestamp.'),
      ),
      'link' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t('The parent website of the feed; comes from the <link> element in the feed.'),
      ),
      'description' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t("The parent website's description; comes from the <description> element in the feed."),
      ),
      'image' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('An image representing the feed.'),
      ),
161
162
163
164
165
166
167
      'hash' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => t('Calculated md5 hash of the feed data, used for validating cache.'),
      ),
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
      'etag' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t('Entity tag HTTP response header, used for validating cache.'),
      ),
      'modified' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('When the feed was last modified, as a Unix timestamp.'),
      ),
      'block' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => t("Number of items to display in the feed's block."),
      )
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' => t('Stores the individual items imported from feeds.'),
198
    'fields' => array(
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
      'iid'  => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique ID for feed item.'),
      ),
      'fid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The {aggregator_feed}.fid to which this item belongs.'),
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t('Title of the feed item.'),
      ),
      'link' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t('Link to the feed item.'),
      ),
      'author' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => t('Author of the feed item.'),
      ),
      'description' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Body of the feed item.'),
      ),
      'timestamp' => array(
        'type' => 'int',
        'not null' => FALSE,
240
        'description' => t('Posted date of the feed item, as a Unix timestamp.'),
241
242
243
244
245
246
247
      ),
      'guid' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => t('Unique identifier for the feed item.'),
      )
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;
}