2013-04-05 16:40:27 +02:00
|
|
|
<?php
|
|
|
|
|
2013-04-22 18:49:06 +02:00
|
|
|
final class PHUIIconView extends AphrontTagView {
|
2013-04-05 16:40:27 +02:00
|
|
|
|
|
|
|
const SPRITE_MINICONS = 'minicons';
|
|
|
|
const SPRITE_ACTIONS = 'actions';
|
2013-04-13 18:09:42 +02:00
|
|
|
const SPRITE_APPS = 'apps';
|
2013-04-20 02:44:20 +02:00
|
|
|
const SPRITE_TOKENS = 'tokens';
|
|
|
|
|
|
|
|
const HEAD_SMALL = 'phuihead-small';
|
|
|
|
const HEAD_MEDIUM = 'phuihead-medium';
|
2013-04-05 16:40:27 +02:00
|
|
|
|
2013-04-22 18:49:06 +02:00
|
|
|
private $href = null;
|
2013-04-05 16:40:27 +02:00
|
|
|
private $image;
|
2013-04-20 02:44:20 +02:00
|
|
|
private $headSize = null;
|
2013-04-05 16:40:27 +02:00
|
|
|
private $spriteIcon;
|
|
|
|
private $spriteSheet;
|
|
|
|
|
|
|
|
public function setHref($href) {
|
|
|
|
$this->href = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setImage($image) {
|
|
|
|
$this->image = $image;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-04-20 02:44:20 +02:00
|
|
|
public function setHeadSize($size) {
|
|
|
|
$this->headSize = $size;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-04-05 16:40:27 +02:00
|
|
|
public function setSpriteIcon($sprite) {
|
|
|
|
$this->spriteIcon = $sprite;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSpriteSheet($sheet) {
|
|
|
|
$this->spriteSheet = $sheet;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-04-22 18:49:06 +02:00
|
|
|
public function getTagName() {
|
2013-04-13 18:09:42 +02:00
|
|
|
$tag = 'span';
|
|
|
|
if ($this->href) {
|
|
|
|
$tag = 'a';
|
|
|
|
}
|
2013-04-22 18:49:06 +02:00
|
|
|
return $tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTagAttributes() {
|
|
|
|
require_celerity_resource('phui-icon-view-css');
|
2013-04-13 18:09:42 +02:00
|
|
|
|
2013-04-22 18:49:06 +02:00
|
|
|
$this->addClass('phui-icon-item-link');
|
2013-04-20 02:44:20 +02:00
|
|
|
|
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-22 18:49:06 +02:00
|
|
|
$this->addClass('sprite-'.$this->spriteSheet);
|
|
|
|
$this->addClass($this->spriteSheet.'-'.$this->spriteIcon);
|
2013-04-05 16:40:27 +02:00
|
|
|
} else {
|
2013-04-20 02:44:20 +02:00
|
|
|
if ($this->headSize) {
|
2013-04-22 18:49:06 +02:00
|
|
|
$this->addClass($this->headSize);
|
2013-04-20 02:44:20 +02:00
|
|
|
}
|
2013-04-22 18:49:06 +02:00
|
|
|
$this->setStyle('background-image: url('.$this->image.');');
|
2013-04-05 16:40:27 +02:00
|
|
|
}
|
|
|
|
|
2013-04-22 18:49:06 +02:00
|
|
|
$attribs = array('href' => $this->href);
|
|
|
|
return $attribs;
|
2013-04-05 16:40:27 +02:00
|
|
|
}
|
|
|
|
}
|