@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PHUIHeadThingView extends AphrontTagView {
4
5 private $image;
6 private $imageHref;
7 private $content;
8 private $size;
9
10 const SMALL = 'head-thing-small';
11 const MEDIUM = 'head-thing-medium';
12
13 public function setImageHref($href) {
14 $this->imageHref = $href;
15 return $this;
16 }
17
18 public function setImage($image) {
19 $this->image = $image;
20 return $this;
21 }
22
23 public function setContent($content) {
24 $this->content = $content;
25 return $this;
26 }
27
28 public function setSize($size) {
29 $this->size = $size;
30 return $this;
31 }
32
33 protected function getTagAttributes() {
34 require_celerity_resource('phui-head-thing-view-css');
35
36 $classes = array();
37 $classes[] = 'phui-head-thing-view';
38 if ($this->image) {
39 $classes[] = 'phui-head-has-image';
40 }
41
42 if ($this->size) {
43 $classes[] = $this->size;
44 } else {
45 $classes[] = self::SMALL;
46 }
47
48 return array(
49 'class' => $classes,
50 );
51 }
52
53 protected function getTagContent() {
54
55 $image = javelin_tag(
56 'a',
57 array(
58 'class' => 'phui-head-thing-image',
59 'style' => 'background-image: url('.$this->image.');',
60 'href' => $this->imageHref,
61 'aural' => false,
62 ));
63
64 if ($this->image) {
65 return array($image, $this->content);
66 } else {
67 return $this->content;
68 }
69
70 }
71
72}