Projet

Général

Profil

Paste
Télécharger (9,4 ko) Statistiques
| Branche: | Révision:

root / htmltest / modules / aggregator / aggregator.install @ 85ad3d82

1
<?php
2

    
3
/**
4
 * @file
5
 * Install, update and uninstall functions for the aggregator module.
6
 */
7

    
8
/**
9
 * Implements hook_uninstall().
10
 */
11
function aggregator_uninstall() {
12
  variable_del('aggregator_allowed_html_tags');
13
  variable_del('aggregator_summary_items');
14
  variable_del('aggregator_clear');
15
  variable_del('aggregator_category_selector');
16
  variable_del('aggregator_fetcher');
17
  variable_del('aggregator_parser');
18
  variable_del('aggregator_processors');
19
  variable_del('aggregator_teaser_length');
20
}
21

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

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

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

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

    
210
  $schema['aggregator_item'] = array(
211
    'description' => 'Stores the individual items imported from feeds.',
212
    'fields' => array(
213
      'iid'  => array(
214
        'type' => 'serial',
215
        'not null' => TRUE,
216
        'description' => 'Primary Key: Unique ID for feed item.',
217
      ),
218
      'fid' => array(
219
        'type' => 'int',
220
        'not null' => TRUE,
221
        'default' => 0,
222
        'description' => 'The {aggregator_feed}.fid to which this item belongs.',
223
      ),
224
      'title' => array(
225
        'type' => 'varchar',
226
        'length' => 255,
227
        'not null' => TRUE,
228
        'default' => '',
229
        'description' => 'Title of the feed item.',
230
      ),
231
      'link' => array(
232
        'type' => 'text',
233
        'not null' => TRUE,
234
        'description' => 'Link to the feed item.',
235
      ),
236
      'author' => array(
237
        'type' => 'varchar',
238
        'length' => 255,
239
        'not null' => TRUE,
240
        'default' => '',
241
        'description' => 'Author of the feed item.',
242
      ),
243
      'description' => array(
244
        'type' => 'text',
245
        'not null' => TRUE,
246
        'size' => 'big',
247
        'description' => 'Body of the feed item.',
248
      ),
249
      'timestamp' => array(
250
        'type' => 'int',
251
        'not null' => FALSE,
252
        'description' => 'Posted date of the feed item, as a Unix timestamp.',
253
      ),
254
      'guid' => array(
255
        'type' => 'text',
256
        'not null' => TRUE,
257
        'description' => 'Unique identifier for the feed item.',
258
      )
259
    ),
260
    'primary key' => array('iid'),
261
    'indexes' => array(
262
      'fid' => array('fid'),
263
    ),
264
    'foreign keys' => array(
265
      'aggregator_feed' => array(
266
        'table' => 'aggregator_feed',
267
        'columns' => array('fid' => 'fid'),
268
      ),
269
    ),
270
  );
271

    
272
  return $schema;
273
}
274

    
275
/**
276
 * @addtogroup updates-6.x-to-7.x
277
 * @{
278
 */
279

    
280
/**
281
 * Add hash column to aggregator_feed table.
282
 */
283
function aggregator_update_7000() {
284
  db_add_field('aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
285
}
286

    
287
/**
288
 * Add aggregator teaser length to settings from old global default teaser length
289
 */
290
function aggregator_update_7001() {
291
  variable_set('aggregator_teaser_length', variable_get('teaser_length'));
292
}
293

    
294
/**
295
 * Add queued timestamp.
296
 */
297
function aggregator_update_7002() {
298
  db_add_field('aggregator_feed', 'queued', array(
299
    'type' => 'int',
300
    'not null' => TRUE,
301
    'default' => 0,
302
    'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
303
  ));
304
  db_add_index('aggregator_feed', 'queued', array('queued'));
305
}
306

    
307
/**
308
 * @} End of "addtogroup updates-6.x-to-7.x"
309
 */
310

    
311
/**
312
 * @addtogroup updates-7.x-extra
313
 * @{
314
 */
315

    
316
/**
317
 * Increase the length of {aggregator_feed}.url.
318
 */
319
function aggregator_update_7003() {
320
  db_drop_unique_key('aggregator_feed', 'url');
321
  db_change_field('aggregator_feed', 'url', 'url', array('type' => 'text', 'not null' => TRUE, 'description' => 'URL to the feed.'));
322
  db_change_field('aggregator_feed', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'The parent website of the feed; comes from the <link> element in the feed.'));
323
  db_change_field('aggregator_item', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'description' => 'Link to the feed item.'));
324
  db_change_field('aggregator_item', 'guid', 'guid', array('type' => 'text', 'not null' => TRUE, 'description' => 'Unique identifier for the feed item.'));
325
  db_add_index('aggregator_feed', 'url', array(array('url', 255)));
326
}
327

    
328
/**
329
 * @} End of "addtogroup updates-7.x-extra"
330
 */