1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-21 04:01:30 +01:00
phorge-phorge/src/applications/feed/controller/PhabricatorFeedMainController.php
epriestley ebf2435c49 Make feed its own application
Summary:
Fixes the two-level nav issue introduced by D4376.

(My claim that this page is device ready in the code is something of a lie, but it's fairly close.)

(@chad, this could use an icon at some point, or you can point me at which one you want and I can take a stab at slicing it.)

Test Plan: Looked at feed; saw it not-broken. Also checked public feed (which should just merge at some point).

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D4381
2013-01-10 16:06:29 -08:00

78 lines
1.8 KiB
PHP

<?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();
}
$header = id(new PhabricatorHeaderView())
->setHeader($title);
$nav->appendChild(
array(
$header,
$feed_view,
$pager,
));
return $this->buildApplicationPage(
$nav,
array(
'title' => $title,
'device' => true,
));
}
}