From 75eff172d58ac5b4f017434743f8f8d5d8fd1554 Mon Sep 17 00:00:00 2001 From: anuko Date: Sat, 13 Jan 2018 19:04:47 +0000 Subject: [PATCH] A bit of refactoring with getting rid of some GLOBALS. --- WEB-INF/lib/DateAndTime.class.php | 23 +++++++++++------------ WEB-INF/templates/footer.tpl | 2 +- initialize.php | 2 -- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/WEB-INF/lib/DateAndTime.class.php b/WEB-INF/lib/DateAndTime.class.php index 4752e99f..20f27426 100644 --- a/WEB-INF/lib/DateAndTime.class.php +++ b/WEB-INF/lib/DateAndTime.class.php @@ -321,18 +321,17 @@ class DateAndTime { */ function preprocessFormatString($format) { global $i18n; - if (isset($GLOBALS['i18n'])) { - // replace locale-dependent strings - $format = str_replace('%a', mb_substr($i18n->getWeekDayName($this->mDay), 0, 3, 'utf-8'), $format); - $format = str_replace('%A', $i18n->getWeekDayName($this->mDay), $format); - $abbrev_month = mb_substr($i18n->monthNames[$this->mMonth], 0, 3, 'utf-8'); - $format = str_replace('%b', $abbrev_month, $format); - $format = str_replace('%h', $abbrev_month, $format); - $format = str_replace('%z', date('O'), $format); - $format = str_replace('%Z', date('O'), $format); // format as 'O' for consistency with JS strftime - if (strpos($format, '%c') !== false) { - $format = str_replace('%c', $this->preprocessFormatString('%a %d %b %Y %T %Z'), $format); - } + + // replace locale-dependent strings + $format = str_replace('%a', mb_substr($i18n->getWeekDayName($this->mDay), 0, 3, 'utf-8'), $format); + $format = str_replace('%A', $i18n->getWeekDayName($this->mDay), $format); + $abbrev_month = mb_substr($i18n->monthNames[$this->mMonth], 0, 3, 'utf-8'); + $format = str_replace('%b', $abbrev_month, $format); + $format = str_replace('%h', $abbrev_month, $format); + $format = str_replace('%z', date('O'), $format); + $format = str_replace('%Z', date('O'), $format); // format as 'O' for consistency with JS strftime + if (strpos($format, '%c') !== false) { + $format = str_replace('%c', $this->preprocessFormatString('%a %d %b %Y %T %Z'), $format); } return $format; } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 3d16e583..d0675018 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.13.15.3744 | Copyright © Anuko | +  Anuko Time Tracker 1.13.15.3745 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/initialize.php b/initialize.php index c9a42458..29425c07 100644 --- a/initialize.php +++ b/initialize.php @@ -199,8 +199,6 @@ if (!$lang) { $i18n->load($lang); $GLOBALS['I18N'] = &$i18n; -$GLOBALS['USER'] = &$user; - // Assign things for smarty to use in template files. $smarty->assign('i18n', $i18n->keys); $smarty->assign('err', $err); -- 2.20.1