@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 160 lines 3.2 kB view raw
1<?php 2 3final class PHUIActionPanelView extends AphrontTagView { 4 5 private $href; 6 private $fontIcon; 7 private $image; 8 private $header; 9 private $subHeader; 10 private $bigText; 11 private $state; 12 private $status; 13 14 const COLOR_RED = 'phui-action-panel-red'; 15 const COLOR_ORANGE = 'phui-action-panel-orange'; 16 const COLOR_YELLOW = 'phui-action-panel-yellow'; 17 const COLOR_GREEN = 'phui-action-panel-green'; 18 const COLOR_BLUE = 'phui-action-panel-blue'; 19 const COLOR_INDIGO = 'phui-action-panel-indigo'; 20 const COLOR_VIOLET = 'phui-action-panel-violet'; 21 const COLOR_PINK = 'phui-action-panel-pink'; 22 23 public function setHref($href) { 24 $this->href = $href; 25 return $this; 26 } 27 28 public function setIcon($image) { 29 $this->fontIcon = $image; 30 return $this; 31 } 32 33 public function setImage($image) { 34 $this->image = $image; 35 return $this; 36 } 37 38 public function setBigText($text) { 39 $this->bigText = $text; 40 return $this; 41 } 42 43 public function setHeader($header) { 44 $this->header = $header; 45 return $this; 46 } 47 48 public function setSubHeader($sub) { 49 $this->subHeader = $sub; 50 return $this; 51 } 52 53 public function setState($state) { 54 $this->state = $state; 55 return $this; 56 } 57 58 public function setStatus($text) { 59 $this->status = $text; 60 return $this; 61 } 62 63 protected function getTagName() { 64 return 'div'; 65 } 66 67 protected function getTagAttributes() { 68 require_celerity_resource('phui-action-panel-css'); 69 70 $classes = array(); 71 $classes[] = 'phui-action-panel'; 72 if ($this->state) { 73 $classes[] = $this->state; 74 } 75 if ($this->bigText) { 76 $classes[] = 'phui-action-panel-bigtext'; 77 } 78 79 return array( 80 'class' => implode(' ', $classes), 81 ); 82 } 83 84 protected function getTagContent() { 85 86 $icon = null; 87 if ($this->fontIcon) { 88 $fonticon = id(new PHUIIconView()) 89 ->setIcon($this->fontIcon); 90 $icon = phutil_tag( 91 'span', 92 array( 93 'class' => 'phui-action-panel-icon', 94 ), 95 $fonticon); 96 } 97 98 if ($this->image) { 99 $image = phutil_tag( 100 'img', 101 array( 102 'class' => 'phui-action-panel-image', 103 'src' => $this->image, 104 )); 105 $icon = phutil_tag( 106 'span', 107 array( 108 'class' => 'phui-action-panel-icon', 109 ), 110 $image); 111 } 112 113 $header = null; 114 if ($this->header) { 115 $header = phutil_tag( 116 'span', 117 array( 118 'class' => 'phui-action-panel-header', 119 ), 120 $this->header); 121 } 122 123 $subheader = null; 124 if ($this->subHeader) { 125 $subheader = phutil_tag( 126 'span', 127 array( 128 'class' => 'phui-action-panel-subheader', 129 ), 130 $this->subHeader); 131 } 132 133 $row = phutil_tag( 134 'span', 135 array( 136 'class' => 'phui-action-panel-row', 137 ), 138 array( 139 $icon, 140 $subheader, 141 )); 142 143 $table = phutil_tag( 144 'span', 145 array( 146 'class' => 'phui-action-panel-table', 147 ), 148 $row); 149 150 return phutil_tag( 151 'a', 152 array( 153 'href' => $this->href, 154 'class' => 'phui-action-panel-hitarea', 155 ), 156 array($header, $table)); 157 158 } 159 160}