Lines 127 to 138 of includes/db_pager.inc:
// Change sort column direction
// in order asc->desc->none->asc
//
function sort_table($col)
{
$ord = $this->columns[$col]['ord'];
$ord = ($ord == '') ? 'asc' : (($ord == 'asc') ? 'desc' : '');
$this->columns[$col]['ord'] = $ord;
$this->set_page(1);
$this->query();
return true;
}
This clearly shows a $ord check for empty being retained as empty becoming ASC, a check for asc being set to DESC but if desc, no enforcement is done unless invoked by a click to be ASC. Hence Line 133:
$ord = ($ord == '') ? 'asc' : (($ord == 'asc') ? 'desc' : '');
should possibly be explicit in all it's redundant splendour (default being to capture any invalid declaration degrading gracefully) like:
switch ($ord) {
case 'asc':
$ord = 'desc';
break;
case 'desc':
case '':
$ord = 'asc';
break;
default:
$ord = 'asc';
}
Hence a setting of 'asc' in the code would result in a default display of DESC in this case as in the earlier one as well. This code fragment does not change any logic and is unnecessary and is placed for an understanding of how activation occurs on clicking only.
If there is a check for an initial value placed in the php page we should use that value to be the default when the $ord is empty thru' clicking route - thereafter, the clicked value of $ord will be available as asc or desc.
Lines 50-62 of includes/ui/db_pager_view.php:
foreach($pager->columns as $num_col=>$col) {
// record status control column is displayed only when control checkbox is on
if (isset($col['head']) && ($col['type']!='inactive' || get_post('show_inactive'))) {
if (!isset($col['ord']))
$headers[] = $col['head'];
else {
$icon = (($col['ord'] == 'desc') ? 'sort_desc.gif' :
($col['ord'] == 'asc' ? 'sort_asc.gif' : 'sort_none.gif'));
$headers[] = navi_button($pager->name.'_sort_'.$num_col,
$col['head'], true, $icon);
}
}
}
sets the sort image on the header correctly and checks used here can be used in the earlier code fragment to synch a similar behaviour.