diff options
author | vdigital <vdigital@piwigo.org> | 2009-06-30 21:16:24 +0000 |
---|---|---|
committer | vdigital <vdigital@piwigo.org> | 2009-06-30 21:16:24 +0000 |
commit | ccb0eaca47dafd34c99f3ba33653510b043302d7 (patch) | |
tree | 88c3e54eff8ea1e78b2b355d4118192e52ba5a5a /plugins/language_switch/language_switch.inc.php | |
parent | 91c7200b59367be519aad81e3d1724fd3bdc1c0d (diff) |
Bug 964 fixed and more
+ ?&lang=en_UK" => ?lang=en_UK"
+ =&lang=en_UK" => &lang=en_UK"
+ Works for any combinations of
$conf['question_mark_in_urls']
$conf['php_extension_in_urls']
=> BUT force a return to home in some cases.
+ Full technical code review
git-svn-id: http://piwigo.org/svn/branches/2.0@3477 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'plugins/language_switch/language_switch.inc.php')
-rw-r--r-- | plugins/language_switch/language_switch.inc.php | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/plugins/language_switch/language_switch.inc.php b/plugins/language_switch/language_switch.inc.php index c641572cd..833b19de6 100644 --- a/plugins/language_switch/language_switch.inc.php +++ b/plugins/language_switch/language_switch.inc.php @@ -60,21 +60,18 @@ class language_controler { global $user, $template, $conf; $available_lang = get_languages(); if ( isset($conf['no_flag_languages']) ) - $available_lang = array_diff_key($available_lang, array_flip($conf['no_flag_languages'])); - $url_starting = $_SERVER['REQUEST_URI']; - if ( isset( $_GET['lang']) ) { - $pos = stripos ( $url_starting , '&lang=' ); - if (is_numeric($pos) and $pos > 0) $url_starting = substr($url_starting, 0, $pos); - } - $pos = stripos($url_starting, script_basename()); - if (is_numeric($pos)) $url_starting = substr($url_starting, $pos); + $available_lang = + array_diff_key($available_lang, array_flip($conf['no_flag_languages'])); + $url_starting = get_query_string_diff(array('lang')); foreach ( $available_lang as $code => $displayname ) { $qlc = array ( - 'url' => add_url_params( $url_starting, array('lang'=> $code) ), + 'url' => str_replace(array('=&','?&'),array('&','?'), + add_url_params( $url_starting, array('lang'=> $code) )), 'alt' => ucwords( $displayname ), - 'img' => 'plugins/language_switch/icons/' . $code . '.jpg', + 'img' => get_root_url().'plugins/language_switch/icons/' . $code . '.jpg', ); - if ( $code !== $user['language'] and file_exists(PHPWG_ROOT_PATH.$qlc['img']) ) + if ( $code !== $user['language'] and + file_exists(dirname(__FILE__) . '/icons/' . $code . '.jpg') ) $lsw['flags'][$code] = $qlc ; else $lsw['Active'] = $qlc; } @@ -87,7 +84,6 @@ class language_controler { $flags = $template->parse('language_flags',true); $template->clear_assign('lang_switch'); $template->concat( 'PLUGIN_INDEX_ACTIONS', $flags); - // TODO : Try to cache $flags and $user['language'] in $_SESSION for performance } } /* {html_head} usage function */ |