2013-07-18 21:40:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PonderQuestionListController extends PonderController
|
|
|
|
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 PonderQuestionSearchEngine())
|
|
|
|
->setNavigation($this->buildSideNavView());
|
|
|
|
|
|
|
|
return $this->delegateToController($controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderResultsList(
|
|
|
|
array $questions,
|
|
|
|
PhabricatorSavedQuery $query) {
|
|
|
|
assert_instances_of($questions, 'PonderQuestion');
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$phids = array();
|
|
|
|
$phids[] = mpull($questions, 'getAuthorPHID');
|
|
|
|
$phids = array_mergev($phids);
|
|
|
|
|
|
|
|
$handles = $this->loadViewerHandles($phids);
|
|
|
|
|
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$view = id(new PHUIObjectItemListView())
|
2013-07-18 21:40:51 +02:00
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
foreach ($questions as $question) {
|
2013-09-09 23:14:34 +02:00
|
|
|
$item = new PHUIObjectItemView();
|
2013-07-18 21:40:51 +02:00
|
|
|
$item->setObjectName('Q'.$question->getID());
|
|
|
|
$item->setHeader($question->getTitle());
|
|
|
|
$item->setHref('/Q'.$question->getID());
|
|
|
|
$item->setObject($question);
|
2013-07-28 03:37:17 +02:00
|
|
|
$item->setBarColor(
|
|
|
|
PonderQuestionStatus::getQuestionStatusTagColor(
|
|
|
|
$question->getStatus()));
|
2013-07-18 21:40:51 +02:00
|
|
|
|
|
|
|
$created_date = phabricator_date($question->getDateCreated(), $viewer);
|
|
|
|
$item->addIcon('none', $created_date);
|
|
|
|
$item->addByline(
|
|
|
|
pht(
|
|
|
|
'Asked by %s',
|
|
|
|
$handles[$question->getAuthorPHID()]->renderLink()));
|
|
|
|
|
|
|
|
$item->addAttribute(
|
|
|
|
pht('%d Answer(s)', $question->getAnswerCount()));
|
|
|
|
|
|
|
|
$view->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|