Differential D9990 Diff 24008 src/applications/settings/panel/PhabricatorSettingsPanelEditingPreferences.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorSettingsPanelEditingPreferences.php
- This file was added.
| <?php | |||||
| final class PhabricatorSettingsPanelEditingPreferences | |||||
| extends PhabricatorSettingsPanel { | |||||
| public function getPanelKey() { | |||||
| return 'editing'; | |||||
| } | |||||
| public function getPanelName() { | |||||
| return pht('Editing Preferences'); | |||||
| } | |||||
| public function getPanelGroup() { | |||||
| return pht('Application Settings'); | |||||
| } | |||||
| public function processRequest(AphrontRequest $request) { | |||||
| $user = $request->getUser(); | |||||
| $preferences = $user->loadPreferences(); | |||||
| $pref_tab_indent = PhabricatorUserPreferences::PREFERENCE_TAB_INSERTS_INDENT; | |||||
| if ($request->isFormPost()) { | |||||
| $tab_indent = $request->getInt($pref_tab_indent); | |||||
| if ($tab_indent && !$preferences->getPreference($pref_tab_indent)) { | |||||
| $preferences->setPreference( | |||||
| $pref_tab_indent, | |||||
| false); | |||||
| } | |||||
| $preferences->setPreference($pref_tab_indent, $tab_indent); | |||||
| $preferences->save(); | |||||
| return id(new AphrontRedirectResponse()) | |||||
| ->setURI($this->getPanelURI('?saved=true')); | |||||
| } | |||||
| $form = id(new AphrontFormView()) | |||||
| ->setUser($user) | |||||
| ->appendChild( | |||||
| id(new AphrontFormSelectControl()) | |||||
| ->setLabel(pht('Tab key inserts indent')) | |||||
| ->setName($pref_tab_indent) | |||||
| ->setValue($preferences->getPreference($pref_tab_indent)) | |||||
| ->setOptions( | |||||
| array( | |||||
| 0 => pht('Disabled'), | |||||
| 1 => pht('Enabled'), | |||||
| )) | |||||
| ->setCaption( | |||||
| pht('When editing text using remarkup text areas, you can press'. | |||||
| 'tab to insert an indent character.'))) | |||||
| ->appendChild( | |||||
| id(new AphrontFormSubmitControl()) | |||||
| ->setValue(pht('Save Preferences'))); | |||||
| $form_box = id(new PHUIObjectBoxView()) | |||||
| ->setHeaderText(pht('Editing Preferences')) | |||||
| ->setFormSaved($request->getBool('saved')) | |||||
| ->setForm($form); | |||||
| return array( | |||||
| $form_box, | |||||
| ); | |||||
| } | |||||
| } | |||||