2016-01-16 06:37:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PHUIIconCircleView extends AphrontTagView {
|
|
|
|
|
|
|
|
private $href = null;
|
|
|
|
private $icon;
|
|
|
|
private $color;
|
|
|
|
private $size;
|
2017-05-26 20:42:31 +02:00
|
|
|
private $state;
|
2016-01-16 06:37:36 +01:00
|
|
|
|
|
|
|
const SMALL = 'circle-small';
|
|
|
|
const MEDIUM = 'circle-medium';
|
|
|
|
|
2017-05-26 20:42:31 +02:00
|
|
|
const STATE_FAIL = 'fa-times-circle';
|
|
|
|
const STATE_INFO = 'fa-info-circle';
|
|
|
|
const STATE_STOP = 'fa-stop-circle';
|
|
|
|
const STATE_START = 'fa-play-circle';
|
|
|
|
const STATE_PAUSE = 'fa-pause-circle';
|
|
|
|
const STATE_SUCCESS = 'fa-check-circle';
|
|
|
|
const STATE_WARNING = 'fa-exclamation-circle';
|
|
|
|
const STATE_PLUS = 'fa-plus-circle';
|
|
|
|
const STATE_MINUS = 'fa-minus-circle';
|
|
|
|
const STATE_UNKNOWN = 'fa-question-circle';
|
|
|
|
|
2016-01-16 06:37:36 +01:00
|
|
|
public function setHref($href) {
|
|
|
|
$this->href = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-01-28 05:38:01 +01:00
|
|
|
public function setIcon($icon) {
|
2016-01-16 06:37:36 +01:00
|
|
|
$this->icon = $icon;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setColor($color) {
|
|
|
|
$this->color = $color;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSize($size) {
|
|
|
|
$this->size = $size;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-05-26 20:42:31 +02:00
|
|
|
public function setState($state) {
|
|
|
|
$this->state = $state;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-01-16 06:37:36 +01:00
|
|
|
protected function getTagName() {
|
|
|
|
$tag = 'span';
|
|
|
|
if ($this->href) {
|
|
|
|
$tag = 'a';
|
|
|
|
}
|
|
|
|
return $tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagAttributes() {
|
|
|
|
require_celerity_resource('phui-icon-view-css');
|
|
|
|
|
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phui-icon-circle';
|
|
|
|
|
|
|
|
if ($this->color) {
|
2016-09-15 06:05:19 +02:00
|
|
|
$classes[] = 'hover-'.$this->color;
|
|
|
|
} else {
|
|
|
|
$classes[] = 'hover-sky';
|
2016-01-16 06:37:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->size) {
|
|
|
|
$classes[] = $this->size;
|
|
|
|
}
|
|
|
|
|
2017-05-26 20:42:31 +02:00
|
|
|
if ($this->state) {
|
|
|
|
$classes[] = 'phui-icon-circle-state';
|
|
|
|
}
|
|
|
|
|
2016-01-16 06:37:36 +01:00
|
|
|
return array(
|
|
|
|
'href' => $this->href,
|
|
|
|
'class' => $classes,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagContent() {
|
2017-05-26 20:42:31 +02:00
|
|
|
$state = null;
|
|
|
|
if ($this->state) {
|
|
|
|
$state = id(new PHUIIconView())
|
|
|
|
->setIcon($this->state.' '.$this->color)
|
|
|
|
->addClass('phui-icon-circle-state-icon');
|
|
|
|
}
|
|
|
|
|
2016-01-16 06:37:36 +01:00
|
|
|
return id(new PHUIIconView())
|
2017-05-26 20:42:31 +02:00
|
|
|
->setIcon($this->icon)
|
|
|
|
->addClass('phui-icon-circle-icon')
|
|
|
|
->appendChild($state);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getStateMap() {
|
|
|
|
return array(
|
|
|
|
self::STATE_FAIL => pht('Failure'),
|
|
|
|
self::STATE_INFO => pht('Information'),
|
|
|
|
self::STATE_STOP => pht('Stop'),
|
|
|
|
self::STATE_START => pht('Start'),
|
|
|
|
self::STATE_PAUSE => pht('Pause'),
|
|
|
|
self::STATE_SUCCESS => pht('Success'),
|
|
|
|
self::STATE_WARNING => pht('Warning'),
|
|
|
|
self::STATE_PLUS => pht('Plus'),
|
|
|
|
self::STATE_MINUS => pht('Minus'),
|
|
|
|
self::STATE_UNKNOWN => pht('Unknown'),
|
|
|
|
);
|
2016-01-16 06:37:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|