blob: d8bf5789bf6367f833231c327e3dd5211f093630 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<?php
/**
* @file
* Definition of views_handler_field_aggregator_title_link.
*/
/**
* Field handler that turns an item's title into a clickable link to the original
* source article.
*
* @ingroup views_field_handlers
*/
class views_handler_field_aggregator_title_link extends views_handler_field {
function construct() {
parent::construct();
$this->additional_fields['link'] = 'link';
}
function option_definition() {
$options = parent::option_definition();
$options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE);
return $options;
}
/**
* Provide link to the page being visited.
*/
function options_form(&$form, &$form_state) {
$form['display_as_link'] = array(
'#title' => t('Display as link'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['display_as_link']),
);
parent::options_form($form, $form_state);
}
function render($values) {
$value = $this->get_value($values);
return $this->render_link($this->sanitize_value($value), $values);
}
function render_link($data, $values) {
$link = $this->get_value($values, 'link');
if (!empty($this->options['display_as_link'])) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $link;
$this->options['alter']['html'] = TRUE;
}
return $data;
}
}
|