Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / modules / node / views_handler_field_node_path.inc @ 76df55b7

1
<?php
2

    
3
/**
4
 * @file
5
 * Handler for node path field.
6
 */
7

    
8
/**
9
 * Field handler to present the path to the node.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_node_path extends views_handler_field {
14

    
15
  function option_definition() {
16
    $options = parent::option_definition();
17
    $options['absolute'] = array('default' => FALSE, 'bool' => TRUE);
18

    
19
    return $options;
20
  }
21

    
22
  function construct() {
23
    parent::construct();
24
    $this->additional_fields['nid'] = 'nid';
25
  }
26

    
27
  function options_form(&$form, &$form_state) {
28
    parent::options_form($form, $form_state);
29
    $form['absolute'] = array(
30
      '#type' => 'checkbox',
31
      '#title' => t('Use absolute link (begins with "http://")'),
32
      '#default_value' => $this->options['absolute'],
33
      '#description' => t('Enable this option to output an absolute link. Required if you want to use the path as a link destination (as in "output this field as a link" above).'),
34
      '#fieldset' => 'alter',
35
    );
36
  }
37

    
38
  function query() {
39
    $this->ensure_my_table();
40
    $this->add_additional_fields();
41
  }
42

    
43
  function render($values) {
44
    $nid = $this->get_value($values, 'nid');
45
    return url("node/$nid", array('absolute' => $this->options['absolute']));
46
  }
47
}