1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* Views handler to display an edit link for Webform configuration.
|
5 |
01f36513
|
Assos Assos
|
*
|
6 |
85ad3d82
|
Assos Assos
|
* 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 |
feca1e4a
|
Assos Assos
|
/**
|
11 |
76bdcd04
|
Assos Assos
|
* {@inheritdoc}
|
12 |
feca1e4a
|
Assos Assos
|
*/
|
13 |
|
|
public function option_definition() {
|
14 |
a45e4bc1
|
Assos Assos
|
$options = parent::option_definition();
|
15 |
|
|
$options['subpath'] = array('default' => '');
|
16 |
|
|
return $options;
|
17 |
|
|
}
|
18 |
|
|
|
19 |
feca1e4a
|
Assos Assos
|
/**
|
20 |
76bdcd04
|
Assos Assos
|
* {@inheritdoc}
|
21 |
feca1e4a
|
Assos Assos
|
*/
|
22 |
|
|
public function options_form(&$form, &$form_state) {
|
23 |
a45e4bc1
|
Assos Assos
|
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 |
85ad3d82
|
Assos Assos
|
/**
|
33 |
|
|
* Renders the link.
|
34 |
|
|
*/
|
35 |
feca1e4a
|
Assos Assos
|
public function render_link($node, $values) {
|
36 |
a45e4bc1
|
Assos Assos
|
// 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 |
85ad3d82
|
Assos Assos
|
return;
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
$this->options['alter']['make_link'] = TRUE;
|
42 |
a45e4bc1
|
Assos Assos
|
$this->options['alter']['path'] = "node/$node->nid/webform" .
|
43 |
|
|
(strlen($this->options['subpath']) ? '/' . $this->options['subpath'] : '');
|
44 |
85ad3d82
|
Assos Assos
|
|
45 |
|
|
$text = !empty($this->options['text']) ? $this->options['text'] : t('edit webform');
|
46 |
|
|
return $text;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
} |