aggregator.views.inc 12 KB

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