2013-08-02 15:53:01 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class HeraldRuleListController extends HeraldController
|
|
|
|
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
|
|
|
|
|
|
private $queryKey;
|
|
|
|
|
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->queryKey = idx($data, 'queryKey');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
|
|
|
->setQueryKey($this->queryKey)
|
|
|
|
->setSearchEngine(new HeraldRuleSearchEngine())
|
|
|
|
->setNavigation($this->buildSideNavView());
|
|
|
|
|
|
|
|
return $this->delegateToController($controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderResultsList(
|
|
|
|
array $rules,
|
|
|
|
PhabricatorSavedQuery $query) {
|
|
|
|
assert_instances_of($rules, 'HeraldRule');
|
|
|
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$phids = mpull($rules, 'getAuthorPHID');
|
|
|
|
$this->loadHandles($phids);
|
|
|
|
|
2013-08-02 21:03:54 +02:00
|
|
|
$content_type_map = HeraldAdapter::getEnabledAdapterMap();
|
2013-08-02 15:53:01 +02:00
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$list = id(new PHUIObjectItemListView())
|
2013-08-02 15:53:01 +02:00
|
|
|
->setUser($viewer);
|
|
|
|
foreach ($rules as $rule) {
|
|
|
|
$id = $rule->getID();
|
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$item = id(new PHUIObjectItemView())
|
2013-08-02 15:53:01 +02:00
|
|
|
->setObjectName(pht('Rule %s', $rule->getID()))
|
|
|
|
->setHeader($rule->getName())
|
|
|
|
->setHref($this->getApplicationURI("rule/{$id}/"));
|
|
|
|
|
|
|
|
if ($rule->isPersonalRule()) {
|
|
|
|
$item->addByline(
|
|
|
|
pht(
|
|
|
|
'Authored by %s',
|
|
|
|
$this->getHandle($rule->getAuthorPHID())->renderLink()));
|
|
|
|
} else {
|
|
|
|
$item->addIcon('world', pht('Global Rule'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$item->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setHref($this->getApplicationURI("history/{$id}/"))
|
|
|
|
->setIcon('transcript')
|
|
|
|
->setName(pht('Edit Log')));
|
|
|
|
|
|
|
|
$item->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setHref('/herald/delete/'.$rule->getID().'/')
|
|
|
|
->setIcon('delete')
|
|
|
|
->setWorkflow(true));
|
|
|
|
|
|
|
|
$content_type_name = idx($content_type_map, $rule->getContentType());
|
|
|
|
$item->addAttribute(pht('Affects: %s', $content_type_name));
|
|
|
|
|
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $list;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|