Changeset 2162 for trunk/plugins
- Timestamp:
- Nov 19, 2007, 8:51:54 PM (17 years ago)
- Location:
- trunk/plugins/language_switch
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/language_switch/language_switch.inc.php
r2161 r2162 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 */ 1 <?php 9 2 // +-----------------------------------------------------------------------+ 10 3 // | PhpWebGallery - a PHP based picture gallery | … … 33 26 function language_switch() 34 27 { 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') ) 28 global $user, $template, $conf, $lang; 29 if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } 30 if ( isset( $_GET['lang']) ) 44 31 { 45 if ($user['is_the_guest'] or $user['status'] == 'generic') 32 if ( !empty($_GET['lang'] ) and 33 file_exists( PHPWG_ROOT_PATH.'language/' 34 . $_GET['lang'].'/common.lang.php') ) 46 35 { 47 setcookie( 'pwg_lang_switch', $_GET['lang'], 48 time()+60*60*24*30, cookie_path() ); 36 if (is_a_guest() or is_generic()) 37 { 38 setcookie( 'pwg_lang_switch', $_GET['lang'], 39 time()+60*60*24*30, cookie_path() ); 40 } 41 else 42 { 43 $query = 'UPDATE '.USER_INFOS_TABLE.' 44 SET language = \''.$_GET['lang'].'\' 45 WHERE user_id = '.$user['id'].' 46 ;'; 47 pwg_query($query); 48 } 49 $user['language'] = $_GET['lang']; 49 50 } 50 else51 {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 51 } 61 }62 52 // Users have $user['language'] 63 53 // Guest or generic members will use their cookied language ! 54 if ((is_a_guest() or is_generic()) 55 and isset( $_COOKIE['pwg_lang_switch'] ) ) 56 { 57 $user['language'] = $_COOKIE['pwg_lang_switch']; 58 } 64 59 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 } 60 load_language('common.lang', '', $user['language']); 61 load_language('local.lang', '', $user['language']); 62 if (defined('IN_ADMIN') and IN_ADMIN) 63 { 64 load_language('admin.lang', '', $user['language']); 65 } 75 66 } 76 67 //if ( isset( $_GET['lang']) ) { redirect( make_index_url() ); } 77 68 78 79 80 81 82 69 function Lang_flags() 83 70 { 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/'71 global $user, $template; 72 $available_lang = get_languages(); 73 foreach ( $available_lang as $code => $displayname ) 74 { 75 $qlc_url = add_url_params( make_index_url(), array( 'lang' => $code ) ); 76 $qlc_alt = ucwords( $displayname ); 77 $qlc_title = $qlc_alt; 78 $qlc_img = PHPWG_PLUGINS_PATH.'language_switch/icons/' 92 79 . $code . '.gif'; 93 // echo $code . ' '. $qlc_url .' // <br />';94 // echo $user['language'] . ' '. $qlc_img .' /// <br />';95 80 96 81 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>'); 82 { 83 $template -> concat_var( 'PLUGIN_INDEX_ACTIONS', 84 '<li><a href="' . $qlc_url . '" ><img src="' . $qlc_img . '" alt="' 85 . $qlc_alt . '" title="' 86 . $qlc_title . '" style="border: 1px solid #000000; ' 87 . ' margin: 0px 2px;" /></a></li>'); 88 } 103 89 } 104 90 } 105 }106 91 ?> -
trunk/plugins/language_switch/main.inc.php
r2161 r2162 2 2 Plugin Name: Language Switch 3 3 Version: 1.0 4 Description: Give you an advice on the administrationpage.4 Description: Switch to another language from flags on your gallery home page. 5 5 Plugin URI: http://www.phpwebgallery.net 6 6 Author: PhpWebGallery team … … 31 31 // | USA. | 32 32 // +-----------------------------------------------------------------------+ 33 include_once(PHPWG_PLUGINS_PATH.'language_switch/language_switch.inc.php'); 33 34 add_event_handler('loading_lang', 'language_switch' ); 34 include_once(PHPWG_PLUGINS_PATH.'language_switch/language_switch.inc.php');35 35 add_event_handler('loc_end_index', 'Lang_flags' ); 36 36 ?>
Note: See TracChangeset
for help on using the changeset viewer.