2011-03-31 04:21:09 +02:00
|
|
|
<?php
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
final class PhabricatorSettingsPanelDisplayPreferences
|
|
|
|
extends PhabricatorSettingsPanel {
|
2011-03-31 04:21:09 +02:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
public function getPanelKey() {
|
|
|
|
return 'display';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPanelName() {
|
|
|
|
return pht('Display Preferences');
|
|
|
|
}
|
2011-03-31 04:21:09 +02:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
public function getPanelGroup() {
|
|
|
|
return pht('Application Settings');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest(AphrontRequest $request) {
|
2011-03-31 04:21:09 +02:00
|
|
|
$user = $request->getUser();
|
|
|
|
$preferences = $user->loadPreferences();
|
|
|
|
|
2013-01-20 02:40:48 +01:00
|
|
|
$pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED;
|
|
|
|
$pref_dark_console = PhabricatorUserPreferences::PREFERENCE_DARK_CONSOLE;
|
|
|
|
$pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR;
|
|
|
|
$pref_multiedit = PhabricatorUserPreferences::PREFERENCE_MULTIEDIT;
|
|
|
|
$pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES;
|
2012-11-27 23:06:31 +01:00
|
|
|
$pref_monospaced_textareas =
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS;
|
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-18 05:32:28 +01:00
|
|
|
|
2011-03-31 04:21:09 +02: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-18 05:32:28 +01:00
|
|
|
$monospaced = $request->getStr($pref_monospaced);
|
2011-03-31 04:21:09 +02:00
|
|
|
|
|
|
|
// Prevent the user from doing stupid things.
|
|
|
|
$monospaced = preg_replace('/[^a-z0-9 ,"]+/i', '', $monospaced);
|
|
|
|
|
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-18 05:32:28 +01:00
|
|
|
$preferences->setPreference($pref_titles, $request->getStr($pref_titles));
|
2012-01-16 20:08:54 +01:00
|
|
|
$preferences->setPreference($pref_editor, $request->getStr($pref_editor));
|
2012-12-04 00:51:18 +01: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-18 05:32:28 +01:00
|
|
|
$preferences->setPreference($pref_monospaced, $monospaced);
|
2012-11-27 23:06:31 +01:00
|
|
|
$preferences->setPreference(
|
|
|
|
$pref_monospaced_textareas,
|
|
|
|
$request->getStr($pref_monospaced_textareas));
|
2013-01-20 02:40:48 +01:00
|
|
|
$preferences->setPreference(
|
|
|
|
$pref_dark_console,
|
|
|
|
$request->getBool($pref_dark_console));
|
2011-03-31 04:21:09 +02:00
|
|
|
|
|
|
|
$preferences->save();
|
|
|
|
return id(new AphrontRedirectResponse())
|
2012-08-13 21:37:26 +02:00
|
|
|
->setURI($this->getPanelURI('?saved=true'));
|
2011-03-31 04:21:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$example_string = <<<EXAMPLE
|
|
|
|
// This is what your monospaced font currently looks like.
|
|
|
|
function helloWorld() {
|
|
|
|
alert("Hello world!");
|
|
|
|
}
|
|
|
|
EXAMPLE;
|
|
|
|
|
2013-01-18 03:57:09 +01:00
|
|
|
$editor_doc_link = phutil_tag(
|
2012-01-31 00:56:42 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => PhabricatorEnv::getDoclink(
|
2012-04-10 19:15:40 +02:00
|
|
|
'article/User_Guide_Configuring_an_External_Editor.html'),
|
2012-01-31 00:56:42 +01:00
|
|
|
),
|
|
|
|
'User Guide: Configuring an External Editor');
|
|
|
|
|
2012-07-07 00:39:43 +02:00
|
|
|
$font_default = PhabricatorEnv::getEnvConfig('style.monospace');
|
|
|
|
|
2012-11-27 23:06:31 +01:00
|
|
|
$pref_monospaced_textareas_value = $preferences
|
|
|
|
->getPreference($pref_monospaced_textareas);
|
|
|
|
if (!$pref_monospaced_textareas_value) {
|
|
|
|
$pref_monospaced_textareas_value = 'disabled';
|
|
|
|
}
|
2013-01-20 02:40:48 +01:00
|
|
|
$pref_dark_console_value = $preferences->getPreference($pref_dark_console);
|
|
|
|
if (!$pref_dark_console_value) {
|
|
|
|
$pref_dark_console_value = 0;
|
|
|
|
}
|
2012-09-17 20:44:03 +02:00
|
|
|
|
2011-03-31 04:21:09 +02:00
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($user)
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel('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-18 05:32:28 +01:00
|
|
|
->setName($pref_titles)
|
|
|
|
->setValue($preferences->getPreference($pref_titles))
|
2011-03-31 04:21:09 +02:00
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
'glyph' =>
|
|
|
|
"In page titles, show Tool names as unicode glyphs: \xE2\x9A\x99",
|
|
|
|
'text' =>
|
|
|
|
'In page titles, show Tool names as plain text: [Differential]',
|
|
|
|
)))
|
2012-01-16 20:08:54 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setLabel('Editor Link')
|
|
|
|
->setName($pref_editor)
|
2013-02-05 22:23:05 +01:00
|
|
|
->setCaption(hsprintf(
|
2012-01-16 20:08:54 +01:00
|
|
|
'Link to edit files in external editor. '.
|
2013-02-05 22:23:05 +01:00
|
|
|
'%%f is replaced by filename, %%l by line number, %%r by repository '.
|
|
|
|
'callsign, %%%% by literal %%. For documentation, see %s.',
|
|
|
|
$editor_doc_link))
|
2012-01-16 20:08:54 +01:00
|
|
|
->setValue($preferences->getPreference($pref_editor)))
|
2012-12-04 00:51:18 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel('Edit Multiple Files')
|
|
|
|
->setName($pref_multiedit)
|
|
|
|
->setOptions(array(
|
|
|
|
'' => 'Supported (paths separated by spaces)',
|
|
|
|
'disable' => 'Not Supported',
|
|
|
|
))
|
|
|
|
->setValue($preferences->getPreference($pref_multiedit)))
|
2011-03-31 04:21:09 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setLabel('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-18 05:32:28 +01:00
|
|
|
->setName($pref_monospaced)
|
2013-02-05 22:23:05 +01:00
|
|
|
->setCaption(hsprintf(
|
2012-08-13 21:37:26 +02:00
|
|
|
'Overrides default fonts in tools like Differential.<br />'.
|
2013-02-05 22:23:05 +01:00
|
|
|
'(Default: %s)',
|
|
|
|
$font_default))
|
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-18 05:32:28 +01:00
|
|
|
->setValue($preferences->getPreference($pref_monospaced)))
|
2011-03-31 04:21:09 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
2013-02-05 23:30:29 +01:00
|
|
|
->setValue(phutil_tag(
|
|
|
|
'pre',
|
|
|
|
array('class' => 'PhabricatorMonospaced'),
|
|
|
|
$example_string)))
|
2012-11-27 23:06:31 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormRadioButtonControl())
|
|
|
|
->setLabel('Monospaced Textareas')
|
|
|
|
->setName($pref_monospaced_textareas)
|
|
|
|
->setValue($pref_monospaced_textareas_value)
|
|
|
|
->addButton('enabled', 'Enabled',
|
|
|
|
'Show all textareas using the monospaced font defined above.')
|
|
|
|
->addButton('disabled', 'Disabled', null))
|
2013-01-20 02:40:48 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormRadioButtonControl())
|
|
|
|
->setLabel('Dark Console')
|
|
|
|
->setName($pref_dark_console)
|
|
|
|
->setValue($pref_dark_console_value ?
|
|
|
|
$pref_dark_console_value : 0)
|
|
|
|
->addButton(1, 'Enabled',
|
|
|
|
'Enabling and using the built-in debugging console.')
|
|
|
|
->addButton(0, 'Disabled', null))
|
2011-03-31 04:21:09 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue('Save Preferences'));
|
|
|
|
|
2013-01-20 02:40:48 +01:00
|
|
|
|
2011-03-31 04:21:09 +02:00
|
|
|
$panel = new AphrontPanelView();
|
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-18 05:32:28 +01:00
|
|
|
$panel->setHeader('Display Preferences');
|
2011-03-31 04:21:09 +02:00
|
|
|
$panel->appendChild($form);
|
2013-01-16 16:49:05 +01:00
|
|
|
$panel->setNoBackground();
|
2011-03-31 04:21:09 +02:00
|
|
|
|
|
|
|
$error_view = null;
|
|
|
|
if ($request->getStr('saved') === 'true') {
|
|
|
|
$error_view = id(new AphrontErrorView())
|
|
|
|
->setTitle('Preferences Saved')
|
|
|
|
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
|
|
|
|
->setErrors(array('Your preferences have been saved.'));
|
|
|
|
}
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
return array(
|
|
|
|
$error_view,
|
|
|
|
$panel,
|
|
|
|
);
|
2011-03-31 04:21:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|