@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 65 lines 1.2 kB view raw
1<?php 2 3final class PHUISegmentBarView extends AphrontTagView { 4 5 private $label; 6 private $segments = array(); 7 8 public function setLabel($label) { 9 $this->label = $label; 10 return $this; 11 } 12 13 public function newSegment() { 14 $segment = new PHUISegmentBarSegmentView(); 15 $this->segments[] = $segment; 16 return $segment; 17 } 18 19 protected function canAppendChild() { 20 return false; 21 } 22 23 protected function getTagAttributes() { 24 return array( 25 'class' => 'phui-segment-bar-view', 26 ); 27 } 28 29 protected function getTagContent() { 30 require_celerity_resource('phui-segment-bar-view-css'); 31 32 $label = $this->label; 33 if ($label !== null) { 34 $label = phutil_tag( 35 'div', 36 array( 37 'class' => 'phui-segment-bar-label', 38 ), 39 $label); 40 } 41 42 $segments = $this->segments; 43 44 $position = 0; 45 foreach ($segments as $segment) { 46 $segment->setPosition($position); 47 $position += $segment->getWidth(); 48 } 49 50 $segments = array_reverse($segments); 51 52 $segments = phutil_tag( 53 'div', 54 array( 55 'class' => 'phui-segment-bar-segments', 56 ), 57 $segments); 58 59 return array( 60 $label, 61 $segments, 62 ); 63 } 64 65}