1.20.x views_handler_area_result.inc | views_handler_area_result::render($empty = FALSE) |
Find out the information to render.
Overrides views_handler_area::render
File
- modules/
views/ handlers/ views_handler_area_result.inc, line 54 - Definition of views_handler_area_result.
Class
- views_handler_area_result
- Views area handler to display some configurable result summary.
Code
function render($empty = FALSE) {
// Must have options and does not work on summaries.
if (!isset($this->options['content']) || $this->view->plugin_name == 'default_summary') {
return;
}
$output = '';
$format = $this->options['content'];
// Calculate the page totals.
$current_page = (int) $this->view->get_current_page() + 1;
$per_page = (int) $this->view->get_items_per_page();
$count = count($this->view->result);
// @TODO: Maybe use a possible is views empty functionality.
// Not every view has total_rows set, use view->result instead.
$total = isset($this->view->total_rows) ? $this->view->total_rows : count($this->view->result);
$name = check_plain($this->view->human_name);
if ($per_page === 0) {
$page_count = 1;
$start = 1;
$end = $total;
}
else {
$page_count = (int) ceil($total / $per_page);
$total_count = $current_page * $per_page;
if ($total_count > $total) {
$total_count = $total;
}
$start = ($current_page - 1) * $per_page + 1;
$end = $total_count;
}
$current_record_count = ($end - $start) + 1;
// Get the search information.
$items = array('start', 'end', 'total', 'name', 'per_page', 'current_page', 'current_record_count', 'page_count');
$replacements = array();
foreach ($items as $item) {
$replacements["@$item"] =${$item};
}
// Send the output.
if (!empty($total)) {
$output .= filter_xss_admin(str_replace(array_keys($replacements), array_values($replacements), $format));
}
return $output;
}