风格:代码统一格式化

This commit is contained in:
sunxiyuan 2021-03-07 13:31:53 +08:00
parent 07f29618c1
commit 7efae508ea
10 changed files with 21125 additions and 20613 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,3 @@
/*Switcher Widget Button*/
a.wpcs_link {
margin-left: 10px;

View file

@ -8,16 +8,16 @@ If you are in a page with no Chinese Switcher, this file will not be loaded .
*/
window.addEventListener('load', function() {
if(typeof wpcs_target_lang == 'undefined') return;
window.addEventListener('load', function () {
if (typeof wpcs_target_lang == 'undefined') return;
var theTextNode = document.querySelector('input[name="s"]');
if (theTextNode) {
var wpcs_input_variant = document.createElement("input");
var theTextNode = document.querySelector('input[name="s"]');
if (theTextNode) {
var wpcs_input_variant = document.createElement("input");
wpcs_input_variant.id = 'wpcs_input_variant';
wpcs_input_variant.type = 'hidden';
wpcs_input_variant.name = 'variant';
wpcs_input_variant.value = wpcs_target_lang;
theTextNode.parentNode.appendChild(wpcs_input_variant);
}
}
});

View file

@ -1,93 +1,97 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Chinese Switcher</title>
<style type="text/css">
body {
margin: 0 auto; width: 900px;
}
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Chinese Switcher</title>
<style type="text/css">
body {
margin: 0 auto;
width: 900px;
}
.general {
margin-top: 20px;
}
</style>
</head>
.general {
margin-top: 20px;
}
</style>
</head>
<body>
<body>
<div id="wrapper" class="general">
<form action="convert.php" method="post" id="form1">
<label for="data">Original Text: </label><br />
<textarea name="data" id="data" rows="20" cols="100"></textarea><br />
<label for="variant">Convert to: </label>
<select id="variant" name="variant" >
<!--
<option value="zh-hans">简体中文 (zh-hans)</option>
<option value="zh-hant">繁體中文 (zh-hant)</option>
-->
<option value="zh-cn">大陆简体 (zh-cn)</option>
<!--
<option value="zh-hk">港澳繁體 (zh-hk)</option>
<option value="zh-mo">澳門繁體 (zh-mo)</option>
<option value="zh-sg">马新简体 (zh-sg)</option>
<option value="zh-my">马来西亚简体 (zh-my)</option>
-->
<option value="zh-tw">台灣正體 (zh-tw)</option>
</select><br />
<input type="hidden" name="dochineseconversion" value="1" />
<input type="submit" id="s" name="submit" value="Submit (Ctrl + Enter)" class="general" />
</form>
<div id="error" class="general"></div>
<div id="return" style="display: none" class="general">
<label for="response">Converted Text: </label><br />
<textarea id="response" rows="20" cols="100"></textarea><br />
</div><br />
<form action="convert.php" method="post" id="form1">
<label for="data">Original Text: </label><br/>
<textarea name="data" id="data" rows="20" cols="100"></textarea><br/>
<label for="variant">Convert to: </label>
<select id="variant" name="variant">
<!--
<option value="zh-hans">简体中文 (zh-hans)</option>
<option value="zh-hant">繁體中文 (zh-hant)</option>
-->
<option value="zh-cn">大陆简体 (zh-cn)</option>
<!--
<option value="zh-hk">港澳繁體 (zh-hk)</option>
<option value="zh-mo">澳門繁體 (zh-mo)</option>
<option value="zh-sg">马新简体 (zh-sg)</option>
<option value="zh-my">马来西亚简体 (zh-my)</option>
-->
<option value="zh-tw">台灣正體 (zh-tw)</option>
</select><br/>
<input type="hidden" name="dochineseconversion" value="1"/>
<input type="submit" id="s" name="submit" value="Submit (Ctrl + Enter)" class="general"/>
</form>
<div id="error" class="general"></div>
<div id="return" style="display: none" class="general">
<label for="response">Converted Text: </label><br/>
<textarea id="response" rows="20" cols="100"></textarea><br/>
</div>
<br/>
</div>
<script type="text/javascript" >
/* <![CDATA[ */
document.forms[0].onsubmit = function() {
if(XMLHttpRequest) {var ajax = new XMLHttpRequest();}
else { var ajax = new ActiveXObject("Microsoft.XMLHTTP"); }
ajax.onreadystatechange = function() {
if( ajax.readyState == 4 ) {
if(ajax.status == 200 ) {
document.getElementById("response").value = ajax.responseText;
document.getElementById("return").style.display = "block";
document.getElementById("error").innerHTML = "";
}
else {
document.getElementById("error").innerHTML = "Error, please try again.";
}
}
}
var t = 'dochineseconversion=1&variant=' +
( document.getElementById("variant").options[document.getElementById("variant").selectedIndex].value || document.getElementById("variant").options[document.getElementById("variant").selectedIndex].text ) +
'&data=' + encodeURIComponent(document.getElementById("data").value);
document.getElementById("error").innerHTML = "Loading...";
ajax.open("POST", 'convert.php', true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send(t);
return false;
}
<script type="text/javascript">
/* <![CDATA[ */
document.forms[0].onsubmit = function () {
if (XMLHttpRequest) {
var ajax = new XMLHttpRequest();
} else {
var ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
ajax.onreadystatechange = function () {
if (ajax.readyState == 4) {
if (ajax.status == 200) {
document.getElementById("response").value = ajax.responseText;
document.getElementById("return").style.display = "block";
document.getElementById("error").innerHTML = "";
} else {
document.getElementById("error").innerHTML = "Error, please try again.";
}
}
}
var t = 'dochineseconversion=1&variant=' +
(document.getElementById("variant").options[document.getElementById("variant").selectedIndex].value || document.getElementById("variant").options[document.getElementById("variant").selectedIndex].text) +
'&data=' + encodeURIComponent(document.getElementById("data").value);
document.getElementById("error").innerHTML = "Loading...";
ajax.open("POST", 'convert.php', true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send(t);
return false;
}
var isCtrl = false;
document.onkeydown = function(e) {
if(typeof(e) == "undefined") e = window.event || window.Event;
if( (e.which || e.keyCode) == 17 ) isCtrl = true;
}
document.onkeyup = function(e) {
if(typeof(e) == "undefined") e = window.event || window.Event;
if( isCtrl &&
( (e.which || e.keyCode) == 13 || (e.which || e.keyCode) == 10 )
) {
if( typeof(e.preventDefault) != "undefined" ) e.preventDefault();
document.getElementById("s").click();
isCtrl = false;
return false;
}
isCtrl = false;
}
/* ]]> */
var isCtrl = false;
document.onkeydown = function (e) {
if (typeof (e) == "undefined") e = window.event || window.Event;
if ((e.which || e.keyCode) == 17) isCtrl = true;
}
document.onkeyup = function (e) {
if (typeof (e) == "undefined") e = window.event || window.Event;
if (isCtrl &&
((e.which || e.keyCode) == 13 || (e.which || e.keyCode) == 10)
) {
if (typeof (e.preventDefault) != "undefined") e.preventDefault();
document.getElementById("s").click();
isCtrl = false;
return false;
}
isCtrl = false;
}
/* ]]> */
</script>
</body>
</html>

View file

@ -1,7 +1,7 @@
<?php
/**
* 本文档是为第三方应用预留的. 本插件中不会加载和使用这个文档.
*
*
* 通过include本文档, 您可以使用中文繁简转换函数zhconversion($str, $variant)
* 如果$_GET['doconversion']$_POST['doconversion'])有设置, 本文档将获取$_REQUEST['data']并把其转换为$_REQUEST['variant']语言后输出.
*
@ -11,70 +11,88 @@
*/
global $zh2Hans, $zh2Hant, $zh2TW, $zh2CN, $zh2SG, $zh2HK;
require_once( dirname(__FILE__) . '/ZhConversion.php');
require_once(dirname(__FILE__) . '/ZhConversion.php');
global $wpcs_langs;
$wpcs_langs = array(
'zh-hans' => array('zhconversion_hans', 'zh2Hans', '简体中文'),
'zh-hant' => array('zhconversion_hant', 'zh2Hant', '繁體中文'),
'zh-cn' => array('zhconversion_cn', 'zh2CN', '大陆简体'),
'zh-hk' => array('zhconversion_hk', 'zh2HK', '港澳繁體'),
'zh-sg' => array('zhconversion_sg', 'zh2SG', '马新简体'),
'zh-tw' => array('zhconversion_tw', 'zh2TW', '台灣正體'),
'zh-mo' => array('zhconversion_hk', 'zh2MO', '澳門繁體'),
'zh-my' => array('zhconversion_sg', 'zh2MY', '马来西亚简体'),
'zh' => array('zhconversion_zh', 'zh2ZH', '中文'),
'zh-hans' => array('zhconversion_hans', 'zh2Hans', '简体中文'),
'zh-hant' => array('zhconversion_hant', 'zh2Hant', '繁體中文'),
'zh-cn' => array('zhconversion_cn', 'zh2CN', '大陆简体'),
'zh-hk' => array('zhconversion_hk', 'zh2HK', '港澳繁體'),
'zh-sg' => array('zhconversion_sg', 'zh2SG', '马新简体'),
'zh-tw' => array('zhconversion_tw', 'zh2TW', '台灣正體'),
'zh-mo' => array('zhconversion_hk', 'zh2MO', '澳門繁體'),
'zh-my' => array('zhconversion_sg', 'zh2MY', '马来西亚简体'),
'zh' => array('zhconversion_zh', 'zh2ZH', '中文'),
);
if( empty($nochineseconversion) && empty($GLOBALS['nochineseconversion']) ) {
if( ( isset($_GET['dochineseconversion']) || isset($_POST['dochineseconversion']) ) &&
isset($_REQUEST['data']) )
{ $wpcs_data = get_magic_quotes_gpc() ? stripslashes($_REQUEST['data']) : $_REQUEST['data'];
$wpcs_variant = str_replace('_', '-', strtolower(trim($_REQUEST['variant'])));
if( !empty($wpcs_variant) && in_array($wpcs_variant, array('zh-hans', 'zh-hant', 'zh-cn', 'zh-hk', 'zh-sg', 'zh-tw', 'zh-my', 'zh-mo')) )
echo zhconversion($wpcs_data, $wpcs_variant);
else echo $wpcs_data;
die();
}
if (empty($nochineseconversion) && empty($GLOBALS['nochineseconversion'])) {
if ((isset($_GET['dochineseconversion']) || isset($_POST['dochineseconversion'])) &&
isset($_REQUEST['data'])) {
$wpcs_data = get_magic_quotes_gpc() ? stripslashes($_REQUEST['data']) : $_REQUEST['data'];
$wpcs_variant = str_replace('_', '-', strtolower(trim($_REQUEST['variant'])));
if ( ! empty($wpcs_variant) && in_array($wpcs_variant, array(
'zh-hans',
'zh-hant',
'zh-cn',
'zh-hk',
'zh-sg',
'zh-tw',
'zh-my',
'zh-mo'
))) {
echo zhconversion($wpcs_data, $wpcs_variant);
} else {
echo $wpcs_data;
}
die();
}
}
function zhconversion($str, $variant) {
global $wpcs_langs;
return $wpcs_langs[$variant][0]($str);
global $wpcs_langs;
return $wpcs_langs[$variant][0]($str);
}
function zhconversion_hant($str) {
global $zh2Hant;
return strtr($str, $zh2Hant );
global $zh2Hant;
return strtr($str, $zh2Hant);
}
function zhconversion_hans($str) {
global $zh2Hans;
return strtr($str, $zh2Hans);
global $zh2Hans;
return strtr($str, $zh2Hans);
}
function zhconversion_cn($str) {
global $zh2Hans, $zh2CN;
return strtr(strtr($str, $zh2CN), $zh2Hans);
global $zh2Hans, $zh2CN;
return strtr(strtr($str, $zh2CN), $zh2Hans);
}
function zhconversion_tw($str) {
global $zh2Hant, $zh2TW;
return strtr(strtr($str, $zh2TW), $zh2Hant);
global $zh2Hant, $zh2TW;
return strtr(strtr($str, $zh2TW), $zh2Hant);
}
function zhconversion_sg($str) {
global $zh2Hans, $zh2SG;
return strtr(strtr($str, $zh2SG), $zh2Hans);
global $zh2Hans, $zh2SG;
return strtr(strtr($str, $zh2SG), $zh2Hans);
}
function zhconversion_hk($str) {
global $zh2Hant, $zh2HK;
return strtr(strtr($str, $zh2HK), $zh2Hant);
global $zh2Hant, $zh2HK;
return strtr(strtr($str, $zh2HK), $zh2Hant);
}
function zhconversion_zh($str) {
return $str;
return $str;
}
?>

View file

@ -5,10 +5,10 @@
*/
//下面这些转换行使繁简语言导航提示不繁简转换.
$zh2Hant['大陆简体']='大陆简体';
$zh2Hant['马新简体']='马新简体';
$zh2Hant['简体中文']='简体中文';
$zh2Hans['港澳繁體']='港澳繁體';
$zh2Hans['台灣正體']='台灣正體';
$zh2Hans['繁體中文']='繁體中文';
$zh2Hant['大陆简体'] = '大陆简体';
$zh2Hant['马新简体'] = '马新简体';
$zh2Hant['简体中文'] = '简体中文';
$zh2Hans['港澳繁體'] = '港澳繁體';
$zh2Hans['台灣正體'] = '台灣正體';
$zh2Hans['繁體中文'] = '繁體中文';

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,92 +1,102 @@
<?php
/**
*wp super cache plugin. Add basic compability with "php cache" mode of wp super cache plugin. Experimental!
*
*Don't edit this file manully.
*
*@since 1.1.11
*
*/
*wp super cache plugin. Add basic compability with "php cache" mode of wp super cache plugin. Experimental!
*
*Don't edit this file manully.
*
* @since 1.1.11
*
*/
$GLOBALS['wp_supercache_wpcs_version'] = '1.0';
function wp_supercache_wpcs_get_prefered_language($accept_languages, $target_langs, $flag = 0) {
$langs = array();
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $accept_languages, $lang_parse);
$langs = array();
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $accept_languages, $lang_parse);
if(count($lang_parse[1])) {
$langs = array_combine($lang_parse[1], $lang_parse[4]);//array_combine需要php5以上版本
foreach($langs as $lang => $val) {
if($val === '') $langs[$lang] = '1';
}
arsort($langs, SORT_NUMERIC);
$langs = array_keys($langs);
$langs = array_map('strtolower', $langs);
if (count($lang_parse[1])) {
$langs = array_combine($lang_parse[1], $lang_parse[4]);//array_combine需要php5以上版本
foreach ($langs as $lang => $val) {
if ($val === '') {
$langs[$lang] = '1';
}
}
arsort($langs, SORT_NUMERIC);
$langs = array_keys($langs);
$langs = array_map('strtolower', $langs);
foreach($langs as $val) {
if(in_array($val, $target_langs))
return $val;
}
foreach ($langs as $val) {
if (in_array($val, $target_langs)) {
return $val;
}
}
if( $flag ) {
$array = array('zh-hans', 'zh-cn', 'zh-sg', 'zh-my');
$a = array_intersect($array, $target_langs);
if(!empty($a)) {
$b = array_intersect($array, $langs);
if(!empty($b)) {
$a = each($a);
return $a[1];
}
}
if ($flag) {
$array = array('zh-hans', 'zh-cn', 'zh-sg', 'zh-my');
$a = array_intersect($array, $target_langs);
if ( ! empty($a)) {
$b = array_intersect($array, $langs);
if ( ! empty($b)) {
$a = each($a);
$array = array('zh-hant', 'zh-tw', 'zh-hk', 'zh-mo');
$a = array_intersect($array, $target_langs);
if(!empty($a)) {
$b = array_intersect($array, $langs);
if(!empty($b)) {
$a = each($a);
return $a[1];
}
}
}
return 'null';
}
return 'null';
return $a[1];
}
}
$array = array('zh-hant', 'zh-tw', 'zh-hk', 'zh-mo');
$a = array_intersect($array, $target_langs);
if ( ! empty($a)) {
$b = array_intersect($array, $langs);
if ( ! empty($b)) {
$a = each($a);
return $a[1];
}
}
}
return 'null';
}
return 'null';
}
function wp_supercache_wpcs_admin() {
$id = 'wpcs-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4>WP Chinese Switcher</h4>
<p>Wp super cache - WP Chinese Switcher plugin is activated. To uninstall it, go to WP Chinese Switcher plugin setting page.</p>
</fieldset>
<?php
$id = 'wpcs-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4>WP Chinese Switcher</h4>
<p>Wp super cache - WP Chinese Switcher plugin is activated. To uninstall it, go to WP Chinese Switcher plugin
setting page.</p>
</fieldset>
<?php
}
add_cacheaction( 'cache_admin_page', 'wp_supercache_wpcs_admin' );
add_cacheaction('cache_admin_page', 'wp_supercache_wpcs_admin');
function wp_supercache_wpcs_cache_key($cachekey) {
global $wpcs_options;
global $wpcs_options;
$browser_lang = wp_supercache_wpcs_get_prefered_language($_SERVER['HTTP_ACCEPT_LANGUAGE'], $wpcs_options['wpcs_used_langs'], $wpcs_options['wpcs_auto_language_recong']);
$browser_lang = wp_supercache_wpcs_get_prefered_language($_SERVER['HTTP_ACCEPT_LANGUAGE'], $wpcs_options['wpcs_used_langs'], $wpcs_options['wpcs_auto_language_recong']);
$cookie_lang = 'null';
foreach( $_COOKIE as $key => $val ) {
if ( preg_match( "/^wpcs_variant_/", $key ) ) {
$cookie_lang = $val;
break;
}
}
$cookie_lang = 'null';
foreach ($_COOKIE as $key => $val) {
if (preg_match("/^wpcs_variant_/", $key)) {
$cookie_lang = $val;
break;
}
}
$is_redirect = 'direct';
foreach( $_COOKIE as $key => $val ) {
if ( preg_match( "/^wpcs_is_redirect_/", $key ) ) {
$is_redirect = 'redirect';
break;
}
}
$is_redirect = 'direct';
foreach ($_COOKIE as $key => $val) {
if (preg_match("/^wpcs_is_redirect_/", $key)) {
$is_redirect = 'redirect';
break;
}
}
return $cachekey . '_' . $browser_lang . '_' . $cookie_lang . '_' . $is_redirect;
return $cachekey . '_' . $browser_lang . '_' . $cookie_lang . '_' . $is_redirect;
}
add_cacheaction('wp_cache_key', 'wp_supercache_wpcs_cache_key');