1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_handler_field_node_link_translate.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Field handler to present a link node translate.
|
10
|
*
|
11
|
* @ingroup views_field_handlers
|
12
|
*/
|
13
|
class views_handler_field_node_link_translate extends views_handler_field_node_link {
|
14
|
|
15
|
/**
|
16
|
* {@inheritdoc}
|
17
|
*/
|
18
|
public function render_link($data, $values) {
|
19
|
// ensure user has access to edit this node.
|
20
|
$node = $this->get_value($values);
|
21
|
$node->status = 1;
|
22
|
// unpublished nodes ignore access control.
|
23
|
if ($node->language == LANGUAGE_NONE || !translation_supported_type($node->type) || !node_access('view', $node) || !user_access('translate content')) {
|
24
|
return;
|
25
|
}
|
26
|
|
27
|
$this->options['alter']['make_link'] = TRUE;
|
28
|
$this->options['alter']['path'] = "node/$node->nid/translate";
|
29
|
$this->options['alter']['query'] = drupal_get_destination();
|
30
|
|
31
|
$text = !empty($this->options['text']) ? $this->options['text'] : t('translate');
|
32
|
return $text;
|
33
|
}
|
34
|
|
35
|
}
|