public static string ParseTextEditor(PublishmentSystemInfo publishmentSystemInfo, string attributeName, NameValueCollection pageScripts, string defaultValue, string width, int height) { var value = defaultValue ?? string.Empty; /****获取编辑器中内容,解析@符号,添加了远程路径处理 20151103****/ value = StringUtility.TextEditorContentDecode(value, publishmentSystemInfo); value = ETextEditorTypeUtils.TranslateToHtml(value); value = StringUtils.HtmlEncode(value); var builder = new StringBuilder(); var controllerUrl = Controllers.Files.UEditor.GetUrl(publishmentSystemInfo.Additional.ApiUrl, publishmentSystemInfo.PublishmentSystemId); var editorUrl = SiteFilesAssets.GetUrl(publishmentSystemInfo.Additional.ApiUrl, "ueditor"); if (pageScripts["uEditor"] == null) { builder.Append( $@"<script type=""text/javascript"">window.UEDITOR_HOME_URL = ""{editorUrl}/"";window.UEDITOR_CONTROLLER_URL = ""{controllerUrl}"";</script><script type=""text/javascript"" src=""{editorUrl}/editor_config.js""></script><script type=""text/javascript"" src=""{editorUrl}/ueditor_all_min.js""></script>"); } pageScripts["uEditor"] = string.Empty; builder.Append($@" <textarea id=""{attributeName}"" name=""{attributeName}"" style=""display:none"">{value}</textarea> <script type=""text/javascript""> $(function(){{ UE.getEditor('{attributeName}', {{allowDivTransToP: false}}); $('#{attributeName}').show(); }}); </script>"); return(builder.ToString()); }
public override void Submit_OnClick(object sender, EventArgs e) { var fileNames = Request.Form["fileNames"]; if (!string.IsNullOrEmpty(fileNames)) { fileNames = fileNames.Trim('|'); var builder = new StringBuilder(); foreach (var fileName in fileNames.Split('|')) { var filePath = WordUtils.GetWordFilePath(fileName); var wordContent = WordUtils.Parse(SiteId, filePath, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked); wordContent = ContentUtility.TextEditorContentDecode(SiteInfo, wordContent, true); builder.Append(wordContent); FileUtils.DeleteFileIfExists(filePath); } var script = "parent." + ETextEditorTypeUtils.GetInsertHtmlScript(_attributeName, builder.ToString()); LayerUtils.CloseWithoutRefresh(Page, script); } else { FailMessage("请选择Word文件上传!"); } }
public static string ParseTextEditor(IAttributes attributes, string attributeName, SiteInfo siteInfo, NameValueCollection pageScripts, StringBuilder extraBuilder) { var value = attributes.GetString(attributeName); value = ContentUtility.TextEditorContentDecode(siteInfo, value, true); value = ETextEditorTypeUtils.TranslateToHtml(value); value = StringUtils.HtmlEncode(value); var controllerUrl = ApiRouteUEditor.GetUrl(PageUtility.OuterApiUrl, siteInfo.Id); var editorUrl = SiteFilesAssets.GetUrl(PageUtility.OuterApiUrl, "ueditor"); if (pageScripts["uEditor"] == null) { extraBuilder.Append( $@"<script type=""text/javascript"">window.UEDITOR_HOME_URL = ""{editorUrl}/"";window.UEDITOR_CONTROLLER_URL = ""{controllerUrl}"";</script><script type=""text/javascript"" src=""{editorUrl}/editor_config.js""></script><script type=""text/javascript"" src=""{editorUrl}/ueditor_all_min.js""></script>"); } pageScripts["uEditor"] = string.Empty; extraBuilder.Append($@" <script type=""text/javascript""> $(function(){{ UE.getEditor('{attributeName}', {{allowDivTransToP: false}}); $('#{attributeName}').show(); }}); </script>"); return($@"<textarea id=""{attributeName}"" name=""{attributeName}"" style=""display:none"">{value}</textarea>"); }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } if (CbIsSmallImage.Checked && string.IsNullOrEmpty(TbSmallImageWidth.Text) && string.IsNullOrEmpty(TbSmallImageHeight.Text)) { FailMessage("缩略图尺寸不能为空!"); return; } ConfigSettings(false); var scripts = string.Empty; var fileNames = TranslateUtils.StringCollectionToStringList(HihFilePaths.Value); foreach (var filePath in fileNames) { if (!string.IsNullOrEmpty(filePath)) { var fileName = PathUtils.GetFileName(filePath); var fileExtName = PathUtils.GetExtension(filePath).ToLower(); var localDirectoryPath = PathUtility.GetUploadDirectoryPath(SiteInfo, fileExtName); var imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, filePath, true); if (CbIsSmallImage.Checked) { var localSmallFileName = StringUtils.Constants.SmallImageAppendix + fileName; var localSmallFilePath = PathUtils.Combine(localDirectoryPath, localSmallFileName); var smallImageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localSmallFilePath, true); var width = TranslateUtils.ToInt(TbSmallImageWidth.Text); var height = TranslateUtils.ToInt(TbSmallImageHeight.Text); ImageUtils.MakeThumbnail(filePath, localSmallFilePath, width, height, true); var insertHtml = CbIsLinkToOriginal.Checked ? $@"<a href=""{imageUrl}"" target=""_blank""><img src=""{smallImageUrl}"" border=""0"" /></a>" : $@"<img src=""{smallImageUrl}"" border=""0"" />"; scripts += "if(parent." + ETextEditorTypeUtils.GetEditorInstanceScript() + ") parent." + ETextEditorTypeUtils.GetInsertHtmlScript("Content", insertHtml); } else { var insertHtml = $@"<img src=""{imageUrl}"" border=""0"" />"; scripts += "if(parent." + ETextEditorTypeUtils.GetEditorInstanceScript() + ") parent." + ETextEditorTypeUtils.GetInsertHtmlScript("Content", insertHtml); } } } LayerUtils.CloseWithoutRefresh(Page, scripts); }
public override void Submit_OnClick(object sender, EventArgs e) { var playUrl = TbPlayUrl.Text; var script = "parent." + ETextEditorTypeUtils.GetInsertAudioScript(_attributeName, playUrl, CbIsAutoPlay.Checked); PageUtils.CloseModalPageWithoutRefresh(Page, script); }
public static void SaveAttributes(IAttributes attributes, SiteInfo siteInfo, List <TableStyleInfo> styleInfoList, NameValueCollection formCollection, List <string> dontAddAttributesLowercase) { if (dontAddAttributesLowercase == null) { dontAddAttributesLowercase = new List <string>(); } foreach (var styleInfo in styleInfoList) { if (dontAddAttributesLowercase.Contains(styleInfo.AttributeName.ToLower())) { continue; } //var theValue = GetValueByForm(styleInfo, siteInfo, formCollection); var theValue = formCollection[styleInfo.AttributeName] ?? string.Empty; var inputType = styleInfo.InputType; if (inputType == InputType.TextEditor) { theValue = ContentUtility.TextEditorContentEncode(siteInfo, theValue); theValue = ETextEditorTypeUtils.TranslateToStlElement(theValue); } if (inputType != InputType.TextEditor && inputType != InputType.Image && inputType != InputType.File && inputType != InputType.Video && styleInfo.AttributeName != ContentAttribute.LinkUrl) { theValue = PageUtils.FilterSqlAndXss(theValue); } attributes.Set(styleInfo.AttributeName, theValue); //TranslateUtils.SetOrRemoveAttributeLowerCase(attributes, styleInfo.AttributeName, theValue); if (styleInfo.Additional.IsFormatString) { var formatString = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatStrong"]); var formatEm = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatEM"]); var formatU = TranslateUtils.ToBool(formCollection[styleInfo.AttributeName + "_formatU"]); var formatColor = formCollection[styleInfo.AttributeName + "_formatColor"]; var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor); attributes.Set(ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName), theFormatString); //TranslateUtils.SetOrRemoveAttributeLowerCase(attributes, ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName), theFormatString); } if (inputType == InputType.Image || inputType == InputType.File || inputType == InputType.Video) { var attributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName); attributes.Set(attributeName, formCollection[attributeName]); //TranslateUtils.SetOrRemoveAttributeLowerCase(attributes, attributeName, formCollection[attributeName]); } } }
private static string GetValueByForm(TableStyleInfo styleInfo, PublishmentSystemInfo publishmentSystemInfo, NameValueCollection formCollection, bool isSaveImage) { var theValue = formCollection[styleInfo.AttributeName] ?? string.Empty; var inputType = EInputTypeUtils.GetEnumType(styleInfo.InputType); if (inputType == EInputType.TextEditor) { theValue = StringUtility.TextEditorContentEncode(theValue, publishmentSystemInfo, isSaveImage && publishmentSystemInfo.Additional.IsSaveImageInTextEditor); theValue = ETextEditorTypeUtils.TranslateToStlElement(theValue); } return(theValue); }
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> "); }
public override void Submit_OnClick(object sender, EventArgs e) { var width = TranslateUtils.ToInt(TbWidth.Text); var height = TranslateUtils.ToInt(TbHeight.Text); if (width > 0 && height > 0 && (width != SiteInfo.Additional.ConfigVideoContentInsertWidth || height != SiteInfo.Additional.ConfigVideoContentInsertHeight)) { SiteInfo.Additional.ConfigVideoContentInsertWidth = width; SiteInfo.Additional.ConfigVideoContentInsertHeight = height; DataProvider.SiteDao.Update(SiteInfo); } var playUrl = TbPlayUrl.Text; var script = "parent." + ETextEditorTypeUtils.GetInsertVideoScript(_attributeName, playUrl, width, height, CbIsAutoPlay.Checked); LayerUtils.CloseWithoutRefresh(Page, script); }
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); }
public override void Submit_OnClick(object sender, EventArgs e) { if (CbIsTitleImage.Checked && string.IsNullOrEmpty(TbTitleImageWidth.Text) && string.IsNullOrEmpty(TbTitleImageHeight.Text)) { FailMessage("缩略图尺寸不能为空!"); return; } if (CbIsSmallImage.Checked && string.IsNullOrEmpty(TbSmallImageWidth.Text) && string.IsNullOrEmpty(TbSmallImageHeight.Text)) { FailMessage("缩略图尺寸不能为空!"); return; } ConfigSettings(false); if (HifUpload.PostedFile == null || "" == HifUpload.PostedFile.FileName) { return; } var filePath = HifUpload.PostedFile.FileName; try { var fileExtName = PathUtils.GetExtension(filePath).ToLower(); var localDirectoryPath = PathUtility.GetUploadDirectoryPath(SiteInfo, fileExtName); var localFileName = PathUtility.GetUploadFileName(SiteInfo, filePath); var localTitleFileName = StringUtils.Constants.TitleImageAppendix + localFileName; var localSmallFileName = StringUtils.Constants.SmallImageAppendix + localFileName; var localFilePath = PathUtils.Combine(localDirectoryPath, localFileName); var localTitleFilePath = PathUtils.Combine(localDirectoryPath, localTitleFileName); var localSmallFilePath = PathUtils.Combine(localDirectoryPath, localSmallFileName); if (!PathUtility.IsImageExtenstionAllowed(SiteInfo, fileExtName)) { FailMessage("上传失败,上传图片格式不正确!"); return; } if (!PathUtility.IsImageSizeAllowed(SiteInfo, HifUpload.PostedFile.ContentLength)) { FailMessage("上传失败,上传图片超出规定文件大小!"); return; } HifUpload.PostedFile.SaveAs(localFilePath); var isImage = EFileSystemTypeUtils.IsImage(fileExtName); //处理上半部分 if (isImage) { FileUtility.AddWaterMark(SiteInfo, localFilePath); if (CbIsTitleImage.Checked) { var width = TranslateUtils.ToInt(TbTitleImageWidth.Text); var height = TranslateUtils.ToInt(TbTitleImageHeight.Text); ImageUtils.MakeThumbnail(localFilePath, localTitleFilePath, width, height, true); } } var imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localFilePath, true); if (CbIsTitleImage.Checked) { imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localTitleFilePath, true); } var textBoxUrl = PageUtility.GetVirtualUrl(SiteInfo, imageUrl); var script = $@" if (parent.document.getElementById('{_textBoxClientId}')) {{ parent.document.getElementById('{_textBoxClientId}').value = '{textBoxUrl}'; }} "; //处理下半部分 if (CbIsShowImageInTextEditor.Checked && isImage) { imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localFilePath, true); var smallImageUrl = imageUrl; if (CbIsSmallImage.Checked) { smallImageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localSmallFilePath, true); } if (CbIsSmallImage.Checked) { var width = TranslateUtils.ToInt(TbSmallImageWidth.Text); var height = TranslateUtils.ToInt(TbSmallImageHeight.Text); ImageUtils.MakeThumbnail(localFilePath, localSmallFilePath, width, height, true); } var insertHtml = CbIsLinkToOriginal.Checked ? $@"<a href=""{imageUrl}"" target=""_blank""><img src=""{smallImageUrl}"" border=""0"" /></a>" : $@"<img src=""{smallImageUrl}"" border=""0"" />"; script += "if(parent." + ETextEditorTypeUtils.GetEditorInstanceScript() + ") parent." + ETextEditorTypeUtils.GetInsertHtmlScript("Content", insertHtml); } LtlScript.Text = $@" <script type=""text/javascript"" language=""javascript""> {script} {LayerUtils.CloseScript} </script>"; } catch (Exception ex) { FailMessage(ex, ex.Message); } }
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()); }
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()); }
public override void Submit_OnClick(object sender, EventArgs e) { if (cbIsTitleImage.Checked && string.IsNullOrEmpty(tbTitleImageWidth.Text) && string.IsNullOrEmpty(tbTitleImageHeight.Text)) { FailMessage("缩略图尺寸不能为空!"); return; } if (cbIsSmallImage.Checked && string.IsNullOrEmpty(tbSmallImageWidth.Text) && string.IsNullOrEmpty(tbSmallImageHeight.Text)) { FailMessage("缩略图尺寸不能为空!"); return; } ConfigSettings(false); if (hifUpload.PostedFile != null && "" != hifUpload.PostedFile.FileName) { var filePath = hifUpload.PostedFile.FileName; try { var fileExtName = PathUtils.GetExtension(filePath).ToLower(); var localDirectoryPath = PathUtility.GetUploadDirectoryPath(PublishmentSystemInfo, fileExtName); var localFileName = PathUtility.GetUploadFileName(PublishmentSystemInfo, filePath); var localTitleFileName = StringUtils.Constants.TitleImageAppendix + localFileName; var localSmallFileName = StringUtils.Constants.SmallImageAppendix + localFileName; var localFilePath = PathUtils.Combine(localDirectoryPath, localFileName); var localTitleFilePath = PathUtils.Combine(localDirectoryPath, localTitleFileName); var localSmallFilePath = PathUtils.Combine(localDirectoryPath, localSmallFileName); if (!PathUtility.IsImageExtenstionAllowed(PublishmentSystemInfo, fileExtName)) { FailMessage("上传失败,上传图片格式不正确!"); return; } if (!PathUtility.IsImageSizeAllowed(PublishmentSystemInfo, hifUpload.PostedFile.ContentLength)) { FailMessage("上传失败,上传图片超出规定文件大小!"); return; } hifUpload.PostedFile.SaveAs(localFilePath); var isImage = EFileSystemTypeUtils.IsImage(fileExtName); //处理上半部分 if (isImage) { FileUtility.AddWaterMark(PublishmentSystemInfo, localFilePath); if (cbIsTitleImage.Checked) { var width = TranslateUtils.ToInt(tbTitleImageWidth.Text); var height = TranslateUtils.ToInt(tbTitleImageHeight.Text); ImageUtils.MakeThumbnail(localFilePath, localTitleFilePath, width, height, cbIsTitleImageLessSizeNotThumb.Checked); } } var imageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo, localFilePath); if (cbIsTitleImage.Checked) { imageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo, localTitleFilePath); } var textBoxUrl = PageUtility.GetVirtualUrl(PublishmentSystemInfo, imageUrl); ltlScript.Text += $@" if (parent.document.getElementById('{_textBoxClientId}')) {{ parent.document.getElementById('{_textBoxClientId}').value = '{textBoxUrl}'; }} "; //处理下半部分 if (cbIsShowImageInTextEditor.Checked && isImage) { imageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo, localFilePath); var smallImageUrl = imageUrl; if (cbIsSmallImage.Checked) { smallImageUrl = PageUtility.GetPublishmentSystemUrlByPhysicalPath(PublishmentSystemInfo, localSmallFilePath); } if (cbIsSmallImage.Checked) { var width = TranslateUtils.ToInt(tbSmallImageWidth.Text); var height = TranslateUtils.ToInt(tbSmallImageHeight.Text); ImageUtils.MakeThumbnail(localFilePath, localSmallFilePath, width, height, cbIsSmallImageLessSizeNotThumb.Checked); } var insertHtml = string.Empty; if (cbIsLinkToOriginal.Checked) { insertHtml = $@"<a href=""{imageUrl}"" target=""_blank""><img src=""{smallImageUrl}"" border=""0"" /></a>"; } else { insertHtml = $@"<img src=""{smallImageUrl}"" border=""0"" />"; } ltlScript.Text += "if(parent." + ETextEditorTypeUtils.GetEditorInstanceScript() + ") parent." + ETextEditorTypeUtils.GetInsertHtmlScript("Content", insertHtml); } ltlScript.Text += PageUtils.HidePopWin; } catch (Exception ex) { FailMessage(ex, ex.Message); } } }