@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 114 lines 2.0 kB view raw
1<?php 2 3final class FuelMenuItemView 4 extends FuelView { 5 6 private $name; 7 private $uri; 8 private $icon; 9 private $disabled; 10 private $backgroundColor; 11 12 public function setURI($uri) { 13 $this->uri = $uri; 14 return $this; 15 } 16 17 public function getURI() { 18 return $this->uri; 19 } 20 21 public function setName($name) { 22 $this->name = $name; 23 return $this; 24 } 25 26 public function getName() { 27 return $this->name; 28 } 29 30 public function setIcon(PHUIIconView $icon) { 31 $this->icon = $icon; 32 return $this; 33 } 34 35 public function getIcon() { 36 return $this->icon; 37 } 38 39 public function newIcon() { 40 $icon = new PHUIIconView(); 41 $this->setIcon($icon); 42 return $icon; 43 } 44 45 public function setDisabled($disabled) { 46 $this->disabled = $disabled; 47 return $this; 48 } 49 50 public function getDisabled() { 51 return $this->disabled; 52 } 53 54 public function setBackgroundColor($background_color) { 55 $this->backgroundColor = $background_color; 56 return $this; 57 } 58 59 public function getBackgroundColor() { 60 return $this->backgroundColor; 61 } 62 63 public function render() { 64 $icon = $this->getIcon(); 65 66 $name = $this->getName(); 67 $uri = $this->getURI(); 68 69 $icon = phutil_tag( 70 'span', 71 array( 72 'class' => 'fuel-menu-item-icon', 73 ), 74 $icon); 75 76 $item_link = phutil_tag( 77 'a', 78 array( 79 'href' => $uri, 80 'class' => 'fuel-menu-item-link', 81 ), 82 array( 83 $icon, 84 $name, 85 )); 86 87 $classes = array(); 88 $classes[] = 'fuel-menu-item'; 89 90 if ($this->getDisabled()) { 91 $classes[] = 'disabled'; 92 } 93 94 $background_color = $this->getBackgroundColor(); 95 if ($background_color !== null) { 96 $classes[] = 'fuel-menu-item-background-color-'.$background_color; 97 } 98 99 100 if ($uri !== null) { 101 $classes[] = 'has-link'; 102 } 103 104 $classes = implode(' ', $classes); 105 106 return phutil_tag( 107 'div', 108 array( 109 'class' => $classes, 110 ), 111 $item_link); 112 } 113 114}