From 352d9f6b06d539705b7733e90443ee13fbcabe60 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 9 May 2014 12:25:52 -0700 Subject: [PATCH] Move more rendering into SearchEngines for panels Summary: Ref T4986. Getting closer. Nothing out of the ordinary in this group. Test Plan: For each application: - Viewed the normal search results. - Created a panel version and viewed it. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4986 Differential Revision: https://secure.phabricator.com/D9024 --- src/__phutil_library_map__.php | 72 +++------------ .../HeraldTranscriptListController.php | 48 +--------- .../query/HeraldTranscriptSearchEngine.php | 47 ++++++++++ .../LegalpadDocumentListController.php | 41 +-------- .../query/LegalpadDocumentSearchEngine.php | 45 +++++++++- .../PhabricatorMacroListController.php | 63 +------------ .../query/PhabricatorMacroSearchEngine.php | 65 ++++++++++++++ .../PhabricatorMailingListsListController.php | 27 +----- .../PhabricatorMailingListSearchEngine.php | 29 ++++++ .../PhabricatorApplicationsListController.php | 32 +------ .../meta/query/PhabricatorAppSearchEngine.php | 34 +++++++ .../PhabricatorOAuthClientListController.php | 29 +----- ...abricatorOAuthServerClientSearchEngine.php | 37 ++++++++ .../PassphraseCredentialListController.php | 40 +-------- .../PassphraseCredentialSearchEngine.php | 43 +++++++++ .../PhabricatorApplicationPholio.php | 3 - .../controller/PholioMockListController.php | 40 +-------- .../pholio/query/PholioMockSearchEngine.php | 41 +++++++++ .../controller/PhrequentListController.php | 85 +----------------- .../phrequent/query/PhrequentSearchEngine.php | 89 +++++++++++++++++++ .../controller/PhrictionListController.php | 67 +------------- .../phriction/query/PhrictionSearchEngine.php | 71 +++++++++++++++ .../PonderQuestionListController.php | 45 +--------- .../query/PonderQuestionSearchEngine.php | 47 ++++++++++ .../PhabricatorProjectListController.php | 30 +------ .../query/PhabricatorProjectSearchEngine.php | 32 +++++++ 26 files changed, 601 insertions(+), 601 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 3e1a46e635..df17f25db0 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3507,11 +3507,7 @@ phutil_register_library_map(array( ), 'HeraldTranscriptController' => 'HeraldController', 'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector', - 'HeraldTranscriptListController' => - array( - 0 => 'HeraldController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'HeraldTranscriptListController' => 'HeraldController', 'HeraldTranscriptQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HeraldTranscriptSearchEngine' => 'PhabricatorApplicationSearchEngine', 'HeraldTranscriptTestCase' => 'PhabricatorTestCase', @@ -3538,11 +3534,7 @@ phutil_register_library_map(array( 'LegalpadDocumentCommentController' => 'LegalpadController', 'LegalpadDocumentEditController' => 'LegalpadController', 'LegalpadDocumentEditor' => 'PhabricatorApplicationTransactionEditor', - 'LegalpadDocumentListController' => - array( - 0 => 'LegalpadController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'LegalpadDocumentListController' => 'LegalpadController', 'LegalpadDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'LegalpadDocumentRemarkupRule' => 'PhabricatorRemarkupRuleObject', 'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine', @@ -3777,11 +3769,7 @@ phutil_register_library_map(array( 'PassphraseCredentialCreateController' => 'PassphraseController', 'PassphraseCredentialDestroyController' => 'PassphraseController', 'PassphraseCredentialEditController' => 'PassphraseController', - 'PassphraseCredentialListController' => - array( - 0 => 'PassphraseController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PassphraseCredentialListController' => 'PassphraseController', 'PassphraseCredentialLockController' => 'PassphraseController', 'PassphraseCredentialPublicController' => 'PassphraseController', 'PassphraseCredentialQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', @@ -3931,11 +3919,7 @@ phutil_register_library_map(array( 'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController', 'PhabricatorApplicationXHProf' => 'PhabricatorApplication', 'PhabricatorApplicationsController' => 'PhabricatorController', - 'PhabricatorApplicationsListController' => - array( - 0 => 'PhabricatorApplicationsController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhabricatorApplicationsListController' => 'PhabricatorApplicationsController', 'PhabricatorAsanaConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController', 'PhabricatorAuditComment' => @@ -4456,11 +4440,7 @@ phutil_register_library_map(array( 'PhabricatorMacroDisableController' => 'PhabricatorMacroController', 'PhabricatorMacroEditController' => 'PhabricatorMacroController', 'PhabricatorMacroEditor' => 'PhabricatorApplicationTransactionEditor', - 'PhabricatorMacroListController' => - array( - 0 => 'PhabricatorMacroController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhabricatorMacroListController' => 'PhabricatorMacroController', 'PhabricatorMacroMailReceiver' => 'PhabricatorObjectMailReceiver', 'PhabricatorMacroMemeController' => 'PhabricatorMacroController', 'PhabricatorMacroMemeDialogController' => 'PhabricatorMacroController', @@ -4493,11 +4473,7 @@ phutil_register_library_map(array( 'PhabricatorMailingListSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorMailingListsController' => 'PhabricatorController', 'PhabricatorMailingListsEditController' => 'PhabricatorMailingListsController', - 'PhabricatorMailingListsListController' => - array( - 0 => 'PhabricatorMailingListsController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhabricatorMailingListsListController' => 'PhabricatorMailingListsController', 'PhabricatorMainMenuGroupView' => 'AphrontView', 'PhabricatorMainMenuIconView' => 'AphrontView', 'PhabricatorMainMenuSearchView' => 'AphrontView', @@ -4560,11 +4536,7 @@ phutil_register_library_map(array( 'PhabricatorOAuthClientBaseController' => 'PhabricatorOAuthServerController', 'PhabricatorOAuthClientDeleteController' => 'PhabricatorOAuthClientBaseController', 'PhabricatorOAuthClientEditController' => 'PhabricatorOAuthClientBaseController', - 'PhabricatorOAuthClientListController' => - array( - 0 => 'PhabricatorOAuthClientBaseController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhabricatorOAuthClientListController' => 'PhabricatorOAuthClientBaseController', 'PhabricatorOAuthClientViewController' => 'PhabricatorOAuthClientBaseController', 'PhabricatorOAuthResponse' => 'AphrontResponse', 'PhabricatorOAuthServerAccessToken' => 'PhabricatorOAuthServerDAO', @@ -4758,11 +4730,7 @@ phutil_register_library_map(array( 'PhabricatorProjectEditMainController' => 'PhabricatorProjectController', 'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController', 'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase', - 'PhabricatorProjectListController' => - array( - 0 => 'PhabricatorProjectController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhabricatorProjectListController' => 'PhabricatorProjectController', 'PhabricatorProjectMembersEditController' => 'PhabricatorProjectController', 'PhabricatorProjectMembersRemoveController' => 'PhabricatorProjectController', 'PhabricatorProjectMoveController' => 'PhabricatorProjectController', @@ -5278,11 +5246,7 @@ phutil_register_library_map(array( 'PholioMockEditor' => 'PhabricatorApplicationTransactionEditor', 'PholioMockEmbedView' => 'AphrontView', 'PholioMockImagesView' => 'AphrontView', - 'PholioMockListController' => - array( - 0 => 'PholioController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PholioMockListController' => 'PholioController', 'PholioMockMailReceiver' => 'PhabricatorObjectMailReceiver', 'PholioMockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PholioMockSearchEngine' => 'PhabricatorApplicationSearchEngine', @@ -5396,11 +5360,7 @@ phutil_register_library_map(array( 'PhragmentZIPController' => 'PhragmentController', 'PhrequentController' => 'PhabricatorController', 'PhrequentDAO' => 'PhabricatorLiskDAO', - 'PhrequentListController' => - array( - 0 => 'PhrequentController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhrequentListController' => 'PhrequentController', 'PhrequentSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhrequentTimeBlock' => 'Phobject', 'PhrequentTimeBlockTestCase' => 'PhabricatorTestCase', @@ -5440,11 +5400,7 @@ phutil_register_library_map(array( 'PhrictionDocumentTestCase' => 'PhabricatorTestCase', 'PhrictionEditController' => 'PhrictionController', 'PhrictionHistoryController' => 'PhrictionController', - 'PhrictionListController' => - array( - 0 => 'PhrictionController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PhrictionListController' => 'PhrictionController', 'PhrictionMoveController' => 'PhrictionController', 'PhrictionNewController' => 'PhrictionController', 'PhrictionPHIDTypeDocument' => 'PhabricatorPHIDType', @@ -5496,11 +5452,7 @@ phutil_register_library_map(array( 'PonderQuestionEditController' => 'PonderController', 'PonderQuestionEditor' => 'PonderEditor', 'PonderQuestionHistoryController' => 'PonderController', - 'PonderQuestionListController' => - array( - 0 => 'PonderController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', - ), + 'PonderQuestionListController' => 'PonderController', 'PonderQuestionMailReceiver' => 'PhabricatorObjectMailReceiver', 'PonderQuestionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PonderQuestionReplyHandler' => 'PhabricatorMailReplyHandler', diff --git a/src/applications/herald/controller/HeraldTranscriptListController.php b/src/applications/herald/controller/HeraldTranscriptListController.php index e77c7be30e..dfa79e252e 100644 --- a/src/applications/herald/controller/HeraldTranscriptListController.php +++ b/src/applications/herald/controller/HeraldTranscriptListController.php @@ -1,7 +1,6 @@ delegateToController($controller); } - - public function renderResultsList( - array $transcripts, - PhabricatorSavedQuery $query) { - assert_instances_of($transcripts, 'HeraldTranscript'); - - $viewer = $this->getRequest()->getUser(); - - // Render the table. - $handles = array(); - if ($transcripts) { - $phids = mpull($transcripts, 'getObjectPHID', 'getObjectPHID'); - $handles = $this->loadViewerHandles($phids); - } - - $list = new PHUIObjectItemListView(); - $list->setCards(true); - foreach ($transcripts as $xscript) { - $view_href = phutil_tag( - 'a', - array( - 'href' => '/herald/transcript/'.$xscript->getID().'/', - ), - pht('View Full Transcript')); - - $item = new PHUIObjectItemView(); - $item->setObjectName($xscript->getID()); - $item->setHeader($view_href); - if ($xscript->getDryRun()) { - $item->addAttribute(pht('Dry Run')); - } - $item->addAttribute($handles[$xscript->getObjectPHID()]->renderLink()); - $item->addAttribute( - number_format((int)(1000 * $xscript->getDuration())).' ms'); - $item->addIcon( - 'none', - phabricator_datetime($xscript->getTime(), $viewer)); - - $list->addItem($item); - } - - return $list; - - } - } diff --git a/src/applications/herald/query/HeraldTranscriptSearchEngine.php b/src/applications/herald/query/HeraldTranscriptSearchEngine.php index 4fa6667ced..7b17f89608 100644 --- a/src/applications/herald/query/HeraldTranscriptSearchEngine.php +++ b/src/applications/herald/query/HeraldTranscriptSearchEngine.php @@ -3,6 +3,10 @@ final class HeraldTranscriptSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationHerald'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); @@ -89,4 +93,47 @@ final class HeraldTranscriptSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function getRequiredHandlePHIDsForResultList( + array $transcripts, + PhabricatorSavedQuery $query) { + return mpull($transcripts, 'getObjectPHID'); + } + + protected function renderResultList( + array $transcripts, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($transcripts, 'HeraldTranscript'); + + $viewer = $this->requireViewer(); + + $list = new PHUIObjectItemListView(); + $list->setCards(true); + foreach ($transcripts as $xscript) { + $view_href = phutil_tag( + 'a', + array( + 'href' => '/herald/transcript/'.$xscript->getID().'/', + ), + pht('View Full Transcript')); + + $item = new PHUIObjectItemView(); + $item->setObjectName($xscript->getID()); + $item->setHeader($view_href); + if ($xscript->getDryRun()) { + $item->addAttribute(pht('Dry Run')); + } + $item->addAttribute($handles[$xscript->getObjectPHID()]->renderLink()); + $item->addAttribute( + number_format((int)(1000 * $xscript->getDuration())).' ms'); + $item->addIcon( + 'none', + phabricator_datetime($xscript->getTime(), $viewer)); + + $list->addItem($item); + } + + return $list; + } + } diff --git a/src/applications/legalpad/controller/LegalpadDocumentListController.php b/src/applications/legalpad/controller/LegalpadDocumentListController.php index ba334bcaf3..20c425d2d8 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentListController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentListController.php @@ -1,10 +1,6 @@ delegateToController($controller); } - public function renderResultsList( - array $documents, - PhabricatorSavedQuery $query) { - assert_instances_of($documents, 'LegalpadDocument'); - - $user = $this->getRequest()->getUser(); - - $contributors = array_mergev( - mpull($documents, 'getRecentContributorPHIDs')); - $this->loadHandles($contributors); - - $list = new PHUIObjectItemListView(); - $list->setUser($user); - foreach ($documents as $document) { - $last_updated = phabricator_date($document->getDateModified(), $user); - $recent_contributors = $document->getRecentContributorPHIDs(); - $updater = $this->getHandle(reset($recent_contributors))->renderLink(); - - $title = $document->getTitle(); - - $item = id(new PHUIObjectItemView()) - ->setObjectName('L'.$document->getID()) - ->setHeader($title) - ->setHref($this->getApplicationURI('view/'.$document->getID())) - ->setObject($document) - ->addIcon('none', pht('Last updated: %s', $last_updated)) - ->addByline(pht('Updated by: %s', $updater)) - ->addAttribute(pht('Versions: %d', $document->getVersions())); - - $list->addItem($item); - } - - return $list; - } - } diff --git a/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php b/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php index 5d11671ab9..cafe4cf67d 100644 --- a/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php +++ b/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php @@ -1,11 +1,12 @@ setParameter( @@ -103,4 +104,42 @@ final class LegalpadDocumentSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function getRequiredHandlePHIDsForResultList( + array $documents, + PhabricatorSavedQuery $query) { + return array_mergev(mpull($documents, 'getRecentContributorPHIDs')); + } + + protected function renderResultList( + array $documents, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($documents, 'LegalpadDocument'); + + $viewer = $this->requireViewer(); + + $list = new PHUIObjectItemListView(); + $list->setUser($viewer); + foreach ($documents as $document) { + $last_updated = phabricator_date($document->getDateModified(), $viewer); + $recent_contributors = $document->getRecentContributorPHIDs(); + $updater = $handles[reset($recent_contributors)]->renderLink(); + + $title = $document->getTitle(); + + $item = id(new PHUIObjectItemView()) + ->setObjectName('L'.$document->getID()) + ->setHeader($title) + ->setHref($this->getApplicationURI('view/'.$document->getID())) + ->setObject($document) + ->addIcon('none', pht('Last updated: %s', $last_updated)) + ->addByline(pht('Updated by: %s', $updater)) + ->addAttribute(pht('Versions: %d', $document->getVersions())); + + $list->addItem($item); + } + + return $list; + } + } diff --git a/src/applications/macro/controller/PhabricatorMacroListController.php b/src/applications/macro/controller/PhabricatorMacroListController.php index 12150db52e..57ab3c891e 100644 --- a/src/applications/macro/controller/PhabricatorMacroListController.php +++ b/src/applications/macro/controller/PhabricatorMacroListController.php @@ -1,7 +1,6 @@ delegateToController($controller); } - public function renderResultsList( - array $macros, - PhabricatorSavedQuery $query) { - - assert_instances_of($macros, 'PhabricatorFileImageMacro'); - $viewer = $this->getRequest()->getUser(); - - $author_phids = mpull($macros, 'getAuthorPHID', 'getAuthorPHID'); - $this->loadHandles($author_phids); - $author_handles = array_select_keys( - $this->getLoadedHandles(), - $author_phids); - - $pinboard = new PHUIPinboardView(); - foreach ($macros as $macro) { - $file = $macro->getFile(); - - $item = new PHUIPinboardItemView(); - if ($file) { - $item->setImageURI($file->getThumb280x210URI()); - $item->setImageSize(280, 210); - } - - if ($macro->getDateCreated()) { - $datetime = phabricator_date($macro->getDateCreated(), $viewer); - $item->appendChild( - phutil_tag( - 'div', - array(), - pht('Created on %s', $datetime))); - } else { - // Very old macros don't have a creation date. Rendering something - // keeps all the pins at the same height and avoids flow issues. - $item->appendChild( - phutil_tag( - 'div', - array(), - pht('Created in ages long past'))); - } - - if ($macro->getAuthorPHID()) { - $author_handle = $this->getHandle($macro->getAuthorPHID()); - $item->appendChild( - pht('Created by %s', $author_handle->renderLink())); - } - - $item->setURI($this->getApplicationURI('/view/'.$macro->getID().'/')); - - $name = $macro->getName(); - if ($macro->getIsDisabled()) { - $name = pht('%s (Disabled)', $name); - } - $item->setHeader($name); - - $pinboard->addItem($item); - } - - return $pinboard; - - } } diff --git a/src/applications/macro/query/PhabricatorMacroSearchEngine.php b/src/applications/macro/query/PhabricatorMacroSearchEngine.php index 933f1fc2c7..1e95cb6833 100644 --- a/src/applications/macro/query/PhabricatorMacroSearchEngine.php +++ b/src/applications/macro/query/PhabricatorMacroSearchEngine.php @@ -3,6 +3,10 @@ final class PhabricatorMacroSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationMacro'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); $saved->setParameter( @@ -153,4 +157,65 @@ final class PhabricatorMacroSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function getRequiredHandlePHIDsForResultList( + array $macros, + PhabricatorSavedQuery $query) { + return mpull($macros, 'getAuthorPHID'); + } + + protected function renderResultList( + array $macros, + PhabricatorSavedQuery $query, + array $handles) { + + assert_instances_of($macros, 'PhabricatorFileImageMacro'); + $viewer = $this->requireViewer(); + + $pinboard = new PHUIPinboardView(); + foreach ($macros as $macro) { + $file = $macro->getFile(); + + $item = new PHUIPinboardItemView(); + if ($file) { + $item->setImageURI($file->getThumb280x210URI()); + $item->setImageSize(280, 210); + } + + if ($macro->getDateCreated()) { + $datetime = phabricator_date($macro->getDateCreated(), $viewer); + $item->appendChild( + phutil_tag( + 'div', + array(), + pht('Created on %s', $datetime))); + } else { + // Very old macros don't have a creation date. Rendering something + // keeps all the pins at the same height and avoids flow issues. + $item->appendChild( + phutil_tag( + 'div', + array(), + pht('Created in ages long past'))); + } + + if ($macro->getAuthorPHID()) { + $author_handle = $handles[$macro->getAuthorPHID()]; + $item->appendChild( + pht('Created by %s', $author_handle->renderLink())); + } + + $item->setURI($this->getApplicationURI('/view/'.$macro->getID().'/')); + + $name = $macro->getName(); + if ($macro->getIsDisabled()) { + $name = pht('%s (Disabled)', $name); + } + $item->setHeader($name); + + $pinboard->addItem($item); + } + + return $pinboard; + } + } diff --git a/src/applications/mailinglists/controller/PhabricatorMailingListsListController.php b/src/applications/mailinglists/controller/PhabricatorMailingListsListController.php index 22a843878f..f4285c77ec 100644 --- a/src/applications/mailinglists/controller/PhabricatorMailingListsListController.php +++ b/src/applications/mailinglists/controller/PhabricatorMailingListsListController.php @@ -1,8 +1,7 @@ delegateToController($controller); } - public function renderResultsList( - array $lists, - PhabricatorSavedQuery $query) { - assert_instances_of($lists, 'PhabricatorMetaMTAMailingList'); - - $view = id(new PHUIObjectItemListView()); - - foreach ($lists as $list) { - $item = new PHUIObjectItemView(); - - $item->setHeader($list->getName()); - $item->setHref($list->getURI()); - $item->addAttribute($list->getEmail()); - $item->addAction( - id(new PHUIListItemView()) - ->setIcon('edit') - ->setHref($this->getApplicationURI('/edit/'.$list->getID().'/'))); - - $view->addItem($item); - } - - return $view; - } - } diff --git a/src/applications/mailinglists/query/PhabricatorMailingListSearchEngine.php b/src/applications/mailinglists/query/PhabricatorMailingListSearchEngine.php index 6f846f5aed..f3a0e33d7e 100644 --- a/src/applications/mailinglists/query/PhabricatorMailingListSearchEngine.php +++ b/src/applications/mailinglists/query/PhabricatorMailingListSearchEngine.php @@ -3,6 +3,10 @@ final class PhabricatorMailingListSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationMailingLists'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); @@ -51,4 +55,29 @@ final class PhabricatorMailingListSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function renderResultList( + array $lists, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($lists, 'PhabricatorMetaMTAMailingList'); + + $view = id(new PHUIObjectItemListView()); + + foreach ($lists as $list) { + $item = new PHUIObjectItemView(); + + $item->setHeader($list->getName()); + $item->setHref($list->getURI()); + $item->addAttribute($list->getEmail()); + $item->addAction( + id(new PHUIListItemView()) + ->setIcon('edit') + ->setHref($this->getApplicationURI('/edit/'.$list->getID().'/'))); + + $view->addItem($item); + } + + return $view; + } + } diff --git a/src/applications/meta/controller/PhabricatorApplicationsListController.php b/src/applications/meta/controller/PhabricatorApplicationsListController.php index 0a358fecc1..5815f7cff2 100644 --- a/src/applications/meta/controller/PhabricatorApplicationsListController.php +++ b/src/applications/meta/controller/PhabricatorApplicationsListController.php @@ -1,8 +1,7 @@ delegateToController($controller); } - public function renderResultsList( - array $applications, - PhabricatorSavedQuery $query) { - assert_instances_of($applications, 'PhabricatorApplication'); - - $list = new PHUIObjectItemListView(); - - $applications = msort($applications, 'getName'); - - foreach ($applications as $application) { - $item = id(new PHUIObjectItemView()) - ->setHeader($application->getName()) - ->setHref('/applications/view/'.get_class($application).'/') - ->addAttribute($application->getShortDescription()); - - if (!$application->isInstalled()) { - $item->addIcon('delete', pht('Uninstalled')); - } - - if ($application->isBeta()) { - $item->addIcon('lint-warning', pht('Beta')); - } - - $list->addItem($item); - } - - return $list; - } - } diff --git a/src/applications/meta/query/PhabricatorAppSearchEngine.php b/src/applications/meta/query/PhabricatorAppSearchEngine.php index 5f25c1739e..a83a84e566 100644 --- a/src/applications/meta/query/PhabricatorAppSearchEngine.php +++ b/src/applications/meta/query/PhabricatorAppSearchEngine.php @@ -3,6 +3,10 @@ final class PhabricatorAppSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationApplications'; + } + public function getPageSize(PhabricatorSavedQuery $saved) { return INF; } @@ -124,4 +128,34 @@ final class PhabricatorAppSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function renderResultList( + array $applications, + PhabricatorSavedQuery $query, + array $handle) { + assert_instances_of($applications, 'PhabricatorApplication'); + + $list = new PHUIObjectItemListView(); + + $applications = msort($applications, 'getName'); + + foreach ($applications as $application) { + $item = id(new PHUIObjectItemView()) + ->setHeader($application->getName()) + ->setHref('/applications/view/'.get_class($application).'/') + ->addAttribute($application->getShortDescription()); + + if (!$application->isInstalled()) { + $item->addIcon('delete', pht('Uninstalled')); + } + + if ($application->isBeta()) { + $item->addIcon('lint-warning', pht('Beta')); + } + + $list->addItem($item); + } + + return $list; + } + } diff --git a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php index f1e94db910..879b98a03d 100644 --- a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php +++ b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php @@ -1,8 +1,7 @@ delegateToController($controller); } - public function renderResultsList( - array $clients, - PhabricatorSavedQuery $query) { - assert_instances_of($clients, 'PhabricatorOauthServerClient'); - - $viewer = $this->getRequest()->getUser(); - $this->loadHandles(mpull($clients, 'getCreatorPHID')); - - $list = id(new PHUIObjectItemListView()) - ->setUser($viewer); - foreach ($clients as $client) { - $creator = $this->getHandle($client->getCreatorPHID()); - - $item = id(new PHUIObjectItemView()) - ->setObjectName(pht('Application %d', $client->getID())) - ->setHeader($client->getName()) - ->setHref($client->getViewURI()) - ->setObject($client) - ->addByline(pht('Creator: %s', $creator->renderLink())); - - $list->addItem($item); - } - - return $list; - } - public function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); diff --git a/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php b/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php index 60523c48a5..1c722f99f6 100644 --- a/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php +++ b/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php @@ -3,6 +3,10 @@ final class PhabricatorOAuthServerClientSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationOAuthServer'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); @@ -76,4 +80,37 @@ final class PhabricatorOAuthServerClientSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + + protected function getRequiredHandlePHIDsForResultList( + array $clients, + PhabricatorSavedQuery $query) { + return mpull($clients, 'getCreatorPHID'); + } + + protected function renderResultList( + array $clients, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($clients, 'PhabricatorOauthServerClient'); + + $viewer = $this->requireViewer(); + + $list = id(new PHUIObjectItemListView()) + ->setUser($viewer); + foreach ($clients as $client) { + $creator = $handles[$client->getCreatorPHID()]; + + $item = id(new PHUIObjectItemView()) + ->setObjectName(pht('Application %d', $client->getID())) + ->setHeader($client->getName()) + ->setHref($client->getViewURI()) + ->setObject($client) + ->addByline(pht('Creator: %s', $creator->renderLink())); + + $list->addItem($item); + } + + return $list; + } + } diff --git a/src/applications/passphrase/controller/PassphraseCredentialListController.php b/src/applications/passphrase/controller/PassphraseCredentialListController.php index bc1bac0258..dae53bc463 100644 --- a/src/applications/passphrase/controller/PassphraseCredentialListController.php +++ b/src/applications/passphrase/controller/PassphraseCredentialListController.php @@ -1,7 +1,6 @@ delegateToController($controller); } - public function renderResultsList( - array $credentials, - PhabricatorSavedQuery $query) { - assert_instances_of($credentials, 'PassphraseCredential'); - - $viewer = $this->getRequest()->getUser(); - - $list = new PHUIObjectItemListView(); - $list->setUser($viewer); - foreach ($credentials as $credential) { - - $item = id(new PHUIObjectItemView()) - ->setObjectName('K'.$credential->getID()) - ->setHeader($credential->getName()) - ->setHref('/K'.$credential->getID()) - ->setObject($credential); - - $item->addAttribute( - pht('Login: %s', $credential->getUsername())); - - if ($credential->getIsDestroyed()) { - $item->addIcon('disable', pht('Destroyed')); - $item->setDisabled(true); - } - - $type = PassphraseCredentialType::getTypeByConstant( - $credential->getCredentialType()); - if ($type) { - $item->addIcon('wrench', $type->getCredentialTypeName()); - } - - $list->addItem($item); - } - - return $list; - } - } diff --git a/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php b/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php index ab2144f213..e4e99790ca 100644 --- a/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php +++ b/src/applications/passphrase/query/PassphraseCredentialSearchEngine.php @@ -3,6 +3,10 @@ final class PassphraseCredentialSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationPassphrase'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); @@ -70,4 +74,43 @@ final class PassphraseCredentialSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function renderResultList( + array $credentials, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($credentials, 'PassphraseCredential'); + + $viewer = $this->requireViewer(); + + $list = new PHUIObjectItemListView(); + $list->setUser($viewer); + foreach ($credentials as $credential) { + + $item = id(new PHUIObjectItemView()) + ->setObjectName('K'.$credential->getID()) + ->setHeader($credential->getName()) + ->setHref('/K'.$credential->getID()) + ->setObject($credential); + + $item->addAttribute( + pht('Login: %s', $credential->getUsername())); + + if ($credential->getIsDestroyed()) { + $item->addIcon('disable', pht('Destroyed')); + $item->setDisabled(true); + } + + $type = PassphraseCredentialType::getTypeByConstant( + $credential->getCredentialType()); + if ($type) { + $item->addIcon('wrench', $type->getCredentialTypeName()); + } + + $list->addItem($item); + } + + return $list; + } + + } diff --git a/src/applications/pholio/application/PhabricatorApplicationPholio.php b/src/applications/pholio/application/PhabricatorApplicationPholio.php index 49a85f7baa..d5e6e62eac 100644 --- a/src/applications/pholio/application/PhabricatorApplicationPholio.php +++ b/src/applications/pholio/application/PhabricatorApplicationPholio.php @@ -1,8 +1,5 @@ delegateToController($controller); } - public function renderResultsList( - array $mocks, - PhabricatorSavedQuery $query) { - assert_instances_of($mocks, 'PholioMock'); - - $viewer = $this->getRequest()->getUser(); - - $author_phids = array(); - foreach ($mocks as $mock) { - $author_phids[] = $mock->getAuthorPHID(); - } - $this->loadHandles($author_phids); - - $board = new PHUIPinboardView(); - foreach ($mocks as $mock) { - $item = id(new PHUIPinboardItemView()) - ->setHeader('M'.$mock->getID().' '.$mock->getName()) - ->setURI('/M'.$mock->getID()) - ->setImageURI($mock->getCoverFile()->getThumb280x210URI()) - ->setImageSize(280, 210) - ->addIconCount('image', count($mock->getImages())) - ->addIconCount('like', $mock->getTokenCount()); - - if ($mock->getAuthorPHID()) { - $author_handle = $this->getHandle($mock->getAuthorPHID()); - $datetime = phabricator_date($mock->getDateCreated(), $viewer); - $item->appendChild( - pht('By %s on %s', $author_handle->renderLink(), $datetime)); - } - - $board->addItem($item); - } - - return $board; - } - } diff --git a/src/applications/pholio/query/PholioMockSearchEngine.php b/src/applications/pholio/query/PholioMockSearchEngine.php index 5da9d405ad..443e43481d 100644 --- a/src/applications/pholio/query/PholioMockSearchEngine.php +++ b/src/applications/pholio/query/PholioMockSearchEngine.php @@ -3,6 +3,10 @@ final class PholioMockSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationPholio'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); $saved->setParameter( @@ -74,4 +78,41 @@ final class PholioMockSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function getRequiredHandlePHIDsForResultList( + array $mocks, + PhabricatorSavedQuery $query) { + return mpull($mocks, 'getAuthorPHID'); + } + + protected function renderResultList( + array $mocks, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($mocks, 'PholioMock'); + + $viewer = $this->requireViewer(); + + $board = new PHUIPinboardView(); + foreach ($mocks as $mock) { + $item = id(new PHUIPinboardItemView()) + ->setHeader('M'.$mock->getID().' '.$mock->getName()) + ->setURI('/M'.$mock->getID()) + ->setImageURI($mock->getCoverFile()->getThumb280x210URI()) + ->setImageSize(280, 210) + ->addIconCount('image', count($mock->getImages())) + ->addIconCount('like', $mock->getTokenCount()); + + if ($mock->getAuthorPHID()) { + $author_handle = $handles[$mock->getAuthorPHID()]; + $datetime = phabricator_date($mock->getDateCreated(), $viewer); + $item->appendChild( + pht('By %s on %s', $author_handle->renderLink(), $datetime)); + } + + $board->addItem($item); + } + + return $board; + } + } diff --git a/src/applications/phrequent/controller/PhrequentListController.php b/src/applications/phrequent/controller/PhrequentListController.php index 7ea8185166..fec1ccff02 100644 --- a/src/applications/phrequent/controller/PhrequentListController.php +++ b/src/applications/phrequent/controller/PhrequentListController.php @@ -1,7 +1,6 @@ delegateToController($controller); } - public function renderResultsList( - array $usertimes, - PhabricatorSavedQuery $query) { - assert_instances_of($usertimes, 'PhrequentUserTime'); - $viewer = $this->getRequest()->getUser(); - - $phids = array(); - $phids[] = mpull($usertimes, 'getUserPHID'); - $phids[] = mpull($usertimes, 'getObjectPHID'); - $phids = array_mergev($phids); - - $handles = $this->loadViewerHandles($phids); - - $view = id(new PHUIObjectItemListView()) - ->setUser($viewer); - - foreach ($usertimes as $usertime) { - $item = new PHUIObjectItemView(); - - if ($usertime->getObjectPHID() === null) { - $item->setHeader($usertime->getNote()); - } else { - $obj = $handles[$usertime->getObjectPHID()]; - $item->setHeader($obj->getLinkName()); - $item->setHref($obj->getURI()); - } - $item->setObject($usertime); - - $item->addByline( - pht( - 'Tracked: %s', - $handles[$usertime->getUserPHID()]->renderLink())); - - $started_date = phabricator_date($usertime->getDateStarted(), $viewer); - $item->addIcon('none', $started_date); - - if ($usertime->getDateEnded() !== null) { - $time_spent = $usertime->getDateEnded() - $usertime->getDateStarted(); - $time_ended = phabricator_datetime($usertime->getDateEnded(), $viewer); - } else { - $time_spent = time() - $usertime->getDateStarted(); - } - - $time_spent = $time_spent == 0 ? 'none' : - phabricator_format_relative_time_detailed($time_spent); - - if ($usertime->getDateEnded() !== null) { - $item->addAttribute( - pht( - 'Tracked %s', - $time_spent)); - $item->addAttribute( - pht( - 'Ended on %s', - $time_ended)); - } else { - $item->addAttribute( - pht( - 'Tracked %s so far', - $time_spent)); - if ($usertime->getObjectPHID() !== null && - $usertime->getUserPHID() === $viewer->getPHID()) { - $item->addAction( - id(new PHUIListItemView()) - ->setIcon('history') - ->addSigil('phrequent-stop-tracking') - ->setWorkflow(true) - ->setRenderNameAsTooltip(true) - ->setName(pht("Stop")) - ->setHref( - '/phrequent/track/stop/'. - $usertime->getObjectPHID().'/')); - } - $item->setBarColor('green'); - } - - $view->addItem($item); - } - - return $view; - } - } diff --git a/src/applications/phrequent/query/PhrequentSearchEngine.php b/src/applications/phrequent/query/PhrequentSearchEngine.php index 48fd907b51..cb1a4c77e0 100644 --- a/src/applications/phrequent/query/PhrequentSearchEngine.php +++ b/src/applications/phrequent/query/PhrequentSearchEngine.php @@ -3,6 +3,10 @@ final class PhrequentSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationPhrequent'; + } + public function getPageSize(PhabricatorSavedQuery $saved) { return $saved->getParameter('limit', 1000); } @@ -110,4 +114,89 @@ final class PhrequentSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function getRequiredHandlePHIDsForResultList( + array $usertimes, + PhabricatorSavedQuery $query) { + return array_mergev( + array( + mpull($usertimes, 'getUserPHID'), + mpull($usertimes, 'getObjectPHID'), + )); + } + + protected function renderResultList( + array $usertimes, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($usertimes, 'PhrequentUserTime'); + $viewer = $this->requireViewer(); + + $view = id(new PHUIObjectItemListView()) + ->setUser($viewer); + + foreach ($usertimes as $usertime) { + $item = new PHUIObjectItemView(); + + if ($usertime->getObjectPHID() === null) { + $item->setHeader($usertime->getNote()); + } else { + $obj = $handles[$usertime->getObjectPHID()]; + $item->setHeader($obj->getLinkName()); + $item->setHref($obj->getURI()); + } + $item->setObject($usertime); + + $item->addByline( + pht( + 'Tracked: %s', + $handles[$usertime->getUserPHID()]->renderLink())); + + $started_date = phabricator_date($usertime->getDateStarted(), $viewer); + $item->addIcon('none', $started_date); + + if ($usertime->getDateEnded() !== null) { + $time_spent = $usertime->getDateEnded() - $usertime->getDateStarted(); + $time_ended = phabricator_datetime($usertime->getDateEnded(), $viewer); + } else { + $time_spent = time() - $usertime->getDateStarted(); + } + + $time_spent = $time_spent == 0 ? 'none' : + phabricator_format_relative_time_detailed($time_spent); + + if ($usertime->getDateEnded() !== null) { + $item->addAttribute( + pht( + 'Tracked %s', + $time_spent)); + $item->addAttribute( + pht( + 'Ended on %s', + $time_ended)); + } else { + $item->addAttribute( + pht( + 'Tracked %s so far', + $time_spent)); + if ($usertime->getObjectPHID() !== null && + $usertime->getUserPHID() === $viewer->getPHID()) { + $item->addAction( + id(new PHUIListItemView()) + ->setIcon('history') + ->addSigil('phrequent-stop-tracking') + ->setWorkflow(true) + ->setRenderNameAsTooltip(true) + ->setName(pht("Stop")) + ->setHref( + '/phrequent/track/stop/'. + $usertime->getObjectPHID().'/')); + } + $item->setBarColor('green'); + } + + $view->addItem($item); + } + + return $view; + } } diff --git a/src/applications/phriction/controller/PhrictionListController.php b/src/applications/phriction/controller/PhrictionListController.php index 1900250455..b3377041bd 100644 --- a/src/applications/phriction/controller/PhrictionListController.php +++ b/src/applications/phriction/controller/PhrictionListController.php @@ -1,8 +1,7 @@ delegateToController($controller); } - public function renderResultsList( - array $documents, - PhabricatorSavedQuery $query) { - assert_instances_of($documents, 'PhrictionDocument'); - - $viewer = $this->getRequest()->getUser(); - - $phids = array(); - foreach ($documents as $document) { - $content = $document->getContent(); - if ($document->hasProject()) { - $phids[] = $document->getProject()->getPHID(); - } - $phids[] = $content->getAuthorPHID(); - } - - $this->loadHandles($phids); - - $list = new PHUIObjectItemListView(); - $list->setUser($viewer); - foreach ($documents as $document) { - $content = $document->getContent(); - $slug = $document->getSlug(); - $author_phid = $content->getAuthorPHID(); - $slug_uri = PhrictionDocument::getSlugURI($slug); - - $byline = pht( - 'Edited by %s', - $this->getHandle($author_phid)->renderLink()); - - $updated = phabricator_datetime( - $content->getDateCreated(), - $viewer); - - $item = id(new PHUIObjectItemView()) - ->setHeader($content->getTitle()) - ->setHref($slug_uri) - ->addByline($byline) - ->addIcon('none', $updated); - - if ($document->hasProject()) { - $item->addAttribute( - $this->getHandle($document->getProject()->getPHID())->renderLink()); - } - - $item->addAttribute($slug_uri); - - switch ($document->getStatus()) { - case PhrictionDocumentStatus::STATUS_DELETED: - $item->setDisabled(true); - $item->addIcon('delete', pht('Deleted')); - break; - case PhrictionDocumentStatus::STATUS_MOVED: - $item->setDisabled(true); - $item->addIcon('arrow-right', pht('Moved Away')); - break; - } - - $list->addItem($item); - } - - return $list; - } - } diff --git a/src/applications/phriction/query/PhrictionSearchEngine.php b/src/applications/phriction/query/PhrictionSearchEngine.php index 1aae7e02d3..04a96bbbed 100644 --- a/src/applications/phriction/query/PhrictionSearchEngine.php +++ b/src/applications/phriction/query/PhrictionSearchEngine.php @@ -109,4 +109,75 @@ final class PhrictionSearchEngine ); } + protected function getRequiredHandlePHIDsForResultList( + array $documents, + PhabricatorSavedQuery $query) { + + $phids = array(); + foreach ($documents as $document) { + $content = $document->getContent(); + if ($document->hasProject()) { + $phids[] = $document->getProject()->getPHID(); + } + $phids[] = $content->getAuthorPHID(); + } + + return $phids; + } + + + protected function renderResultList( + array $documents, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($documents, 'PhrictionDocument'); + + $viewer = $this->requireViewer(); + + $list = new PHUIObjectItemListView(); + $list->setUser($viewer); + foreach ($documents as $document) { + $content = $document->getContent(); + $slug = $document->getSlug(); + $author_phid = $content->getAuthorPHID(); + $slug_uri = PhrictionDocument::getSlugURI($slug); + + $byline = pht( + 'Edited by %s', + $handles[$author_phid]->renderLink()); + + $updated = phabricator_datetime( + $content->getDateCreated(), + $viewer); + + $item = id(new PHUIObjectItemView()) + ->setHeader($content->getTitle()) + ->setHref($slug_uri) + ->addByline($byline) + ->addIcon('none', $updated); + + if ($document->hasProject()) { + $item->addAttribute( + $handles[$document->getProject()->getPHID()]->renderLink()); + } + + $item->addAttribute($slug_uri); + + switch ($document->getStatus()) { + case PhrictionDocumentStatus::STATUS_DELETED: + $item->setDisabled(true); + $item->addIcon('delete', pht('Deleted')); + break; + case PhrictionDocumentStatus::STATUS_MOVED: + $item->setDisabled(true); + $item->addIcon('arrow-right', pht('Moved Away')); + break; + } + + $list->addItem($item); + } + + return $list; + } + } diff --git a/src/applications/ponder/controller/PonderQuestionListController.php b/src/applications/ponder/controller/PonderQuestionListController.php index 66a7a6a5ca..e0a0236a62 100644 --- a/src/applications/ponder/controller/PonderQuestionListController.php +++ b/src/applications/ponder/controller/PonderQuestionListController.php @@ -1,7 +1,6 @@ delegateToController($controller); } - public function renderResultsList( - array $questions, - PhabricatorSavedQuery $query) { - assert_instances_of($questions, 'PonderQuestion'); - $viewer = $this->getRequest()->getUser(); - - $phids = array(); - $phids[] = mpull($questions, 'getAuthorPHID'); - $phids = array_mergev($phids); - - $handles = $this->loadViewerHandles($phids); - - - $view = id(new PHUIObjectItemListView()) - ->setUser($viewer); - - foreach ($questions as $question) { - $item = new PHUIObjectItemView(); - $item->setObjectName('Q'.$question->getID()); - $item->setHeader($question->getTitle()); - $item->setHref('/Q'.$question->getID()); - $item->setObject($question); - $item->setBarColor( - PonderQuestionStatus::getQuestionStatusTagColor( - $question->getStatus())); - - $created_date = phabricator_date($question->getDateCreated(), $viewer); - $item->addIcon('none', $created_date); - $item->addByline( - pht( - 'Asked by %s', - $handles[$question->getAuthorPHID()]->renderLink())); - - $item->addAttribute( - pht('%d Answer(s)', $question->getAnswerCount())); - - $view->addItem($item); - } - - return $view; - } - } diff --git a/src/applications/ponder/query/PonderQuestionSearchEngine.php b/src/applications/ponder/query/PonderQuestionSearchEngine.php index ec715b028a..6dcba96cf0 100644 --- a/src/applications/ponder/query/PonderQuestionSearchEngine.php +++ b/src/applications/ponder/query/PonderQuestionSearchEngine.php @@ -3,6 +3,10 @@ final class PonderQuestionSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationPonder'; + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); @@ -124,4 +128,47 @@ final class PonderQuestionSearchEngine return parent::buildSavedQueryFromBuiltin($query_key); } + protected function getRequiredHandlePHIDsForResultList( + array $questions, + PhabricatorSavedQuery $query) { + return mpull($questions, 'getAuthorPHID'); + } + + protected function renderResultList( + array $questions, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($questions, 'PonderQuestion'); + + $viewer = $this->requireViewer(); + + $view = id(new PHUIObjectItemListView()) + ->setUser($viewer); + + foreach ($questions as $question) { + $item = new PHUIObjectItemView(); + $item->setObjectName('Q'.$question->getID()); + $item->setHeader($question->getTitle()); + $item->setHref('/Q'.$question->getID()); + $item->setObject($question); + $item->setBarColor( + PonderQuestionStatus::getQuestionStatusTagColor( + $question->getStatus())); + + $created_date = phabricator_date($question->getDateCreated(), $viewer); + $item->addIcon('none', $created_date); + $item->addByline( + pht( + 'Asked by %s', + $handles[$question->getAuthorPHID()]->renderLink())); + + $item->addAttribute( + pht('%d Answer(s)', $question->getAnswerCount())); + + $view->addItem($item); + } + + return $view; + } + } diff --git a/src/applications/project/controller/PhabricatorProjectListController.php b/src/applications/project/controller/PhabricatorProjectListController.php index 018e581b9a..171e8a8eb8 100644 --- a/src/applications/project/controller/PhabricatorProjectListController.php +++ b/src/applications/project/controller/PhabricatorProjectListController.php @@ -1,8 +1,7 @@ delegateToController($controller); } - public function renderResultsList( - array $projects, - PhabricatorSavedQuery $query) { - assert_instances_of($projects, 'PhabricatorProject'); - $viewer = $this->getRequest()->getUser(); - - $list = new PHUIObjectItemListView(); - $list->setUser($viewer); - foreach ($projects as $project) { - $id = $project->getID(); - - $item = id(new PHUIObjectItemView()) - ->setHeader($project->getName()) - ->setHref($this->getApplicationURI("view/{$id}/")) - ->setImageURI($project->getProfileImageURI()); - - if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) { - $item->addIcon('delete-grey', pht('Archived')); - $item->setDisabled(true); - } - - $list->addItem($item); - } - - return $list; - } - public function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php index 3f3e146611..3f705c7a63 100644 --- a/src/applications/project/query/PhabricatorProjectSearchEngine.php +++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php @@ -3,6 +3,10 @@ final class PhabricatorProjectSearchEngine extends PhabricatorApplicationSearchEngine { + public function getApplicationClassName() { + return 'PhabricatorApplicationProject'; + } + public function getCustomFieldObject() { return new PhabricatorProject(); } @@ -122,4 +126,32 @@ final class PhabricatorProjectSearchEngine ); } + protected function renderResultList( + array $projects, + PhabricatorSavedQuery $query, + array $handles) { + assert_instances_of($projects, 'PhabricatorProject'); + $viewer = $this->requireViewer(); + + $list = new PHUIObjectItemListView(); + $list->setUser($viewer); + foreach ($projects as $project) { + $id = $project->getID(); + + $item = id(new PHUIObjectItemView()) + ->setHeader($project->getName()) + ->setHref($this->getApplicationURI("view/{$id}/")) + ->setImageURI($project->getProfileImageURI()); + + if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) { + $item->addIcon('delete-grey', pht('Archived')); + $item->setDisabled(true); + } + + $list->addItem($item); + } + + return $list; + } + }