Projet

Général

Profil

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

root / drupal7 / sites / all / modules / webform / views / webform_handler_field_node_link_edit.inc @ 651307cd

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Views handler to display an edit link for Webform configuration.
6
 */
7
8
/**
9
 * Field handler to present a link node edit.
10
 */
11
class webform_handler_field_node_link_edit extends views_handler_field_node_link {
12
13 a45e4bc1 Assos Assos
  function option_definition() {
14
    $options = parent::option_definition();
15
    $options['subpath'] = array('default' => '');
16
    return $options;
17
  }
18
19
  function options_form(&$form, &$form_state) {
20
    parent::options_form($form, $form_state);
21
    $form['subpath'] = array(
22
      '#type' => 'textfield',
23
      '#title' => t('Subpath'),
24
      '#default_value' => $this->options['subpath'],
25
      '#field_prefix' => 'node/NID/webform/',
26
    );
27
  }
28
29 85ad3d82 Assos Assos
  /**
30
   * Renders the link.
31
   */
32
  function render_link($node, $values) {
33 a45e4bc1 Assos Assos
    // Ensure node is webform-enabled and user has access to edit this node.
34
    if (!in_array($node->type, webform_node_types()) || !node_access('update', $node)) {
35 85ad3d82 Assos Assos
      return;
36
    }
37
38
    $this->options['alter']['make_link'] = TRUE;
39 a45e4bc1 Assos Assos
    $this->options['alter']['path'] = "node/$node->nid/webform" .
40
                                      (strlen($this->options['subpath']) ? '/' . $this->options['subpath'] : '');
41 85ad3d82 Assos Assos
42
    $text = !empty($this->options['text']) ? $this->options['text'] : t('edit webform');
43
    return $text;
44
  }
45
46
}