aggregator.install 6.76 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
59
60
61
62
    ),
    'primary key' => array('cid'),
    'unique keys' => array('title' => array('title')),
  );

  $schema['aggregator_category_feed'] = array(
63
    'description' => t('Bridge table; maps feeds to categories.'),
64
    'fields' => array(
65
66
67
68
69
70
71
72
73
74
75
76
      '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.'),
     )
77
78
79
80
81
    ),
    'primary key' => array('fid', 'cid'),
  );

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

  $schema['aggregator_feed'] = array(
101
    'description' => t('Stores feeds to be parsed by the aggregator.'),
102
    'fields' => array(
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
      '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.'),
      ),
      '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."),
      )
173
174
175
176
177
178
179
180
181
    ),
    'unique keys' => array(
      'url'  => array('url'),
      'title' => array('title')
    ),
    'primary key' => array('fid'),
  );

  $schema['aggregator_item'] = array(
182
    'description' => t('Stores the individual items imported from feeds.'),
183
    'fields' => array(
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
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
      '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,
        'description' => t('Post date of feed item, as a Unix timestamp.'),
      ),
      'guid' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'description' => t('Unique identifier for the feed item.'),
      )
233
234
235
236
237
238
239
    ),
    'indexes' => array('fid' => array('fid')),
    'primary key' => array('iid'),
  );

  return $schema;
}