From fdde45c623e0b143322a51156f2d618461dba6b7 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 22 Apr 2013 09:49:06 -0700 Subject: [PATCH] Make PHUIIconView extend AprontTagView Summary: Less code, more options. Test Plan: Test UIExamples page (action headers, tokens, icons and images). No visible difference. Reviewers: epriestley, btrahan, vrana Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5742 --- src/__phutil_library_map__.php | 2 +- src/view/phui/PHUIIconView.php | 51 ++++++++++------------------------ 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ce89a8270d..d3f9f41c91 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2374,7 +2374,7 @@ phutil_register_library_map(array( 'PHUIBoxView' => 'AphrontTagView', 'PHUIFeedStoryView' => 'AphrontView', 'PHUIIconExample' => 'PhabricatorUIExample', - 'PHUIIconView' => 'AphrontView', + 'PHUIIconView' => 'AphrontTagView', 'PackageCreateMail' => 'PackageMail', 'PackageDeleteMail' => 'PackageMail', 'PackageMail' => 'PhabricatorMail', diff --git a/src/view/phui/PHUIIconView.php b/src/view/phui/PHUIIconView.php index 3f2877ea1d..57abce3ecc 100644 --- a/src/view/phui/PHUIIconView.php +++ b/src/view/phui/PHUIIconView.php @@ -1,6 +1,6 @@ workflow = $workflow; - return $this; - } - public function setImage($image) { $this->image = $image; return $this; @@ -47,46 +41,31 @@ final class PHUIIconView extends AphrontView { return $this; } - public function render() { - require_celerity_resource('phui-icon-view-css'); - + public function getTagName() { $tag = 'span'; if ($this->href) { $tag = 'a'; } + return $tag; + } - $classes = array(); - $classes[] = 'phui-icon-item-link'; + public function getTagAttributes() { + require_celerity_resource('phui-icon-view-css'); + + $this->addClass('phui-icon-item-link'); if ($this->spriteIcon) { require_celerity_resource('sprite-'.$this->spriteSheet.'-css'); - $classes[] = 'sprite-'.$this->spriteSheet; - $classes[] = $this->spriteSheet.'-'.$this->spriteIcon; - - $action_icon = phutil_tag( - $tag, - array( - 'href' => $this->href ? $this->href : null, - 'class' => implode(' ', $classes), - 'sigil' => $this->workflow ? 'workflow' : null, - ), - ''); + $this->addClass('sprite-'.$this->spriteSheet); + $this->addClass($this->spriteSheet.'-'.$this->spriteIcon); } else { if ($this->headSize) { - $classes[] = $this->headSize; + $this->addClass($this->headSize); } - - $action_icon = phutil_tag( - $tag, - array( - 'href' => $this->href ? $this->href : null, - 'class' => implode(' ', $classes), - 'sigil' => $this->workflow ? 'workflow' : null, - 'style' => 'background-image: url('.$this->image.');' - ), - ''); + $this->setStyle('background-image: url('.$this->image.');'); } - return $action_icon; + $attribs = array('href' => $this->href); + return $attribs; } }