Differential D18519 Diff 44486 src/applications/config/controller/PhabricatorConfigGroupController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/PhabricatorConfigGroupController.php
<?php | <?php | ||||
final class PhabricatorConfigGroupController | final class PhabricatorConfigGroupController | ||||
extends PhabricatorConfigController { | extends PhabricatorConfigController { | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
$group_key = $request->getURIData('key'); | $group_key = $request->getURIData('key'); | ||||
$groups = PhabricatorApplicationConfigOptions::loadAll(); | $groups = PhabricatorApplicationConfigOptions::loadAll(); | ||||
$options = idx($groups, $group_key); | $options = idx($groups, $group_key); | ||||
if (!$options) { | if (!$options) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$group_uri = PhabricatorConfigGroupConstants::getGroupURI( | $group_uri = PhabricatorConfigGroupConstants::getGroupFullURI( | ||||
$options->getGroup()); | $options->getGroup()); | ||||
$group_name = PhabricatorConfigGroupConstants::getGroupShortName( | $group_name = PhabricatorConfigGroupConstants::getGroupShortName( | ||||
$options->getGroup()); | $options->getGroup()); | ||||
$nav = $this->buildSideNavView(); | $nav = $this->buildSideNavView(); | ||||
$nav->selectFilter($group_uri); | $nav->selectFilter($group_uri); | ||||
$title = pht('%s Configuration', $options->getName()); | $title = pht('%s Configuration', $options->getName()); | ||||
$header = $this->buildHeaderView($title); | |||||
$list = $this->buildOptionList($options->getOptions()); | $list = $this->buildOptionList($options->getOptions()); | ||||
$group_url = phutil_tag('a', array('href' => $group_uri), $group_name); | |||||
$crumbs = $this | $box_header = pht("%s \xC2\xBB %s", $group_url, $options->getName()); | ||||
quark.zju: `$this->getApplicationURI($group_uri)` returns something like `/config/config/application`. | |||||
->buildApplicationCrumbs() | $view = $this->buildConfigBoxView($box_header, $list); | ||||
->addTextCrumb($group_name, $this->getApplicationURI($group_uri)) | |||||
->addTextCrumb($options->getName()) | |||||
->setBorder(true); | |||||
$header = id(new PHUIHeaderView()) | |||||
->setHeader($title) | |||||
->setProfileHeader(true); | |||||
$content = id(new PhabricatorConfigPageView()) | $content = id(new PHUITwoColumnView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setContent($list); | ->setNavigation($nav) | ||||
->setFixed(true) | |||||
->setMainColumn($view); | |||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->appendChild($content); | ||||
->setNavigation($nav) | |||||
->appendChild($content) | |||||
->addClass('white-background'); | |||||
} | } | ||||
private function buildOptionList(array $options) { | private function buildOptionList(array $options) { | ||||
assert_instances_of($options, 'PhabricatorConfigOption'); | assert_instances_of($options, 'PhabricatorConfigOption'); | ||||
require_celerity_resource('config-options-css'); | require_celerity_resource('config-options-css'); | ||||
$db_values = array(); | $db_values = array(); | ||||
Show All 17 Lines | private function buildOptionList(array $options) { | ||||
foreach ($options as $option) { | foreach ($options as $option) { | ||||
$summary = $engine->getOutput($option, 'summary'); | $summary = $engine->getOutput($option, 'summary'); | ||||
$item = id(new PHUIObjectItemView()) | $item = id(new PHUIObjectItemView()) | ||||
->setHeader($option->getKey()) | ->setHeader($option->getKey()) | ||||
->setHref('/config/edit/'.$option->getKey().'/') | ->setHref('/config/edit/'.$option->getKey().'/') | ||||
->addAttribute($summary); | ->addAttribute($summary); | ||||
$label = pht('Current Value:'); | |||||
$color = null; | $color = null; | ||||
$db_value = idx($db_values, $option->getKey()); | $db_value = idx($db_values, $option->getKey()); | ||||
if ($db_value && !$db_value->getIsDeleted()) { | if ($db_value && !$db_value->getIsDeleted()) { | ||||
$item->setEffect('visited'); | $item->setEffect('visited'); | ||||
$color = 'violet'; | $color = 'violet'; | ||||
$label = pht('Customized Value:'); | |||||
} | } | ||||
if ($option->getHidden()) { | if ($option->getHidden()) { | ||||
$item->setStatusIcon('fa-eye-slash grey', pht('Hidden')); | $item->setStatusIcon('fa-eye-slash grey', pht('Hidden')); | ||||
$item->setDisabled(true); | $item->setDisabled(true); | ||||
} else if ($option->getLocked()) { | } else if ($option->getLocked()) { | ||||
$item->setStatusIcon('fa-lock '.$color, pht('Locked')); | $item->setStatusIcon('fa-lock '.$color, pht('Locked')); | ||||
} else if ($color) { | |||||
$item->setStatusIcon('fa-pencil '.$color, pht('Editable')); | |||||
} else { | } else { | ||||
$item->setStatusIcon('fa-pencil-square-o '.$color, pht('Editable')); | $item->setStatusIcon('fa-pencil-square-o '.$color, pht('Editable')); | ||||
} | } | ||||
if (!$option->getHidden()) { | if (!$option->getHidden()) { | ||||
$current_value = PhabricatorEnv::getEnvConfig($option->getKey()); | $current_value = PhabricatorEnv::getEnvConfig($option->getKey()); | ||||
$current_value = PhabricatorConfigJSON::prettyPrintJSON( | $current_value = PhabricatorConfigJSON::prettyPrintJSON( | ||||
$current_value); | $current_value); | ||||
$current_value = phutil_tag( | $current_value = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'config-options-current-value', | 'class' => 'config-options-current-value '.$color, | ||||
), | ), | ||||
array( | array( | ||||
phutil_tag('span', array(), $label), | $current_value, | ||||
' '.$current_value, | |||||
)); | )); | ||||
$item->appendChild($current_value); | $item->setSideColumn($current_value); | ||||
} | } | ||||
$list->addItem($item); | $list->addItem($item); | ||||
} | } | ||||
return $list; | return $list; | ||||
} | } | ||||
} | } |
$this->getApplicationURI($group_uri) returns something like /config/config/application.
Maybe still use PhabricatorConfigGroupConstants::getGroupURI but use getApplicationURI to calculate the full URI?