1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-13 18:32:41 +01:00
phorge-phorge/src/applications/tokens/controller/PhabricatorTokenLeaderController.php

59 lines
1.5 KiB
PHP
Raw Normal View History

<?php
final class PhabricatorTokenLeaderController
extends PhabricatorTokenController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$pager = id(new AphrontCursorPagerView())
->readFromRequest($request);
$query = id(new PhabricatorTokenReceiverQuery());
$objects = $query->setViewer($user)->execute();
$counts = $query->getTokenCounts();
$handles = array();
if ($counts) {
$phids = mpull($objects, 'getPHID');
$handles = id(new PhabricatorObjectHandleData($phids))
->setViewer($user)
->loadHandles();
}
$list = new PhabricatorObjectItemListView();
foreach ($phids as $object) {
$count = idx($counts, $object, 0);
$item = id(new PhabricatorObjectItemView());
$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');
$nav = $this->buildSideNav();
$nav->setCrumbs(
$this->buildApplicationCrumbs()
->addCrumb(
id(new PhabricatorCrumbView())
->setName($title)));
$nav->selectFilter('leaders/');
$nav->appendChild($list);
$nav->appendChild($pager);
return $this->buildApplicationPage(
$nav,
array(
'title' => $title,
'device' => true,
'dust' => true
));
}
}