forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDivinerMainController.php
77 lines (65 loc) · 2.34 KB
/
DivinerMainController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
final class DivinerMainController extends DivinerController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$books = id(new DivinerBookQuery())
->setViewer($viewer)
->execute();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->setBorder(true);
$crumbs->addTextCrumb(pht('Books'));
$query_button = id(new PHUIButtonView())
->setTag('a')
->setHref($this->getApplicationURI('query/'))
->setText(pht('Advanced Search'))
->setIcon('fa-search');
$header = id(new PHUIHeaderView())
->setHeader(pht('Documentation Books'))
->addActionLink($query_button);
$document = new PHUIDocumentView();
$document->setHeader($header);
$document->addClass('diviner-view');
if ($books) {
$books = msort($books, 'getTitle');
$list = array();
foreach ($books as $book) {
$item = id(new DivinerBookItemView())
->setTitle($book->getTitle())
->setHref('/book/'.$book->getName().'/')
->setSubtitle($book->getPreface());
$list[] = $item;
}
$list = id(new PHUIBoxView())
->addPadding(PHUI::PADDING_MEDIUM_TOP)
->appendChild($list);
$document->appendChild($list);
} else {
$text = pht(
"(NOTE) **Looking for documentation?** ".
"If you're looking for help and information about %s, ".
"you can [[https://secure.phabricator.com/diviner/ | ".
"browse the public %s documentation]] on the live site.\n\n".
"Diviner is the documentation generator used to build this ".
"documentation.\n\n".
"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 documentation and have it appear ".
"here, run this command:\n\n".
" %s\n\n",
PlatformSymbols::getPlatformServerName(),
PlatformSymbols::getPlatformServerName(),
'$ ./bin/diviner generate');
$text = new PHUIRemarkupView($viewer, $text);
$document->appendChild($text);
}
return $this->newPage()
->setTitle(pht('Documentation Books'))
->setCrumbs($crumbs)
->appendChild(array(
$document,
));
}
}