views_handler_field_ctools_dropdown.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_field_ctools_dropdown.
  5. */
  6. /**
  7. * Field handler which displays some amount of links as ctools dropdown button.
  8. *
  9. * @ingroup views_field_handlers
  10. */
  11. class views_handler_field_ctools_dropdown extends views_handler_field_links {
  12. function option_definition() {
  13. $options = parent::option_definition();
  14. $options['views_admin_css'] = array('default' => TRUE, 'bool' => TRUE);
  15. return $options;
  16. }
  17. function options_form(&$form, &$form_state) {
  18. parent::options_form($form, $form_state);
  19. $form['fields']['#description'] = t('Fields to be included as ctools dropdown button.');
  20. $form['destination']['#description'] = t('Include a "destination" parameter in the link to return the user to the original view upon completing a link action.');
  21. $form['views_admin_css'] = array(
  22. '#type' => 'checkbox',
  23. '#title' => t('Include Views admin CSS'),
  24. '#description' => t("Add additional css to match the style of the Views admin screen."),
  25. '#default_value' => $this->options['views_admin_css'],
  26. );
  27. }
  28. /**
  29. * Render the dropdown button.
  30. */
  31. function render($values) {
  32. static $added_admin_css;
  33. $links = $this->get_links();
  34. if (!empty($links)) {
  35. if (!empty($this->options['views_admin_css']) && !$added_admin_css) {
  36. views_include('admin');
  37. views_ui_add_admin_css();
  38. $added_admin_css = TRUE;
  39. }
  40. return theme('links__ctools_dropbutton', array('links' => $links, 'attributes' => array('class' => array('links', 'inline'))));
  41. }
  42. else {
  43. return '';
  44. }
  45. }
  46. }