mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-24 05:28:18 +01:00
a29b5b070f
Test Plan: Looked at a diff with inline comment. Reviewers: epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7549
70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
<?php
|
|
|
|
final class PhabricatorFeedBuilder {
|
|
|
|
private $stories;
|
|
private $framed;
|
|
private $hovercards = false;
|
|
|
|
public function __construct(array $stories) {
|
|
assert_instances_of($stories, 'PhabricatorFeedStory');
|
|
$this->stories = $stories;
|
|
}
|
|
|
|
public function setFramed($framed) {
|
|
$this->framed = $framed;
|
|
return $this;
|
|
}
|
|
|
|
public function setUser(PhabricatorUser $user) {
|
|
$this->user = $user;
|
|
return $this;
|
|
}
|
|
|
|
public function setShowHovercards($hover) {
|
|
$this->hovercards = $hover;
|
|
return $this;
|
|
}
|
|
|
|
public function buildView() {
|
|
if (!$this->user) {
|
|
throw new Exception('Call setUser() before buildView()!');
|
|
}
|
|
|
|
$user = $this->user;
|
|
$stories = $this->stories;
|
|
|
|
$null_view = new AphrontNullView();
|
|
|
|
require_celerity_resource('phabricator-feed-css');
|
|
|
|
$last_date = null;
|
|
foreach ($stories as $story) {
|
|
$story->setFramed($this->framed);
|
|
$story->setHovercard($this->hovercards);
|
|
|
|
$date = ucfirst(phabricator_relative_date($story->getEpoch(), $user));
|
|
|
|
if ($date !== $last_date) {
|
|
if ($last_date !== null) {
|
|
$null_view->appendChild(
|
|
phutil_tag_div('phabricator-feed-story-date-separator'));
|
|
}
|
|
$last_date = $date;
|
|
$header = new PhabricatorActionHeaderView();
|
|
$header->setHeaderTitle($date);
|
|
|
|
$null_view->appendChild($header);
|
|
}
|
|
|
|
$view = $story->renderView();
|
|
$view->setUser($user);
|
|
|
|
$null_view->appendChild($view);
|
|
}
|
|
|
|
return id(new AphrontNullView())
|
|
->appendChild($null_view->render());
|
|
}
|
|
|
|
}
|