2011-02-08 19:53:59 +01:00
|
|
|
<?php
|
|
|
|
|
2011-07-04 22:04:22 +02:00
|
|
|
/**
|
|
|
|
* @group maniphest
|
|
|
|
*/
|
2011-02-08 19:53:59 +01:00
|
|
|
abstract class ManiphestController extends PhabricatorController {
|
|
|
|
|
2012-04-10 18:46:04 +02:00
|
|
|
private $defaultQuery;
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
public function buildStandardPageResponse($view, array $data) {
|
|
|
|
$page = $this->buildStandardPageView();
|
|
|
|
|
2013-03-13 07:30:03 +01:00
|
|
|
$page->setApplicationName(pht('Maniphest'));
|
2011-02-08 19:53:59 +01:00
|
|
|
$page->setBaseURI('/maniphest/');
|
|
|
|
$page->setTitle(idx($data, 'title'));
|
|
|
|
$page->setGlyph("\xE2\x9A\x93");
|
2012-06-14 02:28:21 +02:00
|
|
|
$page->appendPageObjects(idx($data, 'pageObjects', array()));
|
2011-02-08 19:53:59 +01:00
|
|
|
$page->appendChild($view);
|
2012-02-15 02:00:12 +01:00
|
|
|
$page->setSearchDefaultScope(PhabricatorSearchScope::SCOPE_OPEN_TASKS);
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
$response = new AphrontWebpageResponse();
|
|
|
|
return $response->setContent($page->render());
|
|
|
|
}
|
|
|
|
|
2013-03-13 07:30:03 +01:00
|
|
|
protected function buildBaseSideNav($filter = null, $for_app = false) {
|
2012-03-01 23:19:11 +01:00
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setBaseURI(new PhutilURI('/maniphest/view/'));
|
2012-04-10 18:46:04 +02:00
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$custom = id(new ManiphestSavedQuery())->loadAllWhere(
|
|
|
|
'userPHID = %s ORDER BY isDefault DESC, name ASC',
|
|
|
|
$user->getPHID());
|
|
|
|
|
2012-12-21 14:42:38 +01:00
|
|
|
// TODO: Enforce uniqueness. Currently, it's possible to save the same
|
|
|
|
// query under multiple names, and then SideNavFilterView explodes on
|
|
|
|
// duplicate keys. Generally, we should clean up the custom/saved query
|
|
|
|
// code as it's a bit of a mess.
|
|
|
|
$custom = mpull($custom, null, 'getQueryKey');
|
|
|
|
|
2012-04-10 18:46:04 +02:00
|
|
|
if ($custom) {
|
|
|
|
$nav->addLabel('Saved Queries');
|
|
|
|
foreach ($custom as $query) {
|
|
|
|
if ($query->getIsDefault()) {
|
|
|
|
$this->defaultQuery = $query;
|
|
|
|
}
|
|
|
|
$nav->addFilter(
|
|
|
|
'Q:'.$query->getQueryKey(),
|
|
|
|
$query->getName(),
|
|
|
|
'/maniphest/view/custom/?key='.$query->getQueryKey());
|
|
|
|
}
|
2013-03-13 07:30:03 +01:00
|
|
|
$nav->addFilter('saved', pht('Edit...'), '/maniphest/custom/');
|
2012-04-10 18:46:04 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 07:30:03 +01:00
|
|
|
if ($for_app) {
|
|
|
|
$nav->addFilter('', pht('Create Task'),
|
|
|
|
$this->getApplicationURI('task/create/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$nav->addLabel(pht('User Tasks'));
|
|
|
|
$nav->addFilter('action', pht('Assigned'));
|
|
|
|
$nav->addFilter('created', pht('Created'));
|
|
|
|
$nav->addFilter('subscribed', pht('Subscribed'));
|
|
|
|
$nav->addFilter('triage', pht('Need Triage'));
|
|
|
|
$nav->addLabel(pht('User Projects'));
|
|
|
|
$nav->addFilter('projecttriage', pht('Need Triage'));
|
|
|
|
$nav->addFilter('projectall', pht('All Tasks'));
|
2012-03-01 23:19:11 +01:00
|
|
|
$nav->addLabel('All Tasks');
|
2013-03-13 07:30:03 +01:00
|
|
|
$nav->addFilter('alltriage', pht('Need Triage'));
|
|
|
|
$nav->addFilter('all', pht('All Tasks'));
|
|
|
|
$nav->addLabel(pht('Custom'));
|
|
|
|
$nav->addFilter('custom', pht('Custom Query'));
|
|
|
|
$nav->addFilter('report', pht('Reports'), '/maniphest/report/');
|
2012-03-01 23:19:11 +01:00
|
|
|
|
|
|
|
return $nav;
|
|
|
|
}
|
|
|
|
|
2013-03-13 07:30:03 +01:00
|
|
|
public function buildApplicationMenu() {
|
|
|
|
return $this->buildBaseSideNav(null, true)->getMenu();
|
|
|
|
}
|
|
|
|
|
2012-04-10 18:46:04 +02:00
|
|
|
protected function getDefaultQuery() {
|
|
|
|
return $this->defaultQuery;
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|