Projet

Général

Profil

Paste
Télécharger (1,52 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / aggregator / views_handler_field_aggregator_title_link.inc @ 5d12d676

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
10
 * original source article.
11
 *
12
 * @ingroup views_field_handlers
13
 */
14
class views_handler_field_aggregator_title_link extends views_handler_field {
15

    
16
  /**
17
   * {@inheritdoc}
18
   */
19
  public function construct() {
20
    parent::construct();
21
    $this->additional_fields['link'] = 'link';
22
  }
23

    
24
  /**
25
   * {@inheritdoc}
26
   */
27
  public function option_definition() {
28
    $options = parent::option_definition();
29

    
30
    $options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE);
31

    
32
    return $options;
33
  }
34

    
35
  /**
36
   * Provide link to the page being visited.
37
   */
38
  public function options_form(&$form, &$form_state) {
39
    $form['display_as_link'] = array(
40
      '#title' => t('Display as link'),
41
      '#type' => 'checkbox',
42
      '#default_value' => !empty($this->options['display_as_link']),
43
    );
44
    parent::options_form($form, $form_state);
45
  }
46

    
47
  /**
48
   * {@inheritdoc}
49
   */
50
  public function render($values) {
51
    $value = $this->get_value($values);
52
    return $this->render_link($this->sanitize_value($value), $values);
53
  }
54

    
55
  /**
56
   * {@inheritdoc}
57
   */
58
  public function render_link($data, $values) {
59
    $link = $this->get_value($values, 'link');
60
    if (!empty($this->options['display_as_link'])) {
61
      $this->options['alter']['make_link'] = TRUE;
62
      $this->options['alter']['path'] = $link;
63
      $this->options['alter']['html'] = TRUE;
64
    }
65

    
66
    return $data;
67
  }
68

    
69
}