forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorCountdownListController.php
69 lines (53 loc) · 1.81 KB
/
PhabricatorCountdownListController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
final class PhabricatorCountdownListController
extends PhabricatorCountdownController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new PhabricatorCountdownSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function renderResultsList(
array $countdowns,
PhabricatorSavedQuery $query) {
assert_instances_of($countdowns, 'PhabricatorCountdown');
$viewer = $this->getRequest()->getUser();
$this->loadHandles(mpull($countdowns, 'getAuthorPHID'));
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($countdowns as $countdown) {
$id = $countdown->getID();
$item = id(new PHUIObjectItemView())
->setObjectName("C{$id}")
->setHeader($countdown->getTitle())
->setHref($this->getApplicationURI("{$id}/"))
->addByline(
pht(
'Created by %s',
$this->getHandle($countdown->getAuthorPHID())->renderLink()));
$epoch = $countdown->getEpoch();
if ($epoch >= time()) {
$item->addIcon(
'none',
pht('Ends %s', phabricator_datetime($epoch, $viewer)));
} else {
$item->addIcon(
'delete',
pht('Ended %s', phabricator_datetime($epoch, $viewer)));
$item->setDisabled(true);
}
$list->addItem($item);
}
return $list;
}
}