Project

General

Profile

Paste
Download (1.77 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / views / handlers / views_handler_field_ctools_dropdown.inc @ 8be7bf84

1
<?php
2

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

    
8
/**
9
 * Field handler which displays some amount of links as ctools dropdown button.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_ctools_dropdown extends views_handler_field_links {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function option_definition() {
19
    $options = parent::option_definition();
20

    
21
    $options['views_admin_css'] = array('default' => TRUE, 'bool' => TRUE);
22

    
23
    return $options;
24
  }
25

    
26
  /**
27
   * {@inheritdoc}
28
   */
29
  public function options_form(&$form, &$form_state) {
30
    parent::options_form($form, $form_state);
31
    $form['fields']['#description'] = t('Fields to be included as ctools dropdown button.');
32
    $form['destination']['#description'] = t('Include a "destination" parameter in the link to return the user to the original view upon completing a link action.');
33

    
34
    $form['views_admin_css'] = array(
35
      '#type' => 'checkbox',
36
      '#title' => t('Include Views admin CSS'),
37
      '#description' => t("Add additional css to match the style of the Views admin screen."),
38
      '#default_value' => $this->options['views_admin_css'],
39
    );
40
  }
41

    
42
  /**
43
   * Render the dropdown button.
44
   */
45
  public function render($values) {
46
    static $added_admin_css;
47
    $links = $this->get_links();
48

    
49
    if (!empty($links)) {
50
      if (!empty($this->options['views_admin_css']) && !$added_admin_css) {
51
        views_include('admin');
52
        views_ui_add_admin_css();
53
        $added_admin_css = TRUE;
54
      }
55

    
56
      $vars = array(
57
        'links' => $links,
58
        'attributes' => array(
59
          'class' => array(
60
            'links',
61
            'inline',
62
          ),
63
        ),
64
      );
65
      return theme('links__ctools_dropbutton', $vars);
66
    }
67
    else {
68
      return '';
69
    }
70
  }
71

    
72
}