2013-06-13 03:23:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PHUIButtonView extends AphrontTagView {
|
|
|
|
|
|
|
|
const GREEN = 'green';
|
|
|
|
const GREY = 'grey';
|
|
|
|
const BLACK = 'black';
|
|
|
|
const DISABLED = 'disabled';
|
2013-12-03 17:34:04 +01:00
|
|
|
const SIMPLE = 'simple';
|
2013-06-13 03:23:35 +02:00
|
|
|
|
|
|
|
const SMALL = 'small';
|
|
|
|
const BIG = 'big';
|
|
|
|
|
|
|
|
private $size;
|
|
|
|
private $text;
|
|
|
|
private $subtext;
|
|
|
|
private $color;
|
2013-06-17 15:12:45 +02:00
|
|
|
private $tag = 'button';
|
2013-06-13 03:23:35 +02:00
|
|
|
private $dropdown;
|
|
|
|
private $icon;
|
2013-12-03 20:58:10 +01:00
|
|
|
private $href = null;
|
2014-02-10 20:11:36 +01:00
|
|
|
private $title = null;
|
2013-06-13 03:23:35 +02:00
|
|
|
|
|
|
|
public function setText($text) {
|
|
|
|
$this->text = $text;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-12-03 20:58:10 +01:00
|
|
|
public function setHref($href) {
|
|
|
|
$this->href = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-02-10 20:11:36 +01:00
|
|
|
public function setTitle($title) {
|
|
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-06-13 03:23:35 +02:00
|
|
|
public function setSubtext($subtext) {
|
|
|
|
$this->subtext = $subtext;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setColor($color) {
|
|
|
|
$this->color = $color;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTag($tag) {
|
|
|
|
$this->tag = $tag;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSize($size) {
|
|
|
|
$this->size = $size;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDropdown($dd) {
|
|
|
|
$this->dropdown = $dd;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIcon(PHUIIconView $icon) {
|
|
|
|
$this->icon = $icon;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTagName() {
|
|
|
|
return $this->tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagAttributes() {
|
|
|
|
|
|
|
|
require_celerity_resource('phui-button-css');
|
|
|
|
|
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'button';
|
|
|
|
|
|
|
|
if ($this->color) {
|
|
|
|
$classes[] = $this->color;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->size) {
|
|
|
|
$classes[] = $this->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->dropdown) {
|
|
|
|
$classes[] = 'dropdown';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->icon) {
|
|
|
|
$classes[] = 'has-icon';
|
|
|
|
}
|
|
|
|
|
2014-02-10 20:11:36 +01:00
|
|
|
return array('class' => $classes,
|
|
|
|
'href' => $this->href,
|
|
|
|
'title' => $this->title);
|
2013-06-13 03:23:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagContent() {
|
|
|
|
|
|
|
|
$icon = null;
|
|
|
|
$text = $this->text;
|
|
|
|
if ($this->icon) {
|
|
|
|
$icon = $this->icon;
|
|
|
|
|
|
|
|
$subtext = null;
|
|
|
|
if ($this->subtext) {
|
|
|
|
$subtext = phutil_tag(
|
2013-06-17 01:31:57 +02:00
|
|
|
'div', array('class' => 'phui-button-subtext'), $this->subtext);
|
2013-06-13 03:23:35 +02:00
|
|
|
}
|
|
|
|
$text = phutil_tag(
|
|
|
|
'div', array('class' => 'phui-button-text'), array($text, $subtext));
|
|
|
|
}
|
|
|
|
|
|
|
|
$caret = null;
|
|
|
|
if ($this->dropdown) {
|
|
|
|
$caret = phutil_tag('span', array('class' => 'caret'), '');
|
|
|
|
}
|
|
|
|
|
|
|
|
return array($icon, $text, $caret);
|
|
|
|
}
|
|
|
|
}
|