diff options
Diffstat (limited to 'application/Utils.php')
-rw-r--r-- | application/Utils.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/application/Utils.php b/application/Utils.php index db046893..4c2d6701 100644 --- a/application/Utils.php +++ b/application/Utils.php | |||
@@ -1,4 +1,5 @@ | |||
1 | <?php | 1 | <?php |
2 | |||
2 | /** | 3 | /** |
3 | * Shaarli utilities | 4 | * Shaarli utilities |
4 | */ | 5 | */ |
@@ -102,7 +103,7 @@ function escape($input) | |||
102 | } | 103 | } |
103 | 104 | ||
104 | if (is_array($input)) { | 105 | if (is_array($input)) { |
105 | $out = array(); | 106 | $out = []; |
106 | foreach ($input as $key => $value) { | 107 | foreach ($input as $key => $value) { |
107 | $out[escape($key)] = escape($value); | 108 | $out[escape($key)] = escape($value); |
108 | } | 109 | } |
@@ -163,7 +164,7 @@ function checkDateFormat($format, $string) | |||
163 | * | 164 | * |
164 | * @return string $referer - final referer. | 165 | * @return string $referer - final referer. |
165 | */ | 166 | */ |
166 | function generateLocation($referer, $host, $loopTerms = array()) | 167 | function generateLocation($referer, $host, $loopTerms = []) |
167 | { | 168 | { |
168 | $finalReferer = './?'; | 169 | $finalReferer = './?'; |
169 | 170 | ||
@@ -196,7 +197,7 @@ function generateLocation($referer, $host, $loopTerms = array()) | |||
196 | function autoLocale($headerLocale) | 197 | function autoLocale($headerLocale) |
197 | { | 198 | { |
198 | // Default if browser does not send HTTP_ACCEPT_LANGUAGE | 199 | // Default if browser does not send HTTP_ACCEPT_LANGUAGE |
199 | $locales = array('en_US', 'en_US.utf8', 'en_US.UTF-8'); | 200 | $locales = ['en_US', 'en_US.utf8', 'en_US.UTF-8']; |
200 | if (! empty($headerLocale)) { | 201 | if (! empty($headerLocale)) { |
201 | if (preg_match_all('/([a-z]{2,3})[-_]?([a-z]{2})?,?/i', $headerLocale, $matches, PREG_SET_ORDER)) { | 202 | if (preg_match_all('/([a-z]{2,3})[-_]?([a-z]{2})?,?/i', $headerLocale, $matches, PREG_SET_ORDER)) { |
202 | $attempts = []; | 203 | $attempts = []; |
@@ -376,7 +377,7 @@ function return_bytes($val) | |||
376 | return $val; | 377 | return $val; |
377 | } | 378 | } |
378 | $val = trim($val); | 379 | $val = trim($val); |
379 | $last = strtolower($val[strlen($val)-1]); | 380 | $last = strtolower($val[strlen($val) - 1]); |
380 | $val = intval(substr($val, 0, -1)); | 381 | $val = intval(substr($val, 0, -1)); |
381 | switch ($last) { | 382 | switch ($last) { |
382 | case 'g': | 383 | case 'g': |
@@ -482,7 +483,9 @@ function alphabetical_sort(&$data, $reverse = false, $byKeys = false) | |||
482 | */ | 483 | */ |
483 | function t($text, $nText = '', $nb = 1, $domain = 'shaarli', $variables = [], $fixCase = false) | 484 | function t($text, $nText = '', $nb = 1, $domain = 'shaarli', $variables = [], $fixCase = false) |
484 | { | 485 | { |
485 | $postFunction = $fixCase ? 'ucfirst' : function ($input) { return $input; }; | 486 | $postFunction = $fixCase ? 'ucfirst' : function ($input) { |
487 | return $input; | ||
488 | }; | ||
486 | 489 | ||
487 | return $postFunction(dn__($domain, $text, $nText, $nb, $variables)); | 490 | return $postFunction(dn__($domain, $text, $nText, $nb, $variables)); |
488 | } | 491 | } |
@@ -494,4 +497,3 @@ function exception2text(Throwable $e): string | |||
494 | { | 497 | { |
495 | return $e->getMessage() . PHP_EOL . $e->getFile() . $e->getLine() . PHP_EOL . $e->getTraceAsString(); | 498 | return $e->getMessage() . PHP_EOL . $e->getFile() . $e->getLine() . PHP_EOL . $e->getTraceAsString(); |
496 | } | 499 | } |
497 | |||