Index: gtranslate.module
===================================================================
--- gtranslate.module (.../trunk/sites/default/modules/gtrans) (revision 16137)
+++ gtranslate.module (.../tags/2010-08-06-B/sites/default/modules/gtrans) (revision 16137)
@@ -19,12 +19,6 @@
} // function gtranslate_perm
function gtranslate_block($op = 'list', $delta = 0) {
-
- global $language;
-
- $from_language = $language->language ? $language->language : variable_get('gtranslate_main_lang', 'en');
- $module_dir = base_path() . drupal_get_path('module', 'gtranslate');
-
if ($op == 'list') {
$block[0]['info'] = t('GTranslate');
return $block;
@@ -50,7 +44,7 @@
$block_content .= '';
+ $block_content .= '';
$block_content .= '';
}
@@ -72,25 +66,25 @@
$block_content .= "//')openTab(unescape(gfg('u')));else if(location.hostname=='".$_SERVER['HTTP_HOST']."' && lang_pair!='".$from_language."|".$from_language."')openTab('http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+escape(location.href));else openTab('http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+unescape(gfg('u')));}";
+ $block_content .= "function doTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(location.hostname=='".$_SERVER['HTTP_HOST']."' && lang_pair=='".variable_get('gtranslate_main_lang', 'en')."|".variable_get('gtranslate_main_lang', 'en')."')return;else if(location.hostname!='".$_SERVER['HTTP_HOST']."' && lang_pair=='".variable_get('gtranslate_main_lang', 'en')."|')openTab(unescape(gfg('u')));else if(location.hostname=='".$_SERVER['HTTP_HOST']."' && lang_pair!='".variable_get('gtranslate_main_lang', 'en')."|".variable_get('gtranslate_main_lang', 'en')."')openTab('http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+escape(location.href));else openTab('http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+unescape(gfg('u')));}";
$block_content .= 'function gfg(name) {name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^]*)";var regex=new RegExp(regexS);var results=regex.exec(location.href);if(results==null)return "";return results[1];}';
}
} else {
if(variable_get('gtranslate_pro', 0)) {
- $block_content .= "function doTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;var lang=lang_pair.split('|')[1];var plang=location.pathname.split('/')[1];if(plang.length !=2 && plang != 'zh-CN' && plang != 'zh-TW')plang='".$from_language."';if(lang == '".$from_language."')location.pathname=location.pathname.replace('/'+plang, '');else location.pathname='/'+lang+location.pathname.replace('/'+plang, '');}";
+ $block_content .= "function doTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;var lang=lang_pair.split('|')[1];var plang=location.pathname.split('/')[1];if(plang.length !=2 && plang != 'zh-CN' && plang != 'zh-TW')plang='".variable_get('gtranslate_main_lang', 'en')."';if(lang == '".variable_get('gtranslate_main_lang', 'en')."')location.pathname=location.pathname.replace('/'+plang, '');else location.pathname='/'+lang+location.pathname.replace('/'+plang, '');}";
} else {
$block_content .= "if(top.location!=self.location)top.location=self.location;";
$block_content .= "window['_tipoff']=function(){};window['_tipon']=function(a){};";
- $block_content .= "function doTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(location.hostname=='".$_SERVER['HTTP_HOST']."' && lang_pair=='".$from_language."|".$from_language."')return;else if(location.hostname!='".$_SERVER['HTTP_HOST']."' && lang_pair=='".$from_language."|".$from_language."')location.href=unescape(gfg('u'));else if(location.hostname=='".$_SERVER['HTTP_HOST']."' && lang_pair!='".$from_language."|".$from_language."')location.href='http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+escape(location.href);else location.href='http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+unescape(gfg('u'));}";
+ $block_content .= "function doTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(location.hostname=='".$_SERVER['HTTP_HOST']."' && lang_pair=='".variable_get('gtranslate_main_lang', 'en')."|".variable_get('gtranslate_main_lang', 'en')."')return;else if(location.hostname!='".$_SERVER['HTTP_HOST']."' && lang_pair=='".variable_get('gtranslate_main_lang', 'en')."|".variable_get('gtranslate_main_lang', 'en')."')location.href=unescape(gfg('u'));else if(location.hostname=='".$_SERVER['HTTP_HOST']."' && lang_pair!='".variable_get('gtranslate_main_lang', 'en')."|".variable_get('gtranslate_main_lang', 'en')."')location.href='http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+escape(location.href);else location.href='http://translate.google.com/translate?client=tmpg&hl=en&langpair='+lang_pair+'&u='+unescape(gfg('u'));}";
$block_content .= 'function gfg(name) {name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^]*)";var regex=new RegExp(regexS);var results=regex.exec(location.href);if(results==null)return "";return results[1];}';
}
}
@@ -103,8 +97,8 @@
case 'both': {
$block_content .= '';
@@ -117,7 +111,7 @@
default: break;
}
- $block_content .= '
';
+ $block_content .= '
';
}
if($i == 7) {
@@ -140,7 +134,7 @@
default: break;
}
- $block_content .= '';
+ $block_content .= '';
}
$i++;
@@ -152,8 +146,8 @@
case 'flags': {
$block_content .= '';
@@ -166,7 +160,7 @@
default: break;
}
- $block_content .= '
';
+ $block_content .= '
';
}
if($i == 7) {
@@ -191,7 +185,7 @@
default: break;
}
- $block_content .= '';
+ $block_content .= '';
}
$i++;