aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/language_switch
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--plugins/language_switch/flags.tpl10
-rw-r--r--plugins/language_switch/language_switch.inc.php20
-rw-r--r--plugins/language_switch/main.inc.php7
3 files changed, 17 insertions, 20 deletions
diff --git a/plugins/language_switch/flags.tpl b/plugins/language_switch/flags.tpl
index 7a30553ee..06d438550 100644
--- a/plugins/language_switch/flags.tpl
+++ b/plugins/language_switch/flags.tpl
@@ -17,7 +17,7 @@
<ul class="flag-pan">
{foreach from=$lang_switch.flags key=code item=flag name=f}
<li>
- <a rel="nofollow" href="{$flag.url}">
+ <a rel="nofollow" href="{$SCRIPT_NAME}{$flag.url}">
<img class="flags" src="{$flag.img}" alt="{$flag.alt}" title="{$flag.alt}"/>
</a>
</li>
@@ -35,14 +35,14 @@
</li>
{html_head}
{if $themeconf.template=='yoga' and $themeconf.theme=='Sylvia'}
-<link rel="stylesheet" type="text/css" href="{$LANGUAGE_SWITCH_PATH|@cat:'language_switch.css'}">
+<link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$LANGUAGE_SWITCH_PATH|@cat:'language_switch.css'}">
{else}
-<link rel="stylesheet" type="text/css" href="{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-default.css'}">
+<link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-default.css'}">
{/if}
{if Componant_exists($LANGUAGE_SWITCH_PATH, 'language_switch-local.css')}
-<link rel="stylesheet" type="text/css" href="{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-local.css'}">
+<link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-local.css'}">
{/if}
<!--[if lte IE 6]>
-<link rel="stylesheet" type="text/css" href="{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-ie6.css'}">
+<link rel="stylesheet" type="text/css" href="{$ROOT_URL}{$LANGUAGE_SWITCH_PATH|@cat:'language_switch-ie6.css'}">
<![endif]-->
{/html_head} \ No newline at end of file
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('=&amp;','?&amp;'),array('&amp;','?'),
+ 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 */
diff --git a/plugins/language_switch/main.inc.php b/plugins/language_switch/main.inc.php
index d81ec050e..c7bd1118c 100644
--- a/plugins/language_switch/main.inc.php
+++ b/plugins/language_switch/main.inc.php
@@ -23,7 +23,7 @@
/*
Plugin Name: Language Switch
-Version: 2.0.2a
+Version: 2.0.2b
Description: Switch to another language from flags on your gallery home page.
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=123
Author: Piwigo team
@@ -31,6 +31,7 @@ Author URI: http://piwigo.org
*/
include_once(PHPWG_PLUGINS_PATH.'language_switch/language_switch.inc.php');
-add_event_handler('loading_lang', 'language_controler::_switch', 5 );
-add_event_handler('loc_end_index', 'language_controler::_flags', 95 );
+$language_controler = new language_controler();
+add_event_handler('loading_lang', array(&$language_controler, '_switch'), 5 );
+add_event_handler('loc_end_index', array(&$language_controler, '_flags'), 95 );
?> \ No newline at end of file