1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Implementation of hook_install(). |
---|
5 | */ |
---|
6 | function aggregator_install() { |
---|
7 | // Create tables. |
---|
8 | drupal_install_schema('aggregator'); |
---|
9 | } |
---|
10 | |
---|
11 | /** |
---|
12 | * Implementation of hook_uninstall(). |
---|
13 | */ |
---|
14 | function aggregator_uninstall() { |
---|
15 | // Remove tables. |
---|
16 | drupal_uninstall_schema('aggregator'); |
---|
17 | |
---|
18 | variable_del('aggregator_allowed_html_tags'); |
---|
19 | variable_del('aggregator_summary_items'); |
---|
20 | variable_del('aggregator_clear'); |
---|
21 | variable_del('aggregator_category_selector'); |
---|
22 | } |
---|
23 | |
---|
24 | /** |
---|
25 | * Implementation of hook_schema(). |
---|
26 | */ |
---|
27 | function aggregator_schema() { |
---|
28 | $schema['aggregator_category'] = array( |
---|
29 | 'description' => 'Stores categories for aggregator feeds and feed items.', |
---|
30 | 'fields' => array( |
---|
31 | 'cid' => array( |
---|
32 | 'type' => 'serial', |
---|
33 | 'not null' => TRUE, |
---|
34 | 'description' => 'Primary Key: Unique aggregator category ID.', |
---|
35 | ), |
---|
36 | 'title' => array( |
---|
37 | 'type' => 'varchar', |
---|
38 | 'length' => 255, |
---|
39 | 'not null' => TRUE, |
---|
40 | 'default' => '', |
---|
41 | 'description' => 'Title of the category.', |
---|
42 | ), |
---|
43 | 'description' => array( |
---|
44 | 'type' => 'text', |
---|
45 | 'not null' => TRUE, |
---|
46 | 'size' => 'big', |
---|
47 | 'description' => 'Description of the category', |
---|
48 | ), |
---|
49 | 'block' => array( |
---|
50 | 'type' => 'int', |
---|
51 | 'not null' => TRUE, |
---|
52 | 'default' => 0, |
---|
53 | 'size' => 'tiny', |
---|
54 | 'description' => 'The number of recent items to show within the category block.', |
---|
55 | ) |
---|
56 | ), |
---|
57 | 'primary key' => array('cid'), |
---|
58 | 'unique keys' => array('title' => array('title')), |
---|
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('fid' => array('fid')), |
---|
79 | ); |
---|
80 | |
---|
81 | $schema['aggregator_category_item'] = array( |
---|
82 | 'description' => 'Bridge table; maps feed items to categories.', |
---|
83 | 'fields' => array( |
---|
84 | 'iid' => array( |
---|
85 | 'type' => 'int', |
---|
86 | 'not null' => TRUE, |
---|
87 | 'default' => 0, |
---|
88 | 'description' => "The feed item's {aggregator_item}.iid.", |
---|
89 | ), |
---|
90 | 'cid' => array( |
---|
91 | 'type' => 'int', |
---|
92 | 'not null' => TRUE, |
---|
93 | 'default' => 0, |
---|
94 | 'description' => 'The {aggregator_category}.cid to which the feed item is being assigned.', |
---|
95 | ) |
---|
96 | ), |
---|
97 | 'primary key' => array('cid', 'iid'), |
---|
98 | 'indexes' => array('iid' => array('iid')), |
---|
99 | ); |
---|
100 | |
---|
101 | $schema['aggregator_feed'] = array( |
---|
102 | 'description' => 'Stores feeds to be parsed by the aggregator.', |
---|
103 | 'fields' => array( |
---|
104 | 'fid' => array( |
---|
105 | 'type' => 'serial', |
---|
106 | 'not null' => TRUE, |
---|
107 | 'description' => 'Primary Key: Unique feed ID.', |
---|
108 | ), |
---|
109 | 'title' => array( |
---|
110 | 'type' => 'varchar', |
---|
111 | 'length' => 255, |
---|
112 | 'not null' => TRUE, |
---|
113 | 'default' => '', |
---|
114 | 'description' => 'Title of the feed.', |
---|
115 | ), |
---|
116 | 'url' => array( |
---|
117 | 'type' => 'varchar', |
---|
118 | 'length' => 255, |
---|
119 | 'not null' => TRUE, |
---|
120 | 'default' => '', |
---|
121 | 'description' => 'URL to the feed.', |
---|
122 | ), |
---|
123 | 'refresh' => array( |
---|
124 | 'type' => 'int', |
---|
125 | 'not null' => TRUE, |
---|
126 | 'default' => 0, |
---|
127 | 'description' => 'How often to check for new feed items, in seconds.', |
---|
128 | ), |
---|
129 | 'checked' => array( |
---|
130 | 'type' => 'int', |
---|
131 | 'not null' => TRUE, |
---|
132 | 'default' => 0, |
---|
133 | 'description' => 'Last time feed was checked for new items, as Unix timestamp.', |
---|
134 | ), |
---|
135 | 'link' => array( |
---|
136 | 'type' => 'varchar', |
---|
137 | 'length' => 255, |
---|
138 | 'not null' => TRUE, |
---|
139 | 'default' => '', |
---|
140 | 'description' => 'The parent website of the feed; comes from the <link> element in the feed.', |
---|
141 | ), |
---|
142 | 'description' => array( |
---|
143 | 'type' => 'text', |
---|
144 | 'not null' => TRUE, |
---|
145 | 'size' => 'big', |
---|
146 | 'description' => "The parent website's description; comes from the <description> element in the feed.", |
---|
147 | ), |
---|
148 | 'image' => array( |
---|
149 | 'type' => 'text', |
---|
150 | 'not null' => TRUE, |
---|
151 | 'size' => 'big', |
---|
152 | 'description' => 'An image representing the feed.', |
---|
153 | ), |
---|
154 | 'etag' => array( |
---|
155 | 'type' => 'varchar', |
---|
156 | 'length' => 255, |
---|
157 | 'not null' => TRUE, |
---|
158 | 'default' => '', |
---|
159 | 'description' => 'Entity tag HTTP response header, used for validating cache.', |
---|
160 | ), |
---|
161 | 'modified' => array( |
---|
162 | 'type' => 'int', |
---|
163 | 'not null' => TRUE, |
---|
164 | 'default' => 0, |
---|
165 | 'description' => 'When the feed was last modified, as a Unix timestamp.', |
---|
166 | ), |
---|
167 | 'block' => array( |
---|
168 | 'type' => 'int', |
---|
169 | 'not null' => TRUE, |
---|
170 | 'default' => 0, |
---|
171 | 'size' => 'tiny', |
---|
172 | 'description' => "Number of items to display in the feed's block.", |
---|
173 | ) |
---|
174 | ), |
---|
175 | 'primary key' => array('fid'), |
---|
176 | 'unique keys' => array( |
---|
177 | 'url' => array('url'), |
---|
178 | 'title' => array('title'), |
---|
179 | ), |
---|
180 | ); |
---|
181 | |
---|
182 | $schema['aggregator_item'] = array( |
---|
183 | 'description' => 'Stores the individual items imported from feeds.', |
---|
184 | 'fields' => array( |
---|
185 | 'iid' => array( |
---|
186 | 'type' => 'serial', |
---|
187 | 'not null' => TRUE, |
---|
188 | 'description' => 'Primary Key: Unique ID for feed item.', |
---|
189 | ), |
---|
190 | 'fid' => array( |
---|
191 | 'type' => 'int', |
---|
192 | 'not null' => TRUE, |
---|
193 | 'default' => 0, |
---|
194 | 'description' => 'The {aggregator_feed}.fid to which this item belongs.', |
---|
195 | ), |
---|
196 | 'title' => array( |
---|
197 | 'type' => 'varchar', |
---|
198 | 'length' => 255, |
---|
199 | 'not null' => TRUE, |
---|
200 | 'default' => '', |
---|
201 | 'description' => 'Title of the feed item.', |
---|
202 | ), |
---|
203 | 'link' => array( |
---|
204 | 'type' => 'varchar', |
---|
205 | 'length' => 255, |
---|
206 | 'not null' => TRUE, |
---|
207 | 'default' => '', |
---|
208 | 'description' => 'Link to the feed item.', |
---|
209 | ), |
---|
210 | 'author' => array( |
---|
211 | 'type' => 'varchar', |
---|
212 | 'length' => 255, |
---|
213 | 'not null' => TRUE, |
---|
214 | 'default' => '', |
---|
215 | 'description' => 'Author of the feed item.', |
---|
216 | ), |
---|
217 | 'description' => array( |
---|
218 | 'type' => 'text', |
---|
219 | 'not null' => TRUE, |
---|
220 | 'size' => 'big', |
---|
221 | 'description' => 'Body of the feed item.', |
---|
222 | ), |
---|
223 | 'timestamp' => array( |
---|
224 | 'type' => 'int', |
---|
225 | 'not null' => FALSE, |
---|
226 | 'description' => 'Post date of feed item, as a Unix timestamp.', |
---|
227 | ), |
---|
228 | 'guid' => array( |
---|
229 | 'type' => 'varchar', |
---|
230 | 'length' => 255, |
---|
231 | 'not null' => FALSE, |
---|
232 | 'description' => 'Unique identifier for the feed item.', |
---|
233 | ) |
---|
234 | ), |
---|
235 | 'primary key' => array('iid'), |
---|
236 | 'indexes' => array('fid' => array('fid')), |
---|
237 | ); |
---|
238 | |
---|
239 | return $schema; |
---|
240 | } |
---|