nodequeue.views.inc 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <?php
  2. /**
  3. * @file nodequeue.views.inc
  4. * Provides support for the Views module.
  5. *
  6. * This implementation is almost entirely based around a relationship
  7. * which is stapled to the 'node' table via hook_views_data_alter.
  8. *
  9. * The relationship allows you to define 0 or more queues that join the
  10. * queue tables, limiting the join to just the queues selected. Once
  11. * the queues are joined in, the queue fields will show up, and they
  12. * have the usual array of arguments, sorts, fields and filters; since
  13. * the real legwork is done by the relationship, most of these are
  14. * really quite simple.
  15. */
  16. /**
  17. * Implements hook_views_data().
  18. */
  19. function nodequeue_views_data() {
  20. $data = array();
  21. // ----------------------------------------------------------------
  22. // nodequeue_nodes table
  23. $data['nodequeue_nodes']['table']['group'] = t('Nodequeue');
  24. // The nodequeue_nodes table is how nodequeue connects to the
  25. // rest of the world, but we will only join it in via relationship.
  26. // position
  27. $data['nodequeue_nodes']['position'] = array(
  28. 'title' => t('Position'),
  29. 'help' => t('The position of the node within a queue.'),
  30. 'field' => array(
  31. 'handler' => 'views_handler_field_numeric',
  32. 'click sortable' => TRUE,
  33. ),
  34. 'sort' => array(
  35. 'handler' => 'views_handler_sort',
  36. ),
  37. 'filter' => array(
  38. 'handler' => 'views_handler_filter_numeric',
  39. ),
  40. 'argument' => array(
  41. 'handler' => 'views_handler_argument_numeric',
  42. ),
  43. );
  44. // timestamp
  45. $data['nodequeue_nodes']['timestamp'] = array(
  46. 'title' => t('Added date'),
  47. 'help' => t('The date the node was added to a queue.'),
  48. 'field' => array(
  49. 'handler' => 'views_handler_field_date',
  50. 'click sortable' => TRUE,
  51. ),
  52. 'sort' => array(
  53. 'handler' => 'views_handler_sort_date',
  54. ),
  55. 'filter' => array(
  56. 'handler' => 'views_handler_filter_date',
  57. ),
  58. );
  59. $data['nodequeue_nodes']['qid'] = array(
  60. 'title' => t('Queue ID'),
  61. 'help' => t('The ID of the queue the node belongs to.'),
  62. 'field' => array(
  63. 'handler' => 'views_handler_field_numeric',
  64. 'click sortable' => TRUE,
  65. ),
  66. 'sort' => array(
  67. 'handler' => 'views_handler_sort',
  68. ),
  69. 'argument' => array(
  70. 'handler' => 'views_handler_argument_numeric',
  71. 'name field' => 'title',
  72. 'name table' => 'nodequeue_queue',
  73. 'empty field name' => t('No queue'),
  74. ),
  75. );
  76. $data['nodequeue_nodes']['sqid'] = array(
  77. 'title' => t('Subqueue ID'),
  78. 'help' => t('The ID of the subqueue the node belongs to.'),
  79. 'field' => array(
  80. 'handler' => 'views_handler_field_numeric',
  81. 'click sortable' => TRUE,
  82. ),
  83. 'sort' => array(
  84. 'handler' => 'views_handler_sort',
  85. ),
  86. 'argument' => array(
  87. 'handler' => 'views_handler_argument_numeric',
  88. 'name field' => 'title',
  89. 'name table' => 'nodequeue_subqueue',
  90. 'empty field name' => t('No queue'),
  91. ),
  92. );
  93. // specialized is null/is not null filter
  94. $data['nodequeue_nodes']['in_queue'] = array(
  95. 'title' => t('In queue'),
  96. 'help' => t('Filter to ensure a node IS or IS NOT in the related queue'),
  97. 'filter' => array(
  98. 'handler' => 'nodequeue_handler_filter_in_queue',
  99. 'label' => t('In queue'),
  100. ),
  101. );
  102. $data['nodequeue_queue']['name'] = array(
  103. 'title' => t('Queue machine name'),
  104. 'help' => t('The machine name of the queue.'),
  105. 'field' => array(
  106. 'handler' => 'views_handler_field',
  107. 'click sortable' => TRUE,
  108. ),
  109. 'sort' => array(
  110. 'handler' => 'views_handler_sort',
  111. ),
  112. 'filter' => array(
  113. 'handler' => 'views_handler_filter_string',
  114. ),
  115. 'argument' => array(
  116. 'handler' => 'views_handler_argument_string',
  117. ),
  118. );
  119. // ----------------------------------------------------------------
  120. // nodequeue_queue table
  121. $data['nodequeue_queue']['table']['group'] = t('Nodequeue');
  122. // For use with the relationship.
  123. $data['nodequeue_queue']['table']['join'] = array(
  124. 'nodequeue_nodes' => array(
  125. 'left_field' => 'qid',
  126. 'field' => 'qid',
  127. ),
  128. );
  129. $data['nodequeue_queue']['title'] = array(
  130. 'title' => t('Queue title'),
  131. 'help' => t('The title of the nodequeue.'),
  132. 'field' => array(
  133. 'handler' => 'views_handler_field',
  134. 'click sortable' => TRUE,
  135. ),
  136. 'sort' => array(
  137. 'handler' => 'views_handler_sort',
  138. ),
  139. 'filter' => array(
  140. 'handler' => 'views_handler_filter_string',
  141. ),
  142. 'argument' => array(
  143. 'handler' => 'views_handler_argument_string',
  144. ),
  145. );
  146. // ----------------------------------------------------------------
  147. // nodequeue_subqueue table
  148. $data['nodequeue_subqueue']['table']['group'] = t('Nodequeue');
  149. // For use with the relationship.
  150. $data['nodequeue_subqueue']['table']['join'] = array(
  151. 'nodequeue_nodes' => array(
  152. 'left_field' => 'sqid',
  153. 'field' => 'sqid',
  154. ),
  155. );
  156. $data['nodequeue_subqueue']['title'] = array(
  157. 'title' => t('Subqueue title'),
  158. 'help' => t('The title of the subqueue.'),
  159. 'field' => array(
  160. 'handler' => 'views_handler_field',
  161. 'click sortable' => TRUE,
  162. ),
  163. 'sort' => array(
  164. 'handler' => 'views_handler_sort',
  165. ),
  166. 'filter' => array(
  167. 'handler' => 'views_handler_filter_string',
  168. ),
  169. 'argument' => array(
  170. 'handler' => 'views_handler_argument_string',
  171. ),
  172. );
  173. $data['nodequeue_subqueue']['reference'] = array(
  174. 'title' => t('Subqueue reference'),
  175. 'help' => t('The reference that defines a subqueue; what this actually is depends upon the type of subqueue, but is a taxonomy tid for smartqueue taxonomy, or a uid for authorview.'),
  176. 'field' => array(
  177. 'handler' => 'views_handler_field',
  178. 'click sortable' => TRUE,
  179. ),
  180. 'sort' => array(
  181. 'handler' => 'views_handler_sort',
  182. ),
  183. 'filter' => array(
  184. 'handler' => 'views_handler_filter_string',
  185. ),
  186. 'argument' => array(
  187. 'handler' => 'views_handler_argument_string',
  188. ),
  189. );
  190. return $data;
  191. }
  192. /**
  193. * Implements hook_views_data_alter().
  194. */
  195. function nodequeue_views_data_alter(&$data) {
  196. // queue relationship
  197. $data['node']['nodequeue_rel'] = array(
  198. 'group' => t('Nodequeue'),
  199. 'title' => t('Queue'),
  200. 'help' => t('Create a relationship to a nodequeue.'),
  201. 'real field' => 'nid',
  202. 'relationship' => array(
  203. 'handler' => 'nodequeue_handler_relationship_nodequeue',
  204. 'base' => 'nodequeue_nodes',
  205. 'field' => 'nid',
  206. 'label' => t('queue'),
  207. ),
  208. );
  209. // links
  210. $data['node']['nodequeue_links'] = array(
  211. 'group' => t('Nodequeue'),
  212. 'title' => t('Add/remove links'),
  213. 'help' => t('Display add/remove links for all eligible nodequeues. Note that this performs a node_load so could add many extra queries to a view.'),
  214. 'real field' => 'nid',
  215. 'field' => array(
  216. 'handler' => 'nodequeue_handler_field_links',
  217. ),
  218. );
  219. $data['node']['nodequeue_queue_tab'] = array(
  220. 'group' => t('Nodequeue'),
  221. 'title' => t('Link to tab'),
  222. 'help' => t('Display add/remove links for all eligible nodequeues. Note that this performs a node_load so could add many extra queries to a view.'),
  223. 'real field' => 'nid',
  224. 'field' => array(
  225. 'handler' => 'nodequeue_handler_field_queue_tab',
  226. ),
  227. );
  228. // all queues
  229. $data['node']['nodequeue_all_queues'] = array(
  230. 'group' => t('Nodequeue'),
  231. 'title' => t('All queues'),
  232. 'help' => t('Display all queues a node is a member of.'),
  233. 'real field' => 'nid',
  234. 'field' => array(
  235. 'handler' => 'nodequeue_handler_field_all_queues',
  236. ),
  237. );
  238. // all subqueues
  239. $data['node']['nodequeue_all_subqueues'] = array(
  240. 'group' => t('Nodequeue'),
  241. 'title' => t('All subqueues'),
  242. 'help' => t('Display all subqueues a node is a member of.'),
  243. 'real field' => 'nid',
  244. 'field' => array(
  245. 'handler' => 'nodequeue_handler_field_all_subqueues',
  246. ),
  247. );
  248. }