redirect.views.inc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <?php
  2. /**
  3. * @file
  4. * Views integration and data for the redirect module.
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. */
  9. function redirect_views_data() {
  10. // Basic table information.
  11. $data['redirect']['table']['group'] = t('Redirect');
  12. // Advertise this table as a possible base table
  13. $data['redirect']['table']['base'] = array(
  14. 'field' => 'rid',
  15. 'title' => t('URL redirects'),
  16. 'help' => t('Listings of URL redirects.'),
  17. 'weight' => 10,
  18. );
  19. // {redirect}.rid
  20. $data['redirect']['rid'] = array(
  21. 'title' => t('Redirect ID'),
  22. 'help' => t('The internal ID of the redirect.'),
  23. 'field' => array(
  24. 'handler' => 'views_handler_field',
  25. 'click sortable' => TRUE,
  26. ),
  27. 'filter' => array(
  28. 'handler' => 'views_handler_filter_numeric',
  29. 'allow empty' => TRUE,
  30. ),
  31. 'sort' => array(
  32. 'handler' => 'views_handler_sort',
  33. ),
  34. 'argument' => array(
  35. 'handler' => 'views_handler_argument_numeric',
  36. ),
  37. );
  38. // {redirect}.type
  39. $data['redirect']['type'] = array(
  40. 'title' => t('Type'),
  41. 'help' => t('The type of redirect.'),
  42. 'field' => array(
  43. 'handler' => 'views_handler_field',
  44. 'click sortable' => TRUE,
  45. ),
  46. 'sort' => array(
  47. 'handler' => 'views_handler_sort',
  48. ),
  49. 'filter' => array(
  50. 'handler' => 'redirect_handler_filter_redirect_type',
  51. ),
  52. 'argument' => array(
  53. 'handler' => 'views_handler_argument_string',
  54. ),
  55. );
  56. // {redirect}.uid
  57. $data['users']['table']['join']['redirect'] = array(
  58. 'left_field' => 'uid',
  59. 'field' => 'uid',
  60. );
  61. $data['redirect']['uid'] = array(
  62. 'title' => t('User ID'),
  63. 'help' => t('ID of user who created the URL redirect.'),
  64. 'field' => array(
  65. 'handler' => 'views_handler_field_user',
  66. 'click sortable' => TRUE,
  67. ),
  68. 'argument' => array(
  69. 'handler' => 'views_handler_argument_user_uid',
  70. 'name field' => 'name',
  71. ),
  72. 'filter' => array(
  73. 'title' => t('Name'),
  74. 'handler' => 'views_handler_filter_user_name',
  75. ),
  76. 'sort' => array(
  77. 'handler' => 'views_handler_sort',
  78. ),
  79. 'relationship' => array(
  80. 'handler' => 'views_handler_relationship',
  81. 'base' => 'users',
  82. 'base field' => 'uid',
  83. 'label' => t('user'),
  84. ),
  85. );
  86. $data['redirect']['uid_current'] = array(
  87. 'real field' => 'uid',
  88. 'title' => t('Current user'),
  89. 'help' => t('Filter the view to the currently logged in user.'),
  90. 'filter' => array(
  91. 'handler' => 'views_handler_filter_user_current',
  92. 'type' => 'yes-no',
  93. ),
  94. );
  95. // {redirect}.source
  96. $data['redirect']['source'] = array(
  97. 'title' => t('Source URL'),
  98. 'help' => t('The source URL which generates a redirect'),
  99. 'field' => array(
  100. 'handler' => 'redirect_handler_field_redirect_source',
  101. 'click sortable' => TRUE,
  102. ),
  103. 'filter' => array(
  104. 'handler' => 'views_handler_filter_string',
  105. ),
  106. 'sort' => array(
  107. 'handler' => 'views_handler_sort',
  108. ),
  109. 'argument' => array(
  110. 'handler' => 'views_handler_argument_string',
  111. ),
  112. );
  113. // {redirect}.redirect
  114. $data['redirect']['redirect'] = array(
  115. 'title' => t('Redirect URL'),
  116. 'help' => t('The destination URL'),
  117. 'field' => array(
  118. 'handler' => 'redirect_handler_field_redirect_redirect',
  119. 'click sortable' => TRUE,
  120. ),
  121. 'filter' => array(
  122. 'handler' => 'views_handler_filter_string',
  123. ),
  124. 'sort' => array(
  125. 'handler' => 'views_handler_sort',
  126. ),
  127. 'argument' => array(
  128. 'handler' => 'views_handler_argument_string',
  129. ),
  130. );
  131. // Language field
  132. if (module_exists('locale')) {
  133. $data['redirect']['language'] = array(
  134. 'title' => t('Language'),
  135. 'help' => t('The language the redirect is for.'),
  136. 'field' => array(
  137. 'handler' => 'views_handler_field_locale_language',
  138. 'click sortable' => TRUE,
  139. ),
  140. 'filter' => array(
  141. 'handler' => 'views_handler_filter_locale_language',
  142. ),
  143. 'argument' => array(
  144. 'handler' => 'views_handler_argument_locale_language',
  145. ),
  146. );
  147. }
  148. // {redirect}.count
  149. $data['redirect']['count'] = array(
  150. 'title' => t('Clicks'),
  151. 'help' => t('Number of times this URL redirect has been followed.'),
  152. 'field' => array(
  153. 'handler' => 'views_handler_field',
  154. 'click sortable' => TRUE,
  155. ),
  156. 'filter' => array(
  157. 'handler' => 'views_handler_filter_numeric',
  158. 'allow empty' => TRUE,
  159. ),
  160. 'sort' => array(
  161. 'handler' => 'views_handler_sort',
  162. ),
  163. 'argument' => array(
  164. 'handler' => 'views_handler_argument_numeric',
  165. ),
  166. );
  167. // {redirect}.access
  168. $data['redirect']['access'] = array(
  169. 'title' => t('Last accessed date'),
  170. 'help' => t('The date/time the URL redirect was last accessed.'),
  171. 'field' => array(
  172. 'handler' => 'views_handler_field_date',
  173. 'click sortable' => TRUE,
  174. ),
  175. 'sort' => array(
  176. 'handler' => 'views_handler_sort',
  177. ),
  178. 'filter' => array(
  179. 'handler' => 'views_handler_filter_date',
  180. ),
  181. );
  182. $data['redirect']['operations'] = array(
  183. 'field' => array(
  184. 'title' => t('Operations'),
  185. 'help' => t('Provide links to operations the user can perform for the URL redirect.'),
  186. 'handler' => 'redirect_handler_field_redirect_operations',
  187. ),
  188. );
  189. $data['redirect']['edit_redirect'] = array(
  190. 'field' => array(
  191. 'title' => t('Edit link'),
  192. 'help' => t('Provide a simple link to edit the URL redirect.'),
  193. 'handler' => 'redirect_handler_field_redirect_link_edit',
  194. ),
  195. );
  196. $data['redirect']['delete_redirect'] = array(
  197. 'field' => array(
  198. 'title' => t('Delete link'),
  199. 'help' => t('Provide a simple link to delete the URL redirect.'),
  200. 'handler' => 'redirect_handler_field_redirect_link_delete',
  201. ),
  202. );
  203. return $data;
  204. }