locale.views.inc

  1. 3.x modules/locale.views.inc
  2. 2.x modules/locale.views.inc

Provides views data and handlers for locale.module.

File

modules/locale.views.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provides views data and handlers for locale.module.
  5. *
  6. * @ingroup views_module_handlers
  7. */
  8. /**
  9. * Implements hook_views_data().
  10. */
  11. function locale_views_data() {
  12. // Basic table information.
  13. // Define the base group of this table.
  14. $data['locales_source']['table']['group'] = t('Locale source');
  15. // Advertise this table as a possible base table.
  16. $data['locales_source']['table']['base'] = array(
  17. 'field' => 'lid',
  18. 'title' => t('Locale source'),
  19. 'help' => t('A source string for translation, in English or the default site language.'),
  20. );
  21. // lid
  22. $data['locales_source']['lid'] = array(
  23. 'title' => t('LID'),
  24. 'help' => t('The ID of the source string.'),
  25. 'field' => array(
  26. 'handler' => 'views_handler_field',
  27. 'click sortable' => TRUE,
  28. ),
  29. 'argument' => array(
  30. 'handler' => 'views_handler_argument_numeric',
  31. 'numeric' => TRUE,
  32. 'validate type' => 'lid',
  33. ),
  34. 'filter' => array(
  35. 'handler' => 'views_handler_filter_numeric',
  36. ),
  37. 'sort' => array(
  38. 'handler' => 'views_handler_sort',
  39. ),
  40. );
  41. // location
  42. $data['locales_source']['location'] = array(
  43. 'group' => t('Locale source'),
  44. 'title' => t('Location'),
  45. 'help' => t('A description of the location or context of the string.'),
  46. 'field' => array(
  47. 'handler' => 'views_handler_field',
  48. 'click sortable' => TRUE,
  49. ),
  50. 'sort' => array(
  51. 'handler' => 'views_handler_sort',
  52. ),
  53. 'filter' => array(
  54. 'handler' => 'views_handler_filter_string',
  55. ),
  56. 'argument' => array(
  57. 'handler' => 'views_handler_argument_string',
  58. ),
  59. );
  60. // Group field
  61. $data['locales_source']['textgroup'] = array(
  62. 'group' => t('Locale source'),
  63. 'title' => t('Group'),
  64. 'help' => t('The group the translation is in.'),
  65. 'field' => array(
  66. 'handler' => 'views_handler_field_locale_group',
  67. 'click sortable' => TRUE,
  68. ),
  69. 'filter' => array(
  70. 'handler' => 'views_handler_filter_locale_group',
  71. ),
  72. 'argument' => array(
  73. 'handler' => 'views_handler_argument_locale_group',
  74. ),
  75. );
  76. // Source field
  77. $data['locales_source']['source'] = array(
  78. 'group' => t('Locale source'),
  79. 'title' => t('Source'),
  80. 'help' => t('The full original string.'),
  81. 'field' => array(
  82. 'handler' => 'views_handler_field',
  83. ),
  84. 'filter' => array(
  85. 'handler' => 'views_handler_filter_string',
  86. ),
  87. );
  88. // Version field
  89. $data['locales_source']['version'] = array(
  90. 'group' => t('Locale source'),
  91. 'title' => t('Version'),
  92. 'help' => t('The version of Drupal core that this string is for.'),
  93. 'field' => array(
  94. 'handler' => 'views_handler_field',
  95. 'click sortable' => TRUE,
  96. ),
  97. 'filter' => array(
  98. 'handler' => 'views_handler_filter_locale_version',
  99. ),
  100. 'argument' => array(
  101. 'handler' => 'views_handler_argument_string',
  102. ),
  103. );
  104. $data['locales_source']['edit_lid'] = array(
  105. 'group' => t('Locale source'),
  106. 'field' => array(
  107. 'title' => t('Edit link'),
  108. 'help' => t('Provide a simple link to edit the translations.'),
  109. 'handler' => 'views_handler_field_locale_link_edit',
  110. ),
  111. );
  112. // ----------------------------------------------------------------------
  113. // Locales target table
  114. // Define the base group of this table. Fields that don't
  115. // have a group defined will go into this field by default.
  116. $data['locales_target']['table']['group'] = t('Locale target');
  117. // Join information
  118. $data['locales_target']['table']['join'] = array(
  119. 'locales_source' => array(
  120. 'left_field' => 'lid',
  121. 'field' => 'lid',
  122. ),
  123. );
  124. // Translation field
  125. $data['locales_target']['translation'] = array(
  126. 'group' => t('Locale target'),
  127. 'title' => t('Translation'),
  128. 'help' => t('The full translation string.'),
  129. 'field' => array(
  130. 'handler' => 'views_handler_field',
  131. ),
  132. 'filter' => array(
  133. 'handler' => 'views_handler_filter_string',
  134. ),
  135. );
  136. // Language field
  137. $data['locales_target']['language'] = array(
  138. 'group' => t('Locale target'),
  139. 'title' => t('Language'),
  140. 'help' => t('The language this translation is in.'),
  141. 'field' => array(
  142. 'handler' => 'views_handler_field_locale_language',
  143. 'click sortable' => TRUE,
  144. ),
  145. 'filter' => array(
  146. 'handler' => 'views_handler_filter_locale_language',
  147. ),
  148. 'argument' => array(
  149. 'handler' => 'views_handler_argument_locale_language',
  150. ),
  151. );
  152. $data['locales_target']['plid'] = array(
  153. 'group' => t('Locale target'),
  154. 'title' => t('Singular LID'),
  155. 'help' => t('The ID of the parent translation.'),
  156. 'field' => array(
  157. 'handler' => 'views_handler_field',
  158. ),
  159. );
  160. // Plural
  161. $data['locales_target']['plural'] = array(
  162. 'group' => t('Locale target'),
  163. 'title' => t('Plural'),
  164. 'help' => t('Whether or not the translation is plural.'),
  165. 'field' => array(
  166. 'handler' => 'views_handler_field_boolean',
  167. 'click sortable' => TRUE,
  168. ),
  169. 'filter' => array(
  170. 'handler' => 'views_handler_filter_boolean_operator',
  171. 'label' => t('Plural'),
  172. 'type' => 'yes-no',
  173. ),
  174. 'sort' => array(
  175. 'handler' => 'views_handler_sort',
  176. ),
  177. );
  178. return $data;
  179. }
  180. /**
  181. * Implements hook_views_data_alter().
  182. */
  183. function locale_views_data_alter(&$data) {
  184. // Language field
  185. $data['node']['language'] = array(
  186. 'title' => t('Language'),
  187. 'help' => t('The language the content is in.'),
  188. 'field' => array(
  189. 'handler' => 'views_handler_field_node_language',
  190. 'click sortable' => TRUE,
  191. ),
  192. 'filter' => array(
  193. 'handler' => 'views_handler_filter_node_language',
  194. ),
  195. 'argument' => array(
  196. 'handler' => 'views_handler_argument_node_language',
  197. ),
  198. 'sort' => array(
  199. 'handler' => 'views_handler_sort',
  200. ),
  201. );
  202. }

Related topics