@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 upstream/main 180 lines 3.8 kB view raw
1<?php 2 3final class PHUIFormationFlankView 4 extends PHUIFormationColumnDynamicView { 5 6 private $isFixed; 7 8 private $head; 9 private $body; 10 private $tail; 11 12 private $headID; 13 private $bodyID; 14 private $tailID; 15 16 private $headerText; 17 18 public function setIsFixed($fixed) { 19 $this->isFixed = $fixed; 20 return $this; 21 } 22 23 public function getIsFixed() { 24 return $this->isFixed; 25 } 26 27 public function setHead($head) { 28 $this->head = $head; 29 return $this; 30 } 31 32 public function setBody($body) { 33 $this->body = $body; 34 return $this; 35 } 36 37 public function setTail($tail) { 38 $this->tail = $tail; 39 return $this; 40 } 41 42 public function getHeadID() { 43 if (!$this->headID) { 44 $this->headID = celerity_generate_unique_node_id(); 45 } 46 return $this->headID; 47 } 48 49 public function getBodyID() { 50 if (!$this->bodyID) { 51 $this->bodyID = celerity_generate_unique_node_id(); 52 } 53 return $this->bodyID; 54 } 55 56 public function getTailID() { 57 if (!$this->tailID) { 58 $this->tailID = celerity_generate_unique_node_id(); 59 } 60 return $this->tailID; 61 } 62 63 public function setHeaderText($header_text) { 64 $this->headerText = $header_text; 65 return $this; 66 } 67 68 public function getHeaderText() { 69 return $this->headerText; 70 } 71 72 public function newClientProperties() { 73 return array( 74 'type' => 'flank', 75 'nodeID' => $this->getID(), 76 'isFixed' => (bool)$this->getIsFixed(), 77 'headID' => $this->getHeadID(), 78 'bodyID' => $this->getBodyID(), 79 'tailID' => $this->getTailID(), 80 ); 81 } 82 83 public function render() { 84 require_celerity_resource('phui-formation-view-css'); 85 86 $width = $this->getWidth(); 87 88 $style = array(); 89 $style[] = sprintf('width: %dpx;', $width); 90 91 $classes = array(); 92 $classes[] = 'phui-flank-view'; 93 94 if ($this->getIsFixed()) { 95 $classes[] = 'phui-flank-view-fixed'; 96 } 97 98 $head_id = $this->getHeadID(); 99 $body_id = $this->getBodyID(); 100 $tail_id = $this->getTailID(); 101 102 $header = phutil_tag( 103 'div', 104 array( 105 'class' => 'phui-flank-header', 106 ), 107 array( 108 phutil_tag( 109 'div', 110 array( 111 'class' => 'phui-flank-header-text', 112 ), 113 $this->getHeaderText()), 114 $this->newHideButton(), 115 )); 116 117 $content = phutil_tag( 118 'div', 119 array( 120 'id' => $this->getID(), 121 'class' => implode(' ', $classes), 122 'style' => implode(' ', $style), 123 ), 124 array( 125 phutil_tag( 126 'div', 127 array( 128 'id' => $head_id, 129 'class' => 'phui-flank-view-head', 130 ), 131 array( 132 $header, 133 $this->head, 134 )), 135 phutil_tag( 136 'div', 137 array( 138 'id' => $body_id, 139 'class' => 'phui-flank-view-body', 140 ), 141 $this->body), 142 phutil_tag( 143 'div', 144 array( 145 'id' => $tail_id, 146 'class' => 'phui-flank-view-tail', 147 ), 148 $this->tail), 149 )); 150 151 return $content; 152 } 153 154 private function newHideButton() { 155 $item = $this->getColumnItem(); 156 $is_right = $item->getIsRightAligned(); 157 158 $hide_classes = array(); 159 $hide_classes[] = 'phui-flank-header-hide'; 160 161 if ($is_right) { 162 $hide_icon = id(new PHUIIconView()) 163 ->setIcon('fa-chevron-right grey'); 164 $hide_classes[] = 'phui-flank-header-hide-right'; 165 } else { 166 $hide_icon = id(new PHUIIconView()) 167 ->setIcon('fa-chevron-left grey'); 168 $hide_classes[] = 'phui-flank-header-hide-left'; 169 } 170 171 return javelin_tag( 172 'div', 173 array( 174 'sigil' => 'phui-flank-header-hide', 175 'class' => implode(' ', $hide_classes), 176 ), 177 $hide_icon); 178 } 179 180}