2013-01-11 01:06:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorFeedMainController extends PhabricatorFeedController {
|
|
|
|
|
|
|
|
private $filter;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->filter = idx($data, 'filter');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$nav = $this->buildSideNavView();
|
|
|
|
$filter = $nav->selectFilter($this->filter, 'all');
|
|
|
|
|
|
|
|
$pager = new AphrontCursorPagerView();
|
|
|
|
$pager->readFromRequest($request);
|
|
|
|
$pager->setPageSize(200);
|
|
|
|
|
|
|
|
|
|
|
|
$query = id(new PhabricatorFeedQuery())
|
|
|
|
->setViewer($user);
|
|
|
|
|
|
|
|
$nodata = null;
|
|
|
|
switch ($filter) {
|
|
|
|
case 'all':
|
|
|
|
$title = pht('Feed');
|
|
|
|
break;
|
|
|
|
case 'projects':
|
|
|
|
$projects = id(new PhabricatorProjectQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withMemberPHIDs(array($user->getPHID()))
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
if (!$projects) {
|
|
|
|
$nodata = pht('You have not joined any projects.');
|
|
|
|
} else {
|
|
|
|
$query->setFilterPHIDs(mpull($projects, 'getPHID'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = pht('Feed: My Projects');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($nodata) {
|
|
|
|
$feed_view = id(new AphrontErrorView())
|
|
|
|
->setSeverity(AphrontErrorView::SEVERITY_NODATA)
|
|
|
|
->setTitle(pht('No Stories'))
|
|
|
|
->appendChild($nodata);
|
|
|
|
} else {
|
|
|
|
$feed = $query->executeWithCursorPager($pager);
|
|
|
|
|
|
|
|
$builder = new PhabricatorFeedBuilder($feed);
|
|
|
|
$builder->setUser($user);
|
|
|
|
$feed_view = $builder->buildView();
|
|
|
|
}
|
|
|
|
|
2013-04-13 18:09:42 +02:00
|
|
|
$crumbs = $this
|
|
|
|
->buildApplicationCrumbs($nav)
|
|
|
|
->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName($title)
|
|
|
|
->setHref($this->getApplicationURI('filter/'.$filter.'/')));
|
|
|
|
|
|
|
|
$nav->setCrumbs($crumbs);
|
|
|
|
|
2013-01-11 01:06:29 +01:00
|
|
|
|
|
|
|
$nav->appendChild(
|
|
|
|
array(
|
|
|
|
$feed_view,
|
|
|
|
$pager,
|
|
|
|
));
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
$nav,
|
|
|
|
array(
|
|
|
|
'title' => $title,
|
|
|
|
'device' => true,
|
2013-04-13 18:09:42 +02:00
|
|
|
'dust' => true,
|
2013-01-11 01:06:29 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|