2013-07-03 20:15:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group legalpad
|
|
|
|
*/
|
|
|
|
final class LegalpadDocumentListController extends LegalpadController
|
|
|
|
implements PhabricatorApplicationSearchResultsControllerInterface {
|
|
|
|
|
|
|
|
private $queryKey;
|
|
|
|
|
|
|
|
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 LegalpadDocumentSearchEngine())
|
|
|
|
->setNavigation($this->buildSideNav());
|
|
|
|
|
|
|
|
return $this->delegateToController($controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderResultsList(
|
|
|
|
array $documents,
|
|
|
|
PhabricatorSavedQuery $query) {
|
|
|
|
assert_instances_of($documents, 'LegalpadDocument');
|
|
|
|
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
2013-07-09 02:06:49 +02:00
|
|
|
$contributors = array_mergev(
|
|
|
|
mpull($documents, 'getRecentContributorPHIDs'));
|
2013-07-03 20:15:45 +02:00
|
|
|
$this->loadHandles($contributors);
|
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$list = new PHUIObjectItemListView();
|
2013-07-03 20:15:45 +02:00
|
|
|
$list->setUser($user);
|
|
|
|
foreach ($documents as $document) {
|
|
|
|
$last_updated = phabricator_date($document->getDateModified(), $user);
|
2013-07-10 20:46:39 +02:00
|
|
|
$recent_contributors = $document->getRecentContributorPHIDs();
|
|
|
|
$updater = $this->getHandle(reset($recent_contributors))->renderLink();
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2013-07-09 02:06:49 +02:00
|
|
|
$title = $document->getTitle();
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$item = id(new PHUIObjectItemView())
|
2013-07-03 20:15:45 +02:00
|
|
|
->setObjectName('L'.$document->getID())
|
|
|
|
->setHeader($title)
|
|
|
|
->setHref($this->getApplicationURI('view/'.$document->getID()))
|
|
|
|
->setObject($document)
|
|
|
|
->addIcon('none', pht('Last updated: %s', $last_updated))
|
|
|
|
->addByline(pht('Updated by: %s', $updater))
|
|
|
|
->addAttribute(pht('Versions: %d', $document->getVersions()));
|
|
|
|
|
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $list;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|