2013-12-03 01:09:07 +01:00
|
|
|
<?php
|
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
final class DrydockBlueprintListController extends DrydockController
|
|
|
|
implements PhabricatorApplicationSearchResultsControllerInterface {
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
private $queryKey;
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->queryKey = idx($data, 'queryKey');
|
|
|
|
}
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
|
|
|
->setQueryKey($this->queryKey)
|
|
|
|
->setSearchEngine(new DrydockBlueprintSearchEngine())
|
|
|
|
->setNavigation($this->buildSideNav());
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
return $this->delegateToController($controller);
|
2013-12-03 01:09:07 +01:00
|
|
|
}
|
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
public function renderResultsList(
|
|
|
|
array $blueprints,
|
|
|
|
PhabricatorSavedQuery $query) {
|
2013-12-03 01:09:07 +01:00
|
|
|
assert_instances_of($blueprints, 'DrydockBlueprint');
|
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
2013-12-03 01:09:07 +01:00
|
|
|
$view = new PHUIObjectItemListView();
|
|
|
|
|
|
|
|
foreach ($blueprints as $blueprint) {
|
|
|
|
$item = id(new PHUIObjectItemView())
|
|
|
|
->setHeader($blueprint->getClassName())
|
|
|
|
->setHref($this->getApplicationURI('/blueprint/'.$blueprint->getID()))
|
|
|
|
->setObjectName(pht('Blueprint %d', $blueprint->getID()));
|
|
|
|
|
|
|
|
if ($blueprint->getImplementation()->isEnabled()) {
|
|
|
|
$item->addAttribute(pht('Enabled'));
|
|
|
|
$item->setBarColor('green');
|
|
|
|
} else {
|
|
|
|
$item->addAttribute(pht('Disabled'));
|
|
|
|
$item->setBarColor('red');
|
|
|
|
}
|
|
|
|
|
|
|
|
$item->addAttribute($blueprint->getImplementation()->getDescription());
|
|
|
|
|
|
|
|
$view->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|