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);
  16. $options['override'] = array('default' => FALSE);
  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. '#process' => array('views_process_dependency'),
  51. '#dependency' => array('edit-style-options-override' => array(TRUE)),
  52. );
  53. }
  54. function render() {
  55. $rows = array();
  56. foreach ($this->view->result as $row) {
  57. // @todo: Include separator as an option.
  58. $rows[] = $row;
  59. }
  60. return theme($this->theme_functions(), $this->view, $this->options, $rows);
  61. }
  62. }