Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / handlers / views_handler_field_contextual_links.inc @ 651307cd

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_field_contextual_links.
6
 */
7

    
8
/**
9
 * Provides a handler that adds contextual links.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_contextual_links extends views_handler_field_links {
14
  function pre_render(&$values) {
15
    // Add a row plugin css class for the contextual link.
16
    $class = 'contextual-links-region';
17
    if (!empty($this->view->style_plugin->options['row_class'])) {
18
      $this->view->style_plugin->options['row_class'] .= " $class";
19
    }
20
    else {
21
      $this->view->style_plugin->options['row_class'] = $class;
22
    }
23
  }
24

    
25
  function options_form(&$form, &$form_state) {
26
    parent::options_form($form, $form_state);
27

    
28
    $form['fields']['#description'] = t('Fields to be included as contextual links.');
29
    $form['destination']['#description'] = t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.');
30
  }
31

    
32
  /**
33
   * Render the contextual fields.
34
   */
35
  function render($values) {
36
    $links = $this->get_links();
37
    if (!empty($links)) {
38
      $build = array(
39
        '#prefix' => '<div class="contextual-links-wrapper">',
40
        '#suffix' => '</div>',
41
        '#theme' => 'links__contextual',
42
        '#links' => $links,
43
        '#attributes' => array('class' => array('contextual-links')),
44
        '#attached' => array(
45
          'library' => array(array('contextual', 'contextual-links')),
46
        ),
47
        '#access' => user_access('access contextual links'),
48
      );
49
      return drupal_render($build);
50
    }
51
    else {
52
      return '';
53
    }
54
  }
55
}