public function views_aggregator_plugin_style_table::build_sort_post in Views Aggregator Plus 7
Records the "active" field, i.e. the column clicked to be sorted.
Also records the sort order ('asc' or 'desc'). This is identical to views_plugin_style_table::build_sort_post(), except for the last statement, which has a condition added.
Overrides views_plugin_style_table::build_sort_post
File
Class
- views_aggregator_plugin_style_table
- Style plugin to render each item as a row in a table.
Code
public function build_sort_post() {
if (!isset($_GET['order'])) {
// Check for a 'default' clicksort. If there isn't one, exit gracefully.
if (empty($this->options['default'])) {
return;
}
$sort = $this->options['default'];
if (!empty($this->options['info'][$sort]['default_sort_order'])) {
$this->order = $this->options['info'][$sort]['default_sort_order'];
}
else {
$this->order = !empty($this->options['order']) ? $this->options['order'] : 'asc';
}
}
else {
$sort = $_GET['order'];
// Store the $order for later use.
$this->order = !empty($_GET['sort']) ? strtolower($_GET['sort']) : 'asc';
}
// If a sort we don't know about gets through, exit gracefully.
if (empty($this->view->field[$sort])) {
return;
}
// Ensure $this->order is valid.
if ($this->order != 'asc' && $this->order != 'desc') {
$this->order = 'asc';
}
// Store the $sort and sortable flag for later use.
$this->active = $sort;
//$this->sortable = $this->options['info'][$sort]['sortable'];
// Tell the field to click-sort, but only if it is not a Math Expression or
// a field not aggregated, in which cases sorting will be dealt with in
// $this->pre_render().
// This is here predominantly to avoid notices from ViewsPHP, but also
// makes normal column sorting more efficient by not adding any unnecessary
// WHERE-clauses, if paging is OFF.
// @todo Refine this logic
if (!is_a($this->view->field[$sort], 'views_handler_field_math')) {
$this->view->field[$sort]
->click_sort($this->order);
}
}