Skip to content

Commit 9b27b5c

Browse files
author
epriestley
committedJun 1, 2016
Convert "Display Preferences" to modular settings
Summary: Ref T4103. Just porting these directly for now, no attempt to organize things yet. Test Plan: {F1669263} Reviewers: chad Reviewed By: chad Maniphest Tasks: T4103 Differential Revision: https://secure.phabricator.com/D15997
1 parent ba505c0 commit 9b27b5c

10 files changed

+245
-2
lines changed
 

‎src/__phutil_library_map__.php

+14
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,7 @@
17111711
'PhabricatorAccessControlTestCase' => 'applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php',
17121712
'PhabricatorAccessLog' => 'infrastructure/log/PhabricatorAccessLog.php',
17131713
'PhabricatorAccessLogConfigOptions' => 'applications/config/option/PhabricatorAccessLogConfigOptions.php',
1714+
'PhabricatorAccessibilitySetting' => 'applications/settings/setting/PhabricatorAccessibilitySetting.php',
17141715
'PhabricatorAccountSettingsPanel' => 'applications/settings/panel/PhabricatorAccountSettingsPanel.php',
17151716
'PhabricatorActionListView' => 'view/layout/PhabricatorActionListView.php',
17161717
'PhabricatorActionView' => 'view/layout/PhabricatorActionView.php',
@@ -2373,6 +2374,8 @@
23732374
'PhabricatorEditPage' => 'applications/transactions/editengine/PhabricatorEditPage.php',
23742375
'PhabricatorEditType' => 'applications/transactions/edittype/PhabricatorEditType.php',
23752376
'PhabricatorEditor' => 'infrastructure/PhabricatorEditor.php',
2377+
'PhabricatorEditorMultipleSetting' => 'applications/settings/setting/PhabricatorEditorMultipleSetting.php',
2378+
'PhabricatorEditorSetting' => 'applications/settings/setting/PhabricatorEditorSetting.php',
23762379
'PhabricatorElasticFulltextStorageEngine' => 'applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php',
23772380
'PhabricatorElasticSearchSetupCheck' => 'applications/config/check/PhabricatorElasticSearchSetupCheck.php',
23782381
'PhabricatorEmailAddressesSettingsPanel' => 'applications/settings/panel/PhabricatorEmailAddressesSettingsPanel.php',
@@ -2732,6 +2735,8 @@
27322735
'PhabricatorMetaMTASendGridReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php',
27332736
'PhabricatorMetaMTAWorker' => 'applications/metamta/PhabricatorMetaMTAWorker.php',
27342737
'PhabricatorMetronomicTriggerClock' => 'infrastructure/daemon/workers/clock/PhabricatorMetronomicTriggerClock.php',
2738+
'PhabricatorMonospacedFontSetting' => 'applications/settings/setting/PhabricatorMonospacedFontSetting.php',
2739+
'PhabricatorMonospacedTextareasSetting' => 'applications/settings/setting/PhabricatorMonospacedTextareasSetting.php',
27352740
'PhabricatorMotivatorProfilePanel' => 'applications/search/profilepanel/PhabricatorMotivatorProfilePanel.php',
27362741
'PhabricatorMultiColumnUIExample' => 'applications/uiexample/examples/PhabricatorMultiColumnUIExample.php',
27372742
'PhabricatorMultiFactorSettingsPanel' => 'applications/settings/panel/PhabricatorMultiFactorSettingsPanel.php',
@@ -3463,6 +3468,7 @@
34633468
'PhabricatorStorageSetupCheck' => 'applications/config/check/PhabricatorStorageSetupCheck.php',
34643469
'PhabricatorStreamingProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorStreamingProtocolAdapter.php',
34653470
'PhabricatorStringListEditField' => 'applications/transactions/editfield/PhabricatorStringListEditField.php',
3471+
'PhabricatorStringSetting' => 'applications/settings/setting/PhabricatorStringSetting.php',
34663472
'PhabricatorSubscribableInterface' => 'applications/subscriptions/interface/PhabricatorSubscribableInterface.php',
34673473
'PhabricatorSubscribedToObjectEdgeType' => 'applications/transactions/edges/PhabricatorSubscribedToObjectEdgeType.php',
34683474
'PhabricatorSubscribersEditField' => 'applications/transactions/editfield/PhabricatorSubscribersEditField.php',
@@ -3522,6 +3528,7 @@
35223528
'PhabricatorTimeGuard' => 'infrastructure/time/PhabricatorTimeGuard.php',
35233529
'PhabricatorTimeTestCase' => 'infrastructure/time/__tests__/PhabricatorTimeTestCase.php',
35243530
'PhabricatorTimezoneSetupCheck' => 'applications/config/check/PhabricatorTimezoneSetupCheck.php',
3531+
'PhabricatorTitleGlyphsSetting' => 'applications/settings/setting/PhabricatorTitleGlyphsSetting.php',
35253532
'PhabricatorToken' => 'applications/tokens/storage/PhabricatorToken.php',
35263533
'PhabricatorTokenController' => 'applications/tokens/controller/PhabricatorTokenController.php',
35273534
'PhabricatorTokenCount' => 'applications/tokens/storage/PhabricatorTokenCount.php',
@@ -6137,6 +6144,7 @@
61376144
'PhabricatorAccessControlTestCase' => 'PhabricatorTestCase',
61386145
'PhabricatorAccessLog' => 'Phobject',
61396146
'PhabricatorAccessLogConfigOptions' => 'PhabricatorApplicationConfigOptions',
6147+
'PhabricatorAccessibilitySetting' => 'PhabricatorSelectSetting',
61406148
'PhabricatorAccountSettingsPanel' => 'PhabricatorSettingsPanel',
61416149
'PhabricatorActionListView' => 'AphrontView',
61426150
'PhabricatorActionView' => 'AphrontView',
@@ -6914,6 +6922,8 @@
69146922
'PhabricatorEditPage' => 'Phobject',
69156923
'PhabricatorEditType' => 'Phobject',
69166924
'PhabricatorEditor' => 'Phobject',
6925+
'PhabricatorEditorMultipleSetting' => 'PhabricatorSelectSetting',
6926+
'PhabricatorEditorSetting' => 'PhabricatorStringSetting',
69176927
'PhabricatorElasticFulltextStorageEngine' => 'PhabricatorFulltextStorageEngine',
69186928
'PhabricatorElasticSearchSetupCheck' => 'PhabricatorSetupCheck',
69196929
'PhabricatorEmailAddressesSettingsPanel' => 'PhabricatorSettingsPanel',
@@ -7318,6 +7328,8 @@
73187328
'PhabricatorMetaMTASendGridReceiveController' => 'PhabricatorMetaMTAController',
73197329
'PhabricatorMetaMTAWorker' => 'PhabricatorWorker',
73207330
'PhabricatorMetronomicTriggerClock' => 'PhabricatorTriggerClock',
7331+
'PhabricatorMonospacedFontSetting' => 'PhabricatorStringSetting',
7332+
'PhabricatorMonospacedTextareasSetting' => 'PhabricatorSelectSetting',
73217333
'PhabricatorMotivatorProfilePanel' => 'PhabricatorProfilePanel',
73227334
'PhabricatorMultiColumnUIExample' => 'PhabricatorUIExample',
73237335
'PhabricatorMultiFactorSettingsPanel' => 'PhabricatorSettingsPanel',
@@ -8204,6 +8216,7 @@
82048216
'PhabricatorStorageSetupCheck' => 'PhabricatorSetupCheck',
82058217
'PhabricatorStreamingProtocolAdapter' => 'PhabricatorProtocolAdapter',
82068218
'PhabricatorStringListEditField' => 'PhabricatorEditField',
8219+
'PhabricatorStringSetting' => 'PhabricatorSetting',
82078220
'PhabricatorSubscribedToObjectEdgeType' => 'PhabricatorEdgeType',
82088221
'PhabricatorSubscribersEditField' => 'PhabricatorTokenizerEditField',
82098222
'PhabricatorSubscribersQuery' => 'PhabricatorQuery',
@@ -8262,6 +8275,7 @@
82628275
'PhabricatorTimeGuard' => 'Phobject',
82638276
'PhabricatorTimeTestCase' => 'PhabricatorTestCase',
82648277
'PhabricatorTimezoneSetupCheck' => 'PhabricatorSetupCheck',
8278+
'PhabricatorTitleGlyphsSetting' => 'PhabricatorSelectSetting',
82658279
'PhabricatorToken' => array(
82668280
'PhabricatorTokenDAO',
82678281
'PhabricatorPolicyInterface',

‎src/applications/celerity/postprocessor/CelerityDefaultPostprocessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public function getPostprocessorKey() {
1010
}
1111

1212
public function getPostprocessorName() {
13-
return pht('Use Default Colors');
13+
return pht('Use Standard Colors');
1414
}
1515

1616
public function buildDefaultPostprocessor() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
final class PhabricatorAccessibilitySetting
4+
extends PhabricatorSelectSetting {
5+
6+
const SETTINGKEY = 'resource-postprocessor';
7+
8+
public function getSettingName() {
9+
return pht('Accessibility');
10+
}
11+
12+
protected function getControlInstructions() {
13+
return pht(
14+
'If you have difficulty reading the Phabricator UI, these settings '.
15+
'may make Phabricator more accessible.');
16+
}
17+
18+
public function getSettingDefaultValue() {
19+
return CelerityDefaultPostprocessor::POSTPROCESSOR_KEY;
20+
}
21+
22+
protected function getSelectOptions() {
23+
$postprocessor_map = CelerityPostprocessor::getAllPostprocessors();
24+
25+
$postprocessor_map = mpull($postprocessor_map, 'getPostprocessorName');
26+
asort($postprocessor_map);
27+
28+
$postprocessor_order = array(
29+
CelerityDefaultPostprocessor::POSTPROCESSOR_KEY,
30+
);
31+
32+
$postprocessor_map = array_select_keys(
33+
$postprocessor_map,
34+
$postprocessor_order) + $postprocessor_map;
35+
36+
return $postprocessor_map;
37+
}
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
final class PhabricatorEditorMultipleSetting
4+
extends PhabricatorSelectSetting {
5+
6+
const SETTINGKEY = 'multiedit';
7+
8+
const VALUE_SPACES = 'spaces';
9+
const VALUE_SINGLE = 'disable';
10+
11+
public function getSettingName() {
12+
return pht('Edit Mulitple Files');
13+
}
14+
15+
protected function getControlInstructions() {
16+
return pht(
17+
'Some editors support opening multiple files with a single URI. You '.
18+
'can specify the behavior of your editor here.');
19+
}
20+
21+
public function getSettingDefaultValue() {
22+
return self::VALUE_SPACES;
23+
}
24+
25+
protected function getSelectOptions() {
26+
return array(
27+
self::VALUE_SPACES => pht('Supported, Separated by Spaces'),
28+
self::VALUE_SINGLE => pht('Not Supported'),
29+
);
30+
}
31+
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
final class PhabricatorEditorSetting
4+
extends PhabricatorStringSetting {
5+
6+
const SETTINGKEY = 'editor';
7+
8+
public function getSettingName() {
9+
return pht('Editor Link');
10+
}
11+
12+
protected function getControlInstructions() {
13+
return pht(
14+
"Many text editors can be configured as URI handlers for special ".
15+
"protocols like `editor://`. If you have such an editor, Phabricator ".
16+
"can generate links that you can click to open files locally.".
17+
"\n\n".
18+
"These special variables are supported:".
19+
"\n\n".
20+
"| Value | Replaced With |\n".
21+
"|-------|---------------|\n".
22+
"| `%%f` | Filename |\n".
23+
"| `%%l` | Line Number |\n".
24+
"| `%%r` | Repository Callsign |\n".
25+
"| `%%%%` | Literal `%%` |\n".
26+
"\n\n".
27+
"For complete instructions on editor configuration, ".
28+
"see **[[ %s | %s ]]**.",
29+
PhabricatorEnv::getDoclink('User Guide: Configuring an External Editor'),
30+
pht('User Guide: Configuring an External Editor'));
31+
}
32+
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
final class PhabricatorMonospacedFontSetting
4+
extends PhabricatorStringSetting {
5+
6+
const SETTINGKEY = 'monospaced';
7+
8+
public function getSettingName() {
9+
return pht('Monospaced Font');
10+
}
11+
12+
protected function getControlInstructions() {
13+
return pht(
14+
'You can customize the font used when showing monospaced text, '.
15+
'including source code. You should enter a valid CSS font declaration '.
16+
'like: `13px Consolas`');
17+
}
18+
19+
public function validateTransactionValue($value) {
20+
if (!strlen($value)) {
21+
return;
22+
}
23+
24+
$filtered = self::filterMonospacedCSSRule($value);
25+
if ($filtered !== $value) {
26+
throw new Exception(
27+
pht(
28+
'Monospaced font value "%s" is unsafe. You may only enter '.
29+
'letters, numbers, spaces, commas, periods, forward slashes '.
30+
'and double quotes.',
31+
$value));
32+
}
33+
}
34+
35+
public static function filterMonospacedCSSRule($monospaced) {
36+
// Prevent the user from doing dangerous things.
37+
return preg_replace('([^a-z0-9 ,"./]+)i', '', $monospaced);
38+
}
39+
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
final class PhabricatorMonospacedTextareasSetting
4+
extends PhabricatorSelectSetting {
5+
6+
const SETTINGKEY = 'monospaced-textareas';
7+
8+
const VALUE_TEXT_VARIABLE_WIDTH = 'disabled';
9+
const VALUE_TEXT_MONOSPACED = 'enabled';
10+
11+
public function getSettingName() {
12+
return pht('Monospaced Textareas');
13+
}
14+
15+
protected function getControlInstructions() {
16+
return pht(
17+
'You can choose to use either a monospaced or variable-width font '.
18+
'in textareas in the UI. Textareas are used for editing descriptions '.
19+
'and writing comments, among other things.');
20+
}
21+
22+
public function getSettingDefaultValue() {
23+
return self::VALUE_TEXT_VARIABLE_WIDTH;
24+
}
25+
26+
protected function getSelectOptions() {
27+
return array(
28+
self::VALUE_TEXT_VARIABLE_WIDTH => pht('Use Variable-Width Font'),
29+
self::VALUE_TEXT_MONOSPACED => pht('Use Monospaced Font'),
30+
);
31+
}
32+
33+
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
abstract class PhabricatorStringSetting
4+
extends PhabricatorSetting {
5+
6+
final protected function newCustomEditField($object) {
7+
return $this->newEditField($object, new PhabricatorTextEditField());
8+
}
9+
10+
public function getTransactionNewValue($value) {
11+
if (!strlen($value)) {
12+
return null;
13+
}
14+
15+
return (string)$value;
16+
}
17+
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
final class PhabricatorTitleGlyphsSetting
4+
extends PhabricatorSelectSetting {
5+
6+
const SETTINGKEY = 'titles';
7+
8+
const VALUE_TITLE_GLYPHS = 'glyph';
9+
const VALUE_TITLE_TEXT = 'text';
10+
11+
public function getSettingName() {
12+
return pht('Page Titles');
13+
}
14+
15+
protected function getControlInstructions() {
16+
return pht(
17+
'Phabricator uses unicode glyphs in page titles to provide a compact '.
18+
'representation of the current application. You can substitute plain '.
19+
'text instead if these glyphs do not display on your system.');
20+
}
21+
22+
public function getSettingDefaultValue() {
23+
return self::VALUE_TITLE_GLYPHS;
24+
}
25+
26+
protected function getSelectOptions() {
27+
return array(
28+
self::VALUE_TITLE_GLYPHS => pht("Use Unicode Glyphs: \xE2\x9A\x99"),
29+
self::VALUE_TITLE_TEXT => pht('Use Plain Text: [Differential]'),
30+
);
31+
}
32+
33+
}

‎src/view/page/PhabricatorStandardPageView.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ protected function getHead() {
374374
// We can't print this normally because escaping quotation marks will
375375
// break the CSS. Instead, filter it strictly and then mark it as safe.
376376
$monospaced = new PhutilSafeHTML(
377-
PhabricatorUserPreferences::filterMonospacedCSSRule(
377+
PhabricatorMonospacedFontSetting::filterMonospacedCSSRule(
378378
$monospaced));
379379

380380
$font_css = hsprintf(

0 commit comments

Comments
 (0)
Failed to load comments.