mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-26 11:10:16 +01:00
Summary: Ref T988. Minor improvements to diviner: link stuff to a valid endpoint which actually works; fix group names on the book index; improve the topics index for atom views. Test Plan: Clicked links in an article, viewed book index, viewed an article with long headers. Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T988 Differential Revision: https://secure.phabricator.com/D6598
72 lines
1.6 KiB
PHP
72 lines
1.6 KiB
PHP
<?php
|
|
|
|
final class DivinerFindController extends DivinerController {
|
|
|
|
public function shouldAllowPublic() {
|
|
return true;
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
$book_name = $request->getStr('book');
|
|
|
|
$book = null;
|
|
if ($book_name) {
|
|
$book = id(new DivinerBookQuery())
|
|
->setViewer($viewer)
|
|
->withNames(array($book_name))
|
|
->executeOne();
|
|
if (!$book) {
|
|
return new Aphront404Response();
|
|
}
|
|
}
|
|
|
|
$query = id(new DivinerAtomQuery())
|
|
->setViewer($viewer)
|
|
->withNames(
|
|
array(
|
|
$request->getStr('name'),
|
|
// TODO: This could probably be more smartly normalized in the DB,
|
|
// but just fake it for now.
|
|
phutil_utf8_strtolower($request->getStr('name')),
|
|
));
|
|
|
|
if ($book) {
|
|
$query->withBookPHIDs(array($book->getPHID()));
|
|
}
|
|
|
|
$context = $request->getStr('context');
|
|
if (strlen($context)) {
|
|
$query->withContexts(array($context));
|
|
}
|
|
|
|
$type = $request->getStr('type');
|
|
if (strlen($type)) {
|
|
$query->withTypes(array($type));
|
|
}
|
|
|
|
$atoms = $query->execute();
|
|
|
|
if (!$atoms) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
if (count($atoms) == 1 && $request->getBool('jump')) {
|
|
$atom_uri = head($atoms)->getURI();
|
|
return id(new AphrontRedirectResponse())->setURI($atom_uri);
|
|
}
|
|
|
|
$list = $this->renderAtomList($atoms);
|
|
|
|
return $this->buildApplicationPage(
|
|
$list,
|
|
array(
|
|
'title' => 'derp',
|
|
'dust' => true,
|
|
'device' => true,
|
|
));
|
|
}
|
|
|
|
}
|