Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/markup/view/PHUIRemarkupImageView.php
| <?php | <?php | ||||
| final class PHUIRemarkupImageView | final class PHUIRemarkupImageView | ||||
| extends AphrontView { | extends AphrontView { | ||||
| private $uri; | private $uri; | ||||
| private $width; | private $width; | ||||
| private $height; | private $height; | ||||
| private $alt; | private $alt; | ||||
| private $classes = array(); | |||||
| public function setURI($uri) { | public function setURI($uri) { | ||||
| $this->uri = $uri; | $this->uri = $uri; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getURI() { | public function getURI() { | ||||
| return $this->uri; | return $this->uri; | ||||
| Show All 21 Lines | public function setAlt($alt) { | ||||
| $this->alt = $alt; | $this->alt = $alt; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getAlt() { | public function getAlt() { | ||||
| return $this->alt; | return $this->alt; | ||||
| } | } | ||||
| public function addClass($class) { | |||||
| $this->classes[] = $class; | |||||
| return $this; | |||||
| } | |||||
| public function render() { | public function render() { | ||||
| $id = celerity_generate_unique_node_id(); | $id = celerity_generate_unique_node_id(); | ||||
| Javelin::initBehavior( | Javelin::initBehavior( | ||||
| 'remarkup-load-image', | 'remarkup-load-image', | ||||
| array( | array( | ||||
| 'uri' => (string)$this->uri, | 'uri' => (string)$this->uri, | ||||
| 'imageID' => $id, | 'imageID' => $id, | ||||
| )); | )); | ||||
| $classes = null; | |||||
| if ($this->classes) { | |||||
| $classes = implode(' ', $this->classes); | |||||
| } | |||||
| return phutil_tag( | return phutil_tag( | ||||
| 'img', | 'img', | ||||
| array( | array( | ||||
| 'id' => $id, | 'id' => $id, | ||||
| 'width' => $this->getWidth(), | 'width' => $this->getWidth(), | ||||
| 'height' => $this->getHeight(), | 'height' => $this->getHeight(), | ||||
| 'alt' => $this->getAlt(), | 'alt' => $this->getAlt(), | ||||
| 'class' => $classes, | |||||
| )); | )); | ||||
| } | } | ||||
| } | } | ||||