1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Paginate the user list view.

This commit is contained in:
epriestley 2011-04-02 09:58:19 -07:00
parent 313da1d5eb
commit 29ce4ed83f
3 changed files with 27 additions and 15 deletions

View file

@ -19,8 +19,25 @@
class PhabricatorPeopleListController extends PhabricatorPeopleController { class PhabricatorPeopleListController extends PhabricatorPeopleController {
public function processRequest() { public function processRequest() {
$request = $this->getRequest();
$user = new PhabricatorUser();
$count = queryfx_one(
$user->establishConnection('r'),
'SELECT COUNT(*) N FROM %T',
$user->getTableName());
$count = idx($count, 'N', 0);
$pager = new AphrontPagerView();
$pager->setOffset($request->getInt('page', 0));
$pager->setCount($count);
$pager->setURI($request->getRequestURI(), 'page');
$users = id(new PhabricatorUser())->loadAllWhere( $users = id(new PhabricatorUser())->loadAllWhere(
'1 = 1 ORDER BY id DESC LIMIT 100'); '1 = 1 ORDER BY id DESC LIMIT %d, %d',
$pager->getOffset(),
$pager->getPageSize());
$rows = array(); $rows = array();
foreach ($users as $user) { foreach ($users as $user) {
@ -35,15 +52,6 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
'href' => '/p/'.$user->getUsername().'/', 'href' => '/p/'.$user->getUsername().'/',
), ),
'View Profile'), 'View Profile'),
/*
phutil_render_tag(
'a',
array(
'class' => 'button grey small',
'href' => '/people/edit/'.$user->getUsername().'/',
),
'Edit'),
*/
); );
} }
@ -54,7 +62,6 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
'Username', 'Username',
'Real Name', 'Real Name',
'', '',
// '',
)); ));
$table->setColumnClasses( $table->setColumnClasses(
array( array(
@ -62,13 +69,12 @@ class PhabricatorPeopleListController extends PhabricatorPeopleController {
null, null,
'wide', 'wide',
'action', 'action',
// 'action',
)); ));
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->appendChild($table);
$panel->setHeader('People'); $panel->setHeader('People');
// $panel->setCreateButton('Create New User', '/people/edit/'); $panel->appendChild($table);
$panel->appendChild($pager);
return $this->buildStandardPageResponse($panel, array( return $this->buildStandardPageResponse($panel, array(
'title' => 'People', 'title' => 'People',

View file

@ -8,6 +8,8 @@
phutil_require_module('phabricator', 'applications/people/controller/base'); phutil_require_module('phabricator', 'applications/people/controller/base');
phutil_require_module('phabricator', 'applications/people/storage/user'); phutil_require_module('phabricator', 'applications/people/storage/user');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/control/pager');
phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel'); phutil_require_module('phabricator', 'view/layout/panel');

View file

@ -19,7 +19,7 @@
final class AphrontPagerView extends AphrontView { final class AphrontPagerView extends AphrontView {
private $offset; private $offset;
private $pageSize; private $pageSize = 100;
private $count; private $count;
private $hasMorePages; private $hasMorePages;
@ -81,6 +81,10 @@ final class AphrontPagerView extends AphrontView {
} }
public function render() { public function render() {
if (!$this->uri) {
throw new Exception(
"You must call setURI() before you can call render().");
}
require_celerity_resource('aphront-pager-view-css'); require_celerity_resource('aphront-pager-view-css');