mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-27 06:58:17 +01:00
61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
|
<?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();
|
||
|
|
||
|
$contributors = array_mergev(mpull($documents, 'getContributors'));
|
||
|
$this->loadHandles($contributors);
|
||
|
|
||
|
$list = new PhabricatorObjectItemListView();
|
||
|
$list->setUser($user);
|
||
|
foreach ($documents as $document) {
|
||
|
$document_body = $document->getDocumentBody();
|
||
|
$last_updated = phabricator_date($document->getDateModified(), $user);
|
||
|
$updater = $this->getHandle(
|
||
|
$document_body->getCreatorPHID())->renderLink();
|
||
|
|
||
|
$title = $document_body->getTitle();
|
||
|
|
||
|
$item = id(new PhabricatorObjectItemView())
|
||
|
->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;
|
||
|
}
|
||
|
|
||
|
}
|