mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 04:02:43 +01:00
3e704f6c78
Summary: Ref T5833. This differentiates address spaces like the public internet from VPNs, so when a service is available at `192.168.0.1`, we'll know it's on some specific NAT block or whatever. Test Plan: See screenshots. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5833 Differential Revision: https://secure.phabricator.com/D10715
83 lines
1.8 KiB
PHP
83 lines
1.8 KiB
PHP
<?php
|
|
|
|
final class AlmanacServiceSearchEngine
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
public function getResultTypeDescription() {
|
|
return pht('Almanac Services');
|
|
}
|
|
|
|
protected function getApplicationClassName() {
|
|
return 'PhabricatorAlmanacApplication';
|
|
}
|
|
|
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
|
$saved = new PhabricatorSavedQuery();
|
|
|
|
return $saved;
|
|
}
|
|
|
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
|
$query = id(new AlmanacServiceQuery());
|
|
|
|
return $query;
|
|
}
|
|
|
|
public function buildSearchForm(
|
|
AphrontFormView $form,
|
|
PhabricatorSavedQuery $saved_query) {}
|
|
|
|
protected function getURI($path) {
|
|
return '/almanac/service/'.$path;
|
|
}
|
|
|
|
public function getBuiltinQueryNames() {
|
|
$names = array(
|
|
'all' => pht('All Services'),
|
|
);
|
|
|
|
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 $services,
|
|
PhabricatorSavedQuery $query) {
|
|
return array();
|
|
}
|
|
|
|
protected function renderResultList(
|
|
array $services,
|
|
PhabricatorSavedQuery $query,
|
|
array $handles) {
|
|
assert_instances_of($services, 'AlmanacService');
|
|
|
|
$viewer = $this->requireViewer();
|
|
|
|
$list = new PHUIObjectItemListView();
|
|
$list->setUser($viewer);
|
|
foreach ($services as $service) {
|
|
$item = id(new PHUIObjectItemView())
|
|
->setObjectName(pht('Service %d', $service->getID()))
|
|
->setHeader($service->getName())
|
|
->setHref($service->getURI())
|
|
->setObject($service);
|
|
|
|
$list->addItem($item);
|
|
}
|
|
|
|
return $list;
|
|
}
|
|
}
|