forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeraldController.php
68 lines (51 loc) · 1.79 KB
/
HeraldController.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
<?php
abstract class HeraldController extends PhabricatorController {
public function buildStandardPageResponse($view, array $data) {
$page = $this->buildStandardPageView();
$page->setApplicationName(pht('Herald'));
$page->setBaseURI('/herald/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x98\xBF");
$page->appendChild($view);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
public function buildApplicationMenu() {
return $this->renderNav()->getMenu();
}
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addAction(
id(new PhabricatorMenuItemView())
->setName(pht('Create Herald Rule'))
->setHref($this->getApplicationURI('new/'))
->setIcon('create'));
return $crumbs;
}
protected function renderNav() {
$nav = id(new AphrontSideNavFilterView())
->setBaseURI(new PhutilURI('/herald/'))
->addLabel(pht('My Rules'))
->addFilter('new', pht('Create Rule'));
$rules_map = HeraldContentTypeConfig::getContentTypeMap();
foreach ($rules_map as $key => $value) {
$nav->addFilter("view/{$key}/personal", $value);
}
$nav->addLabel(pht('Global Rules'));
foreach ($rules_map as $key => $value) {
$nav->addFilter("view/{$key}/global", $value);
}
$nav
->addLabel(pht('Utilities'))
->addFilter('test', pht('Test Console'))
->addFilter('transcript', pht('Transcripts'))
->addFilter('history', pht('Edit Log'));
if ($this->getRequest()->getUser()->getIsAdmin()) {
$nav->addLabel(pht('Admin'));
foreach ($rules_map as $key => $value) {
$nav->addFilter("view/{$key}/all", $value);
}
}
return $nav;
}
}