Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/view/phui/PHUICrumbView.php
12249 views
1
<?php
2
3
final class PHUICrumbView extends AphrontView {
4
5
private $name;
6
private $href;
7
private $icon;
8
private $isLastCrumb;
9
private $workflow;
10
private $aural;
11
private $alwaysVisible;
12
13
public function setAural($aural) {
14
$this->aural = $aural;
15
return $this;
16
}
17
18
public function getAural() {
19
return $this->aural;
20
}
21
22
/**
23
* Make this crumb always visible, even on devices where it would normally
24
* be hidden.
25
*
26
* @param bool True to make the crumb always visible.
27
* @return this
28
*/
29
public function setAlwaysVisible($always_visible) {
30
$this->alwaysVisible = $always_visible;
31
return $this;
32
}
33
34
public function getAlwaysVisible() {
35
return $this->alwaysVisible;
36
}
37
38
public function setWorkflow($workflow) {
39
$this->workflow = $workflow;
40
return $this;
41
}
42
43
public function setName($name) {
44
$this->name = $name;
45
return $this;
46
}
47
48
public function getName() {
49
return $this->name;
50
}
51
52
public function setHref($href) {
53
$this->href = $href;
54
return $this;
55
}
56
57
public function setIcon($icon) {
58
$this->icon = $icon;
59
return $this;
60
}
61
62
protected function canAppendChild() {
63
return false;
64
}
65
66
public function setIsLastCrumb($is_last_crumb) {
67
$this->isLastCrumb = $is_last_crumb;
68
return $this;
69
}
70
71
public function render() {
72
$classes = array(
73
'phui-crumb-view',
74
);
75
76
$aural = null;
77
if ($this->aural !== null) {
78
$aural = javelin_tag(
79
'span',
80
array(
81
'aural' => true,
82
),
83
$this->aural);
84
}
85
86
$icon = null;
87
if ($this->icon) {
88
$classes[] = 'phui-crumb-has-icon';
89
$icon = id(new PHUIIconView())
90
->setIcon($this->icon);
91
}
92
93
// Surround the crumb name with spaces so that double clicking it only
94
// selects the crumb itself.
95
$name = array(' ', $this->name);
96
97
$name = phutil_tag(
98
'span',
99
array(
100
'class' => 'phui-crumb-name',
101
),
102
$name);
103
104
// Because of text-overflow and safari, put the second space on the
105
// outside of the element.
106
$name = array($name, ' ');
107
108
$divider = null;
109
if (!$this->isLastCrumb) {
110
$divider = id(new PHUIIconView())
111
->setIcon('fa-angle-right')
112
->addClass('phui-crumb-divider')
113
->addClass('phui-crumb-view');
114
} else {
115
$classes[] = 'phabricator-last-crumb';
116
}
117
118
if ($this->getAlwaysVisible()) {
119
$classes[] = 'phui-crumb-always-visible';
120
}
121
122
$tag = javelin_tag(
123
$this->href ? 'a' : 'span',
124
array(
125
'sigil' => $this->workflow ? 'workflow' : null,
126
'href' => $this->href,
127
'class' => implode(' ', $classes),
128
),
129
array($aural, $icon, $name));
130
131
return array($tag, $divider);
132
}
133
}
134
135