1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 03:12:41 +01:00
phorge-phorge/src/applications/system/controller/PhabricatorSystemSelectEncodingController.php

56 lines
1.6 KiB
PHP
Raw Normal View History

<?php
final class PhabricatorSystemSelectEncodingController
extends PhabricatorController {
public function shouldRequireLogin() {
return false;
}
public function processRequest() {
$request = $this->getRequest();
if (!function_exists('mb_list_encodings')) {
return $this->newDialog()
->setTitle(pht('No Encoding Support'))
->appendParagraph(
pht(
'This system does not have the "mbstring" extension installed, '.
'so character encodings are not supported. Install "mbstring" to '.
'enable support.'))
->addCancelButton('/');
}
if ($request->isFormPost()) {
$result = array('encoding' => $request->getStr('encoding'));
return id(new AphrontAjaxResponse())->setContent($result);
}
$encodings = mb_list_encodings();
$encodings = array_fuse($encodings);
asort($encodings);
unset($encodings['pass']);
unset($encodings['auto']);
$encodings = array(
'' => pht('(Use Default)'),
) + $encodings;
$form = id(new AphrontFormView())
->setUser($this->getRequest()->getUser())
->appendRemarkupInstructions(pht('Choose a text encoding to use.'))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Encoding'))
->setName('encoding')
->setValue($request->getStr('encoding'))
->setOptions($encodings));
return $this->newDialog()
->setTitle(pht('Select Character Encoding'))
->appendChild($form->buildLayoutView())
->addSubmitButton(pht('Choose Encoding'))
->addCancelButton('/');
}
}