@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 53 lines 1.2 kB view raw
1<?php 2 3final class PHUIButtonBarView extends AphrontTagView { 4 5 private $buttons = array(); 6 private $borderless; 7 8 public function addButton($button) { 9 $this->buttons[] = $button; 10 return $this; 11 } 12 13 public function setBorderless($borderless) { 14 $this->borderless = $borderless; 15 return $this; 16 } 17 18 protected function getTagAttributes() { 19 $classes = array(); 20 $classes[] = 'phui-button-bar'; 21 if ($this->borderless) { 22 $classes[] = 'phui-button-bar-borderless'; 23 } 24 return array('class' => implode(' ', $classes)); 25 } 26 27 protected function getTagName() { 28 return 'span'; 29 } 30 31 protected function getTagContent() { 32 require_celerity_resource('phui-button-bar-css'); 33 34 $i = 1; 35 $j = count($this->buttons); 36 foreach ($this->buttons as $button) { 37 // LeeLoo Dallas Multi-Pass 38 if ($j > 1) { 39 if ($i == 1) { 40 $button->addClass('phui-button-bar-first'); 41 } else if ($i == $j) { 42 $button->addClass('phui-button-bar-last'); 43 } else if ($j > 1) { 44 $button->addClass('phui-button-bar-middle'); 45 } 46 } 47 $this->appendChild($button); 48 $i++; 49 } 50 51 return $this->renderChildren(); 52 } 53}