X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FTemporal.php;h=0186b59dd6157985d89128fa22f125981e95f8ad;hb=b5ad8c3e153976cf3e63753597377f09852d98d7;hp=b6392d72fc043f9e853d3e6315390e743c96a100;hpb=6bc865ff4d68170c83a675cfc75cdc025a192b15;p=friendica.git diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index b6392d72fc..0186b59dd6 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -1,58 +1,73 @@ . + * */ namespace Friendica\Util; use DateTime; use DateTimeZone; -use Friendica\Core\Config; -use Friendica\Core\L10n; -use Friendica\Core\PConfig; use Friendica\Core\Renderer; use Friendica\Database\DBA; +use Friendica\DI; /** - * @brief Temporal class + * Temporal class */ class Temporal { /** - * @brief Two-level sort for timezones. + * Two-level sort for timezones. * * @param string $a * @param string $b + * * @return int */ - private static function timezoneCompareCallback($a, $b) + private static function timezoneCompareCallback(string $a, string $b): int { if (strstr($a, '/') && strstr($b, '/')) { - if (L10n::t($a) == L10n::t($b)) { + if (DI::l10n()->t($a) == DI::l10n()->t($b)) { return 0; } - return (L10n::t($a) < L10n::t($b)) ? -1 : 1; + return (DI::l10n()->t($a) < DI::l10n()->t($b)) ? -1 : 1; } if (strstr($a, '/')) { return -1; } elseif (strstr($b, '/')) { return 1; - } elseif (L10n::t($a) == L10n::t($b)) { + } elseif (DI::l10n()->t($a) == DI::l10n()->t($b)) { return 0; } - return (L10n::t($a) < L10n::t($b)) ? -1 : 1; + return (DI::l10n()->t($a) < DI::l10n()->t($b)) ? -1 : 1; } /** - * @brief Emit a timezone selector grouped (primarily) by continent + * Emit a timezone selector grouped (primarily) by continent * * @param string $current Timezone + * * @return string Parsed HTML output */ - public static function getTimezoneSelect($current = 'America/Los_Angeles') + public static function getTimezoneSelect(string $current = 'America/Los_Angeles'): string { $timezone_identifiers = DateTimeZone::listIdentifiers(); @@ -68,7 +83,7 @@ class Temporal $o .= ''; } $continent = $ex[0]; - $o .= ''; + $o .= ''; } if (count($ex) > 2) { $city = substr($value, strpos($value, '/') + 1); @@ -77,13 +92,13 @@ class Temporal } } else { $city = $ex[0]; - if ($continent != L10n::t('Miscellaneous')) { + if ($continent != DI::l10n()->t('Miscellaneous')) { $o .= ''; - $continent = L10n::t('Miscellaneous'); - $o .= ''; + $continent = DI::l10n()->t('Miscellaneous'); + $o .= ''; } } - $city = str_replace('_', ' ', L10n::t($city)); + $city = str_replace('_', ' ', DI::l10n()->t($city)); $selected = (($value == $current) ? " selected=\"selected\" " : ""); $o .= ""; } @@ -92,21 +107,22 @@ class Temporal } /** - * @brief Generating a Timezone selector + * Generating a Timezone selector * * Return a select using 'field_select_raw' template, with timezones * grouped (primarily) by continent * arguments follow convention as other field_* template array: * 'name', 'label', $value, 'help' * - * @param string $name Name of the selector - * @param string $label Label for the selector + * @param string $name Name of the selector + * @param string $label Label for the selector * @param string $current Timezone - * @param string $help Help text + * @param string $help Help text * * @return string Parsed HTML + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function getTimezoneField($name = 'timezone', $label = '', $current = 'America/Los_Angeles', $help = '') + public static function getTimezoneField(string $name = 'timezone', string $label = '', string $current = 'America/Los_Angeles', string $help = ''): string { $options = self::getTimezoneSelect($current); $options = str_replace('