href = $href; return $this; } public function setImage($image) { $this->image = $image; return $this; } public function setHeadSize($size) { $this->headSize = $size; return $this; } public function setSpriteIcon($sprite) { $this->spriteIcon = $sprite; return $this; } public function setSpriteSheet($sheet) { $this->spriteSheet = $sheet; return $this; } public function getTagName() { $tag = 'span'; if ($this->href) { $tag = 'a'; } return $tag; } public function getTagAttributes() { require_celerity_resource('phui-icon-view-css'); $style = null; $classes = array(); $classes[] = 'phui-icon-view'; if ($this->spriteIcon) { require_celerity_resource('sprite-'.$this->spriteSheet.'-css'); $classes[] = 'sprite-'.$this->spriteSheet; $classes[] = $this->spriteSheet.'-'.$this->spriteIcon; } else { if ($this->headSize) { $classes[] = $this->headSize; } $style = 'background-image: url('.$this->image.');'; } return array( 'href' => $this->href, 'style' => $style, 'class' => $classes, ); } public static function getSheetManifest($sheet) { $root = dirname(phutil_get_library_root('phabricator')); $path = $root.'/resources/sprite/manifest/'.$sheet.'.json'; $data = Filesystem::readFile($path); return idx(json_decode($data, true), 'sprites'); } }