aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/language_switch
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/language_switch')
-rw-r--r--plugins/language_switch/default.css14
-rw-r--r--plugins/language_switch/flags.tpl76
-rw-r--r--plugins/language_switch/language_switch-Sylvia.css7
-rw-r--r--plugins/language_switch/language_switch-default.css19
-rw-r--r--plugins/language_switch/language_switch-ie6.css6
-rw-r--r--plugins/language_switch/language_switch.css7
-rw-r--r--plugins/language_switch/language_switch.inc.php176
-rw-r--r--plugins/language_switch/main.inc.php15
-rw-r--r--plugins/language_switch/style.css14
9 files changed, 152 insertions, 182 deletions
diff --git a/plugins/language_switch/default.css b/plugins/language_switch/default.css
new file mode 100644
index 000000000..a73c67366
--- /dev/null
+++ b/plugins/language_switch/default.css
@@ -0,0 +1,14 @@
+#languageSwitchBox {
+ padding: 0.5em 5px;
+ border-radius: 4px;
+ z-index: 100;
+ text-align:left;
+ display: none;
+ position: absolute;
+ left: 0; top: 0; /*left, right set through js*/
+}
+
+#languageSwitchBox .switchBoxTitle {
+ padding-bottom:5px;
+ margin-bottom:5px;
+} \ No newline at end of file
diff --git a/plugins/language_switch/flags.tpl b/plugins/language_switch/flags.tpl
index 3add5c1a2..e77e89668 100644
--- a/plugins/language_switch/flags.tpl
+++ b/plugins/language_switch/flags.tpl
@@ -1,50 +1,36 @@
-</ul>
-<ul class="categoryActions">
-<li class="menuf">
- <div>
- <ul>
- <li>
- <a rel="nofollow" href="#" class="activeFlag">
- <img class="flags" src="{$lang_switch.Active.img}" alt="{$lang_switch.Active.alt}" title="{$lang_switch.Active.alt}"/>
- </a>
-<!--[if lte IE 6]>
- <a rel="nofollow" href="#">
- <img class="flags" src="{$lang_switch.Active.img}" alt="{$lang_switch.Active.alt}" title="{$lang_switch.Active.alt}"/>
- <table>
- <tr>
- <td>
-<![endif]-->
- <ul class="flag-pan">
- <li class="languageSwitchBoxTitle">{'Language'|@translate}</li>
+<li>{strip}<a id="languageSwitchLink" title="{'Language'|@translate}" class="pwg-state-default pwg-button" rel="nofollow">
+ <span class="pwg-icon" style="background:url('{$lang_switch.Active.img}') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">{'Language'|@translate}</span>
+</a>
+<div id="languageSwitchBox" class="switchBox">
+ <div class="switchBoxTitle">{'Language'|@translate}</div>
+ {foreach from=$lang_switch.flags item=flag name=f}
+ <a rel="nofollow" href="{$flag.url}"><img class="flags" src="{$flag.img}" alt="{$flag.alt}"> {$flag.title}</a>
+ {if ($smarty.foreach.f.index+1)%3 == 0}<br>{/if}
+ {/foreach}
+</div>
+{/strip}</li>
-{foreach from=$lang_switch.flags key=code item=flag name=f}
- <li>
- <a rel="nofollow" href="{$flag.url}">
- <img class="flags" src="{$flag.img}" alt="{$flag.alt}" title="{$flag.alt}"/> {$flag.title}
- </a>
- </li>
-{/foreach}
+{footer_script require='jquery'}{literal}
+jQuery("#languageSwitchLink").click(function() {
+ var elt = jQuery("#languageSwitchBox");
+ elt.css("left", Math.min(jQuery(this).offset().left, jQuery(window).width() - elt.outerWidth(true) - 5))
+ .css("top", jQuery(this).offset().top + jQuery(this).outerHeight(true))
+ .toggle();
+});
+jQuery("#languageSwitchBox").on("mouseleave", function() {
+ jQuery(this).hide();
+});
+{/literal}{/footer_script}
- </ul>
-<!--[if lte IE 6]>
- </td>
- </tr>
- </table>
- </a>
-<![endif]-->
- </li>
- </ul>
- </div>
-</li>
-
-{combine_css path="plugins/language_switch/language_switch-default.css"}
+{* <!-- switchBox structure for theme which don't include default style --> *}
+{if $themeconf.parent != 'default' or (isset($themeconf.load_parent_local_head) and $themeconf.load_parent_local_head == false) }
+{combine_css path=$LANGUAGE_SWITCH_PATH|@cat:"default.css"}
+{/if}
-{if $themeconf.name eq 'Sylvia'}
-{combine_css path="plugins/language_switch/language_switch-Sylvia.css"}
+{* <!-- stylish for non core themes (should be removed when all themes are updated) --> *}
+{if $themeconf.name != 'clear' and $themeconf.name != 'dark' and $themeconf.name != 'elegant' and $themeconf.name != 'Sylvia'}
+{combine_css path=$LANGUAGE_SWITCH_PATH|@cat:"style.css"}
{/if}
-{html_head}
-<!--[if lte IE 6]>
-<link rel="stylesheet" type="text/css" href="{$ROOT_URL}plugins/language_switch/language_switch-ie6.css">
-<![endif]-->
-{/html_head} \ No newline at end of file
+{* <!-- common style specific for LanguageSwitch --> *}
+{combine_css path=$LANGUAGE_SWITCH_PATH|@cat:"language_switch.css"} \ No newline at end of file
diff --git a/plugins/language_switch/language_switch-Sylvia.css b/plugins/language_switch/language_switch-Sylvia.css
deleted file mode 100644
index b0ddc7be0..000000000
--- a/plugins/language_switch/language_switch-Sylvia.css
+++ /dev/null
@@ -1,7 +0,0 @@
-.flag-pan { border:1px solid; background-color: #111; }
-.content ul.categoryActions .flag-pan a:hover {color:#ddd}
-.menuf .flags {border-color: #000 !important; }
-
-.flag-pan { border-radius: 8px; } /* round corners with CSS3 compliant browsers */
-.flag-pan { -moz-border-radius:8px; }
-.flag-pan { -webkit-border-radius: 8px; } \ No newline at end of file
diff --git a/plugins/language_switch/language_switch-default.css b/plugins/language_switch/language_switch-default.css
deleted file mode 100644
index 6f5b60ec0..000000000
--- a/plugins/language_switch/language_switch-default.css
+++ /dev/null
@@ -1,19 +0,0 @@
-.flag-pan { width:380px; z-index:100; border:2px solid #CDCDCD; background-color: #f0f0f0; padding: 2px 5px 10px 5px; }
-.languageSwitchBoxTitle {display:block;width:370px;text-align:center;margin:5px auto;font-weight:bold;color:#464646;}
-.content ul.categoryActions .flag-pan a img.flags { margin-bottom: -2px; }
-.content ul.categoryActions .flag-pan a { margin: 0; border:none; color:#464646;}
-.content ul.categoryActions .flag-pan a:hover {color:black}
-.menuf { width:30px; height:24px; display: inline; }
-.menuf ul li a, .menuf ul li a:visited {display:block; text-decoration:none; width:120px; height:27px; text-align:left; line-height:27px; overflow:hidden; border:none}
-.menuf ul {padding:0; margin:0; list-style: none;}
-.menuf ul li {float:left; position:relative; right:0; top:0; margin-left:5px}
-.menuf ul li ul {display: none;}/* specific to non IE browsers */
-.menuf li a:hover { border:1px dotted #464646}
-.menuf .flags {border:1px solid #ddd !important; margin-top:5px; }
-.menuf ul li:hover ul {display:block; position:absolute; top:0px; right:0px; }
-.menuf ul li:hover ul li ul {display: none;}
-.menuf ul li:hover ul li {display: block;}
-.menuf ul li:hover ul li a {display:block;}
-.menuf ul li:hover ul li:hover ul {display:block; position:absolute; left:0px; top:0;}
-
-.menuf ul li a.activeFlag, .menuf ul li a.activeFlag:visited {width:30px;} \ No newline at end of file
diff --git a/plugins/language_switch/language_switch-ie6.css b/plugins/language_switch/language_switch-ie6.css
deleted file mode 100644
index 73b92a6a2..000000000
--- a/plugins/language_switch/language_switch-ie6.css
+++ /dev/null
@@ -1,6 +0,0 @@
-.menuf ul li a.hide, .menuf ul li a:visited.hide {display:none;}
-.menuf ul li a:hover ul li a.hide {display:none;}
-.menuf ul li a:hover ul { display:block; position:absolute; top:-15%; left:-85%; }
-.menuf ul li a:hover ul li a {display:block; }
-.menuf ul li a:hover ul li a ul {visibility:hidden;}
-.menuf ul li a:hover ul li a:hover ul {visibility:visible; position:absolute; left:105px; top:0;} \ No newline at end of file
diff --git a/plugins/language_switch/language_switch.css b/plugins/language_switch/language_switch.css
new file mode 100644
index 000000000..c2764c306
--- /dev/null
+++ b/plugins/language_switch/language_switch.css
@@ -0,0 +1,7 @@
+#languageSwitchBox a {
+ display:inline-block;
+ width:130px;
+ text-decoration:none;
+ border:none;
+ text-transform:none;
+} \ 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 fc06da5d3..49c1a6c49 100644
--- a/plugins/language_switch/language_switch.inc.php
+++ b/plugins/language_switch/language_switch.inc.php
@@ -21,135 +21,111 @@
// | USA. |
// +-----------------------------------------------------------------------+
-if (!defined('LANGUAGE_SWITCH_PATH'))
-{
- define('LANGUAGE_SWITCH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
-}
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-class language_controler
+function language_controler_switch()
{
- static public function _switch()
- {
- global $user;
+ global $user;
- if (!defined('PHPWG_ROOT_PATH'))
+ $same = $user['language'];
+
+ if (isset($_GET['lang']))
+ {
+ include_once(PHPWG_ROOT_PATH . 'admin/include/languages.class.php');
+ $languages = new languages();
+ if ( !in_array($_GET['lang'], array_keys($languages->fs_languages)) )
{
- die('Hacking attempt!');
+ $_GET['lang'] = PHPWG_DEFAULT_LANGUAGE;
}
-
- $same = $user['language'];
-
- if (isset($_GET['lang']))
+
+ if ( !empty($_GET['lang']) and file_exists(PHPWG_ROOT_PATH.'language/'.$_GET['lang'].'/common.lang.php') )
{
- include_once(PHPWG_ROOT_PATH . 'admin/include/languages.class.php');
- $languages = new languages();
- if (!in_array($_GET['lang'], array_keys($languages->fs_languages)))
+ if ( is_a_guest() or is_generic() )
{
- $_GET['lang'] = PHPWG_DEFAULT_LANGUAGE;
+ pwg_set_session_var('lang_switch', $_GET['lang']);
}
-
- if (!empty($_GET['lang']) and file_exists(PHPWG_ROOT_PATH.'language/'.$_GET['lang'].'/common.lang.php'))
+ else
{
- if (is_a_guest() or is_generic())
- {
- pwg_set_session_var('lang_switch', $_GET['lang']);
- }
- else
- {
- $query = '
+ $query = '
UPDATE '.USER_INFOS_TABLE.'
SET language = \''.$_GET['lang'].'\'
WHERE user_id = '.$user['id'].'
;';
- pwg_query($query);
- }
-
- $user['language'] = $_GET['lang'];
+ pwg_query($query);
}
- }
- elseif ((is_a_guest() or is_generic()))
- {
- $user['language'] = pwg_get_session_var('lang_switch', $user['language']);
- }
-
- // Reload language only if it isn't the same one
- if ( $same !== $user['language'])
- {
- load_language('common.lang', '', array('language'=>$user['language']));
-
- load_language(
- 'lang',
- PHPWG_ROOT_PATH.PWG_LOCAL_DIR,
- array(
- 'language' => $user['language'],
- 'no_fallback' => true,
- 'local' => true
- )
- );
- if (defined('IN_ADMIN') and IN_ADMIN)
- {
- // Never currently
- load_language('admin.lang', '', array('language'=>$user['language']));
- }
+ $user['language'] = $_GET['lang'];
}
}
+ elseif ( (is_a_guest() or is_generic()) )
+ {
+ $user['language'] = pwg_get_session_var('lang_switch', $user['language']);
+ }
- static public function _flags()
+ // Reload language only if it isn't the same one
+ if ( $same !== $user['language'] )
{
- global $user, $template, $conf;
+ load_language('common.lang', '', array('language'=>$user['language']));
- $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 = get_query_string_diff(array('lang'));
-
- foreach ($available_lang as $code => $displayname)
- {
- $qlc = array (
- 'url' => add_url_params(duplicate_index_url(), array('lang'=> $code)),
- 'alt' => ucwords($displayname),
- 'title' => substr($displayname, 0, -4), // remove [FR] or [RU]
- 'img' => get_root_url().'language/'.$code.'/'.$code.'.jpg',
- );
-
- $lsw['flags'][$code] = $qlc ;
-
- if ($code == $user['language'])
- {
- $lsw['Active'] = $qlc;
- }
- }
-
- $template->set_filename('language_flags', dirname(__FILE__) . '/flags.tpl');
-
- $lsw['side'] = ceil(sqrt(count($available_lang)));
-
- $template->assign(
+ load_language(
+ 'lang',
+ PHPWG_ROOT_PATH.PWG_LOCAL_DIR,
array(
- 'lang_switch'=> $lsw,
- 'LANGUAGE_SWITCH_PATH' => LANGUAGE_SWITCH_PATH,
+ 'language' => $user['language'],
+ 'no_fallback' => true,
+ 'local' => true
)
);
- $flags = $template->parse('language_flags',true);
- $template->clear_assign('lang_switch');
- $template->concat( 'PLUGIN_INDEX_ACTIONS', $flags);
+ if ( defined('IN_ADMIN') and IN_ADMIN )
+ {
+ // Never currently
+ load_language('admin.lang', '', array('language'=>$user['language']));
+ }
}
}
- /* {html_head} usage function */
- /* See flags.tpl for example (due no catenation available) */
-if (!function_exists('Componant_exists'))
+function language_controler_flags()
{
- function Componant_exists($path, $file)
+ global $user, $template, $conf;
+
+ $available_lang = get_languages();
+
+ if (isset($conf['no_flag_languages']))
{
- return file_exists( $path . $file);
+ $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(duplicate_index_url(), array('lang'=> $code)),
+ 'alt' => ucwords($displayname),
+ 'title' => substr($displayname, 0, -4), // remove [FR] or [RU]
+ 'img' => get_root_url().'language/'.$code.'/'.$code.'.jpg',
+ );
+
+ $lsw['flags'][$code] = $qlc;
+
+ if ($code == $user['language'])
+ {
+ $lsw['Active'] = $qlc;
+ }
+ }
+
+ $template->set_filename('language_flags', dirname(__FILE__) . '/flags.tpl');
+
+ $template->assign(
+ array(
+ 'lang_switch'=> $lsw,
+ 'LANGUAGE_SWITCH_PATH' => LANGUAGE_SWITCH_PATH,
+ )
+ );
+
+ $template->concat('PLUGIN_INDEX_ACTIONS', $template->parse('language_flags', true) );
+ $template->clear_assign('lang_switch');
}
-?>
+?> \ No newline at end of file
diff --git a/plugins/language_switch/main.inc.php b/plugins/language_switch/main.inc.php
index 6bbc4f51d..e03c2e70b 100644
--- a/plugins/language_switch/main.inc.php
+++ b/plugins/language_switch/main.inc.php
@@ -23,15 +23,20 @@
/*
Plugin Name: Language Switch
-Version: 2.3.0
+Version: 2.4.0
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
Author URI: http://piwigo.org
*/
-include_once(PHPWG_PLUGINS_PATH.'language_switch/language_switch.inc.php');
-$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 );
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+define('LANGUAGE_SWITCH_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+
+include_once(LANGUAGE_SWITCH_PATH.'language_switch.inc.php');
+
+add_event_handler('loading_lang', 'language_controler_switch', 5 );
+add_event_handler('loc_end_index', 'language_controler_flags', 95 );
+
?> \ No newline at end of file
diff --git a/plugins/language_switch/style.css b/plugins/language_switch/style.css
new file mode 100644
index 000000000..8b330272c
--- /dev/null
+++ b/plugins/language_switch/style.css
@@ -0,0 +1,14 @@
+#languageSwitchBox {
+ background-color: #555;
+ border: 1px solid #000;
+}
+
+#languageSwitchBox .switchBoxTitle {
+ border-bottom: 1px solid #444;
+}
+#languageSwitchBox a {
+ color:#aaa;
+}
+#languageSwitchBox a:hover {
+ color:#ddd;
+} \ No newline at end of file