summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/gallery_block.php1
-rw-r--r--modules/gallery/helpers/gallery_theme.php1
-rw-r--r--modules/gallery/helpers/locales.php34
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;
+ }
+}