2011-02-21 03:41:23 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorProjectController extends PhabricatorController {
|
|
|
|
|
2015-01-12 19:04:01 +01:00
|
|
|
public function buildApplicationMenu() {
|
|
|
|
return $this->buildSideNavView(true)->getMenu();
|
|
|
|
}
|
|
|
|
|
2013-07-22 17:34:35 +02:00
|
|
|
public function buildSideNavView($for_app = false) {
|
2015-01-19 19:14:27 +01:00
|
|
|
$viewer = $this->getViewer();
|
2013-02-13 18:22:14 +01:00
|
|
|
|
|
|
|
$nav = new AphrontSideNavFilterView();
|
2013-07-22 17:34:35 +02:00
|
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
2013-02-13 18:22:14 +01:00
|
|
|
|
2015-01-12 19:04:01 +01:00
|
|
|
$id = null;
|
2013-02-13 18:22:14 +01:00
|
|
|
if ($for_app) {
|
2015-01-12 19:04:01 +01:00
|
|
|
$id = $this->getRequest()->getURIData('id');
|
|
|
|
if ($id) {
|
|
|
|
$nav->addFilter("profile/{$id}/", pht('Profile'));
|
|
|
|
$nav->addFilter("board/{$id}/", pht('Workboard'));
|
|
|
|
$nav->addFilter("members/{$id}/", pht('Members'));
|
|
|
|
$nav->addFilter("feed/{$id}/", pht('Feed'));
|
2015-01-19 19:14:27 +01:00
|
|
|
$nav->addFilter("details/{$id}/", pht('Edit Details'));
|
2015-01-12 19:04:01 +01:00
|
|
|
}
|
2013-07-22 17:34:35 +02:00
|
|
|
$nav->addFilter('create', pht('Create Project'));
|
2013-02-13 18:22:14 +01:00
|
|
|
}
|
|
|
|
|
2015-01-12 19:04:01 +01:00
|
|
|
if (!$id) {
|
|
|
|
id(new PhabricatorProjectSearchEngine())
|
2015-01-19 19:14:27 +01:00
|
|
|
->setViewer($viewer)
|
2015-01-12 19:04:01 +01:00
|
|
|
->addNavigationItems($nav->getMenu());
|
|
|
|
}
|
2013-07-22 17:34:35 +02:00
|
|
|
|
|
|
|
$nav->selectFilter(null);
|
|
|
|
|
2013-02-13 18:22:14 +01:00
|
|
|
return $nav;
|
|
|
|
}
|
|
|
|
|
2015-01-12 19:04:01 +01:00
|
|
|
public function buildIconNavView(PhabricatorProject $project) {
|
2015-01-19 19:14:27 +01:00
|
|
|
$viewer = $this->getViewer();
|
2015-01-12 19:04:01 +01:00
|
|
|
$id = $project->getID();
|
|
|
|
$picture = $project->getProfileImageURI();
|
|
|
|
$name = $project->getName();
|
|
|
|
|
2015-01-13 18:53:24 +01:00
|
|
|
$columns = id(new PhabricatorProjectColumnQuery())
|
2015-01-19 19:14:27 +01:00
|
|
|
->setViewer($viewer)
|
2015-01-13 18:53:24 +01:00
|
|
|
->withProjectPHIDs(array($project->getPHID()))
|
|
|
|
->execute();
|
|
|
|
if ($columns) {
|
|
|
|
$board_icon = 'fa-columns';
|
|
|
|
} else {
|
|
|
|
$board_icon = 'fa-columns grey';
|
|
|
|
}
|
|
|
|
|
2015-01-12 19:04:01 +01:00
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setIconNav(true);
|
|
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
|
|
|
$nav->addIcon("profile/{$id}/", $name, null, $picture);
|
2015-01-13 18:53:24 +01:00
|
|
|
$nav->addIcon("board/{$id}/", pht('Workboard'), $board_icon);
|
2015-01-19 19:14:27 +01:00
|
|
|
|
|
|
|
$class = 'PhabricatorManiphestApplication';
|
|
|
|
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
|
|
|
$phid = $project->getPHID();
|
|
|
|
$query_uri = urisprintf(
|
|
|
|
'/maniphest/?statuses=%s&allProjects=%s#R',
|
|
|
|
implode(',', ManiphestTaskStatus::getOpenStatusConstants()),
|
|
|
|
$phid);
|
|
|
|
$nav->addIcon(null, pht('Open Tasks'), 'fa-anchor', null, $query_uri);
|
|
|
|
}
|
|
|
|
|
2015-01-12 19:04:01 +01:00
|
|
|
$nav->addIcon("feed/{$id}/", pht('Feed'), 'fa-newspaper-o');
|
|
|
|
$nav->addIcon("members/{$id}/", pht('Members'), 'fa-group');
|
2015-01-19 19:14:27 +01:00
|
|
|
$nav->addIcon("details/{$id}/", pht('Edit Details'), 'fa-pencil');
|
2015-01-12 19:04:01 +01:00
|
|
|
|
|
|
|
return $nav;
|
|
|
|
}
|
|
|
|
|
2011-02-21 03:41:23 +01:00
|
|
|
}
|