2014-10-17 14:04:02 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class AlmanacNetworkSearchEngine
|
|
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
|
|
|
|
public function getResultTypeDescription() {
|
|
|
|
return pht('Almanac Networks');
|
|
|
|
}
|
|
|
|
|
2015-02-05 00:47:48 +01:00
|
|
|
public function getApplicationClassName() {
|
2014-10-17 14:04:02 +02:00
|
|
|
return 'PhabricatorAlmanacApplication';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
|
|
|
$saved = new PhabricatorSavedQuery();
|
|
|
|
|
|
|
|
return $saved;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
|
|
|
$query = id(new AlmanacNetworkQuery());
|
|
|
|
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSearchForm(
|
|
|
|
AphrontFormView $form,
|
|
|
|
PhabricatorSavedQuery $saved_query) {}
|
|
|
|
|
|
|
|
protected function getURI($path) {
|
|
|
|
return '/almanac/network/'.$path;
|
|
|
|
}
|
|
|
|
|
2015-01-06 21:34:51 +01:00
|
|
|
protected function getBuiltinQueryNames() {
|
2014-10-17 14:04:02 +02:00
|
|
|
$names = array(
|
|
|
|
'all' => pht('All Networks'),
|
|
|
|
);
|
|
|
|
|
|
|
|
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 getRequiredHandlePHIDsForResultList(
|
|
|
|
array $networks,
|
|
|
|
PhabricatorSavedQuery $query) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function renderResultList(
|
|
|
|
array $networks,
|
|
|
|
PhabricatorSavedQuery $query,
|
|
|
|
array $handles) {
|
|
|
|
assert_instances_of($networks, 'AlmanacNetwork');
|
|
|
|
|
|
|
|
$viewer = $this->requireViewer();
|
|
|
|
|
|
|
|
$list = new PHUIObjectItemListView();
|
|
|
|
$list->setUser($viewer);
|
|
|
|
foreach ($networks as $network) {
|
|
|
|
$id = $network->getID();
|
|
|
|
|
|
|
|
$item = id(new PHUIObjectItemView())
|
|
|
|
->setObjectName(pht('Network %d', $id))
|
|
|
|
->setHeader($network->getName())
|
|
|
|
->setHref($this->getApplicationURI("network/{$id}/"))
|
|
|
|
->setObject($network);
|
|
|
|
|
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $list;
|
|
|
|
}
|
|
|
|
}
|