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;
|
|
|
|
private $viewer;
|
|
|
|
|
2011-07-10 00:44:49 +02:00
|
|
|
private $oneLine;
|
|
|
|
|
2011-07-09 22:28:09 +02:00
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
|
|
$this->viewer = $viewer;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
$foot = phabricator_datetime($this->epoch, $this->viewer);
|
|
|
|
} 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
|
|
|
}
|
|
|
|
|
|
|
|
}
|