summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc55
1 files changed, 35 insertions, 20 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc
index a55ac58..faeeedc 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/handlers/views_handler_field_contextual_links.inc
@@ -1,11 +1,21 @@
<?php
+/**
+ * @file
+ * Definition of views_handler_field_contextual_links.
+ */
+
+/**
+ * Provides a handler that adds contextual links.
+ *
+ * @ingroup views_field_handlers
+ */
class views_handler_field_contextual_links extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['fields'] = array('default' => array());
- $options['destination'] = array('default' => 1);
+ $options['destination'] = array('default' => TRUE, 'bool' => TRUE);
return $options;
}
@@ -22,13 +32,9 @@ class views_handler_field_contextual_links extends views_handler_field {
'#default_value' => $this->options['fields'],
);
$form['destination'] = array(
- '#type' => 'select',
+ '#type' => 'checkbox',
'#title' => t('Include destination'),
'#description' => t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'),
- '#options' => array(
- '0' => t('No'),
- '1' => t('Yes'),
- ),
'#default_value' => $this->options['destination'],
);
}
@@ -50,7 +56,7 @@ class views_handler_field_contextual_links extends views_handler_field {
function render($values) {
$links = array();
foreach ($this->options['fields'] as $field) {
- if (empty($this->view->field[$field]->last_render_text)) {
+ if (empty($this->view->style_plugin->rendered_fields[$this->view->row_index][$field])) {
continue;
}
$title = $this->view->field[$field]->last_render_text;
@@ -58,7 +64,11 @@ class views_handler_field_contextual_links extends views_handler_field {
if (!empty($this->view->field[$field]->options['alter']['path'])) {
$path = $this->view->field[$field]->options['alter']['path'];
}
- if (!empty($title)) {
+ if (!empty($title) && !empty($path)) {
+ // Make sure that tokens are replaced for this paths as well.
+ $tokens = $this->get_render_tokens(array());
+ $path = strip_tags(decode_entities(strtr($path, $tokens)));
+
$links[$field] = array(
'href' => $path,
'title' => $title,
@@ -68,19 +78,24 @@ class views_handler_field_contextual_links extends views_handler_field {
}
}
}
- $build = array(
- '#prefix' => '<div class="contextual-links-wrapper">',
- '#suffix' => '</div>',
- '#theme' => 'links__contextual',
- '#links' => $links,
- '#attributes' => array('class' => array('contextual-links')),
- '#attached' => array(
- 'library' => array(array('contextual', 'contextual-links')),
- ),
- '#access' => user_access('access contextual links'),
- );
- return drupal_render($build);
+ if (!empty($links)) {
+ $build = array(
+ '#prefix' => '<div class="contextual-links-wrapper">',
+ '#suffix' => '</div>',
+ '#theme' => 'links__contextual',
+ '#links' => $links,
+ '#attributes' => array('class' => array('contextual-links')),
+ '#attached' => array(
+ 'library' => array(array('contextual', 'contextual-links')),
+ ),
+ '#access' => user_access('access contextual links'),
+ );
+ return drupal_render($build);
+ }
+ else {
+ return '';
+ }
}
function query() { }