diff --git a/src/library/FOSSBilling/i18n.php b/src/library/FOSSBilling/i18n.php index 60ed44cf5..6705dd68d 100644 --- a/src/library/FOSSBilling/i18n.php +++ b/src/library/FOSSBilling/i18n.php @@ -180,14 +180,10 @@ class i18n { if ($disabled) { // Only get a list of the disabled locales - $locales = array_filter(glob(PATH_LANGS . DIRECTORY_SEPARATOR . '*'), function ($dir) { - return is_dir($dir) && file_exists($dir . DIRECTORY_SEPARATOR . '.disabled'); - }); + $locales = array_filter(glob(PATH_LANGS . DIRECTORY_SEPARATOR . '*'), fn($dir) => is_dir($dir) && file_exists($dir . DIRECTORY_SEPARATOR . '.disabled')); } else { // Only get a list of the enabled locales - $locales = array_filter(glob(PATH_LANGS . DIRECTORY_SEPARATOR . '*'), function ($dir) { - return is_dir($dir) && !file_exists($dir . DIRECTORY_SEPARATOR . '.disabled'); - }); + $locales = array_filter(glob(PATH_LANGS . DIRECTORY_SEPARATOR . '*'), fn($dir) => is_dir($dir) && !file_exists($dir . DIRECTORY_SEPARATOR . '.disabled')); } $locales = array_map('basename', $locales); // get only the directory name diff --git a/src/modules/Extension/Api/Admin.php b/src/modules/Extension/Api/Admin.php index 4d812eec3..2240b855f 100644 --- a/src/modules/Extension/Api/Admin.php +++ b/src/modules/Extension/Api/Admin.php @@ -71,15 +71,16 @@ class Admin extends \Api_Abstract public function languages(array $data): array { $data['disabled'] ??= false; + return \FOSSBilling\i18n::getLocales(true, $data['disabled']); } /** * Toggles a given locale to either enable or disable it depending on it's current status. - * + * * @param array $data The post data sent to the API. Should contain a key named `locale_id` which is set to the locale ID to change. (`en_US` for example) - * - * @throws \Box_Exception + * + * @throws \Box_Exception */ public function toggle_language(array $data): bool { @@ -88,11 +89,13 @@ class Admin extends \Api_Abstract ]; $this->di['validator']->checkRequiredParamsForArray($required, $data); + return \FOSSBilling\i18n::toggleLocale($data['locale_id']); } /** * Returns how complete a given locale is. + * * @param array $data $data The post data sent to the API. Should contain a key named `locale_id` which is set to the locale ID to get the completion percentage for. (`en_US` for example) */ public function locale_completion(array $data): int @@ -102,6 +105,7 @@ class Admin extends \Api_Abstract ]; $this->di['validator']->checkRequiredParamsForArray($required, $data); + return \FOSSBilling\i18n::getLocaleCompletionPercent($data['locale_id']); } diff --git a/src/modules/System/Service.php b/src/modules/System/Service.php index 2bfe43390..6d76c0b4e 100644 --- a/src/modules/System/Service.php +++ b/src/modules/System/Service.php @@ -10,10 +10,10 @@ namespace Box\Mod\System; +use FOSSBilling\Environment; use Pimple\Container; use Symfony\Component\HttpClient\HttpClient; use Symfony\Contracts\Cache\ItemInterface; -use FOSSBilling\Environment; class Service { @@ -221,7 +221,7 @@ class Service { $msgs = []; - // Check if there's an update available + // Check if there's an update available try { $updater = $this->di['updater']; if ($updater->isUpdateAvailable()) { @@ -236,16 +236,15 @@ class Service error_log($e->getMessage()); } - $last_exec = $this->getParamValue('last_cron_exec'); $disableAutoCron = $this->di['config']['disable_auto_cron'] ?? false; - /** + /* * Here we check if cron has been run at all or within a recent timeframe. * No matter what, a message will be displayed within the dashboard and by default cron will also be performed to ensure functionality, however this can be disabled. * Results are cached so even if `getMessages` is called multiple times it will still display correctly & so it won't go away before it's noticed. */ - if ((Environment::isProduction())) { + if (Environment::isProduction()) { $cronService = $this->di['mod_service']('cron'); $result = $this->di['cache']->get('cron_issue', function (ItemInterface $item) use ($cronService, $last_exec, $disableAutoCron) {