1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Contains .
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Field handler to present a link to edit a translation.
|
10
|
*
|
11
|
* @ingroup views_field_handlers
|
12
|
*/
|
13
|
class views_handler_field_locale_link_edit extends views_handler_field {
|
14
|
|
15
|
/**
|
16
|
* {@inheritdoc}
|
17
|
*/
|
18
|
public function construct() {
|
19
|
parent::construct();
|
20
|
$this->additional_fields['lid'] = 'lid';
|
21
|
}
|
22
|
|
23
|
/**
|
24
|
* {@inheritdoc}
|
25
|
*/
|
26
|
public function option_definition() {
|
27
|
$options = parent::option_definition();
|
28
|
|
29
|
$options['text'] = array('default' => '', 'translatable' => TRUE);
|
30
|
|
31
|
return $options;
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
* {@inheritdoc}
|
36
|
*/
|
37
|
public function options_form(&$form, &$form_state) {
|
38
|
$form['text'] = array(
|
39
|
'#type' => 'textfield',
|
40
|
'#title' => t('Text to display'),
|
41
|
'#default_value' => $this->options['text'],
|
42
|
);
|
43
|
parent::options_form($form, $form_state);
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* {@inheritdoc}
|
48
|
*/
|
49
|
public function query() {
|
50
|
$this->ensure_my_table();
|
51
|
$this->add_additional_fields();
|
52
|
}
|
53
|
|
54
|
/**
|
55
|
* {@inheritdoc}
|
56
|
*/
|
57
|
public function access() {
|
58
|
// Ensure user has access to edit translations.
|
59
|
return user_access('translate interface');
|
60
|
}
|
61
|
|
62
|
/**
|
63
|
* {@inheritdoc}
|
64
|
*/
|
65
|
public function render($values) {
|
66
|
$value = $this->get_value($values, 'lid');
|
67
|
return $this->render_link($this->sanitize_value($value), $values);
|
68
|
}
|
69
|
|
70
|
/**
|
71
|
* {@inheritdoc}
|
72
|
*/
|
73
|
public function render_link($data, $values) {
|
74
|
$text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
|
75
|
|
76
|
$this->options['alter']['make_link'] = TRUE;
|
77
|
$this->options['alter']['path'] = 'admin/config/regional/translate/edit/' . $data;
|
78
|
$this->options['alter']['query'] = drupal_get_destination();
|
79
|
|
80
|
return $text;
|
81
|
}
|
82
|
|
83
|
}
|