2012-12-28 00:20:09 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorConfigEditController
|
|
|
|
extends PhabricatorConfigController {
|
|
|
|
|
|
|
|
private $key;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
2012-12-31 00:36:06 +01:00
|
|
|
$this->key = $data['key'];
|
2012-12-28 00:20:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2012-12-31 00:36:06 +01:00
|
|
|
|
|
|
|
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
|
|
|
|
if (empty($options[$this->key])) {
|
2013-01-01 23:09:29 +01:00
|
|
|
// This may be a dead config entry, which existed in the past but no
|
|
|
|
// longer exists. Allow it to be edited so it can be reviewed and
|
|
|
|
// deleted.
|
|
|
|
$option = id(new PhabricatorConfigOption())
|
|
|
|
->setKey($this->key)
|
|
|
|
->setType('wild')
|
|
|
|
->setDefault(null)
|
|
|
|
->setDescription(
|
|
|
|
pht(
|
|
|
|
"This configuration option is unknown. It may be misspelled, ".
|
|
|
|
"or have existed in a previous version of Phabricator."));
|
|
|
|
$group = null;
|
|
|
|
$group_uri = $this->getApplicationURI();
|
|
|
|
} else {
|
|
|
|
$option = $options[$this->key];
|
|
|
|
$group = $option->getGroup();
|
|
|
|
$group_uri = $this->getApplicationURI('group/'.$group->getKey().'/');
|
2012-12-28 00:20:09 +01:00
|
|
|
}
|
2012-12-31 00:36:06 +01:00
|
|
|
|
2012-12-31 02:04:38 +01:00
|
|
|
$issue = $request->getStr('issue');
|
|
|
|
if ($issue) {
|
|
|
|
// If the user came here from an open setup issue, send them back.
|
|
|
|
$done_uri = $this->getApplicationURI('issue/'.$issue.'/');
|
|
|
|
} else {
|
|
|
|
$done_uri = $group_uri;
|
|
|
|
}
|
|
|
|
|
2012-12-28 00:20:09 +01:00
|
|
|
// Check if the config key is already stored in the database.
|
|
|
|
// Grab the value if it is.
|
|
|
|
$config_entry = id(new PhabricatorConfigEntry())
|
|
|
|
->loadOneWhere(
|
2012-12-31 00:36:06 +01:00
|
|
|
'configKey = %s AND namespace = %s',
|
2012-12-28 00:20:09 +01:00
|
|
|
$this->key,
|
|
|
|
'default');
|
2013-01-01 23:09:17 +01:00
|
|
|
if (!$config_entry) {
|
2012-12-28 00:20:09 +01:00
|
|
|
$config_entry = id(new PhabricatorConfigEntry())
|
2013-01-01 23:09:17 +01:00
|
|
|
->setConfigKey($this->key)
|
|
|
|
->setNamespace('default')
|
|
|
|
->setIsDeleted(true);
|
2012-12-28 00:20:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$e_value = null;
|
|
|
|
$errors = array();
|
2013-01-02 23:02:43 +01:00
|
|
|
if ($request->isFormPost() && !$option->getLocked()) {
|
2012-12-31 00:36:06 +01:00
|
|
|
|
2013-01-02 03:14:41 +01:00
|
|
|
$result = $this->readRequest(
|
2013-01-01 23:09:17 +01:00
|
|
|
$option,
|
|
|
|
$request);
|
2012-12-28 00:20:09 +01:00
|
|
|
|
2013-01-02 03:14:41 +01:00
|
|
|
list($e_value, $value_errors, $display_value, $xaction) = $result;
|
2013-01-01 23:09:17 +01:00
|
|
|
$errors = array_merge($errors, $value_errors);
|
2012-12-28 00:20:09 +01:00
|
|
|
|
|
|
|
if (!$errors) {
|
2013-01-02 03:14:41 +01:00
|
|
|
|
|
|
|
$editor = id(new PhabricatorConfigEditor())
|
|
|
|
->setActor($user)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setContentSource(
|
|
|
|
PhabricatorContentSource::newForSource(
|
|
|
|
PhabricatorContentSource::SOURCE_WEB,
|
|
|
|
array(
|
|
|
|
'ip' => $request->getRemoteAddr(),
|
2013-01-02 03:15:03 +01:00
|
|
|
)));
|
2013-01-02 03:14:41 +01:00
|
|
|
|
2013-01-02 03:15:03 +01:00
|
|
|
try {
|
|
|
|
$editor->applyTransactions($config_entry, array($xaction));
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
|
|
|
} catch (PhabricatorConfigValidationException $ex) {
|
|
|
|
$e_value = pht('Invalid');
|
|
|
|
$errors[] = $ex->getMessage();
|
|
|
|
}
|
2012-12-28 00:20:09 +01:00
|
|
|
}
|
2013-01-01 23:09:17 +01:00
|
|
|
} else {
|
|
|
|
$display_value = $this->getDisplayValue($option, $config_entry);
|
2012-12-28 00:20:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$form = new AphrontFormView();
|
|
|
|
$form->setFlexible(true);
|
|
|
|
|
|
|
|
$error_view = null;
|
|
|
|
if ($errors) {
|
|
|
|
$error_view = id(new AphrontErrorView())
|
2013-01-01 23:09:17 +01:00
|
|
|
->setTitle(pht('You broke everything!'))
|
2012-12-28 00:20:09 +01:00
|
|
|
->setErrors($errors);
|
2013-01-03 15:01:14 +01:00
|
|
|
} else if ($option->getHidden()) {
|
|
|
|
$msg = pht(
|
|
|
|
"This configuration is hidden and can not be edited or viewed from ".
|
|
|
|
"the web interface.");
|
|
|
|
|
|
|
|
$error_view = id(new AphrontErrorView())
|
|
|
|
->setTitle(pht('Configuration Hidden'))
|
|
|
|
->setSeverity(AphrontErrorView::SEVERITY_WARNING)
|
|
|
|
->appendChild('<p>'.phutil_escape_html($msg).'</p>');
|
2013-01-02 23:02:43 +01:00
|
|
|
} else if ($option->getLocked()) {
|
|
|
|
$msg = pht(
|
|
|
|
"This configuration is locked and can not be edited from the web ".
|
|
|
|
"interface.");
|
|
|
|
|
|
|
|
$error_view = id(new AphrontErrorView())
|
|
|
|
->setTitle(pht('Configuration Locked'))
|
|
|
|
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
|
|
|
|
->appendChild('<p>'.phutil_escape_html($msg).'</p>');
|
2012-12-28 00:20:09 +01:00
|
|
|
}
|
|
|
|
|
2013-01-03 15:01:14 +01:00
|
|
|
if ($option->getHidden()) {
|
|
|
|
$control = null;
|
|
|
|
} else {
|
|
|
|
$control = $this->renderControl(
|
|
|
|
$option,
|
|
|
|
$display_value,
|
|
|
|
$e_value);
|
|
|
|
}
|
2013-01-01 23:09:17 +01:00
|
|
|
|
|
|
|
$engine = new PhabricatorMarkupEngine();
|
|
|
|
$engine->addObject($option, 'description');
|
|
|
|
$engine->process();
|
2013-01-18 09:32:58 +01:00
|
|
|
$description = phutil_tag(
|
2013-01-01 23:09:17 +01:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-remarkup',
|
|
|
|
),
|
2013-01-18 03:47:13 +01:00
|
|
|
phutil_safe_html($engine->getOutput($option, 'description')));
|
2013-01-01 23:09:17 +01:00
|
|
|
|
2012-12-28 00:20:09 +01:00
|
|
|
$form
|
|
|
|
->setUser($user)
|
2012-12-31 02:04:38 +01:00
|
|
|
->addHiddenInput('issue', $request->getStr('issue'))
|
2012-12-28 00:20:09 +01:00
|
|
|
->appendChild(
|
2013-01-01 23:09:17 +01:00
|
|
|
id(new AphrontFormMarkupControl())
|
2013-01-01 23:09:59 +01:00
|
|
|
->setLabel(pht('Description'))
|
2013-01-01 23:09:17 +01:00
|
|
|
->setValue($description))
|
2013-01-02 23:02:43 +01:00
|
|
|
->appendChild($control);
|
|
|
|
|
2013-01-03 15:01:14 +01:00
|
|
|
$submit_control = id(new AphrontFormSubmitControl())
|
|
|
|
->addCancelButton($done_uri);
|
|
|
|
|
2013-01-02 23:02:43 +01:00
|
|
|
if (!$option->getLocked()) {
|
2013-01-03 15:01:14 +01:00
|
|
|
$submit_control->setValue(pht('Save Config Entry'));
|
2013-01-02 23:02:43 +01:00
|
|
|
}
|
2013-01-01 23:09:17 +01:00
|
|
|
|
2013-01-03 15:01:14 +01:00
|
|
|
$form->appendChild($submit_control);
|
|
|
|
|
2013-01-01 23:09:59 +01:00
|
|
|
$examples = $this->renderExamples($option);
|
|
|
|
if ($examples) {
|
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
|
|
|
->setLabel(pht('Examples'))
|
|
|
|
->setValue($examples));
|
|
|
|
}
|
|
|
|
|
2013-01-03 15:01:14 +01:00
|
|
|
if (!$option->getHidden()) {
|
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
|
|
|
->setLabel(pht('Default'))
|
|
|
|
->setValue($this->renderDefaults($option)));
|
|
|
|
}
|
2013-01-01 23:09:17 +01:00
|
|
|
|
2013-01-01 23:10:33 +01:00
|
|
|
$title = pht('Edit %s', $this->key);
|
|
|
|
$short = pht('Edit');
|
2012-12-28 00:20:09 +01:00
|
|
|
|
2012-12-31 00:36:06 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
2013-01-01 23:09:29 +01:00
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName(pht('Config'))
|
|
|
|
->setHref($this->getApplicationURI()));
|
|
|
|
|
|
|
|
if ($group) {
|
|
|
|
$crumbs->addCrumb(
|
2012-12-31 00:36:06 +01:00
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName($group->getName())
|
2013-01-01 23:09:29 +01:00
|
|
|
->setHref($group_uri));
|
|
|
|
}
|
|
|
|
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName($this->key)
|
|
|
|
->setHref('/config/edit/'.$this->key));
|
2012-12-28 00:20:09 +01:00
|
|
|
|
2013-01-02 03:14:41 +01:00
|
|
|
|
|
|
|
$xactions = id(new PhabricatorConfigTransactionQuery())
|
|
|
|
->withObjectPHIDs(array($config_entry->getPHID()))
|
|
|
|
->setViewer($user)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
|
|
|
->setUser($user)
|
|
|
|
->setTransactions($xactions);
|
|
|
|
|
2012-12-28 00:20:09 +01:00
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
id(new PhabricatorHeaderView())->setHeader($title),
|
|
|
|
$error_view,
|
|
|
|
$form,
|
2013-01-02 03:14:41 +01:00
|
|
|
$xaction_view,
|
2012-12-28 00:20:09 +01:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'title' => $title,
|
|
|
|
'device' => true,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2013-01-01 23:09:17 +01:00
|
|
|
private function readRequest(
|
|
|
|
PhabricatorConfigOption $option,
|
|
|
|
AphrontRequest $request) {
|
|
|
|
|
2013-01-02 03:14:41 +01:00
|
|
|
$xaction = new PhabricatorConfigTransaction();
|
|
|
|
$xaction->setTransactionType(PhabricatorConfigTransaction::TYPE_EDIT);
|
|
|
|
|
2013-01-01 23:09:17 +01:00
|
|
|
$e_value = null;
|
|
|
|
$errors = array();
|
|
|
|
|
|
|
|
$value = $request->getStr('value');
|
|
|
|
if (!strlen($value)) {
|
|
|
|
$value = null;
|
2013-01-02 03:14:41 +01:00
|
|
|
|
|
|
|
$xaction->setNewValue(
|
|
|
|
array(
|
|
|
|
'deleted' => true,
|
|
|
|
'value' => null,
|
|
|
|
));
|
|
|
|
|
|
|
|
return array($e_value, $errors, $value, $xaction);
|
2013-01-01 23:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$type = $option->getType();
|
2013-01-02 03:14:41 +01:00
|
|
|
$set_value = null;
|
|
|
|
|
2013-01-01 23:09:17 +01:00
|
|
|
switch ($type) {
|
|
|
|
case 'int':
|
|
|
|
if (preg_match('/^-?[0-9]+$/', trim($value))) {
|
2013-01-02 03:14:41 +01:00
|
|
|
$set_value = (int)$value;
|
2013-01-01 23:09:17 +01:00
|
|
|
} else {
|
|
|
|
$e_value = pht('Invalid');
|
|
|
|
$errors[] = pht('Value must be an integer.');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'string':
|
2013-01-22 03:46:21 +01:00
|
|
|
case 'enum':
|
2013-01-02 03:14:41 +01:00
|
|
|
$set_value = (string)$value;
|
2013-01-01 23:09:17 +01:00
|
|
|
break;
|
2013-01-02 23:02:31 +01:00
|
|
|
case 'list<string>':
|
|
|
|
$set_value = $request->getStrList('value');
|
|
|
|
break;
|
2013-01-17 00:06:07 +01:00
|
|
|
case 'set':
|
|
|
|
$set_value = array_fill_keys($request->getStrList('value'), true);
|
|
|
|
break;
|
2013-01-01 23:09:17 +01:00
|
|
|
case 'bool':
|
|
|
|
switch ($value) {
|
|
|
|
case 'true':
|
2013-01-02 03:14:41 +01:00
|
|
|
$set_value = true;
|
2013-01-01 23:09:17 +01:00
|
|
|
break;
|
|
|
|
case 'false':
|
2013-01-02 03:14:41 +01:00
|
|
|
$set_value = false;
|
2013-01-01 23:09:17 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$e_value = pht('Invalid');
|
|
|
|
$errors[] = pht('Value must be boolean, "true" or "false".');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2013-01-03 15:01:14 +01:00
|
|
|
case 'class':
|
|
|
|
if (!class_exists($value)) {
|
|
|
|
$e_value = pht('Invalid');
|
|
|
|
$errors[] = pht('Class does not exist.');
|
|
|
|
} else {
|
|
|
|
$base = $option->getBaseClass();
|
|
|
|
if (!is_subclass_of($value, $base)) {
|
|
|
|
$e_value = pht('Invalid');
|
|
|
|
$errors[] = pht('Class is not of valid type.');
|
|
|
|
} else {
|
|
|
|
$set_value = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2013-01-01 23:09:17 +01:00
|
|
|
default:
|
|
|
|
$json = json_decode($value, true);
|
|
|
|
if ($json === null && strtolower($value) != 'null') {
|
|
|
|
$e_value = pht('Invalid');
|
|
|
|
$errors[] = pht(
|
|
|
|
'The given value must be valid JSON. This means, among '.
|
|
|
|
'other things, that you must wrap strings in double-quotes.');
|
2013-01-18 14:47:34 +01:00
|
|
|
} else {
|
2013-01-02 03:14:41 +01:00
|
|
|
$set_value = $json;
|
2013-01-01 23:09:17 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-02 03:14:41 +01:00
|
|
|
if (!$errors) {
|
|
|
|
$xaction->setNewValue(
|
|
|
|
array(
|
|
|
|
'deleted' => false,
|
|
|
|
'value' => $set_value,
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
$xaction = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return array($e_value, $errors, $value, $xaction);
|
2013-01-01 23:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function getDisplayValue(
|
|
|
|
PhabricatorConfigOption $option,
|
|
|
|
PhabricatorConfigEntry $entry) {
|
|
|
|
|
|
|
|
if ($entry->getIsDeleted()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$type = $option->getType();
|
|
|
|
$value = $entry->getValue();
|
|
|
|
switch ($type) {
|
|
|
|
case 'int':
|
|
|
|
case 'string':
|
2013-01-22 03:46:21 +01:00
|
|
|
case 'enum':
|
2013-01-01 23:09:17 +01:00
|
|
|
return $value;
|
|
|
|
case 'bool':
|
|
|
|
return $value ? 'true' : 'false';
|
2013-01-02 23:02:31 +01:00
|
|
|
case 'list<string>':
|
|
|
|
return implode("\n", nonempty($value, array()));
|
2013-01-17 00:06:07 +01:00
|
|
|
case 'set':
|
|
|
|
return implode("\n", nonempty(array_keys($value), array()));
|
2013-01-01 23:09:17 +01:00
|
|
|
default:
|
2013-01-12 00:28:33 +01:00
|
|
|
return PhabricatorConfigJSON::prettyPrintJSON($value);
|
2013-01-01 23:09:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderControl(
|
|
|
|
PhabricatorConfigOption $option,
|
|
|
|
$display_value,
|
|
|
|
$e_value) {
|
|
|
|
|
|
|
|
$type = $option->getType();
|
|
|
|
switch ($type) {
|
|
|
|
case 'int':
|
|
|
|
case 'string':
|
|
|
|
$control = id(new AphrontFormTextControl());
|
|
|
|
break;
|
|
|
|
case 'bool':
|
|
|
|
$control = id(new AphrontFormSelectControl())
|
|
|
|
->setOptions(
|
|
|
|
array(
|
2013-01-03 15:01:14 +01:00
|
|
|
'' => pht('(Use Default)'),
|
2013-01-09 17:14:26 +01:00
|
|
|
'true' => idx($option->getBoolOptions(), 0),
|
|
|
|
'false' => idx($option->getBoolOptions(), 1),
|
2013-01-01 23:09:17 +01:00
|
|
|
));
|
|
|
|
break;
|
2013-01-22 03:46:21 +01:00
|
|
|
case 'enum':
|
|
|
|
$options = array_mergev(
|
|
|
|
array(
|
|
|
|
array('' => pht('(Use Default)')),
|
|
|
|
$option->getEnumOptions(),
|
|
|
|
));
|
|
|
|
$control = id(new AphrontFormSelectControl())
|
|
|
|
->setOptions($options);
|
|
|
|
break;
|
2013-01-03 15:01:14 +01:00
|
|
|
case 'class':
|
|
|
|
$symbols = id(new PhutilSymbolLoader())
|
|
|
|
->setType('class')
|
|
|
|
->setAncestorClass($option->getBaseClass())
|
|
|
|
->setConcreteOnly(true)
|
|
|
|
->selectSymbolsWithoutLoading();
|
|
|
|
$names = ipull($symbols, 'name', 'name');
|
2013-01-05 01:22:52 +01:00
|
|
|
asort($names);
|
2013-01-03 15:01:14 +01:00
|
|
|
$names = array(
|
|
|
|
'' => pht('(Use Default)'),
|
|
|
|
) + $names;
|
|
|
|
|
|
|
|
$control = id(new AphrontFormSelectControl())
|
|
|
|
->setOptions($names);
|
|
|
|
break;
|
2013-01-02 23:02:31 +01:00
|
|
|
case 'list<string>':
|
2013-01-17 00:06:07 +01:00
|
|
|
case 'set':
|
2013-01-02 23:02:31 +01:00
|
|
|
$control = id(new AphrontFormTextAreaControl())
|
|
|
|
->setCaption(pht('Separate values with newlines or commas.'));
|
|
|
|
break;
|
2013-01-01 23:09:17 +01:00
|
|
|
default:
|
|
|
|
$control = id(new AphrontFormTextAreaControl())
|
|
|
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
|
|
|
|
->setCustomClass('PhabricatorMonospaced')
|
|
|
|
->setCaption(pht('Enter value in JSON.'));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$control
|
|
|
|
->setLabel('Value')
|
|
|
|
->setError($e_value)
|
|
|
|
->setValue($display_value)
|
|
|
|
->setName('value');
|
|
|
|
|
2013-01-02 23:02:43 +01:00
|
|
|
if ($option->getLocked()) {
|
|
|
|
$control->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
2013-01-01 23:09:17 +01:00
|
|
|
return $control;
|
|
|
|
}
|
|
|
|
|
2013-01-01 23:09:59 +01:00
|
|
|
private function renderExamples(PhabricatorConfigOption $option) {
|
|
|
|
$examples = $option->getExamples();
|
|
|
|
if (!$examples) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = array();
|
2013-01-01 23:10:33 +01:00
|
|
|
$table[] = '<tr class="column-labels">';
|
|
|
|
$table[] = '<th>'.pht('Example').'</th>';
|
|
|
|
$table[] = '<th>'.pht('Value').'</th>';
|
|
|
|
$table[] = '</tr>';
|
2013-01-01 23:09:59 +01:00
|
|
|
foreach ($examples as $example) {
|
|
|
|
list($value, $description) = $example;
|
|
|
|
|
|
|
|
if ($value === null) {
|
2013-01-01 23:10:33 +01:00
|
|
|
$value = '<em>'.pht('(empty)').'</em>';
|
2013-01-01 23:09:59 +01:00
|
|
|
} else {
|
2013-01-02 23:02:31 +01:00
|
|
|
$value = nl2br(phutil_escape_html($value));
|
2013-01-01 23:09:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$table[] = '<tr>';
|
2013-01-01 23:10:33 +01:00
|
|
|
$table[] = '<th>'.phutil_escape_html($description).'</th>';
|
|
|
|
$table[] = '<td>'.$value.'</td>';
|
|
|
|
$table[] = '</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
require_celerity_resource('config-options-css');
|
|
|
|
|
2013-01-18 09:32:58 +01:00
|
|
|
return phutil_tag(
|
2013-01-01 23:10:33 +01:00
|
|
|
'table',
|
|
|
|
array(
|
|
|
|
'class' => 'config-option-table',
|
|
|
|
),
|
2013-01-18 09:32:58 +01:00
|
|
|
new PhutilSafeHTML(implode("\n", $table)));
|
2013-01-01 23:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function renderDefaults(PhabricatorConfigOption $option) {
|
|
|
|
$stack = PhabricatorEnv::getConfigSourceStack();
|
|
|
|
$stack = $stack->getStack();
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
TODO: Once DatabaseSource lands, do this:
|
|
|
|
|
|
|
|
foreach ($stack as $key => $source) {
|
|
|
|
unset($stack[$key]);
|
|
|
|
if ($source instanceof PhabricatorConfigDatabaseSource) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
$table = array();
|
|
|
|
$table[] = '<tr class="column-labels">';
|
|
|
|
$table[] = '<th>'.pht('Source').'</th>';
|
|
|
|
$table[] = '<th>'.pht('Value').'</th>';
|
|
|
|
$table[] = '</tr>';
|
|
|
|
foreach ($stack as $key => $source) {
|
|
|
|
$value = $source->getKeys(
|
|
|
|
array(
|
|
|
|
$option->getKey(),
|
|
|
|
));
|
|
|
|
|
|
|
|
if (!array_key_exists($option->getKey(), $value)) {
|
|
|
|
$value = '<em>'.pht('(empty)').'</em>';
|
|
|
|
} else {
|
2013-01-12 00:28:33 +01:00
|
|
|
$value = PhabricatorConfigJSON::prettyPrintJSON(
|
|
|
|
$value[$option->getKey()]);
|
2013-01-01 23:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$table[] = '<tr>';
|
|
|
|
$table[] = '<th>'.phutil_escape_html($source->getName()).'</th>';
|
|
|
|
$table[] = '<td>'.$value.'</td>';
|
2013-01-01 23:09:59 +01:00
|
|
|
$table[] = '</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
require_celerity_resource('config-options-css');
|
|
|
|
|
2013-01-18 09:32:58 +01:00
|
|
|
return phutil_tag(
|
2013-01-01 23:09:59 +01:00
|
|
|
'table',
|
|
|
|
array(
|
2013-01-01 23:10:33 +01:00
|
|
|
'class' => 'config-option-table',
|
2013-01-01 23:09:59 +01:00
|
|
|
),
|
2013-01-18 09:32:58 +01:00
|
|
|
new PhutilSafeHTML(implode("\n", $table)));
|
2013-01-01 23:09:59 +01:00
|
|
|
}
|
|
|
|
|
2012-12-28 00:20:09 +01:00
|
|
|
}
|