/[drupal]/contributions/modules/views/modules/aggregator.views.inc
ViewVC logotype

Contents of /contributions/modules/views/modules/aggregator.views.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Tue Jun 2 19:46:06 2009 UTC (5 months, 3 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, DRUPAL-6--2-6, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-7--3
Changes since 1.2: +73 -2 lines
File MIME type: text/x-php
#436398 by Pasqualle: Support for aggregator category table.
1 <?php
2 // $Id: aggregator.views.inc,v 1.2 2009/04/07 23:07:31 merlinofchaos Exp $
3 /**
4 * @file
5 * Provide views data and handlers for aggregator.module
6 */
7
8 /**
9 * @defgroup views_aggregator_module aggregator.module handlers
10 *
11 * Includes the core 'aggregator_feed,' 'aggregator_category,' and 'aggregator_item'
12 * tables.
13 *
14 * @{
15 */
16
17 /**
18 * Implementation of hook_views_data()
19 */
20 function aggregator_views_data() {
21 // ----------------------------------------------------------------------
22 // Main Aggregator Item base table
23
24 // Define the base group of this table. Fields that don't
25 // have a group defined will go into this field by default.
26 $data['aggregator_item']['table']['group'] = t('Aggregator');
27
28 // Advertise this table as a possible base table
29 $data['aggregator_item']['table']['base'] = array(
30 'field' => 'iid',
31 'title' => t('Aggregator item'),
32 'help' => t("Aggregator items are imported from external RSS and Atom news feeds."),
33 );
34
35 // ----------------------------------------------------------------
36 // Fields
37
38 // title
39 $data['aggregator_item']['title'] = array(
40 'title' => t('Title'), // The item it appears as on the UI,
41 'help' => t('The title of the aggregator item.'),
42 // Information for displaying a title as a field
43 'field' => array(
44 'handler' => 'views_handler_field_aggregator_title_link',
45 'extra' => array('link'),
46 'click sortable' => TRUE,
47 ),
48 'sort' => array(
49 'handler' => 'views_handler_sort',
50 ),
51 // Information for accepting a title as a filter
52 'filter' => array(
53 'handler' => 'views_handler_filter_string',
54 ),
55 );
56
57 // link
58 $data['aggregator_item']['link'] = array(
59 'title' => t('Link'), // The item it appears as on the UI,
60 'help' => t('The link to the original source URL of the item.'),
61 'field' => array(
62 'handler' => 'views_handler_field_url',
63 'click sortable' => TRUE,
64 ),
65 'sort' => array(
66 'handler' => 'views_handler_sort',
67 ),
68 // Information for accepting a title as a filter
69 'filter' => array(
70 'handler' => 'views_handler_filter_string',
71 ),
72 );
73
74 // author
75 $data['aggregator_item']['author'] = array(
76 'title' => t('Author'), // The item it appears as on the UI,
77 'help' => t('The author of the original imported item.'),
78 // Information for displaying a title as a field
79 'field' => array(
80 'handler' => 'views_handler_field_xss',
81 'click sortable' => TRUE,
82 ),
83 'sort' => array(
84 'handler' => 'views_handler_sort',
85 ),
86 // Information for accepting a title as a filter
87 'filter' => array(
88 'handler' => 'views_handler_filter_string',
89 ),
90 'argument' => array(
91 'handler' => 'views_handler_argument_string',
92 ),
93 );
94
95 // feed body
96 $data['aggregator_item']['description'] = array(
97 'title' => t('Body'), // The item it appears as on the UI,
98 'help' => t('The actual content of the imported item.'),
99 // Information for displaying a title as a field
100 'field' => array(
101 'handler' => 'views_handler_field_xss',
102 'click sortable' => FALSE,
103 ),
104 // Information for accepting a title as a filter
105 'filter' => array(
106 'handler' => 'views_handler_filter_string',
107 ),
108 );
109
110 // item timestamp
111 $data['aggregator_item']['timestamp'] = array(
112 'title' => t('Timestamp'), // The item it appears as on the UI,
113 'help' => t('The date the original feed item was posted. (With some feeds, this will be the date it was imported.)'),
114 // Information for displaying a title as a field
115 'field' => array(
116 'handler' => 'views_handler_field_date',
117 'click sortable' => TRUE,
118 ),
119 'sort' => array(
120 'handler' => 'views_handler_sort_date',
121 ),
122 // Information for accepting a title as a filter
123 'filter' => array(
124 'handler' => 'views_handler_filter_date',
125 ),
126 'argument' => array(
127 'handler' => 'views_handler_argument_date',
128 ),
129 );
130
131
132 // ----------------------------------------------------------------------
133 // Aggregator feed table
134
135 $data['aggregator_feed']['table']['group'] = t('Aggregator feed');
136
137 // Explain how this table joins to others.
138 $data['aggregator_feed']['table']['join'] = array(
139 'aggregator_item' => array(
140 'left_field' => 'fid',
141 'field' => 'fid',
142 ),
143 );
144
145 // fid
146 $data['aggregator_feed']['fid'] = array(
147 'title' => t('Feed ID'),
148 'help' => t('The unique ID of the aggregator feed.'), // The help that appears on the UI,
149 // Information for displaying the fid
150 'field' => array(
151 'handler' => 'views_handler_field_numeric',
152 'click sortable' => TRUE,
153 ),
154 // Information for accepting a fid as an argument
155 'argument' => array(
156 'handler' => 'views_handler_argument_aggregator_fid',
157 'name field' => 'title', // the field to display in the summary.
158 'numeric' => TRUE,
159 ),
160 // Information for accepting a nid as a filter
161 'filter' => array(
162 'handler' => 'views_handler_filter_numeric',
163 ),
164 // Information for sorting on a nid.
165 'sort' => array(
166 'handler' => 'views_handler_sort',
167 ),
168 );
169
170 // title
171 $data['aggregator_feed']['title'] = array(
172 'title' => t('Title'), // The item it appears as on the UI,
173 'help' => t('The title of the aggregator feed.'),
174 // Information for displaying a title as a field
175 'field' => array(
176 'handler' => 'views_handler_field_aggregator_title_link',
177 'extra' => array('link'),
178 'click sortable' => TRUE,
179 ),
180 'sort' => array(
181 'handler' => 'views_handler_sort',
182 ),
183 // Information for accepting a title as a filter
184 'filter' => array(
185 'handler' => 'views_handler_filter_string',
186 ),
187 );
188
189 // link
190 $data['aggregator_feed']['link'] = array(
191 'title' => t('Link'), // The item it appears as on the UI,
192 'help' => t('The link to the source URL of the feed.'),
193 // Information for displaying a title as a field
194 'field' => array(
195 'handler' => 'views_handler_field_url',
196 'click sortable' => TRUE,
197 ),
198 'sort' => array(
199 'handler' => 'views_handler_sort',
200 ),
201 // Information for accepting a title as a filter
202 'filter' => array(
203 'handler' => 'views_handler_filter_string',
204 ),
205 );
206
207 // feed last updated
208 $data['aggregator_feed']['checked'] = array(
209 'title' => t('Last checked'), // The item it appears as on the UI,
210 'help' => t('The date the feed was last checked for new content.'),
211 // Information for displaying a title as a field
212 'field' => array(
213 'handler' => 'views_handler_field_date',
214 'click sortable' => TRUE,
215 ),
216 'sort' => array(
217 'handler' => 'views_handler_sort_date',
218 ),
219 // Information for accepting a title as a filter
220 'filter' => array(
221 'handler' => 'views_handler_filter_date',
222 ),
223 'argument' => array(
224 'handler' => 'views_handler_argument_date',
225 ),
226 );
227
228 // feed description
229 $data['aggregator_feed']['description'] = array(
230 'title' => t('Description'), // The item it appears as on the UI,
231 'help' => t('The description of the aggregator feed.'),
232 // Information for displaying a title as a field
233 'field' => array(
234 'handler' => 'views_handler_field_xss',
235 'click sortable' => FALSE,
236 ),
237 // Information for accepting a title as a filter
238 'filter' => array(
239 'handler' => 'views_handler_filter_string',
240 ),
241 );
242
243 // feed last updated
244 $data['aggregator_feed']['modified'] = array(
245 'title' => t('Last modified'), // The item it appears as on the UI,
246 'help' => t('The date of the most recent new content onf the feed.'),
247 // Information for displaying a title as a field
248 'field' => array(
249 'handler' => 'views_handler_field_date',
250 'click sortable' => TRUE,
251 ),
252 'sort' => array(
253 'handler' => 'views_handler_sort_date',
254 ),
255 // Information for accepting a title as a filter
256 'filter' => array(
257 'handler' => 'views_handler_filter_date',
258 ),
259 'argument' => array(
260 'handler' => 'views_handler_argument_date',
261 ),
262 );
263
264 // ----------------------------------------------------------------------
265 // Aggregator category feed table
266
267 $data['aggregator_category_feed']['table']['join'] = array(
268 'aggregator_item' => array(
269 'left_field' => 'fid',
270 'field' => 'fid',
271 ),
272 );
273
274 // ----------------------------------------------------------------------
275 // Aggregator category table
276
277 $data['aggregator_category']['table']['group'] = t('Aggregator category');
278
279 $data['aggregator_category']['table']['join'] = array(
280 'aggregator_item' => array(
281 'left_table' => 'aggregator_category_feed',
282 'left_field' => 'cid',
283 'field' => 'cid',
284 ),
285 );
286
287 // cid
288 $data['aggregator_category']['cid'] = array(
289 'title' => t('Category ID'),
290 'help' => t('The unique ID of the aggregator category.'),
291 'field' => array(
292 'handler' => 'views_handler_field_numeric',
293 'click sortable' => TRUE,
294 ),
295 'argument' => array(
296 'handler' => 'views_handler_argument_aggregator_category_cid',
297 'name field' => 'title',
298 'numeric' => TRUE,
299 ),
300 'filter' => array(
301 'handler' => 'views_handler_filter_aggregator_category_cid',
302 ),
303 'sort' => array(
304 'handler' => 'views_handler_sort',
305 ),
306 );
307
308 // title
309 $data['aggregator_category']['title'] = array(
310 'title' => t('Category'),
311 'help' => t('The title of the aggregator category.'),
312 'field' => array(
313 'handler' => 'views_handler_field_aggregator_category',
314 'click sortable' => TRUE,
315 ),
316 'sort' => array(
317 'handler' => 'views_handler_sort',
318 ),
319 'filter' => array(
320 'handler' => 'views_handler_filter_string',
321 ),
322 );
323
324 return $data;
325 }
326
327 /**
328 * Implementation of hook_views_handlers() to register all of the basic handlers
329 * views uses.
330 */
331 function aggregator_views_handlers() {
332 return array(
333 'info' => array(
334 'path' => drupal_get_path('module', 'views') . '/modules/aggregator',
335 ),
336 'handlers' => array(
337 // field handlers
338 'views_handler_field_aggregator_title_link' => array(
339 'parent' => 'views_handler_field',
340 ),
341 'views_handler_field_aggregator_category' => array(
342 'parent' => 'views_handler_field',
343 ),
344
345 // argument handlers
346 'views_handler_argument_aggregator_fid' => array(
347 'parent' => 'views_handler_argument_numeric',
348 ),
349 'views_handler_argument_aggregator_category_cid' => array(
350 'parent' => 'views_handler_argument_numeric',
351 ),
352
353 // filter handlers
354 'views_handler_filter_aggregator_category_cid' => array(
355 'parent' => 'views_handler_filter_in_operator',
356 ),
357 ),
358 );
359 }
360
361
362 /**
363 * Implementation of hook_views_plugins
364 */
365 function aggregator_views_plugins() {
366 return array(
367 'module' => 'views', // This just tells our themes are elsewhere.
368 'row' => array(
369 'aggregator_rss' => array(
370 'title' => t('Aggregator item'),
371 'help' => t('Display the aggregator item using the data from the original source.'),
372 'handler' => 'views_plugin_row_aggregator_rss',
373 'path' => drupal_get_path('module', 'views') . '/modules/aggregator', // not necessary for most modules
374 'theme' => 'views_view_row_rss',
375 'base' => array('aggregator_item'), // only works with 'node' as base.
376 'uses options' => TRUE,
377 'type' => 'feed',
378 'help topic' => 'style-aggregator-rss',
379 ),
380 ),
381 );
382 }
383 /**
384 * @}
385 */

  ViewVC Help
Powered by ViewVC 1.1.2