Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2891689
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
6 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/countdown/controller/PhabricatorCountdownListController.php b/src/applications/countdown/controller/PhabricatorCountdownListController.php
index 549b6a8705..2085a6884f 100644
--- a/src/applications/countdown/controller/PhabricatorCountdownListController.php
+++ b/src/applications/countdown/controller/PhabricatorCountdownListController.php
@@ -1,69 +1,27 @@
<?php
final class PhabricatorCountdownListController
- extends PhabricatorCountdownController
- implements PhabricatorApplicationSearchResultsControllerInterface {
+ extends PhabricatorCountdownController {
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;
- }
}
diff --git a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php
index ca843e2c2b..427485401f 100644
--- a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php
+++ b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php
@@ -1,96 +1,146 @@
<?php
final class PhabricatorCountdownSearchEngine
extends PhabricatorApplicationSearchEngine {
+ public function getApplicationClassName() {
+ return 'PhabricatorApplicationCountdown';
+ }
+
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
$saved->setParameter(
'authorPHIDs',
$this->readUsersFromRequest($request, 'authors'));
$saved->setParameter('upcoming', $request->getBool('upcoming'));
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new PhabricatorCountdownQuery());
$author_phids = $saved->getParameter('authorPHIDs', array());
if ($author_phids) {
$query->withAuthorPHIDs($author_phids);
}
if ($saved->getParameter('upcoming')) {
$query->withUpcoming(true);
}
return $query;
}
public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
$phids = $saved_query->getParameter('authorPHIDs', array());
$author_handles = id(new PhabricatorHandleQuery())
->setViewer($this->requireViewer())
->withPHIDs($phids)
->execute();
$upcoming = $saved_query->getParameter('upcoming');
$form
->appendChild(
id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/users/')
->setName('authors')
->setLabel(pht('Authors'))
->setValue($author_handles))
->appendChild(
id(new AphrontFormCheckboxControl())
->addCheckbox(
'upcoming',
1,
pht('Show only countdowns that are still counting down.'),
$upcoming));
}
protected function getURI($path) {
return '/countdown/'.$path;
}
public function getBuiltinQueryNames() {
$names = array(
'upcoming' => pht('Upcoming'),
'all' => pht('All'),
);
if ($this->requireViewer()->getPHID()) {
$names['authored'] = pht('Authored');
}
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
return $query;
case 'authored':
return $query->setParameter(
'authorPHIDs',
array($this->requireViewer()->getPHID()));
case 'upcoming':
return $query->setParameter('upcoming', true);
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
+
+ protected function getRequiredHandlePHIDsForResultList(
+ array $countdowns,
+ PhabricatorSavedQuery $query) {
+ return mpull($countdowns, 'getAuthorPHID');
+ }
+
+ protected function renderResultList(
+ array $countdowns,
+ PhabricatorSavedQuery $query,
+ array $handles) {
+ assert_instances_of($countdowns, 'PhabricatorCountdown');
+
+ $viewer = $this->requireViewer();
+
+ $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',
+ $handles[$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;
+ }
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 15:36 (3 w, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126058
Default Alt Text
(6 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment