2013-03-21 02:01:52 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhluxViewController extends PhluxController {
|
|
|
|
|
|
|
|
private $key;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->key = $data['key'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$var = id(new PhluxVariableQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withKeys(array($this->key))
|
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$var) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
|
|
|
|
$title = $var->getVariableKey();
|
|
|
|
|
2013-12-19 02:47:34 +01:00
|
|
|
$crumbs->addTextCrumb($title, $request->getRequestURI());
|
2013-03-21 02:01:52 +01:00
|
|
|
|
2013-09-17 18:12:37 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
2013-09-19 01:27:24 +02:00
|
|
|
->setHeader($title)
|
2013-09-19 20:56:58 +02:00
|
|
|
->setUser($user)
|
|
|
|
->setPolicyObject($var);
|
2013-03-21 02:01:52 +01:00
|
|
|
|
|
|
|
$actions = id(new PhabricatorActionListView())
|
|
|
|
->setUser($user)
|
2013-07-12 20:39:47 +02:00
|
|
|
->setObjectURI($request->getRequestURI())
|
2013-03-21 02:01:52 +01:00
|
|
|
->setObject($var);
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$user,
|
|
|
|
$var,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
|
|
$actions->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-pencil')
|
2013-03-21 02:01:52 +01:00
|
|
|
->setName(pht('Edit Variable'))
|
|
|
|
->setHref($this->getApplicationURI('/edit/'.$var->getVariableKey().'/'))
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(!$can_edit));
|
|
|
|
|
|
|
|
$display_value = json_encode($var->getVariableValue());
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$properties = id(new PHUIPropertyListView())
|
2013-03-21 02:01:52 +01:00
|
|
|
->setUser($user)
|
|
|
|
->setObject($var)
|
2013-10-11 16:53:56 +02:00
|
|
|
->setActionList($actions)
|
2013-09-19 20:56:58 +02:00
|
|
|
->addProperty(pht('Value'), $display_value);
|
2013-03-21 02:01:52 +01:00
|
|
|
|
|
|
|
$xactions = id(new PhluxTransactionQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withObjectPHIDs(array($var->getPHID()))
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$engine = id(new PhabricatorMarkupEngine())
|
|
|
|
->setViewer($user);
|
|
|
|
|
|
|
|
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
|
|
|
->setUser($user)
|
2013-07-29 03:21:22 +02:00
|
|
|
->setObjectPHID($var->getPHID())
|
2013-03-21 02:01:52 +01:00
|
|
|
->setTransactions($xactions)
|
|
|
|
->setMarkupEngine($engine);
|
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
2013-10-11 16:53:56 +02:00
|
|
|
->addPropertyList($properties);
|
2013-09-29 00:55:38 +02:00
|
|
|
|
2013-03-21 02:01:52 +01:00
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
2013-09-29 00:55:38 +02:00
|
|
|
$object_box,
|
2013-03-21 02:01:52 +01:00
|
|
|
$xaction_view,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'title' => $title,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|