2011-07-05 08:35:18 -07:00
|
|
|
<?php
|
|
|
|
|
2012-03-13 11:18:11 -07:00
|
|
|
final class PhabricatorFeedStoryView extends PhabricatorFeedView {
|
2011-07-05 08:35:18 -07:00
|
|
|
|
2011-07-09 13:28:09 -07:00
|
|
|
private $title;
|
|
|
|
private $image;
|
|
|
|
private $phid;
|
|
|
|
private $epoch;
|
2012-12-07 16:25:23 -08:00
|
|
|
private $viewed;
|
2012-12-07 16:26:43 -08:00
|
|
|
private $href;
|
2011-07-09 13:28:09 -07:00
|
|
|
|
2011-07-09 15:44:49 -07:00
|
|
|
private $oneLine;
|
|
|
|
|
2011-07-09 13:28:09 -07: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;
|
|
|
|
}
|
|
|
|
|
2011-07-09 15:44:49 -07:00
|
|
|
public function setOneLineStory($one_line) {
|
|
|
|
$this->oneLine = $one_line;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-07 16:25:23 -08:00
|
|
|
public function setViewed($viewed) {
|
|
|
|
$this->viewed = $viewed;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getViewed() {
|
|
|
|
return $this->viewed;
|
|
|
|
}
|
|
|
|
|
2012-12-07 16:26:43 -08:00
|
|
|
public function setHref($href) {
|
|
|
|
$this->href = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHref() {
|
|
|
|
return $this->href;
|
|
|
|
}
|
|
|
|
|
2012-12-07 16:25:23 -08:00
|
|
|
public function renderNotification() {
|
|
|
|
$classes = array(
|
|
|
|
'phabricator-notification',
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!$this->viewed) {
|
|
|
|
$classes[] = 'phabricator-notification-unread';
|
|
|
|
}
|
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
return javelin_tag(
|
2012-12-07 16:25:23 -08:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $classes),
|
2012-12-07 16:26:43 -08:00
|
|
|
'sigil' => 'notification',
|
|
|
|
'meta' => array(
|
|
|
|
'href' => $this->getHref(),
|
|
|
|
),
|
2012-12-07 16:25:23 -08:00
|
|
|
),
|
2013-02-12 18:46:01 -08:00
|
|
|
$this->title);
|
2012-12-07 16:25:23 -08:00
|
|
|
}
|
|
|
|
|
2011-07-05 08:35:18 -07:00
|
|
|
public function render() {
|
2011-07-09 13:28:09 -07:00
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
$head = phutil_tag(
|
2011-07-09 13:28:09 -07:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-feed-story-head',
|
|
|
|
),
|
2013-02-12 18:46:01 -08:00
|
|
|
nonempty($this->title, 'Untitled Story'));
|
2011-07-09 13:28:09 -07:00
|
|
|
|
2011-07-09 15:44:49 -07:00
|
|
|
$body = null;
|
|
|
|
$foot = null;
|
2011-07-09 13:28:09 -07:00
|
|
|
$image_style = null;
|
2011-07-09 15:44:49 -07:00
|
|
|
|
|
|
|
if (!$this->oneLine) {
|
2013-02-13 14:50:15 -08:00
|
|
|
$body = phutil_tag(
|
2011-07-09 15:44:49 -07:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-feed-story-body',
|
|
|
|
),
|
2013-02-12 18:46:01 -08:00
|
|
|
$this->renderChildren());
|
2011-07-09 15:44:49 -07:00
|
|
|
|
|
|
|
if ($this->epoch) {
|
2012-12-20 14:48:23 -08:00
|
|
|
$foot = phabricator_datetime($this->epoch, $this->user);
|
2011-07-09 15:44:49 -07:00
|
|
|
} else {
|
|
|
|
$foot = '';
|
|
|
|
}
|
|
|
|
|
2013-01-18 00:32:58 -08:00
|
|
|
$foot = phutil_tag(
|
2011-07-09 15:44:49 -07:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-feed-story-foot',
|
|
|
|
),
|
|
|
|
$foot);
|
|
|
|
|
|
|
|
if ($this->image) {
|
|
|
|
$image_style = 'background-image: url('.$this->image.')';
|
|
|
|
}
|
2011-07-09 13:28:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
require_celerity_resource('phabricator-feed-css');
|
|
|
|
|
2013-02-13 14:50:15 -08:00
|
|
|
return phutil_tag(
|
2011-07-05 08:35:18 -07:00
|
|
|
'div',
|
|
|
|
array(
|
2011-07-09 15:44:49 -07:00
|
|
|
'class' => $this->oneLine
|
|
|
|
? 'phabricator-feed-story phabricator-feed-story-one-line'
|
|
|
|
: 'phabricator-feed-story',
|
2011-07-09 13:28:09 -07:00
|
|
|
'style' => $image_style,
|
2011-07-05 08:35:18 -07:00
|
|
|
),
|
2013-03-09 13:52:41 -08:00
|
|
|
array($head, $body, $foot));
|
2011-07-05 08:35:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|