Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/management/DiffusionRepositoryManagementPanel.php
13395 views
1
<?php
2
3
abstract class DiffusionRepositoryManagementPanel
4
extends Phobject {
5
6
private $viewer;
7
private $repository;
8
private $controller;
9
10
final public function setViewer(PhabricatorUser $viewer) {
11
$this->viewer = $viewer;
12
return $this;
13
}
14
15
final public function getViewer() {
16
return $this->viewer;
17
}
18
19
final public function setRepository(PhabricatorRepository $repository) {
20
$this->repository = $repository;
21
return $this;
22
}
23
24
final public function getRepository() {
25
return $this->repository;
26
}
27
28
final public function getRequest() {
29
return $this->controller->getRequest();
30
}
31
32
final public function setController(PhabricatorController $controller) {
33
$this->controller = $controller;
34
return $this;
35
}
36
37
final public function getManagementPanelKey() {
38
return $this->getPhobjectClassConstant('PANELKEY');
39
}
40
41
abstract public function getManagementPanelLabel();
42
abstract public function getManagementPanelOrder();
43
abstract public function buildManagementPanelContent();
44
public function buildManagementPanelCurtain() { return null; }
45
46
public function getManagementPanelIcon() {
47
return 'fa-pencil';
48
}
49
50
public function getManagementPanelGroupKey() {
51
return DiffusionRepositoryManagementMainPanelGroup::PANELGROUPKEY;
52
}
53
54
public function shouldEnableForRepository(
55
PhabricatorRepository $repository) {
56
return true;
57
}
58
59
public static function getAllPanels() {
60
return id(new PhutilClassMapQuery())
61
->setAncestorClass(__CLASS__)
62
->setUniqueMethod('getManagementPanelKey')
63
->setSortMethod('getManagementPanelOrder')
64
->execute();
65
}
66
67
final protected function newTimeline() {
68
return $this->controller->newTimeline($this->getRepository());
69
}
70
71
final public function getPanelURI() {
72
$repository = $this->getRepository();
73
$key = $this->getManagementPanelKey();
74
return $repository->getPathURI("manage/{$key}/");
75
}
76
77
final public function newEditEnginePage() {
78
$field_keys = $this->getEditEngineFieldKeys();
79
if (!$field_keys) {
80
return null;
81
}
82
83
$key = $this->getManagementPanelKey();
84
$label = $this->getManagementPanelLabel();
85
$panel_uri = $this->getPanelURI();
86
87
return id(new PhabricatorEditPage())
88
->setKey($key)
89
->setLabel($label)
90
->setViewURI($panel_uri)
91
->setFieldKeys($field_keys);
92
}
93
94
protected function getEditEngineFieldKeys() {
95
return array();
96
}
97
98
protected function getEditPageURI($page = null) {
99
if ($page === null) {
100
$page = $this->getManagementPanelKey();
101
}
102
103
$repository = $this->getRepository();
104
$id = $repository->getID();
105
return "/diffusion/edit/{$id}/page/{$page}/";
106
}
107
108
public function getPanelNavigationURI() {
109
return $this->getPanelURI();
110
}
111
112
final protected function newActionList() {
113
$viewer = $this->getViewer();
114
$action_id = celerity_generate_unique_node_id();
115
116
return id(new PhabricatorActionListView())
117
->setViewer($viewer)
118
->setID($action_id);
119
}
120
121
final protected function newCurtainView() {
122
$viewer = $this->getViewer();
123
124
return id(new PHUICurtainView())
125
->setViewer($viewer);
126
}
127
128
final protected function newBox($header_text, $body) {
129
$viewer = $this->getViewer();
130
131
$header = id(new PHUIHeaderView())
132
->setViewer($viewer)
133
->setHeader($header_text);
134
135
$view = id(new PHUIObjectBoxView())
136
->setViewer($viewer)
137
->setHeader($header)
138
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
139
->appendChild($body);
140
141
return $view;
142
}
143
144
}
145
146