From a63274289c896c3a851ec4045c172468a6b5aa06 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 2 Jun 2011 17:13:25 -0700 Subject: [PATCH] Link macro thumbs and show an exact page count Summary: Some of the improvements from T175: link macro thumbnails to the full image, and pull an exact count out of the database. Test Plan: Clicked a thumb, looked at pager. Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen, tomo CC: aran, tuomaspelkonen Differential Revision: 397 --- .../PhabricatorFileMacroListController.php | 28 +++++++++++++++---- .../files/controller/macrolist/__init__.php | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/applications/files/controller/macrolist/PhabricatorFileMacroListController.php b/src/applications/files/controller/macrolist/PhabricatorFileMacroListController.php index 47c7eb3918..1cea7a2abe 100644 --- a/src/applications/files/controller/macrolist/PhabricatorFileMacroListController.php +++ b/src/applications/files/controller/macrolist/PhabricatorFileMacroListController.php @@ -25,12 +25,21 @@ class PhabricatorFileMacroListController extends PhabricatorFileController { $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); - $macros = id(new PhabricatorFileImageMacro())->loadAllWhere( + $macro_table = new PhabricatorFileImageMacro(); + $macros = $macro_table->loadAllWhere( '1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), - $pager->getPageSize() + 1); + $pager->getPageSize()); - $macros = $pager->sliceResults($macros); + // Get an exact count since the size here is reasonably going to be a few + // thousand at most in any reasonable case. + $count = queryfx_one( + $macro_table->establishConnection('r'), + 'SELECT COUNT(*) N FROM %T', + $macro_table->getTableName()); + $count = $count['N']; + + $pager->setCount($count); $pager->setURI($request->getRequestURI(), 'page'); $rows = array(); @@ -44,10 +53,16 @@ class PhabricatorFileMacroListController extends PhabricatorFileController { ), phutil_escape_html($macro->getName())), phutil_render_tag( - 'img', + 'a', array( - 'src' => $src, - )), + 'href' => $src, + 'target' => '_blank', + ), + phutil_render_tag( + 'img', + array( + 'src' => $src, + ))), javelin_render_tag( 'a', array( @@ -75,6 +90,7 @@ class PhabricatorFileMacroListController extends PhabricatorFileController { $panel = new AphrontPanelView(); $panel->appendChild($table); + $panel->setHeader('Image Macros'); $panel->setCreateButton('New Image Macro', '/file/macro/edit/'); $panel->appendChild($pager); diff --git a/src/applications/files/controller/macrolist/__init__.php b/src/applications/files/controller/macrolist/__init__.php index 46fa4fc887..ff62074ed8 100644 --- a/src/applications/files/controller/macrolist/__init__.php +++ b/src/applications/files/controller/macrolist/__init__.php @@ -10,12 +10,12 @@ phutil_require_module('phabricator', 'applications/files/controller/base'); phutil_require_module('phabricator', 'applications/files/storage/imagemacro'); phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'infrastructure/javelin/markup'); +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/layout/panel'); phutil_require_module('phutil', 'markup'); -phutil_require_module('phutil', 'utils'); phutil_require_source('PhabricatorFileMacroListController.php');