2013-03-22 00:04:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorTokenLeaderController
|
2014-04-22 00:33:07 +02:00
|
|
|
extends PhabricatorTokenController {
|
|
|
|
|
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
2013-03-22 00:04:29 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
2013-04-01 17:15:23 +02:00
|
|
|
|
|
|
|
$pager = new AphrontPagerView();
|
|
|
|
$pager->setURI($request->getRequestURI(), 'page');
|
|
|
|
$pager->setOffset($request->getInt('page'));
|
2013-03-22 00:04:29 +01:00
|
|
|
|
|
|
|
$query = id(new PhabricatorTokenReceiverQuery());
|
2013-04-01 17:15:23 +02:00
|
|
|
$objects = $query->setViewer($user)->executeWithOffsetPager($pager);
|
2013-03-22 00:04:29 +01:00
|
|
|
$counts = $query->getTokenCounts();
|
|
|
|
|
|
|
|
$handles = array();
|
2013-05-23 20:58:23 +02:00
|
|
|
$phids = array();
|
2013-03-22 00:04:29 +01:00
|
|
|
if ($counts) {
|
|
|
|
$phids = mpull($objects, 'getPHID');
|
2013-09-11 21:27:28 +02:00
|
|
|
$handles = id(new PhabricatorHandleQuery())
|
2013-03-22 00:04:29 +01:00
|
|
|
->setViewer($user)
|
2013-09-11 21:27:28 +02:00
|
|
|
->withPHIDs($phids)
|
|
|
|
->execute();
|
2013-03-22 00:04:29 +01:00
|
|
|
}
|
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$list = new PHUIObjectItemListView();
|
2015-01-28 18:33:49 +01:00
|
|
|
$list->setStackable(true);
|
2013-03-22 00:04:29 +01:00
|
|
|
foreach ($phids as $object) {
|
|
|
|
$count = idx($counts, $object, 0);
|
2013-09-09 23:14:34 +02:00
|
|
|
$item = id(new PHUIObjectItemView());
|
2013-03-22 00:04:29 +01:00
|
|
|
$handle = $handles[$object];
|
|
|
|
|
|
|
|
$item->setHeader($handle->getFullName());
|
|
|
|
$item->setHref($handle->getURI());
|
|
|
|
$item->addAttribute(pht('Tokens: %s', $count));
|
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = pht('Token Leader Board');
|
|
|
|
|
2015-01-28 18:33:49 +01:00
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText($title)
|
|
|
|
->appendChild($list);
|
|
|
|
|
2013-03-22 00:04:29 +01:00
|
|
|
$nav = $this->buildSideNav();
|
|
|
|
$nav->setCrumbs(
|
|
|
|
$this->buildApplicationCrumbs()
|
2013-12-19 02:47:34 +01:00
|
|
|
->addTextCrumb($title));
|
2013-03-22 00:04:29 +01:00
|
|
|
$nav->selectFilter('leaders/');
|
|
|
|
|
2015-01-28 18:33:49 +01:00
|
|
|
$nav->appendChild($box);
|
2013-03-22 00:04:29 +01:00
|
|
|
$nav->appendChild($pager);
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
$nav,
|
|
|
|
array(
|
|
|
|
'title' => $title,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|