2014-03-05 22:07:50 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DivinerMainController extends DivinerController {
|
|
|
|
|
2014-03-06 02:19:40 +01:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-16 23:09:53 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
2014-03-05 22:07:50 +01:00
|
|
|
|
|
|
|
$books = id(new DivinerBookQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2015-01-30 18:17:17 +01:00
|
|
|
$crumbs->setBorder(true);
|
2014-03-05 22:07:50 +01:00
|
|
|
$crumbs->addTextCrumb(pht('Books'));
|
|
|
|
|
|
|
|
$search_icon = id(new PHUIIconView())
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIconFont('fa-search');
|
2014-03-05 22:07:50 +01:00
|
|
|
|
|
|
|
$query_button = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setHref($this->getApplicationURI('query/'))
|
|
|
|
->setText(pht('Advanced Search'))
|
|
|
|
->setIcon($search_icon);
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Documentation Books'))
|
|
|
|
->addActionLink($query_button);
|
|
|
|
|
2015-06-16 23:09:53 +02:00
|
|
|
$document = id(new PHUIDocumentView())
|
|
|
|
->setHeader($header)
|
|
|
|
->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS)
|
|
|
|
->addClass('diviner-view');
|
2014-03-05 22:07:50 +01:00
|
|
|
|
|
|
|
if ($books) {
|
|
|
|
$books = msort($books, 'getTitle');
|
2014-03-06 20:28:24 +01:00
|
|
|
$list = array();
|
2014-03-05 22:07:50 +01:00
|
|
|
foreach ($books as $book) {
|
2014-03-06 20:28:24 +01:00
|
|
|
$item = id(new DivinerBookItemView())
|
|
|
|
->setTitle($book->getTitle())
|
2014-03-05 22:07:50 +01:00
|
|
|
->setHref('/book/'.$book->getName().'/')
|
2014-03-06 20:28:24 +01:00
|
|
|
->setSubtitle($book->getPreface());
|
|
|
|
$list[] = $item;
|
2014-03-05 22:07:50 +01:00
|
|
|
}
|
2014-03-06 20:28:24 +01:00
|
|
|
$list = id(new PHUIBoxView())
|
|
|
|
->addPadding(PHUI::PADDING_LARGE_LEFT)
|
|
|
|
->addPadding(PHUI::PADDING_LARGE_RIGHT)
|
|
|
|
->addPadding(PHUI::PADDING_SMALL_TOP)
|
|
|
|
->addPadding(PHUI::PADDING_SMALL_BOTTOM)
|
|
|
|
->appendChild($list);
|
2014-03-05 22:07:50 +01:00
|
|
|
|
|
|
|
$document->appendChild($list);
|
|
|
|
} else {
|
|
|
|
$text = pht(
|
2015-06-16 23:09:53 +02:00
|
|
|
"(NOTE) **Looking for Phabricator documentation?** ".
|
|
|
|
"If you're looking for help and information about Phabricator, ".
|
|
|
|
"you can [[https://secure.phabricator.com/diviner/ | ".
|
|
|
|
"browse the public Phabricator documentation]] on the live site.\n\n".
|
|
|
|
"Diviner is the documentation generator used to build the ".
|
|
|
|
"Phabricator documentation.\n\n".
|
2014-03-05 22:07:50 +01:00
|
|
|
"You haven't generated any Diviner documentation books yet, so ".
|
|
|
|
"there's nothing to show here. If you'd like to generate your own ".
|
|
|
|
"local copy of the Phabricator documentation and have it appear ".
|
|
|
|
"here, run this command:\n\n".
|
2015-06-16 23:09:53 +02:00
|
|
|
" %s\n\n",
|
|
|
|
'phabricator/ $ ./bin/diviner generate');
|
2014-03-05 22:07:50 +01:00
|
|
|
|
|
|
|
$text = PhabricatorMarkupEngine::renderOneObject(
|
|
|
|
id(new PhabricatorMarkupOneOff())->setContent($text),
|
|
|
|
'default',
|
|
|
|
$viewer);
|
|
|
|
|
|
|
|
$document->appendChild($text);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$document,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'title' => pht('Documentation Books'),
|
2014-03-06 20:28:24 +01:00
|
|
|
'fonts' => true,
|
2014-03-05 22:07:50 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|