1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-09 05:18:29 +01:00
phorge-phorge/src/applications/feed/builder/PhabricatorFeedBuilder.php

65 lines
1.5 KiB
PHP
Raw Normal View History

<?php
final class PhabricatorFeedBuilder {
private $stories;
private $framed;
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 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);
$date = ucfirst(phabricator_relative_date($story->getEpoch(), $user));
if ($date !== $last_date) {
if ($last_date !== null) {
2013-02-13 14:50:15 -08:00
$null_view->appendChild(hsprintf(
'<div class="phabricator-feed-story-date-separator"></div>'));
}
$last_date = $date;
$header = new PhabricatorActionHeaderView();
$header->setHeaderTitle($date);
$null_view->appendChild($header);
}
$view = $story->renderView();
$view->setUser($user);
$null_view->appendChild($view);
}
2013-02-13 14:50:15 -08:00
return id(new AphrontNullView())->appendChild(hsprintf(
'<div class="phabricator-feed-frame">%s</div>',
$null_view->render()));
}
}