diff --git a/src/applications/files/controller/list/PhabricatorFileListController.php b/src/applications/files/controller/list/PhabricatorFileListController.php index 0fa1f718ba..3820ba8d78 100644 --- a/src/applications/files/controller/list/PhabricatorFileListController.php +++ b/src/applications/files/controller/list/PhabricatorFileListController.php @@ -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', diff --git a/src/applications/files/controller/list/__init__.php b/src/applications/files/controller/list/__init__.php index 91678ceb0e..3bdf0dba19 100644 --- a/src/applications/files/controller/list/__init__.php +++ b/src/applications/files/controller/list/__init__.php @@ -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');