mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
* detatch from User and Util and move to its own enum class * added definitions for all locales the 12340 client could in theory have * this is incompatble with the Intl extension * version bump and php requirement bump
37 lines
771 B
PHP
37 lines
771 B
PHP
<?php
|
|
|
|
if (!defined('AOWOW_REVISION'))
|
|
die('illegal access');
|
|
|
|
class AjaxLocale extends AjaxHandler
|
|
{
|
|
protected $_get = array(
|
|
'locale' => ['filter' => FILTER_CALLBACK, 'options' => 'Locale::tryFrom']
|
|
);
|
|
|
|
public function __construct(array $params)
|
|
{
|
|
parent::__construct($params);
|
|
|
|
// always this one
|
|
$this->handler = 'handleLocale';
|
|
$this->doRedirect = true;
|
|
}
|
|
|
|
/* responses
|
|
header()
|
|
*/
|
|
protected function handleLocale() : string
|
|
{
|
|
if ($this->_get['locale']?->validate())
|
|
{
|
|
User::$preferedLoc = $this->_get['locale'];
|
|
User::save(true);
|
|
}
|
|
|
|
return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '.';
|
|
}
|
|
}
|
|
|
|
?>
|