Projet

Général

Profil

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

root / drupal7 / sites / all / modules / webform / views / webform_handler_field_node_link_edit.inc @ 01f36513

1
<?php
2

    
3
/**
4
 * Views handler to display an edit link for Webform configuration.
5
 *
6
 * Field handler to present a link node edit.
7
 */
8
class webform_handler_field_node_link_edit extends views_handler_field_node_link {
9

    
10
  /**
11
   *
12
   */
13
  public function option_definition() {
14
    $options = parent::option_definition();
15
    $options['subpath'] = array('default' => '');
16
    return $options;
17
  }
18

    
19
  /**
20
   *
21
   */
22
  public function options_form(&$form, &$form_state) {
23
    parent::options_form($form, $form_state);
24
    $form['subpath'] = array(
25
      '#type' => 'textfield',
26
      '#title' => t('Subpath'),
27
      '#default_value' => $this->options['subpath'],
28
      '#field_prefix' => 'node/NID/webform/',
29
    );
30
  }
31

    
32
  /**
33
   * Renders the link.
34
   */
35
  public function render_link($node, $values) {
36
    // Ensure node is webform-enabled and user has access to edit this node.
37
    if (!in_array($node->type, webform_node_types()) || !node_access('update', $node)) {
38
      return;
39
    }
40

    
41
    $this->options['alter']['make_link'] = TRUE;
42
    $this->options['alter']['path'] = "node/$node->nid/webform" .
43
                                      (strlen($this->options['subpath']) ? '/' . $this->options['subpath'] : '');
44

    
45
    $text = !empty($this->options['text']) ? $this->options['text'] : t('edit webform');
46
    return $text;
47
  }
48

    
49
}