views_test_plugin_style_test_mapping.inc

Definition of views_test_plugin_style_test_mapping.

File

tests/test_plugins/views_test_plugin_style_test_mapping.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_test_plugin_style_test_mapping.
  5. */
  6. /**
  7. * Provides a test mapping style plugin.
  8. */
  9. class views_test_plugin_style_test_mapping extends views_plugin_style_mapping {
  10. /**
  11. * Overrides views_plugin_style_mapping::define_mapping().
  12. */
  13. protected function define_mapping() {
  14. return array(
  15. 'title_field' => array(
  16. '#title' => t('Title field'),
  17. '#description' => t('Choose the field with the custom title.'),
  18. '#toggle' => TRUE,
  19. '#required' => TRUE,
  20. ),
  21. 'name_field' => array(
  22. '#title' => t('Name field'),
  23. '#description' => t('Choose the field with the custom name.'),
  24. ),
  25. 'numeric_field' => array(
  26. '#title' => t('Numeric field'),
  27. '#description' => t('Select one or more numeric fields.'),
  28. '#multiple' => TRUE,
  29. '#toggle' => TRUE,
  30. '#filter' => 'filter_numeric_fields',
  31. '#required' => TRUE,
  32. ),
  33. );
  34. }
  35. /**
  36. * Restricts the allowed fields to only numeric fields.
  37. *
  38. * @param array $fields
  39. * An array of field labels, keyed by the field ID.
  40. */
  41. protected function filter_numeric_fields(&$fields) {
  42. foreach ($this->view->field as $id => $field) {
  43. if (!($field instanceof views_handler_field_numeric)) {
  44. unset($fields[$id]);
  45. }
  46. }
  47. }
  48. }