From 53017dbfc275abd8c95a3d80c74afedb0bf188c0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 4 Jun 2013 10:10:51 -0400 Subject: [PATCH] Add the current language information to the response data. --- admin/index.php | 5 +++++ admin/templates/admin_header.tpl | 3 ++- includes/language.php | 35 ++++++++++++++------------------ 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/admin/index.php b/admin/index.php index b760dbf..fc06263 100644 --- a/admin/index.php +++ b/admin/index.php @@ -48,6 +48,11 @@ class FrontController $this->controller = $controller; } + public function OnInitialRequest(http\Request $request, http\Response $response) + { + $response->data['language'] = fetch_user_language(); + } + public function WillRouteRequest(http\Request $request, http\Response $response) { // TODO(port): Write a new cookie function. diff --git a/admin/templates/admin_header.tpl b/admin/templates/admin_header.tpl index e26b7d5..0a6f8c4 100644 --- a/admin/templates/admin_header.tpl +++ b/admin/templates/admin_header.tpl @@ -1,6 +1,7 @@ - + + Bugdar2 Admin Panel - {%= $title %} diff --git a/includes/language.php b/includes/language.php index e5a17c2..de1a546 100644 --- a/includes/language.php +++ b/includes/language.php @@ -28,33 +28,28 @@ define('L_INVALID_ID', T('That is an invalid ID.')); // determines the user's language function fetch_user_language() { - global $bugsys; - - if ($bugsys->userinfo['userid']) - { - $languageid = $bugsys->userinfo['languageid']; - $language = bugdar::$datastore['language']["$languageid"]; + $language = NULL; + if (Bugdar::$user['userid']) { + $languageid = Bugdar::$user['languageid']; + $language = Bugdar::$datastore['language']["$languageid"]; } - if (!$languageid AND is_array(bugdar::$datastore['language'])) - { - foreach (bugdar::$datastore['language'] AS $language) - { - if ($bugsys->options['defaultlanguage'] == $language['languageid']) - { + if (!$language && is_array(Bugdar::$datastore['language'])) { + foreach (Bugdar::$datastore['language'] AS $language) { + if (Bugdar::$options['defaultlanguage'] == $language['languageid']) { $languageid = $language['languageid']; - $language = bugdar::$datastore['language']["$languageid"]; + $language = Bugdar::$datastore['language']["$languageid"]; break; } } } - - $lang['id'] = $language['languageid']; - $lang['charset'] = $language['charset']; - $lang['direction'] = $language['direction']; - $lang['langcode'] = $language['langcode']; - - return $lang; + + return array( + 'id' => $language['languageid'], + 'charset' => $language['charset'], + 'direction' => $language['direction'], + 'langcode' => $language['langcode'], + ); } /** -- 2.43.5