Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/view/phui/PHUISegmentBarView.php
12249 views
1
<?php
2
3
final class PHUISegmentBarView extends AphrontTagView {
4
5
private $label;
6
private $segments = array();
7
8
public function setLabel($label) {
9
$this->label = $label;
10
return $this;
11
}
12
13
public function newSegment() {
14
$segment = new PHUISegmentBarSegmentView();
15
$this->segments[] = $segment;
16
return $segment;
17
}
18
19
protected function canAppendChild() {
20
return false;
21
}
22
23
protected function getTagAttributes() {
24
return array(
25
'class' => 'phui-segment-bar-view',
26
);
27
}
28
29
protected function getTagContent() {
30
require_celerity_resource('phui-segment-bar-view-css');
31
32
$label = $this->label;
33
if (strlen($label)) {
34
$label = phutil_tag(
35
'div',
36
array(
37
'class' => 'phui-segment-bar-label',
38
),
39
$label);
40
}
41
42
$segments = $this->segments;
43
44
$position = 0;
45
foreach ($segments as $segment) {
46
$segment->setPosition($position);
47
$position += $segment->getWidth();
48
}
49
50
$segments = array_reverse($segments);
51
52
$segments = phutil_tag(
53
'div',
54
array(
55
'class' => 'phui-segment-bar-segments',
56
),
57
$segments);
58
59
return array(
60
$label,
61
$segments,
62
);
63
}
64
65
}
66
67