1 | <?php /* |
---|
2 | Plugin Name: Language Switch |
---|
3 | Version: 1.0 |
---|
4 | Description: Give you an advice on the administration page. |
---|
5 | Plugin URI: http://www.phpwebgallery.net |
---|
6 | Author: PhpWebGallery team |
---|
7 | Author URI: http://www.phpwebgallery.net |
---|
8 | */ |
---|
9 | // +-----------------------------------------------------------------------+ |
---|
10 | // | PhpWebGallery - a PHP based picture gallery | |
---|
11 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
12 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
13 | // +-----------------------------------------------------------------------+ |
---|
14 | // | file : $Id: language_switch.inc.php 2161 2007-11-18 19:59:33Z vdigital $ |
---|
15 | // | last update : $Date: 2007-11-18 19:59:33 +0000 (Sun, 18 Nov 2007) $ |
---|
16 | // | last modifier : $Author: vdigital $ |
---|
17 | // | revision : $Revision: 2161 $ |
---|
18 | // +-----------------------------------------------------------------------+ |
---|
19 | // | This program is free software; you can redistribute it and/or modify | |
---|
20 | // | it under the terms of the GNU General Public License as published by | |
---|
21 | // | the Free Software Foundation | |
---|
22 | // | | |
---|
23 | // | This program is distributed in the hope that it will be useful, but | |
---|
24 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
25 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
26 | // | General Public License for more details. | |
---|
27 | // | | |
---|
28 | // | You should have received a copy of the GNU General Public License | |
---|
29 | // | along with this program; if not, write to the Free Software | |
---|
30 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
31 | // | USA. | |
---|
32 | // +-----------------------------------------------------------------------+ |
---|
33 | function language_switch() |
---|
34 | { |
---|
35 | global $user, $template, $conf, $lang; |
---|
36 | |
---|
37 | if (!isset($user['status'])) |
---|
38 | { die('You are not authorized to access this page'); }; |
---|
39 | |
---|
40 | if ( isset( $_GET['lang']) ) |
---|
41 | { |
---|
42 | if ( !empty($_GET['lang'] ) and |
---|
43 | file_exists( PHPWG_ROOT_PATH.'language/'.$_GET['lang'].'/common.lang.php') ) |
---|
44 | { |
---|
45 | if ($user['is_the_guest'] or $user['status'] == 'generic') |
---|
46 | { |
---|
47 | setcookie( 'pwg_lang_switch', $_GET['lang'], |
---|
48 | time()+60*60*24*30, cookie_path() ); |
---|
49 | } |
---|
50 | else |
---|
51 | { |
---|
52 | $query = ' |
---|
53 | UPDATE '.USER_INFOS_TABLE.' |
---|
54 | SET language = \''.$_GET['lang'].'\' |
---|
55 | WHERE user_id = '.$user['id'].' |
---|
56 | ;'; |
---|
57 | pwg_query($query); |
---|
58 | } |
---|
59 | $user['language'] = $_GET['lang']; |
---|
60 | } |
---|
61 | } |
---|
62 | // Users have $user['language'] |
---|
63 | // Guest or generic members will use their cookied language ! |
---|
64 | |
---|
65 | if ((is_a_guest() or is_generic()) |
---|
66 | and isset( $_COOKIE['pwg_lang_switch'] ) ) |
---|
67 | { $user['language'] = $_COOKIE['pwg_lang_switch']; } |
---|
68 | |
---|
69 | load_language('common.lang', '', $user['language']); |
---|
70 | load_language('local.lang', '', $user['language']); |
---|
71 | if (defined('IN_ADMIN') and IN_ADMIN) |
---|
72 | { |
---|
73 | load_language('admin.lang', '', $user['language']); |
---|
74 | } |
---|
75 | } |
---|
76 | //if ( isset( $_GET['lang']) ) { redirect( make_index_url() ); } |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | function Lang_flags() |
---|
83 | { |
---|
84 | global $user, $template; |
---|
85 | $available_lang = get_languages(); |
---|
86 | foreach ( $available_lang as $code => $displayname ) |
---|
87 | { |
---|
88 | $qlc_url = add_url_params( make_index_url(), array( 'lang' => $code ) ); |
---|
89 | $qlc_alt = ucwords( $displayname ); |
---|
90 | $qlc_title = $qlc_alt; |
---|
91 | $qlc_img = PHPWG_PLUGINS_PATH.'language_switch/icons/' |
---|
92 | . $code . '.gif'; |
---|
93 | // echo $code . ' '. $qlc_url .' // <br />'; |
---|
94 | // echo $user['language'] . ' '. $qlc_img .' /// <br />'; |
---|
95 | |
---|
96 | if ( $code !== $user['language'] and file_exists($qlc_img) ) |
---|
97 | { |
---|
98 | $template -> concat_var( 'PLUGIN_INDEX_ACTIONS', |
---|
99 | '<li><a href="' . $qlc_url . '" ><img src="' . $qlc_img . '" alt="' |
---|
100 | . $qlc_alt . '" title="' |
---|
101 | . $qlc_title . '" style="border: 1px solid #000000; ' |
---|
102 | . ' margin: 0px 2px;" /></a></li>'); |
---|
103 | } |
---|
104 | } |
---|
105 | } |
---|
106 | ?> |
---|