views_content_plugin_style_ctools_context.inc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @file
  4. * Contains the default style plugin.
  5. */
  6. /**
  7. * Default style plugin to render rows one after another with no
  8. * decorations.
  9. *
  10. * @ingroup views_style_plugins
  11. */
  12. class views_content_plugin_style_ctools_context extends views_plugin_style {
  13. var $rows = array();
  14. /**
  15. * Render the display in this style.
  16. */
  17. function render() {
  18. if (!empty($this->view->display_handler->previewing)) {
  19. return parent::render();
  20. }
  21. $this->rows = array();
  22. $this->groups = array();
  23. if ($this->uses_row_plugin() && empty($this->row_plugin)) {
  24. vpr('views_plugin_style_default: Missing row plugin');
  25. return;
  26. }
  27. // Some engines like solr key results on ids, but rendering really expects
  28. // things to be keyed exclusively by row index. Using array_values()
  29. // guarantees that.
  30. $this->view->result = array_values($this->view->result);
  31. // Group the rows according to the grouping field, if specified.
  32. $sets = $this->render_grouping($this->view->result, $this->options['grouping']);
  33. // Render each group separately and concatenate. Plugins may override this
  34. // method if they wish some other way of handling grouping.
  35. $output = '';
  36. foreach ($sets as $title => $records) {
  37. foreach ($records as $row_index => $row) {
  38. $this->view->row_index = $row_index;
  39. $this->rows[$row_index] = $this->row_plugin->render($row);
  40. $this->groups[$row_index] = $title;
  41. }
  42. }
  43. unset($this->view->row_index);
  44. return $this->rows;
  45. }
  46. }