Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/view/phui/PHUIBadgeMiniView.php
12249 views
1
<?php
2
3
final class PHUIBadgeMiniView extends AphrontTagView {
4
5
private $href;
6
private $icon;
7
private $quality;
8
private $header;
9
private $tipDirection;
10
11
public function setIcon($icon) {
12
$this->icon = $icon;
13
return $this;
14
}
15
16
public function setHref($href) {
17
$this->href = $href;
18
return $this;
19
}
20
21
public function setQuality($quality) {
22
$this->quality = $quality;
23
return $this;
24
}
25
26
public function setHeader($header) {
27
$this->header = $header;
28
return $this;
29
}
30
31
public function setTipDirection($direction) {
32
$this->tipDirection = $direction;
33
return $this;
34
}
35
36
protected function getTagName() {
37
if ($this->href) {
38
return 'a';
39
} else {
40
return 'span';
41
}
42
}
43
44
protected function getTagAttributes() {
45
require_celerity_resource('phui-badge-view-css');
46
Javelin::initBehavior('phabricator-tooltips');
47
48
$classes = array();
49
$classes[] = 'phui-badge-mini';
50
if ($this->quality) {
51
$quality_color = PhabricatorBadgesQuality::getQualityColor(
52
$this->quality);
53
$classes[] = 'phui-badge-mini-'.$quality_color;
54
}
55
56
return array(
57
'class' => implode(' ', $classes),
58
'sigil' => 'has-tooltip',
59
'href' => $this->href,
60
'meta' => array(
61
'tip' => $this->header,
62
'align' => $this->tipDirection,
63
'size' => 300,
64
),
65
);
66
}
67
68
protected function getTagContent() {
69
return id(new PHUIIconView())
70
->setIcon($this->icon);
71
}
72
73
}
74
75