2011-07-05 17:35:18 +02:00
|
|
|
<?php
|
|
|
|
|
2013-04-15 04:32:26 +02:00
|
|
|
final class PHUIFeedStoryView extends AphrontView {
|
2011-07-05 17:35:18 +02:00
|
|
|
|
2011-07-09 22:28:09 +02:00
|
|
|
private $title;
|
|
|
|
private $image;
|
2013-04-13 18:09:42 +02:00
|
|
|
private $imageHref;
|
|
|
|
private $appIcon;
|
2011-07-09 22:28:09 +02:00
|
|
|
private $phid;
|
|
|
|
private $epoch;
|
2012-12-08 01:25:23 +01:00
|
|
|
private $viewed;
|
2012-12-08 01:26:43 +01:00
|
|
|
private $href;
|
2011-07-09 22:28:09 +02:00
|
|
|
|
|
|
|
public function setTitle($title) {
|
|
|
|
$this->title = $title;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setEpoch($epoch) {
|
|
|
|
$this->epoch = $epoch;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setImage($image) {
|
|
|
|
$this->image = $image;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-04-13 18:09:42 +02:00
|
|
|
public function setImageHref($image_href) {
|
|
|
|
$this->imageHref = $image_href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setAppIcon($icon) {
|
|
|
|
$this->appIcon = $icon;
|
2011-07-10 00:44:49 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:25:23 +01:00
|
|
|
public function setViewed($viewed) {
|
|
|
|
$this->viewed = $viewed;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getViewed() {
|
|
|
|
return $this->viewed;
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:26:43 +01:00
|
|
|
public function setHref($href) {
|
|
|
|
$this->href = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHref() {
|
|
|
|
return $this->href;
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:25:23 +01:00
|
|
|
public function renderNotification() {
|
|
|
|
$classes = array(
|
|
|
|
'phabricator-notification',
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!$this->viewed) {
|
|
|
|
$classes[] = 'phabricator-notification-unread';
|
|
|
|
}
|
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
return javelin_tag(
|
2012-12-08 01:25:23 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $classes),
|
2012-12-08 01:26:43 +01:00
|
|
|
'sigil' => 'notification',
|
|
|
|
'meta' => array(
|
|
|
|
'href' => $this->getHref(),
|
|
|
|
),
|
2012-12-08 01:25:23 +01:00
|
|
|
),
|
2013-02-13 03:46:01 +01:00
|
|
|
$this->title);
|
2012-12-08 01:25:23 +01:00
|
|
|
}
|
|
|
|
|
2011-07-05 17:35:18 +02:00
|
|
|
public function render() {
|
2011-07-09 22:28:09 +02:00
|
|
|
|
2013-04-13 18:09:42 +02:00
|
|
|
|
|
|
|
$actor = '';
|
|
|
|
if ($this->image) {
|
|
|
|
$actor = new PhabricatorActionIconView();
|
|
|
|
$actor->setImage($this->image);
|
|
|
|
if ($this->imageHref) {
|
|
|
|
$actor->setHref($this->imageHref);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
$head = phutil_tag(
|
2011-07-09 22:28:09 +02:00
|
|
|
'div',
|
|
|
|
array(
|
2013-04-15 04:32:26 +02:00
|
|
|
'class' => 'phui-feed-story-head',
|
2011-07-09 22:28:09 +02:00
|
|
|
),
|
2013-04-13 18:09:42 +02:00
|
|
|
array(
|
|
|
|
$actor,
|
|
|
|
nonempty($this->title, pht('Untitled Story')),
|
|
|
|
));
|
2011-07-09 22:28:09 +02:00
|
|
|
|
2011-07-10 00:44:49 +02:00
|
|
|
$body = null;
|
|
|
|
$foot = null;
|
2011-07-09 22:28:09 +02:00
|
|
|
$image_style = null;
|
2013-04-15 22:07:54 +02:00
|
|
|
$body_content = $this->renderChildren();
|
|
|
|
if ($body_content) {
|
|
|
|
$body = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-feed-story-body',
|
|
|
|
),
|
|
|
|
$body_content);
|
|
|
|
}
|
2011-07-10 00:44:49 +02:00
|
|
|
|
2013-04-13 18:09:42 +02:00
|
|
|
if ($this->epoch) {
|
|
|
|
$foot = phabricator_datetime($this->epoch, $this->user);
|
|
|
|
} else {
|
|
|
|
$foot = pht('No time specified.');
|
|
|
|
}
|
2011-07-10 00:44:49 +02:00
|
|
|
|
2013-04-13 18:09:42 +02:00
|
|
|
$icon = null;
|
|
|
|
if ($this->appIcon) {
|
|
|
|
$icon = new PhabricatorActionIconView();
|
|
|
|
$icon->setSpriteIcon($this->appIcon);
|
|
|
|
$icon->setSpriteSheet(PhabricatorActionIconView::SPRITE_APPS);
|
2011-07-09 22:28:09 +02:00
|
|
|
}
|
|
|
|
|
2013-04-13 18:09:42 +02:00
|
|
|
$foot = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
2013-04-15 04:32:26 +02:00
|
|
|
'class' => 'phui-feed-story-foot',
|
2013-04-13 18:09:42 +02:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
$icon,
|
|
|
|
$foot));
|
|
|
|
|
2013-04-15 04:32:26 +02:00
|
|
|
require_celerity_resource('phui-feed-story-css');
|
2011-07-09 22:28:09 +02:00
|
|
|
|
2013-04-13 18:09:42 +02:00
|
|
|
$story = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
2013-04-15 04:32:26 +02:00
|
|
|
'class' => 'phui-feed-story',
|
2013-04-13 18:09:42 +02:00
|
|
|
'style' => $image_style,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$head,
|
|
|
|
$body,
|
|
|
|
$foot));
|
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
return phutil_tag(
|
2011-07-05 17:35:18 +02:00
|
|
|
'div',
|
2013-04-13 18:09:42 +02:00
|
|
|
array(
|
2013-04-15 04:32:26 +02:00
|
|
|
'class' => 'phui-feed-wrap'
|
2013-04-13 18:09:42 +02:00
|
|
|
),
|
|
|
|
$story);
|
2011-07-05 17:35:18 +02:00
|
|
|
}
|
|
|
|
}
|