2012-03-15 04:47:17 +01:00
|
|
|
<?php
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
final class PhabricatorSettingsPanelSearchPreferences
|
|
|
|
extends PhabricatorSettingsPanel {
|
2012-03-15 04:47:17 +01:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
public function getPanelKey() {
|
|
|
|
return 'search';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPanelName() {
|
|
|
|
return pht('Search Preferences');
|
|
|
|
}
|
2012-03-15 04:47:17 +01:00
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
public function getPanelGroup() {
|
|
|
|
return pht('Application Settings');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest(AphrontRequest $request) {
|
2012-03-15 04:47:17 +01:00
|
|
|
$user = $request->getUser();
|
|
|
|
$preferences = $user->loadPreferences();
|
|
|
|
|
|
|
|
$pref_jump = PhabricatorUserPreferences::PREFERENCE_SEARCHBAR_JUMP;
|
|
|
|
$pref_shortcut = PhabricatorUserPreferences::PREFERENCE_SEARCH_SHORTCUT;
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$preferences->setPreference($pref_jump,
|
|
|
|
$request->getBool($pref_jump));
|
|
|
|
|
|
|
|
$preferences->setPreference($pref_shortcut,
|
|
|
|
$request->getBool($pref_shortcut));
|
|
|
|
|
|
|
|
$preferences->save();
|
|
|
|
return id(new AphrontRedirectResponse())
|
2012-08-13 21:37:26 +02:00
|
|
|
->setURI($this->getPanelURI('?saved=true'));
|
2012-03-15 04:47:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($user)
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormCheckboxControl())
|
|
|
|
->addCheckbox($pref_jump,
|
|
|
|
1,
|
2013-03-03 15:52:42 +01:00
|
|
|
pht('Enable jump nav functionality in all search boxes.'),
|
2012-03-15 04:47:17 +01:00
|
|
|
$preferences->getPreference($pref_jump, 1))
|
|
|
|
->addCheckbox($pref_shortcut,
|
|
|
|
1,
|
2013-03-03 15:52:42 +01:00
|
|
|
pht("Press '/' to focus the search input."),
|
2013-02-19 22:33:10 +01:00
|
|
|
$preferences->getPreference($pref_shortcut, 1)))
|
2012-03-15 04:47:17 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2013-03-03 15:52:42 +01:00
|
|
|
->setValue(pht('Save')));
|
2012-03-15 04:47:17 +01:00
|
|
|
|
|
|
|
$error_view = null;
|
|
|
|
if ($request->getStr('saved') === 'true') {
|
|
|
|
$error_view = id(new AphrontErrorView())
|
2013-03-03 15:52:42 +01:00
|
|
|
->setTitle(pht('Preferences Saved'))
|
2012-03-15 04:47:17 +01:00
|
|
|
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
|
2013-03-03 15:52:42 +01:00
|
|
|
->setErrors(array(pht('Your preferences have been saved.')));
|
2012-03-15 04:47:17 +01:00
|
|
|
}
|
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-26 20:53:11 +02:00
|
|
|
->setHeaderText(pht('Search Preferences'))
|
|
|
|
->setFormError($error_view)
|
|
|
|
->setForm($form);
|
|
|
|
|
2012-08-13 21:37:26 +02:00
|
|
|
return array(
|
2013-08-26 20:53:11 +02:00
|
|
|
$form_box,
|
2012-08-13 21:37:26 +02:00
|
|
|
);
|
2012-03-15 04:47:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|