forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorActionHeaderView.php
148 lines (124 loc) · 3.25 KB
/
PhabricatorActionHeaderView.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
final class PhabricatorActionHeaderView extends AphrontView {
const ICON_GREY = 'grey';
const ICON_WHITE = 'white';
const HEADER_GREY = 'grey';
const HEADER_DARK_GREY = 'dark-grey';
const HEADER_BLUE = 'blue';
const HEADER_GREEN = 'green';
const HEADER_RED = 'red';
const HEADER_YELLOW = 'yellow';
private $headerTitle;
private $headerHref;
private $headerIcon;
private $headerSigils = array();
private $actions = array();
private $iconColor = PhabricatorActionHeaderView::ICON_GREY;
private $headerColor;
private $dropdown;
public function setDropdown($dropdown) {
$this->dropdown = $dropdown;
return $this;
}
public function addAction(PHUIIconView $action) {
$this->actions[] = $action;
return $this;
}
public function setTag(PhabricatorTagView $tag) {
$this->actions[] = $tag;
return $this;
}
public function setHeaderTitle($header) {
$this->headerTitle = $header;
return $this;
}
public function setHeaderHref($href) {
$this->headerHref = $href;
return $this;
}
public function addHeaderSigil($sigil) {
$this->headerSigils[] = $sigil;
return $this;
}
public function setHeaderIcon($minicon) {
$this->headerIcon = $minicon;
return $this;
}
public function setIconColor($color) {
$this->iconColor = $color;
return $this;
}
public function setHeaderColor($color) {
$this->headerColor = $color;
return $this;
}
public function render() {
require_celerity_resource('phabricator-action-header-view-css');
$classes = array();
$classes[] = 'phabricator-action-header';
if ($this->headerColor) {
$classes[] = 'sprite-gradient';
$classes[] = 'gradient-'.$this->headerColor.'-header';
}
if ($this->dropdown) {
$classes[] = 'dropdown';
}
$action_list = array();
foreach ($this->actions as $action) {
$action_list[] = phutil_tag(
'li',
array(
'class' => 'phabricator-action-header-icon-item'
),
$action);
}
$header_icon = '';
if ($this->headerIcon) {
require_celerity_resource('sprite-minicons-css');
$header_icon = phutil_tag(
'span',
array(
'class' => 'sprite-minicons minicons-'.$this->headerIcon
),
'');
}
$header_title = $this->headerTitle;
if ($this->headerHref) {
$header_title = javelin_tag(
'a',
array(
'class' => 'phabricator-action-header-link',
'href' => $this->headerHref,
'sigil' => implode(' ', $this->headerSigils)
),
$this->headerTitle);
}
$header = phutil_tag(
'h3',
array(
'class' => 'phabricator-action-header-title'
),
array(
$header_icon,
$header_title));
$icons = '';
if (!empty($action_list)) {
$classes[] = 'phabricator-action-header-icon-'.$this->iconColor;
$icons = phutil_tag(
'ul',
array(
'class' => 'phabricator-action-header-icon-list'
),
$action_list);
}
return phutil_tag(
'div',
array(
'class' => implode(' ', $classes)
),
array(
$header,
$icons
));
}
}