@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 PHUIFeedStoryExample extends PhabricatorUIExample {
4
5 public function getName() {
6 return pht('Feed Story');
7 }
8
9 public function getDescription() {
10 return pht(
11 'An outlandish exaggeration of intricate tales from around the realm.');
12 }
13
14 public function getCategory() {
15 return pht('Single Use');
16 }
17
18 public function renderExample() {
19 $request = $this->getRequest();
20 $user = $request->getUser();
21
22 /* Basic Story */
23 $text = hsprintf(
24 '<strong><a>harding (Tom Harding)</a></strong> closed <a>'.
25 'D12: New spacer classes for blog views</a>.');
26 $story1 = id(new PHUIFeedStoryView())
27 ->setTitle($text)
28 ->setImage(celerity_get_resource_uri('/rsrc/image/people/harding.png'))
29 ->setImageHref('https://en.wikipedia.org/wiki/Warren_G._Harding')
30 ->setEpoch(1)
31 ->setAppIcon('fa-star')
32 ->setViewer($user);
33
34 /* Text Story, useful in Blogs, Ponders, Status */
35 $tokens = array(
36 'like-1',
37 'like-2',
38 'heart-1',
39 'heart-2',
40 );
41 $tokenview = array();
42 foreach ($tokens as $token) {
43 $tokenview[] =
44 id(new PHUIIconView())
45 ->setSpriteSheet(PHUIIconView::SPRITE_TOKENS)
46 ->setSpriteIcon($token);
47 }
48 $text = hsprintf(
49 '<strong><a>lincoln (Honest Abe)</a></strong> wrote a '.
50 'new blog post.');
51 $story2 = id(new PHUIFeedStoryView())
52 ->setTitle($text)
53 ->setImage(celerity_get_resource_uri('/rsrc/image/people/lincoln.png'))
54 ->setImageHref('https://en.wikipedia.org/wiki/Abraham_Lincoln')
55 ->setEpoch(strtotime('November 19, 1863'))
56 ->setAppIcon('fa-star')
57 ->setViewer($user)
58 ->setTokenBar($tokenview)
59 ->setPontification(
60 'Four score and seven years ago our fathers brought '.
61 'forth on this continent, a new nation, conceived in Liberty, and '.
62 'dedicated to the proposition that all men are created equal. '.
63 'Now we are engaged in a great civil war, testing whether that '.
64 'nation, or any nation so conceived and so dedicated, can long '.
65 'endure. We are met on a great battle-field of that war. We have '.
66 'come to dedicate a portion of that field, as a final resting '.
67 'place for those who here gave their lives that that nation might '.
68 'live. It is altogether fitting and proper that we should do this.',
69 'Gettysburg Address');
70
71 /* Action Story, let's give people tokens! */
72
73 $text = hsprintf(
74 '<strong><a>harding (Tom Harding)</a></strong> awarded '.
75 '<a>M10: Workboards</a> a token.');
76 $action1 = id(new PHUIIconView())
77 ->setIcon('fa-trophy bluegrey')
78 ->setHref('#');
79 $token =
80 id(new PHUIIconView())
81 ->setSpriteSheet(PHUIIconView::SPRITE_TOKENS)
82 ->setSpriteIcon('like-1');
83 $story3 = id(new PHUIFeedStoryView())
84 ->setTitle($text)
85 ->setImage(celerity_get_resource_uri('/rsrc/image/people/harding.png'))
86 ->setImageHref('https://en.wikipedia.org/wiki/Warren_G._Harding')
87 ->appendChild($token)
88 ->setEpoch(1)
89 ->addAction($action1)
90 ->setAppIcon('fa-trophy')
91 ->setViewer($user);
92
93 /* Image Story, used in Pholio, Macro */
94 $text = hsprintf(
95 '<strong><a>wgharding (Warren Harding)</a></strong> '.
96 'asked a new question.');
97 $action1 = id(new PHUIIconView())
98 ->setIcon('fa-chevron-up bluegrey')
99 ->setHref('#');
100 $action2 = id(new PHUIIconView())
101 ->setIcon('fa-chevron-down bluegrey')
102 ->setHref('#');
103 $story4 = id(new PHUIFeedStoryView())
104 ->setTitle($text)
105 ->setImage(celerity_get_resource_uri('/rsrc/image/people/harding.png'))
106 ->setImageHref('https://en.wikipedia.org/wiki/Warren_G._Harding')
107 ->setEpoch(1)
108 ->setAppIcon('fa-cogs')
109 ->setPontification(
110 'Why does inline-block add space under my spans and anchors?')
111 ->addAction($action1)
112 ->addAction($action2)
113 ->setViewer($user);
114
115 /* Text Story, useful in Blogs, Ponders, Status */
116 $text = hsprintf(
117 '<strong><a>lincoln (Honest Abe)</a></strong> updated '.
118 'his status.');
119 $story5 = id(new PHUIFeedStoryView())
120 ->setTitle($text)
121 ->setImage(celerity_get_resource_uri('/rsrc/image/people/lincoln.png'))
122 ->setImageHref('https://en.wikipedia.org/wiki/Abraham_Lincoln')
123 ->setEpoch(strtotime('November 19, 1863'))
124 ->setAppIcon('fa-rocket')
125 ->setViewer($user)
126 ->setPontification(
127 'If we ever create a lightweight status app '.
128 'this story would be how that would be displayed.');
129
130 /* Basic "One Line" Story */
131 $text = hsprintf(
132 '<strong><a>harding (Tom Harding)</a></strong> updated <a>'.
133 'D12: New spacer classes for blog views</a>.');
134 $story6 = id(new PHUIFeedStoryView())
135 ->setTitle($text)
136 ->setImage(celerity_get_resource_uri('/rsrc/image/people/harding.png'))
137 ->setImageHref('https://en.wikipedia.org/wiki/Warren_G._Harding')
138 ->setEpoch(1)
139 ->setAppIcon('fa-wifi')
140 ->setViewer($user);
141
142
143 $head1 = id(new PHUIHeaderView())
144 ->setHeader(pht('Basic Story'));
145
146 $head2 = id(new PHUIHeaderView())
147 ->setHeader(pht('Title / Text Story'));
148
149 $head3 = id(new PHUIHeaderView())
150 ->setHeader(pht('Token Story'));
151
152 $head4 = id(new PHUIHeaderView())
153 ->setHeader(pht('Action Story'));
154
155 $head5 = id(new PHUIHeaderView())
156 ->setHeader(pht('Status Story'));
157
158 $head6 = id(new PHUIHeaderView())
159 ->setHeader(pht('One Line Story'));
160
161 $wrap1 =
162 array(
163 id(new PHUIBoxView())
164 ->appendChild($story1)
165 ->addMargin(PHUI::MARGIN_MEDIUM)
166 ->addPadding(PHUI::PADDING_SMALL),
167 );
168
169 $wrap2 =
170 array(
171 id(new PHUIBoxView())
172 ->appendChild($story2)
173 ->addMargin(PHUI::MARGIN_MEDIUM)
174 ->addPadding(PHUI::PADDING_SMALL),
175 );
176
177 $wrap3 =
178 array(
179 id(new PHUIBoxView())
180 ->appendChild($story3)
181 ->addMargin(PHUI::MARGIN_MEDIUM)
182 ->addPadding(PHUI::PADDING_SMALL),
183 );
184
185 $wrap4 =
186 array(
187 id(new PHUIBoxView())
188 ->appendChild($story4)
189 ->addMargin(PHUI::MARGIN_MEDIUM)
190 ->addPadding(PHUI::PADDING_SMALL),
191 );
192
193 $wrap5 =
194 array(
195 id(new PHUIBoxView())
196 ->appendChild($story5)
197 ->addMargin(PHUI::MARGIN_MEDIUM)
198 ->addPadding(PHUI::PADDING_SMALL),
199 );
200
201 $wrap6 =
202 array(
203 id(new PHUIBoxView())
204 ->appendChild($story6)
205 ->addMargin(PHUI::MARGIN_MEDIUM)
206 ->addPadding(PHUI::PADDING_SMALL),
207 );
208
209 return phutil_tag(
210 'div',
211 array(),
212 array(
213 $head1,
214 $wrap1,
215 $head2,
216 $wrap2,
217 $head3,
218 $wrap3,
219 $head4,
220 $wrap4,
221 $head5,
222 $wrap5,
223 $head6,
224 $wrap6,
225 ));
226 }
227}