Commit 457e8dee authored by merlinofchaos's avatar merlinofchaos

#551752 by dereine: Clean up row counter code.

parent 2ed88c94
......@@ -44,6 +44,7 @@ Views 2.x-dev
o #563540 by dereine: Fix description of cache plugin settings.
o #563564 by dereine: Unformatted style does not use options, so the options icon should not appear.
o #564536 by dereine: Node links should allow language setting from node data.
o #551752 by dereine: Clean up row counter code.
Other changes:
o Implement a post_render hook (for themes too) and cache method.
......
......@@ -35,7 +35,7 @@ class views_handler_field_counter extends views_handler_field {
$count += ($pager['items_per_page'] * $pager['current_page']) + $pager['offset'];
}
// Add the counter for the current site.
$count += array_search($values, $this->view->result) + 1;
$count += $this->view->row_index + 1;
return $count;
}
......
......@@ -152,11 +152,13 @@ class views_plugin_style extends views_plugin {
// Render each group separately and concatenate. Plugins may override this
// method if they wish some other way of handling grouping.
$output = '';
$this->view->row_index = 0;
foreach ($sets as $title => $records) {
if ($this->uses_row_plugin()) {
$rows = array();
foreach ($records as $label => $row) {
$rows[] = $this->row_plugin->render($row);
$this->view->row_index++;
}
}
else {
......@@ -165,6 +167,7 @@ class views_plugin_style extends views_plugin {
$output .= theme($this->theme_functions(), $this->view, $this->options, $rows, $title);
}
unset($this->view->row_index);
return $output;
}
......@@ -182,6 +185,7 @@ class views_plugin_style extends views_plugin {
function render_grouping($records, $grouping_field = '') {
$sets = array();
if ($grouping_field) {
$this->view->row_index = 0;
foreach ($records as $row) {
$grouping = '';
// Group on the rendered version of the field, not the raw. That way,
......@@ -189,12 +193,14 @@ class views_plugin_style extends views_plugin {
// the admin or theme layer or anywhere else we'd like.
if (isset($this->view->field[$grouping_field])) {
$grouping = $this->view->field[$grouping_field]->theme($row);
$this->view->row_index++;
if ($this->view->field[$grouping_field]->options['label']) {
$grouping = $this->view->field[$grouping_field]->options['label'] . ': ' . $grouping;
}
}
$sets[$grouping][] = $row;
}
unset($this->view->row_index);
}
else {
// Create a single group with an empty grouping field.
......
......@@ -302,12 +302,15 @@ function template_preprocess_views_view_table(&$vars) {
// Fields must be rendered in order as of Views 2.3, so we will pre-render
// everything.
$renders = array();
$view->row_index = 0;
$keys = array_keys($view->field);
foreach ($result as $count => $row) {
foreach ($keys as $id) {
$renders[$count][$id] = $view->field[$id]->theme($row);
}
$view->row_index = $count;
}
unset($view->row_index);
foreach ($columns as $field => $column) {
// render the header labels
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment