Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUITagView.php
| Show All 38 Lines | final class PHUITagView extends AphrontTagView { | ||||
| private $backgroundColor; | private $backgroundColor; | ||||
| private $dotColor; | private $dotColor; | ||||
| private $closed; | private $closed; | ||||
| private $external; | private $external; | ||||
| private $icon; | private $icon; | ||||
| private $shade; | private $shade; | ||||
| private $slimShady; | private $slimShady; | ||||
| private $border; | private $border; | ||||
| private $contextObject; | |||||
| private $isExiled; | |||||
| public function setType($type) { | public function setType($type) { | ||||
| $this->type = $type; | $this->type = $type; | ||||
| switch ($type) { | switch ($type) { | ||||
| case self::TYPE_SHADE: | case self::TYPE_SHADE: | ||||
| case self::TYPE_OUTLINE: | case self::TYPE_OUTLINE: | ||||
| break; | break; | ||||
| case self::TYPE_OBJECT: | case self::TYPE_OBJECT: | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | public function setSlimShady($is_eminem) { | ||||
| $this->slimShady = $is_eminem; | $this->slimShady = $is_eminem; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function getTagName() { | protected function getTagName() { | ||||
| return strlen($this->href) ? 'a' : 'span'; | return strlen($this->href) ? 'a' : 'span'; | ||||
| } | } | ||||
| public function setContextObject($context_object) { | |||||
| $this->contextObject = $context_object; | |||||
| return $this; | |||||
| } | |||||
| public function getContextObject() { | |||||
| return $this->contextObject; | |||||
| } | |||||
| public function setIsExiled($is_exiled) { | |||||
| $this->isExiled = $is_exiled; | |||||
| return $this; | |||||
| } | |||||
| public function getIsExiled() { | |||||
| return $this->isExiled; | |||||
| } | |||||
| protected function getTagAttributes() { | protected function getTagAttributes() { | ||||
| require_celerity_resource('phui-tag-view-css'); | require_celerity_resource('phui-tag-view-css'); | ||||
| $classes = array( | $classes = array( | ||||
| 'phui-tag-view', | 'phui-tag-view', | ||||
| 'phui-tag-type-'.$this->type, | 'phui-tag-type-'.$this->type, | ||||
| ); | ); | ||||
| Show All 12 Lines | protected function getTagAttributes() { | ||||
| if ($this->icon) { | if ($this->icon) { | ||||
| $classes[] = 'phui-tag-icon-view'; | $classes[] = 'phui-tag-icon-view'; | ||||
| } | } | ||||
| if ($this->border) { | if ($this->border) { | ||||
| $classes[] = 'phui-tag-'.$this->border; | $classes[] = 'phui-tag-'.$this->border; | ||||
| } | } | ||||
| if ($this->getIsExiled()) { | |||||
| $classes[] = 'phui-tag-exiled'; | |||||
| } | |||||
| $attributes = array( | $attributes = array( | ||||
| 'href' => $this->href, | 'href' => $this->href, | ||||
| 'class' => $classes, | 'class' => $classes, | ||||
| ); | ); | ||||
| if ($this->external) { | if ($this->external) { | ||||
| $attributes += array( | $attributes += array( | ||||
| 'target' => '_blank', | 'target' => '_blank', | ||||
| 'rel' => 'noreferrer', | 'rel' => 'noreferrer', | ||||
| ); | ); | ||||
| } | } | ||||
| if ($this->phid) { | if ($this->phid) { | ||||
| Javelin::initBehavior('phui-hovercards'); | Javelin::initBehavior('phui-hovercards'); | ||||
| $hovercard_spec = array( | |||||
| 'objectPHID' => $this->phid, | |||||
| ); | |||||
| $context_object = $this->getContextObject(); | |||||
| if ($context_object) { | |||||
| $hovercard_spec['contextPHID'] = $context_object->getPHID(); | |||||
| } | |||||
| $attributes += array( | $attributes += array( | ||||
| 'sigil' => 'hovercard', | 'sigil' => 'hovercard', | ||||
| 'meta' => array( | 'meta' => array( | ||||
| 'hoverPHID' => $this->phid, | 'hovercardSpec' => $hovercard_spec, | ||||
| ), | ), | ||||
| ); | ); | ||||
| } | } | ||||
| return $attributes; | return $attributes; | ||||
| } | } | ||||
| protected function getTagContent() { | protected function getTagContent() { | ||||
| ▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines | |||||