translation.views.inc

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

Provide views data and handlers for translation.module

File

modules/translation.views.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. *
  5. * Provide views data and handlers for translation.module
  6. */
  7. /**
  8. * @defgroup views_translation_module translation.module handlers
  9. *
  10. * @{
  11. */
  12. /**
  13. * Implementation of hook_views_data_alter().
  14. *
  15. * Add translation information to the node table.
  16. */
  17. function translation_views_data_alter(&$data) {
  18. // Joins
  19. $data['node']['table']['join']['node'] = array(
  20. 'left_field' => 'tnid',
  21. 'field' => 'tnid',
  22. );
  23. // Language field
  24. $data['node']['language'] = array(
  25. 'group' => t('Node translation'),
  26. 'title' => t('Language'),
  27. 'help' => t('The language the content is in.'),
  28. 'field' => array(
  29. 'handler' => 'views_handler_field_node_language',
  30. 'click sortable' => TRUE,
  31. ),
  32. 'filter' => array(
  33. 'handler' => 'views_handler_filter_node_language',
  34. ),
  35. 'argument' => array(
  36. 'handler' => 'views_handler_argument_node_language',
  37. ),
  38. );
  39. // The translation ID (nid of the "source" translation)
  40. $data['node']['tnid'] = array(
  41. 'group' => t('Node translation'),
  42. 'title' => t('Translation set node ID'),
  43. 'help' => t('The ID of the translation set the content belongs to.'),
  44. 'field' => array(
  45. 'handler' => 'views_handler_field_node',
  46. 'click sortable' => TRUE,
  47. ),
  48. 'filter' => array(
  49. 'handler' => 'views_handler_filter_numeric',
  50. ),
  51. 'argument' => array(
  52. 'handler' => 'views_handler_argument_node_tnid',
  53. 'parent' => 'views_handler_argument_numeric', // make sure parent is included
  54. 'name field' => 'title', // the field to display in the summary.
  55. 'numeric' => TRUE,
  56. 'validate type' => 'tnid',
  57. ),
  58. 'sort' => array(
  59. 'handler' => 'views_handler_sort',
  60. ),
  61. 'relationship' => array(
  62. 'title' => t('Source translation'),
  63. 'help' => t('The source that this content was translated from.'),
  64. 'base' => 'node',
  65. 'base field' => 'nid',
  66. 'handler' => 'views_handler_relationship',
  67. 'label' => t('Source translation'),
  68. ),
  69. );
  70. // The source translation.
  71. $data['node']['translation'] = array(
  72. 'group' => t('Node translation'),
  73. 'title' => t('Translations'),
  74. 'help' => t('Versions of content in different languages.'),
  75. 'relationship' => array(
  76. 'title' => t('Translations'),
  77. 'help' => t('Versions of content in different languages.'),
  78. 'base' => 'node',
  79. 'base field' => 'tnid',
  80. 'relationship table' => 'node',
  81. 'relationship field' => 'nid',
  82. 'handler' => 'views_handler_relationship_translation',
  83. 'label' => t('Translations'),
  84. ),
  85. );
  86. // The source translation.
  87. $data['node']['source_translation'] = array(
  88. 'group' => t('Node translation'),
  89. 'title' => t('Source translation'),
  90. 'help' => t('Nodes that are either untranslated or are the original versions of a translation set.'),
  91. 'filter' => array(
  92. 'handler' => 'views_handler_filter_node_tnid',
  93. ),
  94. );
  95. // The source translation.
  96. $data['node']['child_translation'] = array(
  97. 'group' => t('Node translation'),
  98. 'title' => t('Child translation'),
  99. 'help' => t('Nodes that are translations of a source translation.'),
  100. 'filter' => array(
  101. 'handler' => 'views_handler_filter_node_tnid_child',
  102. ),
  103. );
  104. // Translation status
  105. $data['node']['translate'] = array(
  106. 'group' => t('Node translation'),
  107. 'title' => t('Translation status'),
  108. 'help' => t('The translation status of the node--whether or not the translation needs to be updated.'),
  109. 'field' => array(
  110. 'handler' => 'views_handler_field_boolean',
  111. 'click sortable' => TRUE,
  112. ),
  113. 'filter' => array(
  114. 'handler' => 'views_handler_filter_boolean_operator',
  115. 'label' => t('Outdated'),
  116. 'type' => 'yes-no',
  117. ),
  118. 'sort' => array(
  119. 'handler' => 'views_handler_sort',
  120. ),
  121. );
  122. // Translate node link.
  123. $data['node']['translate_node'] = array(
  124. 'group' => t('Node translation'),
  125. 'title' => t('Translate link'),
  126. 'help' => t('Provide a simple link to translate the node.'),
  127. 'field' => array(
  128. 'handler' => 'views_handler_field_node_link_translate',
  129. ),
  130. );
  131. }
  132. /**
  133. * Implementation of hook_views_handlers() to register all of the basic handlers
  134. * views uses.
  135. */
  136. function translation_views_handlers() {
  137. return array(
  138. 'info' => array(
  139. 'path' => drupal_get_path('module', 'views') . '/modules/translation',
  140. ),
  141. 'handlers' => array(
  142. // field handlers
  143. 'views_handler_field_node_language' => array(
  144. 'parent' => 'views_handler_field_node',
  145. ),
  146. 'views_handler_field_node_link_translate' => array(
  147. 'parent' => 'views_handler_field_node_link',
  148. ),
  149. // argument handlers
  150. 'views_handler_argument_node_language' => array(
  151. 'parent' => 'views_handler_argument',
  152. ),
  153. 'views_handler_argument_node_tnid' => array(
  154. 'parent' => 'views_handler_argument',
  155. ),
  156. // filters
  157. 'views_handler_filter_node_language' => array(
  158. 'parent' => 'views_handler_filter_in_operator',
  159. ),
  160. 'views_handler_filter_node_tnid' => array(
  161. 'parent' => 'views_handler_filter',
  162. ),
  163. // relationships
  164. 'views_handler_relationship_translation' => array(
  165. 'parent' => 'views_handler_relationship',
  166. ),
  167. 'views_handler_filter_node_tnid_child' => array(
  168. 'parent' => 'views_handler_filter',
  169. ),
  170. ),
  171. );
  172. }
  173. /**
  174. * @}
  175. */