3 final class PHUIFeedStoryView
extends AphrontView
{
13 private $pontification = null;
14 private $tokenBar = array();
15 private $projects = array();
16 private $actions = array();
17 private $chronologicalKey;
20 private $showTimestamp = true;
22 public function setTags($tags) {
27 public function getTags() {
31 public function setChronologicalKey($chronological_key) {
32 $this->chronologicalKey
= $chronological_key;
36 public function getChronologicalKey() {
37 return $this->chronologicalKey
;
40 public function setTitle($title) {
41 $this->title
= $title;
45 public function getTitle() {
49 public function setEpoch($epoch) {
50 $this->epoch
= $epoch;
54 public function setImage($image) {
55 $this->image
= $image;
59 public function getImage() {
63 public function setImageHref($image_href) {
64 $this->imageHref
= $image_href;
68 public function setAppIcon($icon) {
69 $this->appIcon
= $icon;
73 public function setViewed($viewed) {
74 $this->viewed
= $viewed;
78 public function getViewed() {
82 public function setHref($href) {
87 public function setAuthorIcon($author_icon) {
88 $this->authorIcon
= $author_icon;
92 public function getAuthorIcon() {
93 return $this->authorIcon
;
96 public function setTokenBar(array $tokens) {
97 $this->tokenBar
= $tokens;
101 public function setShowTimestamp($show_timestamp) {
102 $this->showTimestamp
= $show_timestamp;
106 public function getShowTimestamp() {
107 return $this->showTimestamp
;
110 public function addProject($project) {
111 $this->projects
[] = $project;
115 public function addAction(PHUIIconView
$action) {
116 $this->actions
[] = $action;
120 public function setPontification($text, $title = null) {
122 $title = phutil_tag('h3', array(), $title);
127 'class' => 'phui-feed-story-bigtext-post',
133 $this->appendChild($copy);
137 public function getHref() {
141 public function renderNotification($user) {
143 'phabricator-notification',
146 if (!$this->viewed
) {
147 $classes[] = 'phabricator-notification-unread';
150 if ($this->getShowTimestamp()) {
153 $marker = id(new PHUIIconView())
154 ->setIcon('fa-circle')
155 ->addClass('phabricator-notification-status');
156 $date = phabricator_datetime($this->epoch
, $user);
160 'class' => 'phabricator-notification-date',
166 'class' => 'phabricator-notification-foot',
176 $foot = pht('No time specified.');
185 'class' => implode(' ', $classes),
186 'sigil' => 'notification',
188 'href' => $this->getHref(),
191 array($this->title
, $foot));
194 public function render() {
196 require_celerity_resource('phui-feed-story-css');
197 Javelin
::initBehavior('phui-hovercards');
202 $actor = new PHUIIconView();
203 $actor->addClass('phui-feed-story-actor');
205 $author_icon = $this->getAuthorIcon();
208 $actor->addClass('phui-feed-story-actor-image');
209 $actor->setImage($this->image
);
210 } else if ($author_icon) {
211 $actor->addClass('phui-feed-story-actor-icon');
212 $actor->setIcon($author_icon);
215 if ($this->imageHref
) {
216 $actor->setHref($this->imageHref
);
220 // TODO: This is really bad; when rendering through Conduit and via
221 // renderText() we don't have a user.
222 if ($this->hasViewer()) {
223 $foot = phabricator_datetime($this->epoch
, $this->getViewer());
228 $foot = pht('No time specified.');
231 if ($this->chronologicalKey
) {
235 'href' => '/feed/'.$this->chronologicalKey
.'/',
241 if ($this->appIcon
) {
242 $icon = id(new PHUIIconView())
243 ->setIcon($this->appIcon
);
246 $action_list = array();
248 foreach ($this->actions
as $action) {
249 $action_list[] = phutil_tag(
252 'class' => 'phui-feed-story-action-item',
256 if (!empty($action_list)) {
260 'class' => 'phui-feed-story-action-list',
268 'class' => 'phui-feed-story-head',
272 nonempty($this->title
, pht('Untitled Story')),
276 if (!empty($this->tokenBar
)) {
277 $tokenview = phutil_tag(
280 'class' => 'phui-feed-token-bar',
283 $this->appendChild($tokenview);
286 $body_content = $this->renderChildren();
291 'class' => 'phui-feed-story-body phabricator-remarkup',
307 'class' => 'phui-feed-story-foot',
315 $classes = array('phui-feed-story');
317 return id(new PHUIBoxView())
318 ->addClass(implode(' ', $classes))
320 ->addMargin(PHUI
::MARGIN_MEDIUM_BOTTOM
)
321 ->appendChild(array($head, $body, $foot));