2013-04-05 16:40:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorActionIconView extends AphrontView {
|
|
|
|
|
|
|
|
const SPRITE_MINICONS = 'minicons';
|
|
|
|
const SPRITE_ACTIONS = 'actions';
|
2013-04-13 18:09:42 +02:00
|
|
|
const SPRITE_APPS = 'apps';
|
2013-04-05 16:40:27 +02:00
|
|
|
|
|
|
|
private $href;
|
|
|
|
private $workflow;
|
|
|
|
private $image;
|
|
|
|
private $spriteIcon;
|
|
|
|
private $spriteSheet;
|
|
|
|
|
|
|
|
public function setHref($href) {
|
|
|
|
$this->href = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setWorkflow($workflow) {
|
|
|
|
$this->workflow = $workflow;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setImage($image) {
|
|
|
|
$this->image = $image;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSpriteIcon($sprite) {
|
|
|
|
$this->spriteIcon = $sprite;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSpriteSheet($sheet) {
|
|
|
|
$this->spriteSheet = $sheet;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
require_celerity_resource('phabricator-action-icon-view-css');
|
|
|
|
|
2013-04-13 18:09:42 +02:00
|
|
|
$tag = 'span';
|
|
|
|
if ($this->href) {
|
|
|
|
$tag = 'a';
|
|
|
|
}
|
|
|
|
|
2013-04-05 16:40:27 +02:00
|
|
|
if ($this->spriteIcon) {
|
2013-04-13 18:09:42 +02:00
|
|
|
require_celerity_resource('sprite-'.$this->spriteSheet.'-css');
|
|
|
|
|
2013-04-05 16:40:27 +02:00
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phabricator-action-icon-item-link';
|
|
|
|
$classes[] = 'sprite-'.$this->spriteSheet;
|
|
|
|
$classes[] = $this->spriteSheet.'-'.$this->spriteIcon;
|
|
|
|
|
|
|
|
$action_icon = phutil_tag(
|
2013-04-13 18:09:42 +02:00
|
|
|
$tag,
|
2013-04-05 16:40:27 +02:00
|
|
|
array(
|
2013-04-13 18:09:42 +02:00
|
|
|
'href' => $this->href ? $this->href : null,
|
2013-04-05 16:40:27 +02:00
|
|
|
'class' => implode(' ', $classes),
|
|
|
|
'sigil' => $this->workflow ? 'workflow' : null,
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
} else {
|
|
|
|
$action_icon = phutil_tag(
|
2013-04-13 18:09:42 +02:00
|
|
|
$tag,
|
2013-04-05 16:40:27 +02:00
|
|
|
array(
|
2013-04-13 18:09:42 +02:00
|
|
|
'href' => $this->href ? $this->href : null,
|
2013-04-05 16:40:27 +02:00
|
|
|
'class' => 'phabricator-action-icon-item-link',
|
|
|
|
'sigil' => $this->workflow ? 'workflow' : null,
|
|
|
|
'style' => 'background-image: url('.$this->image.');'
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $action_icon;
|
|
|
|
}
|
|
|
|
}
|