@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 74 lines 1.5 kB view raw
1<?php 2 3final 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 'aria-label' => $this->header, 61 'meta' => array( 62 'tip' => $this->header, 63 'align' => $this->tipDirection, 64 'size' => 300, 65 ), 66 ); 67 } 68 69 protected function getTagContent() { 70 return id(new PHUIIconView()) 71 ->setIcon($this->icon); 72 } 73 74}