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