2016-02-26 23:34:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PHUIHeadThingView extends AphrontTagView {
|
|
|
|
|
|
|
|
private $image;
|
|
|
|
private $imageHref;
|
|
|
|
private $content;
|
|
|
|
private $size;
|
|
|
|
|
|
|
|
const SMALL = 'head-thing-small';
|
|
|
|
const MEDIUM = 'head-thing-medium';
|
|
|
|
|
|
|
|
public function setImageHref($href) {
|
|
|
|
$this->imageHref = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setImage($image) {
|
|
|
|
$this->image = $image;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setContent($content) {
|
|
|
|
$this->content = $content;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSize($size) {
|
|
|
|
$this->size = $size;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagAttributes() {
|
|
|
|
require_celerity_resource('phui-head-thing-view-css');
|
|
|
|
|
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phui-head-thing-view';
|
2016-03-17 20:01:22 +01:00
|
|
|
if ($this->image) {
|
|
|
|
$classes[] = 'phui-head-has-image';
|
|
|
|
}
|
2016-02-26 23:34:51 +01:00
|
|
|
|
|
|
|
if ($this->size) {
|
|
|
|
$classes[] = $this->size;
|
|
|
|
} else {
|
|
|
|
$classes[] = self::SMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'class' => $classes,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagContent() {
|
|
|
|
|
|
|
|
$image = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
2018-08-16 22:48:42 +02:00
|
|
|
'class' => 'phui-head-thing-image visual-only',
|
2016-02-26 23:34:51 +01:00
|
|
|
'style' => 'background-image: url('.$this->image.');',
|
|
|
|
'href' => $this->imageHref,
|
|
|
|
));
|
|
|
|
|
2016-03-17 20:01:22 +01:00
|
|
|
if ($this->image) {
|
|
|
|
return array($image, $this->content);
|
|
|
|
} else {
|
|
|
|
return $this->content;
|
|
|
|
}
|
2016-02-26 23:34:51 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|