views_plugin_style_summary.inc

  1. 3.x plugins/views_plugin_style_summary.inc
  2. 2.x plugins/views_plugin_style_summary.inc

Contains the default summary style plugin, which displays items in an HTML list.

File

plugins/views_plugin_style_summary.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains the default summary style plugin, which displays items in an HTML list.
  5. */
  6. /**
  7. * The default style plugin for summaries.
  8. *
  9. * @ingroup views_style_plugins
  10. */
  11. class views_plugin_style_summary extends views_plugin_style {
  12. function option_definition() {
  13. $options = parent::option_definition();
  14. $options['base_path'] = array('default' => '');
  15. $options['count'] = array('default' => TRUE, 'bool' => TRUE);
  16. $options['override'] = array('default' => FALSE, 'bool' => TRUE);
  17. $options['items_per_page'] = array('default' => 25);
  18. return $options;
  19. }
  20. function query() {
  21. if (!empty($this->options['override'])) {
  22. $this->view->set_items_per_page(intval($this->options['items_per_page']));
  23. }
  24. }
  25. function options_form(&$form, &$form_state) {
  26. $form['base_path'] = array(
  27. '#type' => 'textfield',
  28. '#title' => t('Base path'),
  29. '#default_value' => $this->options['base_path'],
  30. '#description' => t('Define the base path for links in this summary
  31. view, i.e. http://example.com/<strong>your_view_path/archive</strong>.
  32. Do not include beginning and ending forward slash. If this value
  33. is empty, views will use the first path found as the base path,
  34. in page displays, or / if no path could be found.'),
  35. );
  36. $form['count'] = array(
  37. '#type' => 'checkbox',
  38. '#default_value' => !empty($this->options['count']),
  39. '#title' => t('Display record count with link'),
  40. );
  41. $form['override'] = array(
  42. '#type' => 'checkbox',
  43. '#default_value' => !empty($this->options['override']),
  44. '#title' => t('Override number of items to display'),
  45. );
  46. $form['items_per_page'] = array(
  47. '#type' => 'textfield',
  48. '#title' => t('Items to display'),
  49. '#default_value' => $this->options['items_per_page'],
  50. '#dependency' => array(
  51. 'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1)
  52. ),
  53. );
  54. }
  55. function render() {
  56. $rows = array();
  57. foreach ($this->view->result as $row) {
  58. // @todo: Include separator as an option.
  59. $rows[] = $row;
  60. }
  61. return theme($this->theme_functions(), array(
  62. 'view' => $this->view,
  63. 'options' => $this->options,
  64. 'rows' => $rows
  65. ));
  66. }
  67. }