Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorSettingsPanelAccount.php
Show All 33 Lines | if ($request->isFormPost()) { | ||||
$sex = $request->getStr('sex'); | $sex = $request->getStr('sex'); | ||||
$sexes = array(PhutilPerson::SEX_MALE, PhutilPerson::SEX_FEMALE); | $sexes = array(PhutilPerson::SEX_MALE, PhutilPerson::SEX_FEMALE); | ||||
if (in_array($sex, $sexes)) { | if (in_array($sex, $sexes)) { | ||||
$user->setSex($sex); | $user->setSex($sex); | ||||
} else { | } else { | ||||
$user->setSex(null); | $user->setSex(null); | ||||
} | } | ||||
// Checked in runtime. | |||||
$user->setTranslation($request->getStr('translation')); | |||||
$preferences->setPreference($pref_time, $request->getStr($pref_time)); | $preferences->setPreference($pref_time, $request->getStr($pref_time)); | ||||
if (!$errors) { | if (!$errors) { | ||||
$preferences->save(); | $preferences->save(); | ||||
$user->save(); | $user->save(); | ||||
return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
->setURI($this->getPanelURI('?saved=true')); | ->setURI($this->getPanelURI('?saved=true')); | ||||
} | } | ||||
} | } | ||||
$timezone_ids = DateTimeZone::listIdentifiers(); | $timezone_ids = DateTimeZone::listIdentifiers(); | ||||
$timezone_id_map = array_fuse($timezone_ids); | $timezone_id_map = array_fuse($timezone_ids); | ||||
$label_unknown = pht('%s updated their profile', $username); | $label_unknown = pht('%s updated their profile', $username); | ||||
$label_her = pht('%s updated her profile', $username); | $label_her = pht('%s updated her profile', $username); | ||||
$label_his = pht('%s updated his profile', $username); | $label_his = pht('%s updated his profile', $username); | ||||
$sexes = array( | $sexes = array( | ||||
PhutilPerson::SEX_UNKNOWN => $label_unknown, | PhutilPerson::SEX_UNKNOWN => $label_unknown, | ||||
PhutilPerson::SEX_MALE => $label_his, | PhutilPerson::SEX_MALE => $label_his, | ||||
PhutilPerson::SEX_FEMALE => $label_her, | PhutilPerson::SEX_FEMALE => $label_her, | ||||
); | ); | ||||
$translations = array(); | |||||
$symbols = id(new PhutilSymbolLoader()) | |||||
->setType('class') | |||||
->setAncestorClass('PhabricatorTranslation') | |||||
->setConcreteOnly(true) | |||||
->selectAndLoadSymbols(); | |||||
foreach ($symbols as $symbol) { | |||||
$class = $symbol['name']; | |||||
$translations[$class] = newv($class, array())->getName(); | |||||
} | |||||
asort($translations); | |||||
$default = PhabricatorEnv::newObjectFromConfig('translation.provider'); | |||||
$translations = array( | |||||
'' => pht('Server Default (%s)', $default->getName()), | |||||
) + $translations; | |||||
$form = new AphrontFormView(); | $form = new AphrontFormView(); | ||||
$form | $form | ||||
->setUser($user) | ->setUser($user) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSelectControl()) | id(new AphrontFormSelectControl()) | ||||
->setLabel(pht('Timezone')) | ->setLabel(pht('Timezone')) | ||||
->setName('timezone') | ->setName('timezone') | ||||
->setOptions($timezone_id_map) | ->setOptions($timezone_id_map) | ||||
->setValue($user->getTimezoneIdentifier())) | ->setValue($user->getTimezoneIdentifier())) | ||||
->appendRemarkupInstructions(pht("**Choose the pronoun you prefer:**")) | ->appendRemarkupInstructions(pht("**Choose the pronoun you prefer:**")) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSelectControl()) | id(new AphrontFormSelectControl()) | ||||
->setOptions($sexes) | ->setOptions($sexes) | ||||
->setLabel(pht('Pronoun')) | ->setLabel(pht('Pronoun')) | ||||
->setName('sex') | ->setName('sex') | ||||
->setValue($user->getSex())) | ->setValue($user->getSex())) | ||||
->appendChild( | |||||
id(new AphrontFormSelectControl()) | |||||
->setOptions($translations) | |||||
->setLabel(pht('Translation')) | |||||
->setName('translation') | |||||
->setValue($user->getTranslation())) | |||||
->appendRemarkupInstructions( | ->appendRemarkupInstructions( | ||||
pht( | pht( | ||||
"**Custom Date and Time Formats**\n\n". | "**Custom Date and Time Formats**\n\n". | ||||
"You can specify custom formats which will be used when ". | "You can specify custom formats which will be used when ". | ||||
"rendering dates and times of day. Examples:\n\n". | "rendering dates and times of day. Examples:\n\n". | ||||
"| Format | Example | Notes |\n". | "| Format | Example | Notes |\n". | ||||
"| ------ | -------- | ----- |\n". | "| ------ | -------- | ----- |\n". | ||||
"| `g:i A` | 2:34 PM | Default 12-hour time. |\n". | "| `g:i A` | 2:34 PM | Default 12-hour time. |\n". | ||||
Show All 27 Lines |