2011-02-21 03:41:23 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorProjectController extends PhabricatorController {
|
|
|
|
|
2015-02-23 20:27:19 +01:00
|
|
|
private $project;
|
|
|
|
|
|
|
|
protected function setProject(PhabricatorProject $project) {
|
|
|
|
$this->project = $project;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getProject() {
|
|
|
|
return $this->project;
|
|
|
|
}
|
|
|
|
|
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-02-23 20:27:19 +01:00
|
|
|
$project = $this->getProject();
|
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-02-23 20:27:19 +01:00
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
2015-02-23 21:45:59 +01:00
|
|
|
$id = null;
|
2013-02-13 18:22:14 +01:00
|
|
|
if ($for_app) {
|
2015-02-23 20:27:19 +01:00
|
|
|
if ($project) {
|
|
|
|
$id = $project->getID();
|
2015-01-12 19:04:01 +01:00
|
|
|
$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-02-23 20:27:19 +01:00
|
|
|
$this->setProject($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-19 19:14:27 +01:00
|
|
|
|
|
|
|
$class = 'PhabricatorManiphestApplication';
|
|
|
|
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
|
|
|
$phid = $project->getPHID();
|
2015-11-08 04:25:21 +01:00
|
|
|
$nav->addIcon("board/{$id}/", pht('Workboard'), $board_icon);
|
2015-01-19 19:14:27 +01:00
|
|
|
$query_uri = urisprintf(
|
2015-04-26 16:15:25 +02:00
|
|
|
'/maniphest/?statuses=open()&projects=%s#R',
|
|
|
|
$phid);
|
2015-01-19 19:14:27 +01:00
|
|
|
$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
|
|
|
}
|