Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/view/phui/PHUIPinboardItemView.php
12249 views
1
<?php
2
3
final class PHUIPinboardItemView extends AphrontView {
4
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;
13
14
public function setHeader($header) {
15
$this->header = $header;
16
return $this;
17
}
18
19
public function setURI($uri) {
20
$this->uri = $uri;
21
return $this;
22
}
23
24
public function setImageURI($image_uri) {
25
$this->imageURI = $image_uri;
26
return $this;
27
}
28
29
public function setImageSize($x, $y) {
30
$this->imageWidth = $x;
31
$this->imageHeight = $y;
32
return $this;
33
}
34
35
public function addIconCount($icon, $count) {
36
$this->iconBlock[] = array($icon, $count);
37
return $this;
38
}
39
40
public function setDisabled($disabled) {
41
$this->disabled = $disabled;
42
return $this;
43
}
44
45
public function setObject($object) {
46
$this->object = $object;
47
return $this;
48
}
49
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';
57
}
58
$header = phutil_tag(
59
'div',
60
array(
61
'class' => 'phui-pinboard-item-header '.$header_color,
62
),
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,
71
),
72
$this->header),
73
));
74
}
75
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',
83
),
84
phutil_tag(
85
'img',
86
array(
87
'src' => $this->imageURI,
88
'width' => $this->imageWidth,
89
'height' => $this->imageHeight,
90
)));
91
}
92
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');
100
101
$count = phutil_tag('span', array(), $block[1]);
102
$icon_list[] = phutil_tag(
103
'span',
104
array(
105
'class' => 'phui-pinboard-item-count',
106
),
107
array($icon, $count));
108
}
109
$icons = phutil_tag(
110
'div',
111
array(
112
'class' => 'phui-pinboard-icons',
113
),
114
$icon_list);
115
}
116
117
$content = $this->renderChildren();
118
if ($content) {
119
$content = phutil_tag(
120
'div',
121
array(
122
'class' => 'phui-pinboard-item-content',
123
),
124
$content);
125
}
126
127
$classes = array();
128
$classes[] = 'phui-pinboard-item-view';
129
if ($this->disabled) {
130
$classes[] = 'phui-pinboard-item-disabled';
131
}
132
133
$item = phutil_tag(
134
'div',
135
array(
136
'class' => implode(' ', $classes),
137
),
138
array(
139
$image,
140
$header,
141
$content,
142
$icons,
143
));
144
145
return phutil_tag(
146
'li',
147
array(
148
'class' => 'phui-pinboard-list-item',
149
),
150
$item);
151
}
152
153
}
154
155