Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / handlers / views_handler_field_markup.inc @ 651307cd

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
14
 *           used to control the format such as the 'format' field in the node,
15
 *           which goes with the 'body' field.
16
 *
17
 * @ingroup views_field_handlers
18
 */
19
class views_handler_field_markup extends views_handler_field {
20
  /**
21
   * Constructor; calls to base object constructor.
22
   */
23
  function construct() {
24
    parent::construct();
25

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

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

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

    
48
  function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
49
    if ($inline) {
50
      return 'span';
51
    }
52

    
53
    if (isset($this->definition['element type'])) {
54
      return $this->definition['element type'];
55
    }
56

    
57
    return 'div';
58
  }
59
}