From e7c6861507ea7ca01d3d4ed7b4189c030c8d07b3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 16:58:00 -0700 Subject: Don't send back the gzipped version if we're using zlib.output_compression in PHP, since that means that the stream is already compressed. Fixes ticket 555. --- modules/gallery/controllers/combined.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index 925d052d..9a790fdf 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -60,14 +60,15 @@ class Combined_Controller extends Controller { $cache = Cache::instance(); $use_gzip = function_exists("gzencode") && - (strpos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false); + stripos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false && + (int) ini_get("zlib.output_compression") === 0; + if ($use_gzip && $content = $cache->get("{$key}_gz")) { header("Content-Encoding: gzip"); } else { // Fall back to non-gzipped if we have to $content = $cache->get($key); } - if (empty($content)) { Kohana::show_404(); } -- cgit v1.2.3 From 6200955003844ba9a196db72f068650f8056acda Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 18:19:43 -0700 Subject: Don't bother making gzencoded version of combined CSS/JS if zlib.output_compression=On --- modules/gallery/libraries/Gallery_View.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 133066d7..4b85f2f0 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -104,7 +104,10 @@ class Gallery_View_Core extends View { } $cache->set($key, $contents, array($type), 30 * 84600); - if (function_exists("gzencode")) { + + $use_gzip = function_exists("gzencode") && + (int) ini_get("zlib.output_compression") === 0; + if ($use_gzip) { $cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP), array($type, "gzip"), 30 * 84600); } -- cgit v1.2.3 From d692002bcfca1cc630ddd0e55b693744ef7fa924 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 18:24:31 -0700 Subject: Don't show the combined CSS/JS elements if we didn't combine anything. Fixes ticket #554. --- modules/gallery/libraries/Gallery_View.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 4b85f2f0..31231ca6 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -73,6 +73,10 @@ class Gallery_View_Core extends View { protected function combine_files($files, $type) { $links = array(); + if (empty($files)) { + return; + } + // Include the url in the cache key so that if the Gallery moves, we don't use old cached // entries. $key = array(url::abs_file("")); -- cgit v1.2.3 From df22832a5b7e7c1962940becab1c90aaec3392f9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 18:35:06 -0700 Subject: Rename "locale" helper to "locales" to avoid conflicting with PHP 5.3. Fixes ticket #194 --- modules/gallery/controllers/admin_languages.php | 6 +- modules/gallery/helpers/l10n_client.php | 2 +- modules/gallery/helpers/locale.php | 124 ------------------------ modules/gallery/helpers/locales.php | 124 ++++++++++++++++++++++++ modules/gallery/libraries/MY_View.php | 2 +- modules/gallery/views/l10n_client.html.php | 2 +- modules/user/helpers/user.php | 2 +- 7 files changed, 131 insertions(+), 131 deletions(-) delete mode 100644 modules/gallery/helpers/locale.php create mode 100644 modules/gallery/helpers/locales.php (limited to 'modules') diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php index d1b805da..ae90ad07 100644 --- a/modules/gallery/controllers/admin_languages.php +++ b/modules/gallery/controllers/admin_languages.php @@ -36,7 +36,7 @@ class Admin_Languages_Controller extends Admin_Controller { $form = $this->_languages_form(); if ($form->validate()) { module::set_var("gallery", "default_locale", $form->choose_language->locale->value); - locale::update_installed($form->choose_language->installed_locales->value); + locales::update_installed($form->choose_language->installed_locales->value); message::success(t("Settings saved")); } url::redirect("admin/languages"); @@ -89,8 +89,8 @@ class Admin_Languages_Controller extends Admin_Controller { } private function _languages_form() { - $all_locales = locale::available(); - $installed_locales = locale::installed(); + $all_locales = locales::available(); + $installed_locales = locales::installed(); $form = new Forge("admin/languages/save", "", "post", array("id" => "gLanguageSettingsForm")); $group = $form->group("choose_language") ->label(t("Language settings")); diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 6d4da0eb..b576b4e1 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -74,7 +74,7 @@ class l10n_client_Core { $request->locales = array(); $request->messages = new stdClass(); - $locales = locale::installed(); + $locales = locales::installed(); foreach ($locales as $locale => $locale_data) { $request->locales[] = $locale; } diff --git a/modules/gallery/helpers/locale.php b/modules/gallery/helpers/locale.php deleted file mode 100644 index 41b78834..00000000 --- a/modules/gallery/helpers/locale.php +++ /dev/null @@ -1,124 +0,0 @@ -$code)) { - $installed[$code] = $available[$code]; - } - } - return $installed; - } - - static function update_installed($locales) { - // Ensure that the default is included... - $default = module::get_var("gallery", "default_locale"); - $locales = in_array($default, $locales) - ? $locales - : array_merge($locales, array($default)); - - module::set_var("gallery", "installed_locales", join("|", $locales)); - } - - // @todo Might want to add a localizable language name as well. - private static function _init_language_data() { - $l["af_ZA"] = "Afrikaans"; // Afrikaans - $l["ar_SA"] = "العربية"; // Arabic - $l["be_BY"] = "Беларускі"; // Belarusian - $l["bg_BG"] = "Български"; // Bulgarian - $l["ca_ES"] = "Catalan"; // Catalan - $l["cs_CZ"] = "Česky"; // Czech - $l["da_DK"] = "Dansk"; // Danish - $l["de_DE"] = "Deutsch"; // German - $l["el_GR"] = "Greek"; // Greek - $l["en_GB"] = "English (UK)"; // English (UK) - $l["en_US"] = "English (US)"; // English (US) - $l["es_AR"] = "Español (AR)"; // Spanish (AR) - $l["es_ES"] = "Español"; // Spanish (ES) - $l["es_MX"] = "Español (MX)"; // Spanish (MX) - $l["et_EE"] = "Eesti"; // Estonian - $l["eu_ES"] = "Euskara"; // Basque - $l["fa_IR"] = "فارسي"; // Farsi - $l["fi_FI"] = "Suomi"; // Finnish - $l["fr_FR"] = "Français"; // French - $l["ga_IE"] = "Gaeilge"; // Irish - $l["he_IL"] = "עברית"; // Hebrew - $l["hu_HU"] = "Magyar"; // Hungarian - $l["is_IS"] = "Icelandic"; // Icelandic - $l["it_IT"] = "Italiano"; // Italian - $l["ja_JP"] = "日本語"; // Japanese - $l["ko_KR"] = "한국말"; // Korean - $l["lt_LT"] = "Lietuvių"; // Lithuanian - $l["lv_LV"] = "Latviešu"; // Latvian - $l["nl_NL"] = "Nederlands"; // Dutch - $l["no_NO"] = "Norsk bokmål"; // Norwegian - $l["pl_PL"] = "Polski"; // Polish - $l["pt_BR"] = "Português Brasileiro"; // Portuguese (BR) - $l["pt_PT"] = "Português"; // Portuguese (PT) - $l["ro_RO"] = "Română"; // Romanian - $l["ru_RU"] = "Русский"; // Russian - $l["sk_SK"] = "Slovenčina"; // Slovak - $l["sl_SI"] = "Slovenščina"; // Slovenian - $l["sr_CS"] = "Srpski"; // Serbian - $l["sv_SE"] = "Svenska"; // Swedish - $l["tr_TR"] = "Türkçe"; // Turkish - $l["uk_UA"] = "Українська"; // Ukrainian - $l["vi_VN"] = "Tiếng Việt"; // Vietnamese - $l["zh_CN"] = "简体中文"; // Chinese (CN) - $l["zh_TW"] = "繁體中文"; // Chinese (TW) - asort($l, SORT_LOCALE_STRING); - self::$locales = $l; - } - - static function display_name($locale=null) { - if (empty(self::$locales)) { - self::_init_language_data(); - } - $locale or $locale = I18n::instance()->locale(); - - return self::$locales["$locale"]; - } - - static function is_rtl($locale=null) { - $locale or $locale = I18n::instance()->locale(); - list ($language, $territory) = explode('_', $locale . "_"); - return in_array($language, array("he", "fa", "ar")); - } -} \ No newline at end of file diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php new file mode 100644 index 00000000..3762b97b --- /dev/null +++ b/modules/gallery/helpers/locales.php @@ -0,0 +1,124 @@ +$code)) { + $installed[$code] = $available[$code]; + } + } + return $installed; + } + + static function update_installed($locales) { + // Ensure that the default is included... + $default = module::get_var("gallery", "default_locale"); + $locales = in_array($default, $locales) + ? $locales + : array_merge($locales, array($default)); + + module::set_var("gallery", "installed_locales", join("|", $locales)); + } + + // @todo Might want to add a localizable language name as well. + private static function _init_language_data() { + $l["af_ZA"] = "Afrikaans"; // Afrikaans + $l["ar_SA"] = "العربية"; // Arabic + $l["be_BY"] = "Беларускі"; // Belarusian + $l["bg_BG"] = "Български"; // Bulgarian + $l["ca_ES"] = "Catalan"; // Catalan + $l["cs_CZ"] = "Česky"; // Czech + $l["da_DK"] = "Dansk"; // Danish + $l["de_DE"] = "Deutsch"; // German + $l["el_GR"] = "Greek"; // Greek + $l["en_GB"] = "English (UK)"; // English (UK) + $l["en_US"] = "English (US)"; // English (US) + $l["es_AR"] = "Español (AR)"; // Spanish (AR) + $l["es_ES"] = "Español"; // Spanish (ES) + $l["es_MX"] = "Español (MX)"; // Spanish (MX) + $l["et_EE"] = "Eesti"; // Estonian + $l["eu_ES"] = "Euskara"; // Basque + $l["fa_IR"] = "فارسي"; // Farsi + $l["fi_FI"] = "Suomi"; // Finnish + $l["fr_FR"] = "Français"; // French + $l["ga_IE"] = "Gaeilge"; // Irish + $l["he_IL"] = "עברית"; // Hebrew + $l["hu_HU"] = "Magyar"; // Hungarian + $l["is_IS"] = "Icelandic"; // Icelandic + $l["it_IT"] = "Italiano"; // Italian + $l["ja_JP"] = "日本語"; // Japanese + $l["ko_KR"] = "한국말"; // Korean + $l["lt_LT"] = "Lietuvių"; // Lithuanian + $l["lv_LV"] = "Latviešu"; // Latvian + $l["nl_NL"] = "Nederlands"; // Dutch + $l["no_NO"] = "Norsk bokmål"; // Norwegian + $l["pl_PL"] = "Polski"; // Polish + $l["pt_BR"] = "Português Brasileiro"; // Portuguese (BR) + $l["pt_PT"] = "Português"; // Portuguese (PT) + $l["ro_RO"] = "Română"; // Romanian + $l["ru_RU"] = "Русский"; // Russian + $l["sk_SK"] = "Slovenčina"; // Slovak + $l["sl_SI"] = "Slovenščina"; // Slovenian + $l["sr_CS"] = "Srpski"; // Serbian + $l["sv_SE"] = "Svenska"; // Swedish + $l["tr_TR"] = "Türkçe"; // Turkish + $l["uk_UA"] = "Українська"; // Ukrainian + $l["vi_VN"] = "Tiếng Việt"; // Vietnamese + $l["zh_CN"] = "简体中文"; // Chinese (CN) + $l["zh_TW"] = "繁體中文"; // Chinese (TW) + asort($l, SORT_LOCALE_STRING); + self::$locales = $l; + } + + static function display_name($locale=null) { + if (empty(self::$locales)) { + self::_init_language_data(); + } + $locale or $locale = I18n::instance()->locale(); + + return self::$locales["$locale"]; + } + + static function is_rtl($locale=null) { + $locale or $locale = I18n::instance()->locale(); + list ($language, $territory) = explode('_', $locale . "_"); + return in_array($language, array("he", "fa", "ar")); + } +} \ No newline at end of file diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php index 96dcc71b..84ee0892 100644 --- a/modules/gallery/libraries/MY_View.php +++ b/modules/gallery/libraries/MY_View.php @@ -45,7 +45,7 @@ class View extends View_Core { } public function body_attributes() { - if (locale::is_rtl()) { + if (locales::is_rtl()) { return 'class="rtl"'; } return ''; diff --git a/modules/gallery/views/l10n_client.html.php b/modules/gallery/views/l10n_client.html.php index c0cbbfa2..c73719ca 100644 --- a/modules/gallery/views/l10n_client.html.php +++ b/modules/gallery/views/l10n_client.html.php @@ -9,7 +9,7 @@

locale::display_name())) ?>

+ array("language" => locales::display_name())) ?>
    diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php index 4105d745..53e9052c 100644 --- a/modules/user/helpers/user.php +++ b/modules/user/helpers/user.php @@ -79,7 +79,7 @@ class user_Core { } private static function _add_locale_dropdown(&$form, $user=null) { - $locales = locale::installed(); + $locales = locales::installed(); if (count($locales) > 1) { // Put "none" at the first position in the array $locales = array_merge(array("" => t("« none »")), $locales); -- cgit v1.2.3