Ejemplo n.º 1
0
        public static string GetTextEditorCommands(SiteInfo siteInfo, string attributeName)
        {
            return($@"
<script type=""text/javascript"">
function getWordSpliter(){{
    var pureText = {ETextEditorTypeUtils.GetPureTextScript(attributeName)}
	$.post('{AjaxCmsService.GetWordSpliterUrl(siteInfo.Id)}&r=' + Math.random(), {{content:pureText}}, function(data) {{
		if(data !=''){{
            $('.nav-pills').children('li').eq(1).find('a').click();
			$('#TbTags').val(data).focus();
		}}else{{
            {AlertUtils.Error("提取关键字", "对不起,内容不足,无法提取关键字")}
        }}
	}});	
}}
function detection_{attributeName}(){{
    var pureText = {ETextEditorTypeUtils.GetPureTextScript(attributeName)}
    var htmlContent = {ETextEditorTypeUtils.GetContentScript(attributeName)}
    var keyword = '';
	$.post('{AjaxCmsService.GetDetectionUrl(siteInfo.Id)}&r=' + Math.random(), {{content:pureText}}, function(data) {{
		if(data){{
			var arr = data.split(',');
            var i=0;
			for(;i<arr.length;i++)
			{{
                var reg = new RegExp(arr[i], 'gi');
				htmlContent = htmlContent.replace(reg,'<span style=""background-color:#ffff00;"">' + arr[i] + '</span>');
			}}
            keyword=data;
			{ETextEditorTypeUtils.GetSetContentScript(attributeName, "htmlContent")}
            {AlertUtils.Warning("敏感词检测", "共检测到' + i + '个敏感词,内容已用黄色背景标明", "取 消", string.Empty, string.Empty)}
		}} else {{
            {AlertUtils.Success("敏感词检测", "检测成功,没有检测到任何敏感词")}
        }}
	}});	
}}
</script>
<div class=""btn-group btn-group-sm"">
    <button class=""btn"" onclick=""{ModalTextEditorImportWord.GetOpenWindowString(siteInfo.Id, attributeName)}"">导入Word</button>
    <button class=""btn"" onclick=""{ModalTextEditorInsertImage.GetOpenWindowString(siteInfo.Id, attributeName)}"">插入图片</button>
    <button class=""btn"" onclick=""{ModalTextEditorInsertVideo.GetOpenWindowString(siteInfo.Id, attributeName)}"">插入视频</button>
    <button class=""btn"" onclick=""{ModalTextEditorInsertAudio.GetOpenWindowString(siteInfo.Id, attributeName)}"">插入音频</button>
    <button class=""btn"" onclick=""getWordSpliter();return false;"">提取关键字</button>
    <button class=""btn"" onclick=""detection_{attributeName}();return false;"">敏感词检测</button>
</div>
");
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
0
        public static string GetTextEditorCommands(PublishmentSystemInfo publishmentSystemInfo, string attributeName)
        {
            var builder = new StringBuilder();

            builder.Append(
                $@"<div class=""btn_word"" onclick=""{ModalTextEditorImportWord.GetOpenWindowString(
                    publishmentSystemInfo.PublishmentSystemId, attributeName)}"">导入Word</div>");

            builder.Append(
                $@"<div class=""btn_video"" onclick=""{ModalTextEditorInsertVideo.GetOpenWindowString(
                    publishmentSystemInfo.PublishmentSystemId, attributeName)}"">插入视频</div>");

            builder.Append(
                $@"<div class=""btn_audio"" onclick=""{ModalTextEditorInsertAudio.GetOpenWindowString(
                    publishmentSystemInfo.PublishmentSystemId, attributeName)}"">插入音频</div>");

            var command = @"<div class=""btn_keywords"" onclick=""getWordSpliter();"">提取关键字</div>
<script type=""text/javascript"">
function getWordSpliter(){
    var pureText = [getPureText]
	$.post('[url]&r=' + Math.random(), {content:pureText}, function(data) {
		if(data !=''){
			$('#Tags').val(data).focus();
		}else{
            [tips]
        }
	});	
}
</script>
";

            command = command.Replace("[url]", AjaxCmsService.GetWordSpliterUrl(publishmentSystemInfo.PublishmentSystemId));
            command = command.Replace("[getPureText]", ETextEditorTypeUtils.GetPureTextScript(attributeName));
            command = command.Replace("[tips]", PageUtils.GetOpenTipsString("对不起,内容不足,无法提取关键字", PageUtils.TipsError));

            builder.Append(command);

            command = @"<div class=""btn_detection"" onclick=""detection_[attributeName]();"">敏感词检测</div>
<script type=""text/javascript"">
function detection_[attributeName](){
    var pureText = [getPureText]
    var htmlContent = [getContent]
    var keyword = '';
	$.post('[url]&r=' + Math.random(), {content:pureText}, function(data) {
        debugger;
		if(data){
			var arr = data.split(',');
            var i=0;
			for(;i<arr.length;i++)
			{
                var reg = new RegExp(arr[i], 'gi');
				htmlContent = htmlContent.replace(reg,'<span style=""background-color:#ffff00;"">' + arr[i] + '</span>');
			}
            keyword=data;
			[setContent]
            [tips_warn]
		}else{
            [tips_success]
        }
	});	
}
</script>
";
            command = command.Replace("[attributeName]", attributeName);
            command = command.Replace("[url]", AjaxCmsService.GetDetectionUrl(publishmentSystemInfo.PublishmentSystemId));
            command = command.Replace("[getPureText]", ETextEditorTypeUtils.GetPureTextScript(attributeName));
            command = command.Replace("[getContent]", ETextEditorTypeUtils.GetContentScript(attributeName));
            command = command.Replace("[setContent]", ETextEditorTypeUtils.GetSetContentScript(attributeName, "htmlContent"));
            command = command.Replace("[tips_warn]", PageUtils.GetOpenTipsString("共检测到' + i + '个敏感词,内容已用黄色背景标明", PageUtils.TipsWarn));
            command = command.Replace("[tips_success]", PageUtils.GetOpenTipsString("检测成功,没有检测到任何敏感词", PageUtils.TipsSuccess));
            builder.Append(command);

            return(builder.ToString());
        }