Guarantee terms in PhabricatorAuthPasswordEngine are strings
[phabricator/blender.git] / src / view / phui / PHUIPinboardItemView.php
blob1fafefc3d62c5b95d17f0ac7b78b806dadc9be37
1 <?php
3 final class PHUIPinboardItemView extends AphrontView {
5 private $imageURI;
6 private $uri;
7 private $header;
8 private $iconBlock = array();
9 private $disabled;
10 private $object;
11 private $imageWidth;
12 private $imageHeight;
14 public function setHeader($header) {
15 $this->header = $header;
16 return $this;
19 public function setURI($uri) {
20 $this->uri = $uri;
21 return $this;
24 public function setImageURI($image_uri) {
25 $this->imageURI = $image_uri;
26 return $this;
29 public function setImageSize($x, $y) {
30 $this->imageWidth = $x;
31 $this->imageHeight = $y;
32 return $this;
35 public function addIconCount($icon, $count) {
36 $this->iconBlock[] = array($icon, $count);
37 return $this;
40 public function setDisabled($disabled) {
41 $this->disabled = $disabled;
42 return $this;
45 public function setObject($object) {
46 $this->object = $object;
47 return $this;
50 public function render() {
51 require_celerity_resource('phui-pinboard-view-css');
52 $header = null;
53 if ($this->header) {
54 $header_color = null;
55 if ($this->disabled) {
56 $header_color = 'phui-pinboard-disabled';
58 $header = phutil_tag(
59 'div',
60 array(
61 'class' => 'phui-pinboard-item-header '.$header_color,
63 array(
64 id(new PHUISpacesNamespaceContextView())
65 ->setUser($this->getUser())
66 ->setObject($this->object),
67 phutil_tag(
68 'a',
69 array(
70 'href' => $this->uri,
72 $this->header),
73 ));
76 $image = null;
77 if ($this->imageWidth) {
78 $image = phutil_tag(
79 'a',
80 array(
81 'href' => $this->uri,
82 'class' => 'phui-pinboard-item-image-link',
84 phutil_tag(
85 'img',
86 array(
87 'src' => $this->imageURI,
88 'width' => $this->imageWidth,
89 'height' => $this->imageHeight,
90 )));
93 $icons = array();
94 if ($this->iconBlock) {
95 $icon_list = array();
96 foreach ($this->iconBlock as $block) {
97 $icon = id(new PHUIIconView())
98 ->setIcon($block[0].' lightgreytext')
99 ->addClass('phui-pinboard-icon');
101 $count = phutil_tag('span', array(), $block[1]);
102 $icon_list[] = phutil_tag(
103 'span',
104 array(
105 'class' => 'phui-pinboard-item-count',
107 array($icon, $count));
109 $icons = phutil_tag(
110 'div',
111 array(
112 'class' => 'phui-pinboard-icons',
114 $icon_list);
117 $content = $this->renderChildren();
118 if ($content) {
119 $content = phutil_tag(
120 'div',
121 array(
122 'class' => 'phui-pinboard-item-content',
124 $content);
127 $classes = array();
128 $classes[] = 'phui-pinboard-item-view';
129 if ($this->disabled) {
130 $classes[] = 'phui-pinboard-item-disabled';
133 $item = phutil_tag(
134 'div',
135 array(
136 'class' => implode(' ', $classes),
138 array(
139 $image,
140 $header,
141 $content,
142 $icons,
145 return phutil_tag(
146 'li',
147 array(
148 'class' => 'phui-pinboard-list-item',
150 $item);