1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-23 02:38:48 +02:00
phorge-phorge/src/applications/settings/panel/PhabricatorSettingsPanelDiffPreferences.php
Chad Little 9be7a948f9 Move PHUIFormBoxView to PHUIObjectBoxView
Summary: I'd like to reuse this for other content areas, renaming for now. This might be weird to keep setForm, but I can fix that later if we need.

Test Plan: reload a few forms in maniphest, projects, differential

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: Korvin, aran

Differential Revision: https://secure.phabricator.com/D7120
2013-09-25 11:23:29 -07:00

79 lines
2.2 KiB
PHP

<?php
final class PhabricatorSettingsPanelDiffPreferences
extends PhabricatorSettingsPanel {
public function getPanelKey() {
return 'diff';
}
public function getPanelName() {
return pht('Diff Preferences');
}
public function getPanelGroup() {
return pht('Application Settings');
}
public function processRequest(AphrontRequest $request) {
$user = $request->getUser();
$preferences = $user->loadPreferences();
$pref_filetree = PhabricatorUserPreferences::PREFERENCE_DIFF_FILETREE;
if ($request->isFormPost()) {
$filetree = $request->getInt($pref_filetree);
if ($filetree && !$preferences->getPreference($pref_filetree)) {
$preferences->setPreference(
PhabricatorUserPreferences::PREFERENCE_NAV_COLLAPSED,
false);
}
$preferences->setPreference($pref_filetree, $filetree);
$preferences->save();
return id(new AphrontRedirectResponse())
->setURI($this->getPanelURI('?saved=true'));
}
$form = id(new AphrontFormView())
->setUser($user)
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Show Filetree'))
->setName($pref_filetree)
->setValue($preferences->getPreference($pref_filetree))
->setOptions(
array(
0 => pht('Disable Filetree'),
1 => pht('Enable Filetree'),
))
->setCaption(
pht("When looking at a revision or commit, enable a sidebar ".
"showing affected files. You can press %s to show or hide ".
"the sidebar.",
phutil_tag('tt', array(), 'f'))))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Save Preferences')));
$error_view = null;
if ($request->getBool('saved')) {
$error_view = id(new AphrontErrorView())
->setTitle(pht('Preferences Saved'))
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
->setErrors(array(pht('Your preferences have been saved.')));
}
$form_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Diff Preferences'))
->setFormError($error_view)
->setForm($form);
return array(
$form_box,
);
}
}