Changeset 17067 for extensions/language_switch_menubar/main.inc.php
- Timestamp:
- Jul 25, 2012, 10:24:24 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/language_switch_menubar/main.inc.php
r15179 r17067 31 31 */ 32 32 33 34 35 36 33 if (!defined('PHPWG_ROOT_PATH')) 34 { 35 die('Hacking attempt!'); 36 } 37 37 38 38 define('LSM_DIR' , basename(dirname(__FILE__))); … … 53 53 function lsm_apply($menu_ref_arr) 54 54 { 55 global $template, $user, $template, $conf ;55 global $template, $user, $template, $conf, $page; 56 56 57 $menu = & $menu_ref_arr[0];57 $menu = & $menu_ref_arr[0]; 58 58 59 load_language('plugin.lang', LSM_PATH); 60 $template->assign( 61 array ( 62 'LSMTITLE' => l10n('Language'), 63 )); 64 65 if (($block = $menu->get_block( 'mbLSM' )) != null) { 66 $template->set_template_dir(LSM_PATH.'template/'); 67 $block->template = 'flags.tpl'; 59 load_language('plugin.lang', LSM_PATH); 60 $template->assign( 61 array ( 62 'LSMTITLE' => l10n('Language'), 63 ) 64 ); 65 66 if (($block = $menu->get_block( 'mbLSM' )) != null) 67 { 68 $template->set_template_dir(LSM_PATH.'template/'); 69 $block->template = 'flags.tpl'; 70 } 71 72 if ($page['section'] == 'additional_page' and isset($page['additional_page'])) 73 { 74 $base_url = make_index_url(array('section'=>'page')).'/'.(isset($page['additional_page']['permalink']) ? $page['additional_page']['permalink'] : $page['additional_page']['id']); 75 } 76 else 77 { 78 $base_url = duplicate_index_url(); 79 } 80 81 $available_lang = get_languages(); 82 foreach ($available_lang as $code => $displayname) 83 { 84 $qlc = array ( 85 'url' => add_url_params($base_url, array('lang'=> $code)), 86 'alt' => ucwords($displayname), 87 'img' => get_root_url().'language/'.$code.'/'.$code.'.jpg', 88 ); 89 90 $lsw['flags'][$code] = $qlc ; 91 92 if ($code == $user['language']) 93 { 94 $lsw['Active'] = $qlc; 68 95 } 69 70 $available_lang = get_languages(); 71 foreach ($available_lang as $code => $displayname) 72 { 73 $qlc = array ( 74 'url' => add_url_params(duplicate_index_url(), array('lang'=> $code)), 75 'alt' => ucwords($displayname), 76 'img' => get_root_url().'language/'.$code.'/'.$code.'.jpg', 77 ); 78 79 $lsw['flags'][$code] = $qlc ; 80 81 if ($code == $user['language']) 82 { 83 $lsw['Active'] = $qlc; 84 } 85 } 96 } 86 97 87 88 89 90 91 92 93 94 98 $lsw['side'] = ceil(sqrt(count($available_lang))); 99 $template->clear_assign('lang_switch'); 100 $template->assign( 101 array( 102 'lang_switch'=> $lsw, 103 'LSM_PATH' => LSM_PATH, 104 ) 105 ); 95 106 } 96 107 … … 98 109 { 99 110 global $user; 100 111 $same = $user['language']; 101 112 102 if (isset($_GET['lang'])) 113 if (isset($_GET['lang'])) 114 { 115 if (!empty($_GET['lang']) and file_exists(PHPWG_ROOT_PATH.'language/'.$_GET['lang'].'/common.lang.php')) 103 116 { 104 if ( !empty($_GET['lang']) and file_exists(PHPWG_ROOT_PATH.'language/'.$_GET['lang'].'/common.lang.php'))117 if (is_a_guest() or is_generic()) 105 118 { 106 if (is_a_guest() or is_generic()) 107 { 108 pwg_set_session_var('lang_switch', $_GET['lang']); 109 } 110 else 111 { 112 $query = ' 119 pwg_set_session_var('lang_switch', $_GET['lang']); 120 } 121 else 122 { 123 $query = ' 113 124 UPDATE '.USER_INFOS_TABLE.' 114 125 SET language = \''.$_GET['lang'].'\' 115 126 WHERE user_id = '.$user['id'].' 116 127 ;'; 117 pwg_query($query); 118 } 119 $user['language'] = $_GET['lang']; 128 pwg_query($query); 120 129 } 130 $user['language'] = $_GET['lang']; 121 131 } 122 elseif ((is_a_guest() or is_generic())) 123 { 124 $user['language'] = pwg_get_session_var('lang_switch', $user['language']); 125 } 132 } 133 elseif ((is_a_guest() or is_generic())) 134 { 135 $user['language'] = pwg_get_session_var('lang_switch', $user['language']); 136 } 137 138 if ( $same !== $user['language']) 139 { 140 load_language('common.lang', '', array('language'=>$user['language'])); 126 141 127 if ( $same !== $user['language']) 128 { 129 load_language('common.lang', '', array('language'=>$user['language'])); 130 131 load_language( 132 'lang', 133 PHPWG_ROOT_PATH.PWG_LOCAL_DIR, 134 array( 135 'language' => $user['language'], 136 'no_fallback' => true, 137 'local' => true 138 ) 139 );} 140 141 if (defined('IN_ADMIN') and IN_ADMIN) 142 { 143 load_language('admin.lang', '', array('language'=>$user['language'])); 144 } 145 142 load_language( 143 'lang', 144 PHPWG_ROOT_PATH.PWG_LOCAL_DIR, 145 array( 146 'language' => $user['language'], 147 'no_fallback' => true, 148 'local' => true 149 ) 150 ); 151 } 152 153 if (defined('IN_ADMIN') and IN_ADMIN) 154 { 155 load_language('admin.lang', '', array('language'=>$user['language'])); 156 } 146 157 } 147 158
Note: See TracChangeset
for help on using the changeset viewer.