private function _setDisplayPartsAndTotal($displayParts)
{
$the_total = 0;
// 1. Following variables are needed for use in isset/empty or
// use with array indexes or safe use in foreach
$db = $this->__get('db');
$table = $this->__get('table');
$unlim_num_rows = $this->__get('unlim_num_rows');
$num_rows = $this->__get('num_rows');
$printview = $this->__get('printview');
// 2. Updates the display parts
if ($printview == '1') {
$displayParts = $this->_setDisplayPartsForPrintView($displayParts);
} elseif ($this->__get('is_count') || $this->__get('is_analyse') || $this->__get('is_maint') || $this->__get('is_explain')) {
$displayParts = $this->_setDisplayPartsForNonData($displayParts);
} elseif ($this->__get('is_show')) {
$displayParts = $this->_setDisplayPartsForShow($displayParts);
} else {
$displayParts = $this->_setDisplayPartsForSelect($displayParts);
}
// end if..elseif...else
// 3. Gets the total number of rows if it is unknown
if (isset($unlim_num_rows) && $unlim_num_rows != '') {
$the_total = $unlim_num_rows;
} elseif (($displayParts['nav_bar'] == '1' || $displayParts['sort_lnk'] == '1') && (strlen($db) > 0 && strlen($table) > 0)) {
$the_total = $GLOBALS['dbi']->getTable($db, $table)->countRecords();
}
// if for COUNT query, number of rows returned more than 1
// (may be being used GROUP BY)
if ($this->__get('is_count') && isset($num_rows) && $num_rows > 1) {
$displayParts['nav_bar'] = (string) '1';
$displayParts['sort_lnk'] = (string) '1';
}
// 4. If navigation bar or sorting fields names URLs should be
// displayed but there is only one row, change these settings to
// false
if ($displayParts['nav_bar'] == '1' || $displayParts['sort_lnk'] == '1') {
// - Do not display sort links if less than 2 rows.
// - For a VIEW we (probably) did not count the number of rows
// so don't test this number here, it would remove the possibility
// of sorting VIEW results.
$_table = new Table($table, $db);
if (isset($unlim_num_rows) && $unlim_num_rows < 2 && !$_table->isView()) {
$displayParts['sort_lnk'] = (string) '0';
}
}
// end if (3)
return array($displayParts, $the_total);
}