示例#1
0
        public static string GetAutoCheckKeywordsScript(SiteInfo siteInfo)
        {
            var isAutoCheckKeywords = siteInfo.Additional.IsAutoCheckKeywords.ToString().ToLower();
            var url         = AjaxCmsService.GetDetectionReplaceUrl(siteInfo.Id);
            var getPureText = ETextEditorTypeUtils.GetPureTextScript(BackgroundContentAttribute.Content);
            var getContent  = ETextEditorTypeUtils.GetContentScript(BackgroundContentAttribute.Content);
            var setContent  = ETextEditorTypeUtils.GetSetContentScript(BackgroundContentAttribute.Content, "htmlContent");
            var tipsWarn    = AlertUtils.Warning("敏感词检测", "内容中共检测到' + i + '个敏感词,已用黄色背景标明", "取 消", "自动替换并保存",
                                                 "autoReplaceKeywords");

            var command = $@"
<script type=""text/javascript"">
var bairongKeywordArray;
function autoCheckKeywords() {{
    if({isAutoCheckKeywords}) {{
        var pureText = {getPureText}
        var htmlContent = {getContent}
	    $.post('{url}&r=' + Math.random(), {{content:pureText}}, function(data) {{
		    if(data) {{
                bairongKeywordArray = data;
			    var arr = data.split(',');
                var i=0;
			    for(;i<arr.length;i++)
			    {{
                    var tmpArr = arr[i].split('|');
                    var keyword = tmpArr[0];
                    var replace = tmpArr.length==2?tmpArr[1]:'';
                    var reg = new RegExp(keyword, 'gi');
				    htmlContent = htmlContent.replace(reg,'<span style=""background-color:#ffff00;"">' + keyword + '</span>');
			    }}
			    {setContent}
                {tipsWarn}
		    }} else {{
                $('#BtnSubmit').attr('onclick', '').click();
            }}
	    }});
        return false;	
    }}
}}
function autoReplaceKeywords() {{
    var arr = bairongKeywordArray.split(',');
    var i=0;
    var htmlContent = {getContent}
	for(;i<arr.length;i++)
	{{
        var tmpArr = arr[i].split('|');
        var keyword = tmpArr[0];
        var replace = tmpArr.length==2?tmpArr[1]:'';
        var reg = new RegExp('<span style=""background-color:#ffff00;"">' + keyword + '</span>', 'gi');
		htmlContent = htmlContent.replace(reg, replace);
        //IE8
        reg = new RegExp('<span style=""background-color:#ffff00"">' + keyword + '</span>', 'gi');
		htmlContent = htmlContent.replace(reg, replace);
	}}
    {setContent}
    $('#BtnSubmit').attr('onclick', '').click();
}}
</script>
";



            return(command);
        }
示例#2
0
        public static string GetAutoCheckKeywordsScript(PublishmentSystemInfo publishmentSystemInfo)
        {
            var builder = new StringBuilder();

            var command = @"
<script type=""text/javascript"">
var bairongKeywordArray;
function autoCheckKeywords(){
    if([isAutoCheckKeywords]){
        var pureText = [getPureText]
        var htmlContent = [getContent]
	    $.post('[url]&r=' + Math.random(), {content:pureText}, function(data) {
		    if(data){
                bairongKeywordArray = data;
			    var arr = data.split(',');
                var i=0;
			    for(;i<arr.length;i++)
			    {
                    var tmpArr = arr[i].split('|');
                    var keyword = tmpArr[0];
                    var replace = tmpArr.length==2?tmpArr[1]:'';
                    var reg = new RegExp(keyword, 'gi');
				    htmlContent = htmlContent.replace(reg,'<span style=""background-color:#ffff00;"">' + keyword + '</span>');
			    }
			    [setContent]
                [tips_warn]
		    }else{
                $('#BtnSubmit').attr('onclick', '').click();
            }
	    });
        return false;	
    }
}
function autoReplaceKeywords(){
    var arr = bairongKeywordArray.split(',');
    var i=0;
    var htmlContent = [getContent]
	for(;i<arr.length;i++)
	{
        var tmpArr = arr[i].split('|');
        var keyword = tmpArr[0];
        var replace = tmpArr.length==2?tmpArr[1]:'';
        var reg = new RegExp('<span style=""background-color:#ffff00;"">' + keyword + '</span>', 'gi');
		htmlContent = htmlContent.replace(reg, replace);
        //IE8
        reg = new RegExp('<span style=""background-color:#ffff00"">' + keyword + '</span>', 'gi');
		htmlContent = htmlContent.replace(reg, replace);
	}
    [setContent]
    $('#BtnSubmit').attr('onclick', '').click();
}
</script>
";

            command = command.Replace("[isAutoCheckKeywords]",
                                      $"{publishmentSystemInfo.Additional.IsAutoCheckKeywords.ToString().ToLower()}");
            command = command.Replace("[url]", AjaxCmsService.GetDetectionReplaceUrl(publishmentSystemInfo.PublishmentSystemId));
            command = command.Replace("[getPureText]", ETextEditorTypeUtils.GetPureTextScript(BackgroundContentAttribute.Content));
            command = command.Replace("[getContent]", ETextEditorTypeUtils.GetContentScript(BackgroundContentAttribute.Content));
            command = command.Replace("[setContent]", ETextEditorTypeUtils.GetSetContentScript(BackgroundContentAttribute.Content, "htmlContent"));

            command = command.Replace("[tips_warn]", PageUtils.GetOpenTipsString("内容中共检测到' + i + '个敏感词,已用黄色背景标明", PageUtils.TipsWarn, false, "自动替换并保存", "autoReplaceKeywords"));
            builder.Append(command);

            return(builder.ToString());
        }