Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / view / phui / PHUICrumbView.php
blob1e5dad2ec6417d3aea60003bbe54019d5e799471
1 <?php
3 final class PHUICrumbView extends AphrontView {
5 private $name;
6 private $href;
7 private $icon;
8 private $isLastCrumb;
9 private $workflow;
10 private $aural;
11 private $alwaysVisible;
13 public function setAural($aural) {
14 $this->aural = $aural;
15 return $this;
18 public function getAural() {
19 return $this->aural;
22 /**
23 * Make this crumb always visible, even on devices where it would normally
24 * be hidden.
26 * @param bool True to make the crumb always visible.
27 * @return this
29 public function setAlwaysVisible($always_visible) {
30 $this->alwaysVisible = $always_visible;
31 return $this;
34 public function getAlwaysVisible() {
35 return $this->alwaysVisible;
38 public function setWorkflow($workflow) {
39 $this->workflow = $workflow;
40 return $this;
43 public function setName($name) {
44 $this->name = $name;
45 return $this;
48 public function getName() {
49 return $this->name;
52 public function setHref($href) {
53 $this->href = $href;
54 return $this;
57 public function setIcon($icon) {
58 $this->icon = $icon;
59 return $this;
62 protected function canAppendChild() {
63 return false;
66 public function setIsLastCrumb($is_last_crumb) {
67 $this->isLastCrumb = $is_last_crumb;
68 return $this;
71 public function render() {
72 $classes = array(
73 'phui-crumb-view',
76 $aural = null;
77 if ($this->aural !== null) {
78 $aural = javelin_tag(
79 'span',
80 array(
81 'aural' => true,
83 $this->aural);
86 $icon = null;
87 if ($this->icon) {
88 $classes[] = 'phui-crumb-has-icon';
89 $icon = id(new PHUIIconView())
90 ->setIcon($this->icon);
93 // Surround the crumb name with spaces so that double clicking it only
94 // selects the crumb itself.
95 $name = array(' ', $this->name);
97 $name = phutil_tag(
98 'span',
99 array(
100 'class' => 'phui-crumb-name',
102 $name);
104 // Because of text-overflow and safari, put the second space on the
105 // outside of the element.
106 $name = array($name, ' ');
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';
118 if ($this->getAlwaysVisible()) {
119 $classes[] = 'phui-crumb-always-visible';
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),
129 array($aural, $icon, $name));
131 return array($tag, $divider);