2012-12-31 00:36:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorConfigGroupController
|
|
|
|
extends PhabricatorConfigController {
|
|
|
|
|
|
|
|
private $groupKey;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->groupKey = $data['key'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$groups = PhabricatorApplicationConfigOptions::loadAll();
|
|
|
|
$options = idx($groups, $this->groupKey);
|
|
|
|
if (!$options) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = pht('%s Configuration', $options->getName());
|
|
|
|
$list = $this->buildOptionList($options->getOptions());
|
|
|
|
|
2014-06-27 17:28:33 +02:00
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText($title)
|
|
|
|
->appendChild($list);
|
|
|
|
|
2012-12-31 00:36:06 +01:00
|
|
|
$crumbs = $this
|
|
|
|
->buildApplicationCrumbs()
|
2013-12-19 02:47:34 +01:00
|
|
|
->addTextCrumb(pht('Config'), $this->getApplicationURI())
|
|
|
|
->addTextCrumb($options->getName(), $this->getApplicationURI());
|
2012-12-31 00:36:06 +01:00
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
2014-06-27 17:28:33 +02:00
|
|
|
$box,
|
2012-12-31 00:36:06 +01:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'title' => $title,
|
2013-02-19 22:33:10 +01:00
|
|
|
));
|
2012-12-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function buildOptionList(array $options) {
|
|
|
|
assert_instances_of($options, 'PhabricatorConfigOption');
|
|
|
|
|
2013-01-01 23:11:39 +01:00
|
|
|
require_celerity_resource('config-options-css');
|
|
|
|
|
|
|
|
$db_values = array();
|
|
|
|
if ($options) {
|
|
|
|
$db_values = id(new PhabricatorConfigEntry())->loadAllWhere(
|
|
|
|
'configKey IN (%Ls) AND namespace = %s',
|
|
|
|
mpull($options, 'getKey'),
|
|
|
|
'default');
|
|
|
|
$db_values = mpull($db_values, null, 'getConfigKey');
|
|
|
|
}
|
|
|
|
|
2013-01-16 18:08:13 +01:00
|
|
|
$engine = id(new PhabricatorMarkupEngine())
|
|
|
|
->setViewer($this->getRequest()->getUser());
|
|
|
|
foreach ($options as $option) {
|
|
|
|
$engine->addObject($option, 'summary');
|
|
|
|
}
|
|
|
|
$engine->process();
|
2013-01-01 23:11:39 +01:00
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$list = new PHUIObjectItemListView();
|
2013-03-10 02:55:01 +01:00
|
|
|
$list->setStackable(true);
|
2012-12-31 00:36:06 +01:00
|
|
|
foreach ($options as $option) {
|
2013-01-16 18:08:13 +01:00
|
|
|
$summary = $engine->getOutput($option, 'summary');
|
|
|
|
|
2013-09-09 23:14:34 +02:00
|
|
|
$item = id(new PHUIObjectItemView())
|
2012-12-31 00:36:06 +01:00
|
|
|
->setHeader($option->getKey())
|
|
|
|
->setHref('/config/edit/'.$option->getKey().'/')
|
2013-01-16 18:08:13 +01:00
|
|
|
->addAttribute($summary);
|
2013-01-03 15:01:14 +01:00
|
|
|
|
2013-01-15 21:03:44 +01:00
|
|
|
if (!$option->getHidden() && !$option->getMasked()) {
|
2013-01-03 15:01:14 +01:00
|
|
|
$current_value = PhabricatorEnv::getEnvConfig($option->getKey());
|
2013-01-12 00:28:33 +01:00
|
|
|
$current_value = PhabricatorConfigJSON::prettyPrintJSON(
|
|
|
|
$current_value);
|
2013-01-18 09:32:58 +01:00
|
|
|
$current_value = phutil_tag(
|
2013-01-03 15:01:14 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'config-options-current-value',
|
|
|
|
),
|
2013-01-18 09:32:58 +01:00
|
|
|
array(
|
|
|
|
phutil_tag('span', array(), pht('Current Value:')),
|
|
|
|
' '.$current_value,
|
|
|
|
));
|
2013-01-03 15:01:14 +01:00
|
|
|
|
|
|
|
$item->appendChild($current_value);
|
|
|
|
}
|
2013-01-01 23:11:39 +01:00
|
|
|
|
|
|
|
$db_value = idx($db_values, $option->getKey());
|
|
|
|
if ($db_value && !$db_value->getIsDeleted()) {
|
|
|
|
$item->addIcon('edit', pht('Customized'));
|
|
|
|
}
|
|
|
|
|
2013-01-03 15:01:14 +01:00
|
|
|
if ($option->getHidden()) {
|
|
|
|
$item->addIcon('unpublish', pht('Hidden'));
|
2013-01-15 21:03:44 +01:00
|
|
|
} else if ($option->getMasked()) {
|
|
|
|
$item->addIcon('unpublish-grey', pht('Masked'));
|
2013-01-03 15:01:14 +01:00
|
|
|
} else if ($option->getLocked()) {
|
2013-01-02 23:02:43 +01:00
|
|
|
$item->addIcon('lock', pht('Locked'));
|
|
|
|
}
|
|
|
|
|
2012-12-31 00:36:06 +01:00
|
|
|
$list->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $list;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|