Configurable language cache interval, sort languages by their native name
This commit is contained in:
parent
84453234b4
commit
f45e0a03d8
|
@ -19,6 +19,7 @@ INSERT INTO `DBPREFIXconfig` (`identifier`, `type`, `value`, `user_editable`) VA
|
||||||
('loginpokeclient', 'BOOL', 'true', 1),
|
('loginpokeclient', 'BOOL', 'true', 1),
|
||||||
('cache_logincode', 'INT', '120', 1),
|
('cache_logincode', 'INT', '120', 1),
|
||||||
('cache_adminstatus', 'INT', '60', 1),
|
('cache_adminstatus', 'INT', '60', 1),
|
||||||
|
('cache_languages', 'INT', '300', 1),
|
||||||
('adminstatus_groups', 'JSON', '[]', 1),
|
('adminstatus_groups', 'JSON', '[]', 1),
|
||||||
('adminstatus_mode', 'INT', '2', 1),
|
('adminstatus_mode', 'INT', '2', 1),
|
||||||
('adminstatus_enabled', 'BOOL', 'true', 1),
|
('adminstatus_enabled', 'BOOL', 'true', 1),
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Wruczek\TSWebsite\Utils\Language;
|
namespace Wruczek\TSWebsite\Utils\Language;
|
||||||
|
|
||||||
use Wruczek\PhpFileCache\PhpFileCache;
|
use Wruczek\PhpFileCache\PhpFileCache;
|
||||||
|
use Wruczek\TSWebsite\Config;
|
||||||
use Wruczek\TSWebsite\Utils\DatabaseUtils;
|
use Wruczek\TSWebsite\Utils\DatabaseUtils;
|
||||||
use Wruczek\TSWebsite\Utils\SingletonTait;
|
use Wruczek\TSWebsite\Utils\SingletonTait;
|
||||||
|
|
||||||
|
@ -147,10 +148,18 @@ class LanguageUtils {
|
||||||
$langs[] = new Language($langid, $englishname, $nativename, $langcode, $isdefault, $languageItems);
|
$langs[] = new Language($langid, $englishname, $nativename, $langcode, $isdefault, $languageItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uasort($langs, function ($a, $b) {
|
||||||
|
if ($a->getLanguageId() === $b->getLanguageId()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return strnatcmp($a->getLanguageNameNative(), $b->getLanguageNameNative());
|
||||||
|
});
|
||||||
|
|
||||||
$this->languages = $langs;
|
$this->languages = $langs;
|
||||||
|
|
||||||
if($updateCache)
|
if($updateCache)
|
||||||
$this->cache->store("languages", $langs, 300);
|
$this->cache->store("languages", $langs, Config::get("cache_languages", 300));
|
||||||
|
|
||||||
return $langs;
|
return $langs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue