Skip to content

Instantly share code, notes, and snippets.

@FMCorz
Created August 11, 2015 05:54
Show Gist options
  • Save FMCorz/341229234894bdfb7eb4 to your computer and use it in GitHub Desktop.
Save FMCorz/341229234894bdfb7eb4 to your computer and use it in GitHub Desktop.
<?php
/**
* Gets the sort direction for a given field
*
* @param string $field
* @return string ASC or DESC
*/
public function get_field_sort_direction($field) {
$dir = $this->sortdirection || self::DEFAULTSORTDIRECTION;
if ($field == $this->sort) {
$dir = ($dir == 'ASC') ? 'DESC' : 'ASC';
}
if ($field == 'lastaccess') {
$dir = ($dir == 'ASC') ? 'DESC' : 'ASC';
}
return self::DEFAULTSORTDIRECTION;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment