Rearrange alphanav to better fit 3CL

This commit is contained in:
Zach Copley 2011-03-07 14:32:14 -08:00
parent 4b24f09ab4
commit b431a3b216
3 changed files with 14 additions and 5 deletions

View File

@ -121,7 +121,7 @@ class DirectoryPlugin extends Plugin
$m->connect(
'directory/users/:filter',
array('action' => 'userdirectory'),
array('filter' => '[0-9a-zA-Z_]{1,64}')
array('filter' => '([0-9a-zA-Z_]{1,64}|0-9)')
);
return true;

View File

@ -213,7 +213,7 @@ class UserdirectoryAction extends Action
$this->elementStart('div', array('id' => 'user_directory'));
$alphaNav = new AlphaNav($this, true, array('All'));
$alphaNav = new AlphaNav($this, false, false, array('0-9', 'All'));
$alphaNav->show();
$profile = null;
@ -320,7 +320,16 @@ class UserdirectoryAction extends Action
$sort = $this->getSortKey();
$sql = 'SELECT profile.* FROM profile, user WHERE profile.id = user.id';
if ($this->filter != 'all') {
switch($this->filter)
{
case 'all':
// NOOP
break;
case '0-9':
$sql .=
' AND LEFT(profile.nickname, 1) BETWEEN \'0\' AND \'9\'';
break;
default:
$sql .= sprintf(
' AND LEFT(LOWER(profile.nickname), 1) = \'%s\'',
$this->filter

View File

@ -75,11 +75,11 @@ class AlphaNav extends Widget
$this->filters = array_merge($this->filters, range(0, 9));
}
$this->filters = array_merge($this->filters, range('A', 'Z'));
if ($append) {
$this->filters = array_merge($this->filters, $append);
}
$this->filters = array_merge($this->filters, range('A', 'Z'));
}
/**