1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

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
This commit is contained in:
epriestley 2011-06-02 17:13:25 -07:00
parent f505584809
commit a63274289c
2 changed files with 23 additions and 7 deletions

View file

@ -25,12 +25,21 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
$pager = new AphrontPagerView(); $pager = new AphrontPagerView();
$pager->setOffset($request->getInt('page')); $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', '1 = 1 ORDER BY id DESC LIMIT %d, %d',
$pager->getOffset(), $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'); $pager->setURI($request->getRequestURI(), 'page');
$rows = array(); $rows = array();
@ -44,10 +53,16 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
), ),
phutil_escape_html($macro->getName())), phutil_escape_html($macro->getName())),
phutil_render_tag( phutil_render_tag(
'img', 'a',
array( array(
'src' => $src, 'href' => $src,
)), 'target' => '_blank',
),
phutil_render_tag(
'img',
array(
'src' => $src,
))),
javelin_render_tag( javelin_render_tag(
'a', 'a',
array( array(
@ -75,6 +90,7 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->appendChild($table); $panel->appendChild($table);
$panel->setHeader('Image Macros'); $panel->setHeader('Image Macros');
$panel->setCreateButton('New Image Macro', '/file/macro/edit/'); $panel->setCreateButton('New Image Macro', '/file/macro/edit/');
$panel->appendChild($pager); $panel->appendChild($pager);

View file

@ -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/storage/imagemacro');
phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'infrastructure/javelin/markup'); 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/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');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorFileMacroListController.php'); phutil_require_source('PhabricatorFileMacroListController.php');