Project

General

Profile

Paste
Download (3.47 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / views / modules / translation.views.inc @ d719f12f

1
<?php
2

    
3
/**
4
 * @file
5
 * Provide views data and handlers for translation.module.
6
 *
7
 * @ingroup views_module_handlers
8
 */
9

    
10
/**
11
 * Implements hook_views_data_alter().
12
 *
13
 * Add translation information to the node table.
14
 */
15
function translation_views_data_alter(&$data) {
16

    
17
  // Joins
18
  $data['node']['table']['join']['node'] = array(
19
    'left_field' => 'tnid',
20
    'field' => 'tnid',
21
  );
22

    
23
  // The translation ID (nid of the "source" translation)
24
  $data['node']['tnid'] = array(
25
    'group' => t('Content translation'),
26
    'title' => t('Translation set node ID'),
27
    'help' => t('The ID of the translation set the content belongs to.'),
28
    'field' => array(
29
      'handler' => 'views_handler_field_node',
30
      'click sortable' => TRUE,
31
    ),
32
    'filter' => array(
33
      'handler' => 'views_handler_filter_numeric',
34
    ),
35
    'argument' => array(
36
      'handler' => 'views_handler_argument_node_tnid',
37
      'name field' => 'title', // the field to display in the summary.
38
      'numeric' => TRUE,
39
      'validate type' => 'tnid',
40
    ),
41
    'sort' => array(
42
      'handler' => 'views_handler_sort',
43
    ),
44
    'relationship' => array(
45
      'title' => t('Source translation'),
46
      'help' => t('The source that this content was translated from.'),
47
      'base' => 'node',
48
      'base field' => 'nid',
49
      'handler' => 'views_handler_relationship',
50
      'label' => t('Source translation'),
51
    ),
52
  );
53

    
54
  // All translations.
55
  $data['node']['translation'] = array(
56
    'group' => t('Content translation'),
57
    'title' => t('Translations'),
58
    'help' => t('Versions of content in different languages.'),
59
    'relationship' => array(
60
      'title' => t('Translations'),
61
      'help' => t('Versions of content in different languages.'),
62
      'base' => 'node',
63
      'base field' => 'tnid',
64
      'relationship table' => 'node',
65
      'relationship field' => 'tnid',
66
      'handler' => 'views_handler_relationship_translation',
67
      'label' => t('Translations'),
68
    ),
69
  );
70

    
71
  // The source translation.
72
  $data['node']['source_translation'] = array(
73
    'group' => t('Content translation'),
74
    'title' => t('Source translation'),
75
    'help' => t('Content that is either untranslated or is the original version of a translation set.'),
76
    'filter' => array(
77
      'handler' => 'views_handler_filter_node_tnid',
78
    ),
79
  );
80

    
81
  // Child translation.
82
  $data['node']['child_translation'] = array(
83
    'group' => t('Node translation'),
84
    'title' => t('Child translation'),
85
    'help' => t('Content that is a translation of a source translation.'),
86
    'filter' => array(
87
      'handler' => 'views_handler_filter_node_tnid_child',
88
    ),
89
  );
90

    
91
  // Translation status
92
  $data['node']['translate'] = array(
93
    'group' => t('Content translation'),
94
    'title' => t('Translation status'),
95
    'help' => t('The translation status of the content - whether or not the translation needs to be updated.'),
96
    'field' => array(
97
      'handler' => 'views_handler_field_boolean',
98
      'click sortable' => TRUE,
99
    ),
100
    'filter' => array(
101
      'handler' => 'views_handler_filter_boolean_operator',
102
      'label' => t('Outdated'),
103
      'type' => 'yes-no',
104
    ),
105
    'sort' => array(
106
      'handler' => 'views_handler_sort',
107
    ),
108
  );
109

    
110
  // Translate node link.
111
  $data['node']['translate_node'] = array(
112
    'group' => t('Content translation'),
113
    'title' => t('Translate link'),
114
    'help' => t('Provide a simple link to translate the node.'),
115
    'field' => array(
116
      'handler' => 'views_handler_field_node_link_translate',
117
    ),
118
  );
119

    
120

    
121
}