diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-13 12:53:33 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-13 12:53:33 -0700 |
commit | 1f9d45861d68b95c4a4069e7d862a7076fae6ba4 (patch) | |
tree | aaff4eb798244d5c647f72f2c05ae9fab7c557ed /modules/gallery/helpers | |
parent | ab73a4092ff70a87ced1d7ffcfbe9bcee788f1f3 (diff) | |
parent | 1c313e9d2da84a9dd839ea6a4910cdf6809007fb (diff) |
Merge branch 'master' into talmdal_dev
Conflicts:
modules/gallery/helpers/gallery_block.php
modules/gallery/helpers/gallery_theme.php
modules/gallery/helpers/user.php
modules/user/helpers/user_event.php
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/gallery_block.php | 1 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_theme.php | 1 | ||||
-rw-r--r-- | modules/gallery/helpers/locales.php | 34 |
3 files changed, 33 insertions, 3 deletions
diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index f43d82c9..a4f4dae0 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -109,7 +109,6 @@ class gallery_block_Core { } break; } - return $block; } diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 54b35fb7..a342b4bd 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -55,7 +55,6 @@ class gallery_theme_Core { if ($theme->page_type != "login") { $view = new View("login.html"); $view->user = user::active(); - $view->writable = user::is_writable(); return $view->render(); } } diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php index faec7816..17286adf 100644 --- a/modules/gallery/helpers/locales.php +++ b/modules/gallery/helpers/locales.php @@ -236,4 +236,36 @@ class locales_Core { } return array(null, 0); } -}
\ No newline at end of file + + static function set_request_locale() { + // 1. Check the session specific preference (cookie) + $locale = self::cookie_locale(); + // 2. Check the user's preference + if (!$locale) { + $locale = user::active()->locale; + } + // 3. Check the browser's / OS' preference + if (!$locale) { + $locale = locales::locale_from_http_request(); + } + // If we have any preference, override the site's default locale + if ($locale) { + I18n::instance()->locale($locale); + } + } + + static function cookie_locale() { + $cookie_data = Input::instance()->cookie("g_locale"); + $locale = null; + if ($cookie_data) { + if (preg_match("/^([a-z]{2,3}(?:_[A-Z]{2})?)$/", trim($cookie_data), $matches)) { + $requested_locale = $matches[1]; + $installed_locales = locales::installed(); + if (isset($installed_locales[$requested_locale])) { + $locale = $requested_locale; + } + } + } + return $locale; + } +} |