Projet

Général

Profil

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

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

1
<?php
2

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

    
8
/**
9
 * A handler to run a field through check_markup, using a companion
10
 * format field.
11
 *
12
 * - format: (REQUIRED) Either a string format id to use for this field or an
13
 *   array('field' => {$field}) where $field is the field in this table used to
14
 *   control the format such as the 'format' field in the node, which goes with
15
 *   the 'body' field.
16
 *
17
 * @ingroup views_field_handlers
18
 */
19
class views_handler_field_markup extends views_handler_field {
20

    
21
  /**
22
   * {@inheritdoc}
23
   */
24
  public function construct() {
25
    parent::construct();
26

    
27
    $this->format = $this->definition['format'];
28

    
29
    $this->additional_fields = array();
30
    if (is_array($this->format)) {
31
      $this->additional_fields['format'] = $this->format;
32
    }
33
  }
34

    
35
  /**
36
   * {@inheritdoc}
37
   */
38
  public function render($values) {
39
    $value = $this->get_value($values);
40
    if (is_array($this->format)) {
41
      $format = $this->get_value($values, 'format');
42
    }
43
    else {
44
      $format = $this->format;
45
    }
46
    if ($value) {
47
      $value = str_replace('<!--break-->', '', $value);
48
      return check_markup($value, $format, '');
49
    }
50
  }
51

    
52
  /**
53
   * {@inheritdoc}
54
   */
55
  public function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
56
    if ($inline) {
57
      return 'span';
58
    }
59

    
60
    if (isset($this->definition['element type'])) {
61
      return $this->definition['element type'];
62
    }
63

    
64
    return 'div';
65
  }
66

    
67
}