Differential D17672 Diff 42503 src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
| <?php | <?php | ||||
| final class PhabricatorSearchApplicationSearchEngine | final class PhabricatorSearchApplicationSearchEngine | ||||
| extends PhabricatorApplicationSearchEngine { | extends PhabricatorApplicationSearchEngine { | ||||
| private $resultSet; | |||||
| public function getResultTypeDescription() { | public function getResultTypeDescription() { | ||||
| return pht('Fulltext Search Results'); | return pht('Fulltext Search Results'); | ||||
| } | } | ||||
| public function getApplicationClassName() { | public function getApplicationClassName() { | ||||
| return 'PhabricatorSearchApplication'; | return 'PhabricatorSearchApplication'; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | public function shouldUseOffsetPaging() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| protected function renderResultList( | protected function renderResultList( | ||||
| array $results, | array $results, | ||||
| PhabricatorSavedQuery $query, | PhabricatorSavedQuery $query, | ||||
| array $handles) { | array $handles) { | ||||
| $result_set = $this->resultSet; | |||||
| $fulltext_tokens = $result_set->getFulltextTokens(); | |||||
| $viewer = $this->requireViewer(); | $viewer = $this->requireViewer(); | ||||
| $list = new PHUIObjectItemListView(); | $list = new PHUIObjectItemListView(); | ||||
| $list->setNoDataString(pht('No results found.')); | $list->setNoDataString(pht('No results found.')); | ||||
| if ($results) { | if ($results) { | ||||
| $objects = id(new PhabricatorObjectQuery()) | $objects = id(new PhabricatorObjectQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withPHIDs(mpull($results, 'getPHID')) | ->withPHIDs(mpull($results, 'getPHID')) | ||||
| ->execute(); | ->execute(); | ||||
| foreach ($results as $phid => $handle) { | foreach ($results as $phid => $handle) { | ||||
| $view = id(new PhabricatorSearchResultView()) | $view = id(new PhabricatorSearchResultView()) | ||||
| ->setHandle($handle) | ->setHandle($handle) | ||||
| ->setQuery($query) | ->setQuery($query) | ||||
| ->setObject(idx($objects, $phid)) | ->setObject(idx($objects, $phid)) | ||||
| ->render(); | ->render(); | ||||
| $list->addItem($view); | $list->addItem($view); | ||||
| } | } | ||||
| } | } | ||||
| $fulltext_view = null; | |||||
| if ($fulltext_tokens) { | |||||
| require_celerity_resource('phabricator-search-results-css'); | |||||
| $fulltext_view = array(); | |||||
| foreach ($fulltext_tokens as $token) { | |||||
| $fulltext_view[] = $token->newTag(); | |||||
| } | |||||
| $fulltext_view = phutil_tag( | |||||
| 'div', | |||||
| array( | |||||
| 'class' => 'phui-fulltext-tokens', | |||||
| ), | |||||
| array( | |||||
| pht('Searched For:'), | |||||
| ' ', | |||||
| $fulltext_view, | |||||
| )); | |||||
| } | |||||
| $result = new PhabricatorApplicationSearchResultView(); | $result = new PhabricatorApplicationSearchResultView(); | ||||
| $result->setContent($fulltext_view); | |||||
| $result->setObjectList($list); | $result->setObjectList($list); | ||||
| return $result; | return $result; | ||||
| } | } | ||||
| private function readOwnerPHIDs(PhabricatorSavedQuery $saved) { | private function readOwnerPHIDs(PhabricatorSavedQuery $saved) { | ||||
| $owner_phids = $saved->getParameter('ownerPHIDs', array()); | $owner_phids = $saved->getParameter('ownerPHIDs', array()); | ||||
| // This was an old checkbox from before typeahead functions. | // This was an old checkbox from before typeahead functions. | ||||
| if ($saved->getParameter('withUnowned')) { | if ($saved->getParameter('withUnowned')) { | ||||
| $owner_phids[] = PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN; | $owner_phids[] = PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN; | ||||
| } | } | ||||
| return $owner_phids; | return $owner_phids; | ||||
| } | } | ||||
| protected function didExecuteQuery(PhabricatorPolicyAwareQuery $query) { | |||||
| $this->resultSet = $query->getFulltextResultSet(); | |||||
| } | |||||
| } | } | ||||