Differential D20934 Diff 49950 src/applications/config/controller/settings/PhabricatorConfigEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/settings/PhabricatorConfigEditController.php
- This file was moved from src/applications/config/controller/PhabricatorConfigEditController.php.
<?php | <?php | ||||
final class PhabricatorConfigEditController | final class PhabricatorConfigEditController | ||||
extends PhabricatorConfigController { | extends PhabricatorConfigSettingsController { | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
$key = $request->getURIData('key'); | $key = $request->getURIData('key'); | ||||
$options = PhabricatorApplicationConfigOptions::loadAllOptions(); | $options = PhabricatorApplicationConfigOptions::loadAllOptions(); | ||||
if (empty($options[$key])) { | if (empty($options[$key])) { | ||||
$ancient = PhabricatorExtraConfigSetupCheck::getAncientConfig(); | $ancient = PhabricatorExtraConfigSetupCheck::getAncientConfig(); | ||||
Show All 12 Lines | if (empty($options[$key])) { | ||||
// longer exists. Allow it to be edited so it can be reviewed and | // longer exists. Allow it to be edited so it can be reviewed and | ||||
// deleted. | // deleted. | ||||
$option = id(new PhabricatorConfigOption()) | $option = id(new PhabricatorConfigOption()) | ||||
->setKey($key) | ->setKey($key) | ||||
->setType('wild') | ->setType('wild') | ||||
->setDefault(null) | ->setDefault(null) | ||||
->setDescription($desc); | ->setDescription($desc); | ||||
$group = null; | $group = null; | ||||
$group_uri = $this->getApplicationURI(); | |||||
} else { | } else { | ||||
$option = $options[$key]; | $option = $options[$key]; | ||||
$group = $option->getGroup(); | $group = $option->getGroup(); | ||||
$group_uri = $this->getApplicationURI('group/'.$group->getKey().'/'); | |||||
} | } | ||||
$issue = $request->getStr('issue'); | $issue = $request->getStr('issue'); | ||||
if ($issue) { | if ($issue) { | ||||
// If the user came here from an open setup issue, send them back. | // If the user came here from an open setup issue, send them back. | ||||
$done_uri = $this->getApplicationURI('issue/'.$issue.'/'); | $done_uri = $this->getApplicationURI('issue/'.$issue.'/'); | ||||
} else { | } else { | ||||
$done_uri = $group_uri; | $done_uri = $this->getApplicationURI('settings/'); | ||||
} | } | ||||
// Check if the config key is already stored in the database. | // Check if the config key is already stored in the database. | ||||
// Grab the value if it is. | // Grab the value if it is. | ||||
$config_entry = id(new PhabricatorConfigEntry()) | $config_entry = id(new PhabricatorConfigEntry()) | ||||
->loadOneWhere( | ->loadOneWhere( | ||||
'configKey = %s AND namespace = %s', | 'configKey = %s AND namespace = %s', | ||||
$key, | $key, | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | if ($examples) { | ||||
$examples = $this->buildConfigBoxView( | $examples = $this->buildConfigBoxView( | ||||
pht('Examples'), | pht('Examples'), | ||||
$examples); | $examples); | ||||
} | } | ||||
$title = $key; | $title = $key; | ||||
$box_header = array(); | $box_header = array(); | ||||
if ($group) { | |||||
$box_header[] = phutil_tag( | |||||
'a', | |||||
array( | |||||
'href' => $group_uri, | |||||
), | |||||
$group->getName()); | |||||
$box_header[] = " \xC2\xBB "; | |||||
} | |||||
$box_header[] = $key; | $box_header[] = $key; | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->newCrumbs() | ||||
if ($group) { | ->addTextCrumb($key, '/config/edit/'.$key); | ||||
$crumbs->addTextCrumb($group->getName(), $group_uri); | |||||
} | |||||
$crumbs->addTextCrumb($key, '/config/edit/'.$key); | |||||
$crumbs->setBorder(true); | |||||
$form_box = $this->buildConfigBoxView($box_header, $form, $tag); | $form_box = $this->buildConfigBoxView($box_header, $form, $tag); | ||||
$timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
$config_entry, | $config_entry, | ||||
new PhabricatorConfigTransactionQuery()); | new PhabricatorConfigTransactionQuery()); | ||||
$timeline->setShouldTerminate(true); | $timeline->setShouldTerminate(true); | ||||
$nav = $this->buildSideNavView(); | |||||
$nav->selectFilter($group_uri); | |||||
$header = $this->buildHeaderView($title); | $header = $this->buildHeaderView($title); | ||||
$view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setFooter( | ->setFooter( | ||||
array( | array( | ||||
$error_view, | $error_view, | ||||
$form_box, | $form_box, | ||||
$status_items, | $status_items, | ||||
$examples, | $examples, | ||||
$current_config, | $current_config, | ||||
)); | )); | ||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->setNavigation($nav) | |||||
->appendChild($view); | ->appendChild($view); | ||||
} | } | ||||
private function readRequest( | private function readRequest( | ||||
PhabricatorConfigOption $option, | PhabricatorConfigOption $option, | ||||
AphrontRequest $request) { | AphrontRequest $request) { | ||||
$type = $option->newOptionType(); | $type = $option->newOptionType(); | ||||
▲ Show 20 Lines • Show All 231 Lines • Show Last 20 Lines |