1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Add author field to image macro display

Summary:
this is a request from Facebook:
> someone has added macros for common words like 'push', 'lgtm'.
> We want to let he image macro page at least attribute to an owner so
> that we can publicly shame whoever added the 800px 'clowntown' macro.

Test Plan:
test macros with/without author (all macro should have
author. This is just to be safe).

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: hwang, aran, arice, jungejason, epriestley

Differential Revision: 984
This commit is contained in:
Jason Ge 2011-10-04 23:05:40 -07:00
parent a8519c6837
commit ce8799176e
2 changed files with 20 additions and 0 deletions

View file

@ -42,9 +42,22 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
$pager->setCount($count);
$pager->setURI($request->getRequestURI(), 'page');
$file_phids = mpull($macros, 'getFilePHID');
$files = id(new PhabricatorFile())->loadAllWhere(
"phid IN (%Ls)",
$file_phids);
$author_phids = mpull($files, 'getAuthorPHID', 'getPHID');
$handles = id(new PhabricatorObjectHandleData($author_phids))
->loadHandles();
$rows = array();
foreach ($macros as $macro) {
$src = PhabricatorFileURI::getViewURIForPHID($macro->getFilePHID());
$file_phid = $macro->getFilePHID();
$author_link = isset($author_phids[$file_phid])
? $handles[$author_phids[$file_phid]]->renderLink()
: null;
$rows[] = array(
phutil_render_tag(
'a',
@ -52,6 +65,8 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
'href' => '/file/macro/edit/'.$macro->getID().'/',
),
phutil_escape_html($macro->getName())),
$author_link,
phutil_render_tag(
'a',
array(
@ -78,12 +93,14 @@ class PhabricatorFileMacroListController extends PhabricatorFileController {
$table->setHeaders(
array(
'Name',
'Author',
'Image',
'',
));
$table->setColumnClasses(
array(
'pri',
'',
'wide thumb',
'action',
));

View file

@ -7,8 +7,10 @@
phutil_require_module('phabricator', 'applications/files/controller/base');
phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/files/storage/imagemacro');
phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/javelin/markup');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/control/pager');
@ -16,6 +18,7 @@ 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');