2011-03-30 19:21:09 -07:00
|
|
|
<?php
|
|
|
|
|
2015-01-02 15:20:08 +11:00
|
|
|
final class PhabricatorDisplayPreferencesSettingsPanel
|
2012-08-13 12:37:26 -07:00
|
|
|
extends PhabricatorSettingsPanel {
|
2011-03-30 19:21:09 -07:00
|
|
|
|
2012-08-13 12:37:26 -07:00
|
|
|
public function getPanelKey() {
|
|
|
|
return 'display';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPanelName() {
|
|
|
|
return pht('Display Preferences');
|
|
|
|
}
|
2011-03-30 19:21:09 -07:00
|
|
|
|
2012-08-13 12:37:26 -07:00
|
|
|
public function getPanelGroup() {
|
|
|
|
return pht('Application Settings');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest(AphrontRequest $request) {
|
2011-03-30 19:21:09 -07:00
|
|
|
$user = $request->getUser();
|
|
|
|
$preferences = $user->loadPreferences();
|
|
|
|
|
2013-01-19 17:40:48 -08:00
|
|
|
$pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED;
|
|
|
|
$pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR;
|
|
|
|
$pref_multiedit = PhabricatorUserPreferences::PREFERENCE_MULTIEDIT;
|
|
|
|
$pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES;
|
2012-11-27 14:06:31 -08:00
|
|
|
$pref_monospaced_textareas =
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS;
|
2015-06-20 06:10:42 -07:00
|
|
|
$pref_postprocessor =
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_RESOURCE_POSTPROCESSOR;
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-17 20:32:28 -08:00
|
|
|
|
2014-03-17 13:00:37 -07:00
|
|
|
$errors = array();
|
|
|
|
$e_editor = null;
|
2011-03-30 19:21:09 -07:00
|
|
|
if ($request->isFormPost()) {
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-17 20:32:28 -08:00
|
|
|
$monospaced = $request->getStr($pref_monospaced);
|
2015-04-22 09:28:35 -07:00
|
|
|
$monospaced = PhabricatorUserPreferences::filterMonospacedCSSRule(
|
|
|
|
$monospaced);
|
2011-03-30 19:21:09 -07:00
|
|
|
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-17 20:32:28 -08:00
|
|
|
$preferences->setPreference($pref_titles, $request->getStr($pref_titles));
|
2012-01-16 11:08:54 -08:00
|
|
|
$preferences->setPreference($pref_editor, $request->getStr($pref_editor));
|
2012-12-03 15:51:18 -08:00
|
|
|
$preferences->setPreference(
|
|
|
|
$pref_multiedit,
|
|
|
|
$request->getStr($pref_multiedit));
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-17 20:32:28 -08:00
|
|
|
$preferences->setPreference($pref_monospaced, $monospaced);
|
2012-11-27 14:06:31 -08:00
|
|
|
$preferences->setPreference(
|
|
|
|
$pref_monospaced_textareas,
|
|
|
|
$request->getStr($pref_monospaced_textareas));
|
2015-06-20 06:10:42 -07:00
|
|
|
$preferences->setPreference(
|
|
|
|
$pref_postprocessor,
|
|
|
|
$request->getStr($pref_postprocessor));
|
2011-03-30 19:21:09 -07:00
|
|
|
|
2014-03-17 13:00:37 -07:00
|
|
|
$editor_pattern = $preferences->getPreference($pref_editor);
|
|
|
|
if (strlen($editor_pattern)) {
|
|
|
|
$ok = PhabricatorHelpEditorProtocolController::hasAllowedProtocol(
|
|
|
|
$editor_pattern);
|
|
|
|
if (!$ok) {
|
|
|
|
$allowed_key = 'uri.allowed-editor-protocols';
|
|
|
|
$allowed_protocols = PhabricatorEnv::getEnvConfig($allowed_key);
|
|
|
|
|
|
|
|
$proto_names = array();
|
|
|
|
foreach (array_keys($allowed_protocols) as $protocol) {
|
|
|
|
$proto_names[] = $protocol.'://';
|
|
|
|
}
|
|
|
|
|
|
|
|
$errors[] = pht(
|
|
|
|
'Editor link has an invalid or missing protocol. You must '.
|
|
|
|
'use a whitelisted editor protocol from this list: %s. To '.
|
|
|
|
'add protocols, update %s.',
|
|
|
|
implode(', ', $proto_names),
|
|
|
|
phutil_tag('tt', array(), $allowed_key));
|
|
|
|
|
|
|
|
$e_editor = pht('Invalid');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$errors) {
|
|
|
|
$preferences->save();
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI($this->getPanelURI('?saved=true'));
|
|
|
|
}
|
2011-03-30 19:21:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
$example_string = <<<EXAMPLE
|
|
|
|
// This is what your monospaced font currently looks like.
|
|
|
|
function helloWorld() {
|
|
|
|
alert("Hello world!");
|
|
|
|
}
|
|
|
|
EXAMPLE;
|
|
|
|
|
2013-01-17 18:57:09 -08:00
|
|
|
$editor_doc_link = phutil_tag(
|
2012-01-30 15:56:42 -08:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => PhabricatorEnv::getDoclink(
|
2014-03-17 15:01:31 -07:00
|
|
|
'User Guide: Configuring an External Editor'),
|
2012-01-30 15:56:42 -08:00
|
|
|
),
|
2013-03-03 06:52:42 -08:00
|
|
|
pht('User Guide: Configuring an External Editor'));
|
2012-01-30 15:56:42 -08:00
|
|
|
|
2012-11-27 14:06:31 -08:00
|
|
|
$pref_monospaced_textareas_value = $preferences
|
|
|
|
->getPreference($pref_monospaced_textareas);
|
|
|
|
if (!$pref_monospaced_textareas_value) {
|
|
|
|
$pref_monospaced_textareas_value = 'disabled';
|
|
|
|
}
|
2012-09-17 11:44:03 -07:00
|
|
|
|
2015-05-22 17:27:56 +10:00
|
|
|
$editor_instructions = pht(
|
|
|
|
'Link to edit files in external editor. '.
|
2013-03-03 06:52:42 -08:00
|
|
|
'%%f is replaced by filename, %%l by line number, %%r by repository '.
|
|
|
|
'callsign, %%%% by literal %%. For documentation, see: %s',
|
2013-11-11 09:23:23 -08:00
|
|
|
$editor_doc_link);
|
2013-03-03 06:52:42 -08:00
|
|
|
|
2015-05-22 17:27:56 +10:00
|
|
|
$font_instructions = pht(
|
|
|
|
'Overrides default fonts in tools like Differential. '.
|
|
|
|
'Input should be valid CSS "font" declaration, such as '.
|
2015-04-22 12:13:11 -07:00
|
|
|
'"13px Consolas"');
|
|
|
|
|
2015-06-20 06:10:42 -07:00
|
|
|
$postprocessor_map = CelerityPostprocessor::getAllPostprocessors();
|
|
|
|
$postprocessor_map = mpull($postprocessor_map, 'getPostprocessorName');
|
|
|
|
asort($postprocessor_map);
|
|
|
|
$postprocessor_order = array(
|
|
|
|
CelerityDefaultPostprocessor::POSTPROCESSOR_KEY,
|
|
|
|
);
|
|
|
|
|
|
|
|
$postprocessor_map = array_select_keys(
|
|
|
|
$postprocessor_map,
|
|
|
|
$postprocessor_order) + $postprocessor_map;
|
|
|
|
|
2011-03-30 19:21:09 -07:00
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($user)
|
2015-06-20 06:10:42 -07:00
|
|
|
->appendControl(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Accessibility'))
|
|
|
|
->setName($pref_postprocessor)
|
|
|
|
->setValue($preferences->getPreference($pref_postprocessor))
|
|
|
|
->setOptions($postprocessor_map))
|
2011-03-30 19:21:09 -07:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
2013-03-03 06:52:42 -08:00
|
|
|
->setLabel(pht('Page Titles'))
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-17 20:32:28 -08:00
|
|
|
->setName($pref_titles)
|
|
|
|
->setValue($preferences->getPreference($pref_titles))
|
2011-03-30 19:21:09 -07:00
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
'glyph' =>
|
2015-05-22 17:27:56 +10:00
|
|
|
pht(
|
|
|
|
'In page titles, show Tool names as unicode glyphs: %s',
|
2013-03-03 06:52:42 -08:00
|
|
|
"\xE2\x9A\x99"),
|
2011-03-30 19:21:09 -07:00
|
|
|
'text' =>
|
2015-05-22 17:27:56 +10:00
|
|
|
pht(
|
|
|
|
'In page titles, show Tool names as plain text: '.
|
2013-03-03 06:52:42 -08:00
|
|
|
'[Differential]'),
|
2011-03-30 19:21:09 -07:00
|
|
|
)))
|
2012-01-16 11:08:54 -08:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
2013-03-03 06:52:42 -08:00
|
|
|
->setLabel(pht('Editor Link'))
|
2012-01-16 11:08:54 -08:00
|
|
|
->setName($pref_editor)
|
2013-03-03 06:52:42 -08:00
|
|
|
->setCaption($editor_instructions)
|
2014-03-17 13:00:37 -07:00
|
|
|
->setError($e_editor)
|
2012-01-16 11:08:54 -08:00
|
|
|
->setValue($preferences->getPreference($pref_editor)))
|
2012-12-03 15:51:18 -08:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
2013-03-03 06:52:42 -08:00
|
|
|
->setLabel(pht('Edit Multiple Files'))
|
2012-12-03 15:51:18 -08:00
|
|
|
->setName($pref_multiedit)
|
|
|
|
->setOptions(array(
|
2013-03-03 06:52:42 -08:00
|
|
|
'' => pht('Supported (paths separated by spaces)'),
|
|
|
|
'disable' => pht('Not Supported'),
|
2012-12-03 15:51:18 -08:00
|
|
|
))
|
|
|
|
->setValue($preferences->getPreference($pref_multiedit)))
|
2011-03-30 19:21:09 -07:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
2013-03-03 06:52:42 -08:00
|
|
|
->setLabel(pht('Monospaced Font'))
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-17 20:32:28 -08:00
|
|
|
->setName($pref_monospaced)
|
2015-04-22 12:13:11 -07:00
|
|
|
->setCaption($font_instructions)
|
Add optional "Re:" prefix to all threaded mail and allow disabling mail about
your own actions
Summary:
- Mail.app on Lion has cumbersome threading rules, see T782. Add an option to
stick "Re: " in front of all threaded mail so it behaves. This is horrible, but
apparently the least-horrible option.
- While I was in there, I added an option for T228.
Test Plan:
- Sent a bunch of threaded and unthreaded mail with varous "Re:" settings,
seemed to get "Re:" in the right places.
- Disabled email about my stuff, created a task with just me, got voided mail,
added a CC, got mail to just the CC.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, mkjones
Maniphest Tasks: T228, T782
Differential Revision: https://secure.phabricator.com/D1448
2012-01-17 20:32:28 -08:00
|
|
|
->setValue($preferences->getPreference($pref_monospaced)))
|
2011-03-30 19:21:09 -07:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
2013-02-05 14:30:29 -08:00
|
|
|
->setValue(phutil_tag(
|
|
|
|
'pre',
|
|
|
|
array('class' => 'PhabricatorMonospaced'),
|
|
|
|
$example_string)))
|
2012-11-27 14:06:31 -08:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormRadioButtonControl())
|
2013-03-03 06:52:42 -08:00
|
|
|
->setLabel(pht('Monospaced Textareas'))
|
2012-11-27 14:06:31 -08:00
|
|
|
->setName($pref_monospaced_textareas)
|
|
|
|
->setValue($pref_monospaced_textareas_value)
|
2013-03-03 06:52:42 -08:00
|
|
|
->addButton('enabled', pht('Enabled'),
|
|
|
|
pht('Show all textareas using the monospaced font defined above.'))
|
|
|
|
->addButton('disabled', pht('Disabled'), null));
|
2013-02-22 06:16:48 -08:00
|
|
|
|
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2013-03-03 06:52:42 -08:00
|
|
|
->setValue(pht('Save Preferences')));
|
2013-01-19 17:40:48 -08:00
|
|
|
|
2013-09-25 11:23:29 -07:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-26 11:53:11 -07:00
|
|
|
->setHeaderText(pht('Display Preferences'))
|
2014-03-17 13:00:37 -07:00
|
|
|
->setFormErrors($errors)
|
2014-01-10 09:17:37 -08:00
|
|
|
->setFormSaved($request->getStr('saved') === 'true')
|
2013-08-26 11:53:11 -07:00
|
|
|
->setForm($form);
|
|
|
|
|
2012-08-13 12:37:26 -07:00
|
|
|
return array(
|
2013-08-26 11:53:11 -07:00
|
|
|
$form_box,
|
2012-08-13 12:37:26 -07:00
|
|
|
);
|
2011-03-30 19:21:09 -07:00
|
|
|
}
|
|
|
|
}
|