1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +01:00

Add a pager to "Files"

Summary:
Adds a pager control to the "Files" tool so you can page through files if there
are >100.

Test Plan:
Set page size to a smaller number, paged through files.

Reviewed By: aran
Reviewers: aran, tuomaspelkonen, jungejason
CC: aran
Differential Revision: 211
This commit is contained in:
epriestley 2011-05-02 08:53:08 -07:00
parent 7ca4835438
commit 59cd14bc61
2 changed files with 18 additions and 1 deletions

View file

@ -19,8 +19,23 @@
class PhabricatorFileListController extends PhabricatorFileController {
public function processRequest() {
$request = $this->getRequest();
$pager = new AphrontPagerView();
$pager->setOffset($request->getInt('page'));
$files = id(new PhabricatorFile())->loadAllWhere(
'1 = 1 ORDER BY id DESC LIMIT 100');
'1 = 1 ORDER BY id DESC LIMIT %d, %d',
$pager->getOffset(),
$pager->getPageSize() + 1);
if (count($files) > $pager->getPageSize()) {
$files = array_slice($files, 0, $pager->getPageSize(), true);
$pager->setHasMorePages(true);
}
$pager->setURI($request->getRequestURI(), 'page');
$rows = array();
foreach ($files as $file) {
@ -81,6 +96,7 @@ class PhabricatorFileListController extends PhabricatorFileController {
$panel->appendChild($table);
$panel->setHeader('Files');
$panel->setCreateButton('Upload File', '/file/upload/');
$panel->appendChild($pager);
return $this->buildStandardPageResponse($panel, array(
'title' => 'Files',

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'applications/files/controller/base');
phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'view/control/pager');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');