2015-05-19 22:59:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorSearchApplicationStorageEnginePanel
|
|
|
|
extends PhabricatorApplicationConfigurationPanel {
|
|
|
|
|
|
|
|
public function getPanelKey() {
|
|
|
|
return 'search';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldShowForApplication(
|
|
|
|
PhabricatorApplication $application) {
|
|
|
|
return $application instanceof PhabricatorSearchApplication;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildConfigurationPagePanel() {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$application = $this->getApplication();
|
|
|
|
|
2017-07-18 19:44:56 +02:00
|
|
|
$services = PhabricatorSearchService::getAllServices();
|
2015-05-19 22:59:58 +02:00
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
$rowc = array();
|
|
|
|
|
2017-07-18 19:44:56 +02:00
|
|
|
foreach ($services as $key => $service) {
|
2015-05-19 22:59:58 +02:00
|
|
|
try {
|
2017-07-18 19:44:56 +02:00
|
|
|
$name = $service->getDisplayName();
|
2015-05-19 22:59:58 +02:00
|
|
|
} catch (Exception $ex) {
|
2017-07-18 19:44:56 +02:00
|
|
|
$name = phutil_tag('em', array(), pht('Error'));
|
2015-05-19 22:59:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2017-07-18 19:44:56 +02:00
|
|
|
$can_read = $service->isReadable() ? pht('Yes') : pht('No');
|
2015-05-19 22:59:58 +02:00
|
|
|
} catch (Exception $ex) {
|
2017-07-18 19:44:56 +02:00
|
|
|
$can_read = pht('N/A');
|
2015-05-19 22:59:58 +02:00
|
|
|
}
|
|
|
|
|
2017-07-18 19:44:56 +02:00
|
|
|
try {
|
|
|
|
$can_write = $service->isWritable() ? pht('Yes') : pht('No');
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
$can_write = pht('N/A');
|
2015-05-19 22:59:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$rows[] = array(
|
2017-07-18 19:44:56 +02:00
|
|
|
$name,
|
|
|
|
$can_read,
|
|
|
|
$can_write,
|
2015-05-19 22:59:58 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-07-18 19:44:56 +02:00
|
|
|
$instructions = pht(
|
|
|
|
'To configure the search engines, edit [[ %s | `%s` ]] configuration. '.
|
|
|
|
'See **[[ %s | %s ]]** for documentation.',
|
|
|
|
'/config/edit/cluster.search/',
|
|
|
|
'cluster.search',
|
|
|
|
PhabricatorEnv::getDoclink('Cluster: Search'),
|
|
|
|
pht('Cluster: Search'));
|
|
|
|
|
|
|
|
|
2015-05-19 22:59:58 +02:00
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setNoDataString(pht('No search engines available.'))
|
2017-07-18 19:44:56 +02:00
|
|
|
->setNotice(new PHUIRemarkupView($viewer, $instructions))
|
2015-05-19 22:59:58 +02:00
|
|
|
->setHeaders(
|
|
|
|
array(
|
2017-07-18 19:44:56 +02:00
|
|
|
pht('Engine Name'),
|
|
|
|
pht('Writable'),
|
|
|
|
pht('Readable'),
|
2015-05-19 22:59:58 +02:00
|
|
|
))
|
|
|
|
->setRowClasses($rowc)
|
|
|
|
->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'wide',
|
|
|
|
'',
|
2017-07-18 19:44:56 +02:00
|
|
|
'',
|
2015-05-19 22:59:58 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Search Engines'))
|
|
|
|
->appendChild($table);
|
|
|
|
|
|
|
|
return $box;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handlePanelRequest(
|
|
|
|
AphrontRequest $request,
|
|
|
|
PhabricatorController $controller) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|