Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conpherence/query/ConpherenceThreadSearchEngine.php
<?php | <?php | ||||
final class ConpherenceThreadSearchEngine | final class ConpherenceThreadSearchEngine | ||||
extends PhabricatorApplicationSearchEngine { | extends PhabricatorApplicationSearchEngine { | ||||
public function getResultTypeDescription() { | public function getResultTypeDescription() { | ||||
return pht('Rooms'); | return pht('Rooms'); | ||||
} | } | ||||
public function getApplicationClassName() { | public function getApplicationClassName() { | ||||
return 'PhabricatorConpherenceApplication'; | return 'PhabricatorConpherenceApplication'; | ||||
} | } | ||||
public function buildSavedQueryFromRequest(AphrontRequest $request) { | public function newQuery() { | ||||
$saved = new PhabricatorSavedQuery(); | return id(new ConpherenceThreadQuery()) | ||||
->needParticipantCache(true); | |||||
$saved->setParameter( | |||||
'participantPHIDs', | |||||
$this->readUsersFromRequest($request, 'participants')); | |||||
$saved->setParameter('fulltext', $request->getStr('fulltext')); | |||||
return $saved; | |||||
} | } | ||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { | protected function buildCustomSearchFields() { | ||||
$query = id(new ConpherenceThreadQuery()) | return array( | ||||
->needParticipantCache(true); | id(new PhabricatorSearchUsersField()) | ||||
->setLabel(pht('Participants')) | |||||
->setKey('participants') | |||||
->setAliases(array('participant')), | |||||
id(new PhabricatorSearchTextField()) | |||||
->setLabel(pht('Contains Words')) | |||||
->setKey('fulltext'), | |||||
); | |||||
} | |||||
$participant_phids = $saved->getParameter('participantPHIDs', array()); | protected function getDefaultFieldOrder() { | ||||
if ($participant_phids && is_array($participant_phids)) { | return array( | ||||
$query->withParticipantPHIDs($participant_phids); | 'participants', | ||||
'...', | |||||
); | |||||
} | } | ||||
$fulltext = $saved->getParameter('fulltext'); | protected function shouldShowOrderField() { | ||||
if (strlen($fulltext)) { | return false; | ||||
$query->withFulltext($fulltext); | |||||
} | } | ||||
return $query; | protected function buildQueryFromParameters(array $map) { | ||||
$query = $this->newQuery(); | |||||
if ($map['participants']) { | |||||
$query->withParticipantPHIDs($map['participants']); | |||||
} | |||||
if ($map['fulltext']) { | |||||
$query->withFulltext($map['fulltext']); | |||||
} | } | ||||
public function buildSearchForm( | return $query; | ||||
AphrontFormView $form, | |||||
PhabricatorSavedQuery $saved) { | |||||
$participant_phids = $saved->getParameter('participantPHIDs', array()); | |||||
$fulltext = $saved->getParameter('fulltext'); | |||||
$form | |||||
->appendControl( | |||||
id(new AphrontFormTokenizerControl()) | |||||
->setDatasource(new PhabricatorPeopleDatasource()) | |||||
->setName('participants') | |||||
->setLabel(pht('Participants')) | |||||
->setValue($participant_phids)) | |||||
->appendControl( | |||||
id(new AphrontFormTextControl()) | |||||
->setName('fulltext') | |||||
->setLabel(pht('Contains Words')) | |||||
->setValue($fulltext)); | |||||
} | } | ||||
protected function getURI($path) { | protected function getURI($path) { | ||||
return '/conpherence/search/'.$path; | return '/conpherence/search/'.$path; | ||||
} | } | ||||
protected function getBuiltinQueryNames() { | protected function getBuiltinQueryNames() { | ||||
$names = array(); | $names = array(); | ||||
$names = array( | |||||
'all' => pht('All Rooms'), | |||||
); | |||||
if ($this->requireViewer()->isLoggedIn()) { | if ($this->requireViewer()->isLoggedIn()) { | ||||
$names['participant'] = pht('Joined Rooms'); | $names['participant'] = pht('Joined Rooms'); | ||||
} | } | ||||
$names['all'] = pht('All Rooms'); | |||||
return $names; | return $names; | ||||
} | } | ||||
public function buildSavedQueryFromBuiltin($query_key) { | public function buildSavedQueryFromBuiltin($query_key) { | ||||
$query = $this->newSavedQuery(); | $query = $this->newSavedQuery(); | ||||
$query->setQueryKey($query_key); | $query->setQueryKey($query_key); | ||||
switch ($query_key) { | switch ($query_key) { | ||||
case 'all': | case 'all': | ||||
return $query; | return $query; | ||||
case 'participant': | case 'participant': | ||||
return $query->setParameter( | return $query->setParameter( | ||||
'participantPHIDs', | 'participants', | ||||
array($this->requireViewer()->getPHID())); | array($this->requireViewer()->getPHID())); | ||||
} | } | ||||
return parent::buildSavedQueryFromBuiltin($query_key); | return parent::buildSavedQueryFromBuiltin($query_key); | ||||
} | } | ||||
protected function getRequiredHandlePHIDsForResultList( | protected function getRequiredHandlePHIDsForResultList( | ||||
array $conpherences, | array $conpherences, | ||||
▲ Show 20 Lines • Show All 334 Lines • Show Last 20 Lines |