2015-06-05 19:44:18 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class NuanceSourceSearchEngine
|
|
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
|
|
|
|
public function getApplicationClassName() {
|
|
|
|
return 'PhabricatorNuanceApplication';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getResultTypeDescription() {
|
|
|
|
return pht('Nuance Sources');
|
|
|
|
}
|
|
|
|
|
2016-03-08 00:24:59 +01:00
|
|
|
public function newQuery() {
|
|
|
|
return new NuanceSourceQuery();
|
2015-06-05 19:44:18 +02:00
|
|
|
}
|
|
|
|
|
2016-03-08 00:24:59 +01:00
|
|
|
protected function buildQueryFromParameters(array $map) {
|
|
|
|
$query = $this->newQuery();
|
2015-06-05 19:44:18 +02:00
|
|
|
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
2016-03-08 00:24:59 +01:00
|
|
|
protected function buildCustomSearchFields() {
|
|
|
|
return array();
|
|
|
|
}
|
2015-06-05 19:44:18 +02:00
|
|
|
|
|
|
|
protected function getURI($path) {
|
|
|
|
return '/nuance/source/'.$path;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getBuiltinQueryNames() {
|
|
|
|
$names = array(
|
|
|
|
'all' => pht('All Sources'),
|
|
|
|
);
|
|
|
|
|
|
|
|
return $names;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
$query = $this->newSavedQuery();
|
|
|
|
$query->setQueryKey($query_key);
|
|
|
|
|
|
|
|
switch ($query_key) {
|
|
|
|
case 'all':
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function renderResultList(
|
|
|
|
array $sources,
|
|
|
|
PhabricatorSavedQuery $query,
|
|
|
|
array $handles) {
|
|
|
|
assert_instances_of($sources, 'NuanceSource');
|
|
|
|
|
|
|
|
$viewer = $this->requireViewer();
|
|
|
|
|
|
|
|
$list = new PHUIObjectItemListView();
|
|
|
|
$list->setUser($viewer);
|
|
|
|
foreach ($sources as $source) {
|
|
|
|
$item = id(new PHUIObjectItemView())
|
|
|
|
->setObjectName(pht('Source %d', $source->getID()))
|
|
|
|
->setHeader($source->getName())
|
|
|
|
->setHref($source->getURI());
|
|
|
|
|
|
|
|
$item->addIcon('none', $source->getType());
|
|
|
|
|
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
2015-06-19 12:46:20 +02:00
|
|
|
$result = new PhabricatorApplicationSearchResultView();
|
|
|
|
$result->setObjectList($list);
|
|
|
|
$result->setNoDataString(pht('No sources found.'));
|
|
|
|
|
|
|
|
return $result;
|
2015-06-05 19:44:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|