[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/view/phui/ -> PHUIButtonView.php (source)

   1  <?php
   2  
   3  final class PHUIButtonView extends AphrontTagView {
   4  
   5    const GREEN = 'green';
   6    const GREY = 'grey';
   7    const BLACK = 'black';
   8    const DISABLED = 'disabled';
   9    const SIMPLE = 'simple';
  10  
  11    const SMALL = 'small';
  12    const BIG = 'big';
  13  
  14    private $size;
  15    private $text;
  16    private $subtext;
  17    private $color;
  18    private $tag = 'button';
  19    private $dropdown;
  20    private $icon;
  21    private $href = null;
  22    private $title = null;
  23    private $disabled;
  24    private $name;
  25  
  26    public function setName($name) {
  27      $this->name = $name;
  28      return $this;
  29    }
  30  
  31    public function getName() {
  32      return $this->name;
  33    }
  34  
  35    public function setText($text) {
  36      $this->text = $text;
  37      return $this;
  38    }
  39  
  40    public function setHref($href) {
  41      $this->href = $href;
  42      return $this;
  43    }
  44  
  45    public function setTitle($title) {
  46      $this->title = $title;
  47      return $this;
  48    }
  49  
  50    public function setSubtext($subtext) {
  51      $this->subtext = $subtext;
  52      return $this;
  53    }
  54  
  55    public function setColor($color) {
  56      $this->color = $color;
  57      return $this;
  58    }
  59  
  60    public function setDisabled($disabled) {
  61      $this->disabled = $disabled;
  62      return $this;
  63    }
  64  
  65    public function setTag($tag) {
  66      $this->tag = $tag;
  67      return $this;
  68    }
  69  
  70    public function setSize($size) {
  71      $this->size = $size;
  72      return $this;
  73    }
  74  
  75    public function setDropdown($dd) {
  76      $this->dropdown = $dd;
  77      return $this;
  78    }
  79  
  80    public function setIcon(PHUIIconView $icon) {
  81      $this->icon = $icon;
  82      return $this;
  83    }
  84  
  85    public function getTagName() {
  86      return $this->tag;
  87    }
  88  
  89    protected function getTagAttributes() {
  90  
  91      require_celerity_resource('phui-button-css');
  92  
  93      $classes = array();
  94      $classes[] = 'button';
  95  
  96      if ($this->color) {
  97        $classes[] = $this->color;
  98      }
  99  
 100      if ($this->size) {
 101        $classes[] = $this->size;
 102      }
 103  
 104      if ($this->dropdown) {
 105        $classes[] = 'dropdown';
 106      }
 107  
 108      if ($this->icon) {
 109        $classes[] = 'has-icon';
 110      }
 111  
 112      if ($this->disabled) {
 113        $classes[] = 'disabled';
 114      }
 115  
 116      return array(
 117        'class'  => $classes,
 118        'href'   => $this->href,
 119        'name'   => $this->name,
 120        'title'  => $this->title,
 121      );
 122    }
 123  
 124    protected function getTagContent() {
 125  
 126      $icon = null;
 127      $text = $this->text;
 128      if ($this->icon) {
 129        $icon = $this->icon;
 130  
 131        $subtext = null;
 132        if ($this->subtext) {
 133          $subtext = phutil_tag(
 134            'div', array('class' => 'phui-button-subtext'), $this->subtext);
 135        }
 136        $text = phutil_tag(
 137          'div', array('class' => 'phui-button-text'), array($text, $subtext));
 138      }
 139  
 140      $caret = null;
 141      if ($this->dropdown) {
 142        $caret = phutil_tag('span', array('class' => 'caret'), '');
 143      }
 144  
 145      return array($icon, $text, $caret);
 146    }
 147  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1