2011-07-08 20:13:11 +02:00
|
|
|
<?php
|
|
|
|
|
2011-09-14 17:02:31 +02:00
|
|
|
/**
|
|
|
|
* @group slowvote
|
|
|
|
*/
|
2011-07-08 20:13:11 +02:00
|
|
|
abstract class PhabricatorSlowvoteController extends PhabricatorController {
|
|
|
|
|
2013-02-14 01:47:24 +01:00
|
|
|
const VIEW_ALL = 'all';
|
|
|
|
const VIEW_CREATED = 'created';
|
|
|
|
const VIEW_VOTED = 'voted';
|
|
|
|
|
2011-07-08 20:13:11 +02:00
|
|
|
public function buildStandardPageResponse($view, array $data) {
|
|
|
|
$page = $this->buildStandardPageView();
|
|
|
|
|
2013-02-14 01:47:24 +01:00
|
|
|
$page->setApplicationName(pht('Slowvote'));
|
2011-07-08 20:13:11 +02:00
|
|
|
$page->setBaseURI('/vote/');
|
|
|
|
$page->setTitle(idx($data, 'title'));
|
|
|
|
$page->setGlyph("\xE2\x9C\x94");
|
|
|
|
|
|
|
|
$page->appendChild($view);
|
|
|
|
|
|
|
|
$response = new AphrontWebpageResponse();
|
|
|
|
return $response->setContent($page->render());
|
|
|
|
}
|
|
|
|
|
2013-02-14 01:47:24 +01:00
|
|
|
public function buildSideNavView($filter = null, $for_app = false) {
|
|
|
|
|
|
|
|
$views = $this->getViews();
|
|
|
|
$side_nav = new AphrontSideNavFilterView();
|
|
|
|
$side_nav->setBaseURI(new PhutilURI('/vote/view/'));
|
|
|
|
foreach ($views as $key => $name) {
|
|
|
|
$side_nav->addFilter($key, $name);
|
|
|
|
}
|
|
|
|
if ($filter) {
|
|
|
|
$side_nav->selectFilter($filter, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($for_app) {
|
|
|
|
$side_nav->addFilter('', pht('Create Question'),
|
|
|
|
$this->getApplicationURI('create/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $side_nav;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildApplicationMenu() {
|
|
|
|
return $this->buildSideNavView(null, true)->getMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildApplicationCrumbs() {
|
|
|
|
$crumbs = parent::buildApplicationCrumbs();
|
|
|
|
|
|
|
|
$crumbs->addAction(
|
2013-06-05 17:41:43 +02:00
|
|
|
id(new PHUIListItemView())
|
2013-02-14 01:47:24 +01:00
|
|
|
->setName(pht('Create Question'))
|
|
|
|
->setHref($this->getApplicationURI('create/'))
|
|
|
|
->setIcon('create'));
|
|
|
|
|
|
|
|
return $crumbs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getViews() {
|
|
|
|
return array(
|
|
|
|
self::VIEW_ALL => pht('All Slowvotes'),
|
|
|
|
self::VIEW_CREATED => pht('Created'),
|
|
|
|
self::VIEW_VOTED => pht('Voted In'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-07-08 20:13:11 +02:00
|
|
|
}
|