Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / handlers / views_handler_field_time_interval.inc @ 4003efde

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_field_time_interval.
6
 */
7

    
8
/**
9
 * A handler to provide proper displays for time intervals.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_time_interval extends views_handler_field {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function option_definition() {
19
    $options = parent::option_definition();
20

    
21
    $options['granularity'] = array('default' => 2);
22

    
23
    return $options;
24
  }
25

    
26
  /**
27
   * {@inheritdoc}
28
   */
29
  public function options_form(&$form, &$form_state) {
30
    parent::options_form($form, $form_state);
31

    
32
    $form['granularity'] = array(
33
      '#type' => 'textfield',
34
      '#title' => t('Granularity'),
35
      '#description' => t('How many different units to display in the string.'),
36
      '#default_value' => $this->options['granularity'],
37
    );
38
  }
39

    
40
  /**
41
   * {@inheritdoc}
42
   */
43
  public function render($values) {
44
    $value = $values->{$this->field_alias};
45
    return format_interval($value, isset($this->options['granularity']) ? $this->options['granularity'] : 2);
46
  }
47

    
48
}