1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_handler_field_accesslog_path.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Provide simple renderer that turns a URL into a clickable link.
|
10
|
*
|
11
|
* @ingroup views_field_handlers
|
12
|
*/
|
13
|
class views_handler_field_accesslog_path extends views_handler_field {
|
14
|
|
15
|
/**
|
16
|
* Override init function to provide generic option to link to node.
|
17
|
*/
|
18
|
public function init(&$view, &$options) {
|
19
|
parent::init($view, $options);
|
20
|
if (!empty($this->options['display_as_link'])) {
|
21
|
$this->additional_fields['path'] = 'path';
|
22
|
}
|
23
|
}
|
24
|
|
25
|
/**
|
26
|
* {@inheritdoc}
|
27
|
*/
|
28
|
public function option_definition() {
|
29
|
$options = parent::option_definition();
|
30
|
|
31
|
$options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE);
|
32
|
|
33
|
return $options;
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* Provide link to the page being visited.
|
38
|
*/
|
39
|
public function options_form(&$form, &$form_state) {
|
40
|
$form['display_as_link'] = array(
|
41
|
'#title' => t('Display as link'),
|
42
|
'#type' => 'checkbox',
|
43
|
'#default_value' => !empty($this->options['display_as_link']),
|
44
|
);
|
45
|
parent::options_form($form, $form_state);
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* {@inheritdoc}
|
50
|
*/
|
51
|
public function render($values) {
|
52
|
$value = $this->get_value($values);
|
53
|
return $this->render_link($this->sanitize_value($value), $values);
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* {@inheritdoc}
|
58
|
*/
|
59
|
public function render_link($data, $values) {
|
60
|
if (!empty($this->options['display_as_link'])) {
|
61
|
$this->options['alter']['make_link'] = TRUE;
|
62
|
$this->options['alter']['path'] = $this->get_value($values, 'path');
|
63
|
$this->options['alter']['html'] = TRUE;
|
64
|
}
|
65
|
|
66
|
return $data;
|
67
|
}
|
68
|
|
69
|
}
|