views_plugin_style_grid.inc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_plugin_style_grid.
  5. */
  6. /**
  7. * Style plugin to render each item in a grid cell.
  8. *
  9. * @ingroup views_style_plugins
  10. */
  11. class views_plugin_style_grid extends views_plugin_style {
  12. /**
  13. * Set default options.
  14. */
  15. public function option_definition() {
  16. $options = parent::option_definition();
  17. $options['columns'] = array('default' => '4');
  18. $options['alignment'] = array('default' => 'horizontal');
  19. $options['fill_single_line'] = array('default' => TRUE, 'bool' => TRUE);
  20. $options['summary'] = array('default' => '');
  21. $options['caption'] = array('default' => '');
  22. return $options;
  23. }
  24. /**
  25. * Render the given style.
  26. */
  27. public function options_form(&$form, &$form_state) {
  28. parent::options_form($form, $form_state);
  29. $form['columns'] = array(
  30. '#type' => 'textfield',
  31. '#title' => t('Number of columns'),
  32. '#default_value' => $this->options['columns'],
  33. '#required' => TRUE,
  34. '#element_validate' => array('views_element_validate_integer'),
  35. );
  36. $form['alignment'] = array(
  37. '#type' => 'radios',
  38. '#title' => t('Alignment'),
  39. '#options' => array('horizontal' => t('Horizontal'), 'vertical' => t('Vertical')),
  40. '#default_value' => $this->options['alignment'],
  41. '#description' => t('Horizontal alignment will place items starting in the upper left and moving right. Vertical alignment will place items starting in the upper left and moving down.'),
  42. );
  43. $form['fill_single_line'] = array(
  44. '#type' => 'checkbox',
  45. '#title' => t('Fill up single line'),
  46. '#description' => t('If you disable this option, a grid with only one row will have the same number of table cells (<TD>) as items. Disabling it can cause problems with your CSS.'),
  47. '#default_value' => !empty($this->options['fill_single_line']),
  48. );
  49. $form['caption'] = array(
  50. '#type' => 'textfield',
  51. '#title' => t('Short description of table'),
  52. '#description' => t('Include a caption for better accessibility of your table.'),
  53. '#default_value' => $this->options['caption'],
  54. );
  55. $form['summary'] = array(
  56. '#type' => 'textfield',
  57. '#title' => t('Table summary'),
  58. '#description' => t('This value will be displayed as table-summary attribute in the html. Use this to give a summary of complex tables.'),
  59. '#default_value' => $this->options['summary'],
  60. );
  61. }
  62. }