1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 03:12:41 +01:00
phorge-phorge/src/view/phui/PHUIButtonView.php
Chad Little ce5eafe7f1 Move "Open in Editor" to File Box
Summary: Moves this single action to the File Contents box in Diffusion Browse. Also fixes a PHUIObjectBox missing when enable highlighting is on.

Test Plan: Enable/Disable Highlighting. See disabled Editor button.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4467

Differential Revision: https://secure.phabricator.com/D8300
2014-02-21 14:43:24 -08:00

134 lines
2.5 KiB
PHP

<?php
final class PHUIButtonView extends AphrontTagView {
const GREEN = 'green';
const GREY = 'grey';
const BLACK = 'black';
const DISABLED = 'disabled';
const SIMPLE = 'simple';
const SMALL = 'small';
const BIG = 'big';
private $size;
private $text;
private $subtext;
private $color;
private $tag = 'button';
private $dropdown;
private $icon;
private $href = null;
private $title = null;
private $disabled;
public function setText($text) {
$this->text = $text;
return $this;
}
public function setHref($href) {
$this->href = $href;
return $this;
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function setSubtext($subtext) {
$this->subtext = $subtext;
return $this;
}
public function setColor($color) {
$this->color = $color;
return $this;
}
public function setDisabled($disabled) {
$this->disabled = $disabled;
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';
}
if ($this->disabled) {
$classes[] = 'disabled';
}
return array('class' => $classes,
'href' => $this->href,
'title' => $this->title);
}
protected function getTagContent() {
$icon = null;
$text = $this->text;
if ($this->icon) {
$icon = $this->icon;
$subtext = null;
if ($this->subtext) {
$subtext = phutil_tag(
'div', array('class' => 'phui-button-subtext'), $this->subtext);
}
$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);
}
}