Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diviner/controller/DivinerMainController.php
| <?php | <?php | ||||
| final class DivinerMainController extends DivinerController { | final class DivinerMainController extends DivinerController { | ||||
| public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function processRequest() { | public function handleRequest(AphrontRequest $request) { | ||||
| $request = $this->getRequest(); | $viewer = $request->getViewer(); | ||||
| $viewer = $request->getUser(); | |||||
| $books = id(new DivinerBookQuery()) | $books = id(new DivinerBookQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->execute(); | ->execute(); | ||||
| $crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
| $crumbs->setBorder(true); | $crumbs->setBorder(true); | ||||
| $crumbs->addTextCrumb(pht('Books')); | $crumbs->addTextCrumb(pht('Books')); | ||||
| $search_icon = id(new PHUIIconView()) | $search_icon = id(new PHUIIconView()) | ||||
| ->setIconFont('fa-search'); | ->setIconFont('fa-search'); | ||||
| $query_button = id(new PHUIButtonView()) | $query_button = id(new PHUIButtonView()) | ||||
| ->setTag('a') | ->setTag('a') | ||||
| ->setHref($this->getApplicationURI('query/')) | ->setHref($this->getApplicationURI('query/')) | ||||
| ->setText(pht('Advanced Search')) | ->setText(pht('Advanced Search')) | ||||
| ->setIcon($search_icon); | ->setIcon($search_icon); | ||||
| $header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
| ->setHeader(pht('Documentation Books')) | ->setHeader(pht('Documentation Books')) | ||||
| ->addActionLink($query_button); | ->addActionLink($query_button); | ||||
| $document = new PHUIDocumentView(); | $document = id(new PHUIDocumentView()) | ||||
| $document->setHeader($header); | ->setHeader($header) | ||||
| $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS); | ->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS) | ||||
| $document->addClass('diviner-view'); | ->addClass('diviner-view'); | ||||
| if ($books) { | if ($books) { | ||||
| $books = msort($books, 'getTitle'); | $books = msort($books, 'getTitle'); | ||||
| $list = array(); | $list = array(); | ||||
| foreach ($books as $book) { | foreach ($books as $book) { | ||||
| $item = id(new DivinerBookItemView()) | $item = id(new DivinerBookItemView()) | ||||
| ->setTitle($book->getTitle()) | ->setTitle($book->getTitle()) | ||||
| ->setHref('/book/'.$book->getName().'/') | ->setHref('/book/'.$book->getName().'/') | ||||
| ->setSubtitle($book->getPreface()); | ->setSubtitle($book->getPreface()); | ||||
| $list[] = $item; | $list[] = $item; | ||||
| } | } | ||||
| $list = id(new PHUIBoxView()) | $list = id(new PHUIBoxView()) | ||||
| ->addPadding(PHUI::PADDING_LARGE_LEFT) | ->addPadding(PHUI::PADDING_LARGE_LEFT) | ||||
| ->addPadding(PHUI::PADDING_LARGE_RIGHT) | ->addPadding(PHUI::PADDING_LARGE_RIGHT) | ||||
| ->addPadding(PHUI::PADDING_SMALL_TOP) | ->addPadding(PHUI::PADDING_SMALL_TOP) | ||||
| ->addPadding(PHUI::PADDING_SMALL_BOTTOM) | ->addPadding(PHUI::PADDING_SMALL_BOTTOM) | ||||
| ->appendChild($list); | ->appendChild($list); | ||||
| $document->appendChild($list); | $document->appendChild($list); | ||||
| } else { | } else { | ||||
| $text = pht( | $text = pht( | ||||
| "(NOTE) **Looking for Phabricator documentation?** If you're looking ". | "(NOTE) **Looking for Phabricator documentation?** ". | ||||
| "for help and information about Phabricator, you can ". | "If you're looking for help and information about Phabricator, ". | ||||
| "[[ https://secure.phabricator.com/diviner/ | browse the public ". | "you can [[https://secure.phabricator.com/diviner/ | ". | ||||
| "Phabricator documentation ]] on the live site.\n\n". | "browse the public Phabricator documentation]] on the live site.\n\n". | ||||
| "Diviner is the documentation generator used to build the Phabricator ". | "Diviner is the documentation generator used to build the ". | ||||
| "documentation.\n\n". | "Phabricator documentation.\n\n". | ||||
| "You haven't generated any Diviner documentation books yet, so ". | "You haven't generated any Diviner documentation books yet, so ". | ||||
| "there's nothing to show here. If you'd like to generate your own ". | "there's nothing to show here. If you'd like to generate your own ". | ||||
| "local copy of the Phabricator documentation and have it appear ". | "local copy of the Phabricator documentation and have it appear ". | ||||
| "here, run this command:\n\n". | "here, run this command:\n\n". | ||||
| " phabricator/ $ ./bin/diviner generate\n\n". | " %s\n\n", | ||||
| "Right now, Diviner isn't very useful for generating documentation ". | 'phabricator/ $ ./bin/diviner generate'); | ||||
| "for projects other than Phabricator. If you're interested in using ". | |||||
| "it in your own projects, leave feedback for us on ". | |||||
| "[[ https://secure.phabricator.com/T4558 | T4558 ]]."); | |||||
| $text = PhabricatorMarkupEngine::renderOneObject( | $text = PhabricatorMarkupEngine::renderOneObject( | ||||
| id(new PhabricatorMarkupOneOff())->setContent($text), | id(new PhabricatorMarkupOneOff())->setContent($text), | ||||
| 'default', | 'default', | ||||
| $viewer); | $viewer); | ||||
| $document->appendChild($text); | $document->appendChild($text); | ||||
| } | } | ||||
| Show All 12 Lines | |||||