2013-01-24 12:13:31 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorApplicationDetailViewController
|
|
|
|
extends PhabricatorApplicationsController{
|
|
|
|
|
|
|
|
private $application;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->application = $data['application'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2013-01-30 10:53:43 -08:00
|
|
|
$selected = PhabricatorApplication::getByClass($this->application);
|
2013-01-24 12:13:31 -08:00
|
|
|
|
|
|
|
if (!$selected) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = $selected->getName();
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName(pht('Applications'))
|
|
|
|
->setHref($this->getApplicationURI()));
|
|
|
|
|
2013-01-29 09:14:03 -08:00
|
|
|
$properties = $this->buildPropertyView($selected);
|
|
|
|
$actions = $this->buildActionView($user, $selected);
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
id(new PhabricatorHeaderView())->setHeader($title),
|
|
|
|
$actions,
|
|
|
|
$properties,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'title' => $title,
|
|
|
|
'device' => true,
|
|
|
|
));
|
2013-01-24 12:13:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyView(PhabricatorApplication $selected) {
|
|
|
|
$properties = new PhabricatorPropertyListView();
|
|
|
|
|
2013-01-29 09:14:03 -08:00
|
|
|
if ($selected->isInstalled()) {
|
|
|
|
$properties->addProperty(
|
|
|
|
pht('Status'), pht('Installed'));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$properties->addProperty(
|
|
|
|
pht('Status'), pht('Uninstalled'));
|
|
|
|
}
|
2013-01-24 12:13:31 -08:00
|
|
|
|
|
|
|
$properties->addProperty(
|
|
|
|
pht('Description'), $selected->getShortDescription());
|
|
|
|
|
|
|
|
return $properties;
|
|
|
|
}
|
|
|
|
|
2013-01-29 09:14:03 -08:00
|
|
|
private function buildActionView(
|
|
|
|
PhabricatorUser $user, PhabricatorApplication $selected) {
|
|
|
|
|
2013-01-30 13:32:32 -08:00
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($user);
|
|
|
|
|
2013-01-29 09:14:03 -08:00
|
|
|
if ($selected->canUninstall()) {
|
|
|
|
if ($selected->isInstalled()) {
|
2013-01-30 13:32:32 -08:00
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Uninstall'))
|
|
|
|
->setIcon('delete')
|
|
|
|
->setHref(
|
2013-01-29 09:14:03 -08:00
|
|
|
$this->getApplicationURI(get_class($selected).'/uninstall/'))
|
2013-01-30 13:32:32 -08:00
|
|
|
);
|
2013-01-29 09:14:03 -08:00
|
|
|
} else {
|
2013-01-30 13:32:32 -08:00
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Install'))
|
|
|
|
->setIcon('new')
|
|
|
|
->setHref(
|
|
|
|
$this->getApplicationURI(get_class($selected).'/install/'))
|
|
|
|
);
|
2013-01-29 09:14:03 -08:00
|
|
|
}
|
2013-01-30 13:32:32 -08:00
|
|
|
} else {
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Uninstall'))
|
|
|
|
->setIcon('delete')
|
|
|
|
->setDisabled(true)
|
|
|
|
->setHref(
|
|
|
|
$this->getApplicationURI(get_class($selected).'/uninstall/'))
|
|
|
|
);
|
2013-01-29 09:14:03 -08:00
|
|
|
}
|
2013-01-30 13:32:32 -08:00
|
|
|
return $view;
|
2013-01-24 12:13:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|