2011-07-05 17:35:18 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-13 19:18:11 +01:00
|
|
|
final class PhabricatorFeedStoryView extends PhabricatorFeedView {
|
2011-07-05 17:35:18 +02:00
|
|
|
|
2011-07-09 22:28:09 +02:00
|
|
|
private $title;
|
|
|
|
private $image;
|
|
|
|
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
|
|
|
|
2011-07-10 00:44:49 +02:00
|
|
|
private $oneLine;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-07-10 00:44:49 +02:00
|
|
|
public function setOneLineStory($one_line) {
|
|
|
|
$this->oneLine = $one_line;
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:26:43 +01:00
|
|
|
return javelin_render_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
|
|
|
),
|
|
|
|
$this->title);
|
|
|
|
}
|
|
|
|
|
2011-07-05 17:35:18 +02:00
|
|
|
public function render() {
|
2011-07-09 22:28:09 +02:00
|
|
|
|
|
|
|
$head = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-feed-story-head',
|
|
|
|
),
|
|
|
|
nonempty($this->title, 'Untitled Story'));
|
|
|
|
|
2011-07-10 00:44:49 +02:00
|
|
|
$body = null;
|
|
|
|
$foot = null;
|
2011-07-09 22:28:09 +02:00
|
|
|
$image_style = null;
|
2011-07-10 00:44:49 +02:00
|
|
|
|
|
|
|
if (!$this->oneLine) {
|
|
|
|
$body = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-feed-story-body',
|
|
|
|
),
|
|
|
|
$this->renderChildren());
|
|
|
|
|
|
|
|
if ($this->epoch) {
|
2012-12-20 23:48:23 +01:00
|
|
|
$foot = phabricator_datetime($this->epoch, $this->user);
|
2011-07-10 00:44:49 +02:00
|
|
|
} else {
|
|
|
|
$foot = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$foot = phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-feed-story-foot',
|
|
|
|
),
|
|
|
|
$foot);
|
|
|
|
|
|
|
|
if ($this->image) {
|
|
|
|
$image_style = 'background-image: url('.$this->image.')';
|
|
|
|
}
|
2011-07-09 22:28:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
require_celerity_resource('phabricator-feed-css');
|
|
|
|
|
2011-07-05 17:35:18 +02:00
|
|
|
return phutil_render_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
2011-07-10 00:44:49 +02:00
|
|
|
'class' => $this->oneLine
|
|
|
|
? 'phabricator-feed-story phabricator-feed-story-one-line'
|
|
|
|
: 'phabricator-feed-story',
|
2011-07-09 22:28:09 +02:00
|
|
|
'style' => $image_style,
|
2011-07-05 17:35:18 +02:00
|
|
|
),
|
2011-07-09 22:28:09 +02:00
|
|
|
$head.$body.$foot);
|
2011-07-05 17:35:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|