public async Task <Content> DecodeContentAsync(Site site, Channel channel, Content content) { content = content.Clone <Content>(); var tableStyles = await _tableStyleRepository.GetContentStylesAsync(site, channel); foreach (var style in tableStyles) { if (style.InputType == InputType.Image || style.InputType == InputType.Video || style.InputType == InputType.File) { var countName = ColumnsManager.GetCountName(style.AttributeName); var count = content.Get <int>(countName); for (var i = 0; i <= count; i++) { var extendName = ColumnsManager.GetExtendName(style.AttributeName, i); var value = content.Get <string>(extendName); value = await ParseSiteUrlAsync(site, value, false); content.Set(extendName, value); } } else if (style.InputType == InputType.TextEditor) { var value = content.Get <string>(style.AttributeName); value = await DecodeTextEditorAsync(site, value, true); value = UEditorUtils.TranslateToHtml(value); content.Set(style.AttributeName, value); } } return(content); }
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 = UEditorUtils.TranslateToHtml(value); value = StringUtils.HtmlEncode(value); var controllerUrl = ApiRouteUEditor.GetUrl(ApiManager.InnerApiUrl, siteInfo.Id); var editorUrl = SiteServerAssets.GetUrl("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}', {UEditorUtils.ConfigValues}); $('#{attributeName}').show(); }}); </script>"); return($@"<textarea id=""{attributeName}"" name=""{attributeName}"" style=""display:none"">{value}</textarea>"); }
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 = PathUtils.GetTemporaryFilesPath(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." + UEditorUtils.GetInsertHtmlScript(_attributeName, builder.ToString()); LayerUtils.CloseWithoutRefresh(Page, script); } else { FailMessage("请选择Word文件上传!"); } }
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 = 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." + UEditorUtils.GetEditorInstanceScript() + ") parent." + UEditorUtils.GetInsertHtmlScript("Content", insertHtml); } else { var insertHtml = $@"<img src=""{imageUrl}"" border=""0"" />"; scripts += "if(parent." + UEditorUtils.GetEditorInstanceScript() + ") parent." + UEditorUtils.GetInsertHtmlScript("Content", insertHtml); } } } LayerUtils.CloseWithoutRefresh(Page, scripts); }
public static string GetTextEditorCommands(SiteInfo siteInfo, int channelId, string attributeName) { var url = $"editorLayerImage.cshtml?siteId={siteInfo.Id}&channelId={channelId}&attributeName={attributeName}"; var insertImage = $@"utils.openLayer({{title: '插入图片', url: '{url}', width: 700, height: 500}});return false;"; url = $"editorLayerText.cshtml?siteId={siteInfo.Id}&channelId={channelId}&attributeName={attributeName}"; var insertText = $@"utils.openLayer({{title: '插入图文', url: '{url}', full: true}});return false;"; return($@" <script type=""text/javascript""> function getWordSpliter(){{ var pureText = {UEditorUtils.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(); $vue.tagNames = data.split(' '); location.hash = '#tagNames'; }}else{{ {AlertUtils.Error("提取关键字", "对不起,内容不足,无法提取关键字")} }} }}); }} function detection_{attributeName}(){{ var pureText = {UEditorUtils.GetPureTextScript(attributeName)} var htmlContent = {UEditorUtils.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; {UEditorUtils.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=""{insertImage}"">插入图片</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=""{insertText}"">插入图文</button> <button class=""btn"" onclick=""getWordSpliter();return false;"">提取关键字</button> <button class=""btn"" onclick=""detection_{attributeName}();return false;"">敏感词检测</button> </div> "); // <button class=""btn"" onclick=""{ModalTextEditorInsertImage.GetOpenWindowString(siteInfo.Id, attributeName)}"">插入图片</button> }
public async Task <ActionResult <BoolResult> > Submit([FromBody] SubmitRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.SettingsSite)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); var styles = await GetInputStylesAsync(request.SiteId); foreach (var style in styles) { var inputType = style.InputType; if (inputType == InputType.TextEditor) { var value = request.Get(style.AttributeName, string.Empty); value = await _pathManager.EncodeTextEditorAsync(site, value); value = UEditorUtils.TranslateToStlElement(value); site.Set(style.AttributeName, value); } else if (inputType == InputType.Image || inputType == InputType.Video || inputType == InputType.File) { var count = request.Get(ColumnsManager.GetCountName(style.AttributeName), 0); site.Set(ColumnsManager.GetCountName(style.AttributeName), count); for (var n = 0; n <= count; n++) { site.Set(ColumnsManager.GetExtendName(style.AttributeName, n), request.Get(ColumnsManager.GetExtendName(style.AttributeName, n), string.Empty)); } } else if (inputType == InputType.CheckBox || style.InputType == InputType.SelectMultiple) { var list = request.Get <List <object> >(style.AttributeName); site.Set(style.AttributeName, ListUtils.ToString(list)); } else { var value = request.Get(style.AttributeName, string.Empty); site.Set(style.AttributeName, value); } } await _siteRepository.UpdateAsync(site); await _authManager.AddSiteLogAsync(request.SiteId, "修改站点设置"); return(new BoolResult { Value = true }); }
public static string GetTextEditorCommands(SiteInfo siteInfo, string attributeName) { return($@" <script type=""text/javascript""> function getWordSpliter(){{ var pureText = {UEditorUtils.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 = {UEditorUtils.GetPureTextScript(attributeName)} var htmlContent = {UEditorUtils.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; {UEditorUtils.GetSetContentScript(attributeName, "htmlContent")} {AlertUtils.Warning("敏感词检测", "共检测到' + i + '个敏感词,内容已用黄色背景标明", "取 消", string.Empty, string.Empty)} }} else {{ {AlertUtils.Success("敏感词检测", "检测成功,没有检测到任何敏感词")} }} }}); }} </script> <div class="" ""> <button class=""btn"" onclick=""{ModalTextEditorImportWord.GetOpenWindowString(siteInfo.Id, attributeName)}"">导入Word</button> <button class=""btn"" onclick=""{ModalTextEditorInsertImage.GetOpenWindowString(siteInfo.Id, attributeName)}"">插入图片</button> <button style='display:none;'class=""btn"" onclick=""{ModalTextEditorInsertVideo.GetOpenWindowString(siteInfo.Id, attributeName)}"">插入视频</button> <button style='display:none;' 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> "); ////modify on 2019/1/27 }
public static Dictionary <string, object> SaveAttributes(SiteInfo siteInfo, List <TableStyleInfo> styleInfoList, NameValueCollection formCollection, List <string> dontAddAttributes) { var dict = new Dictionary <string, object>(); if (dontAddAttributes == null) { dontAddAttributes = new List <string>(); } foreach (var styleInfo in styleInfoList) { if (StringUtils.ContainsIgnoreCase(dontAddAttributes, styleInfo.AttributeName)) { 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 = UEditorUtils.TranslateToStlElement(theValue); } if (inputType != InputType.TextEditor && inputType != InputType.Image && inputType != InputType.File && inputType != InputType.Video && styleInfo.AttributeName != ContentAttribute.LinkUrl) { theValue = AttackUtils.FilterXss(theValue); } dict[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); dict[ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName)] = theFormatString; } if (inputType == InputType.Image || inputType == InputType.File || inputType == InputType.Video) { var attributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName); dict[attributeName] = formCollection[attributeName]; } } return(dict); }
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 = UEditorUtils.TranslateToStlElement(theValue); } if (inputType != InputType.TextEditor && inputType != InputType.Image && inputType != InputType.File && inputType != InputType.Video && styleInfo.AttributeName != ContentAttribute.LinkUrl) { theValue = AttackUtils.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]); } } }
public override void Submit_OnClick(object sender, EventArgs e) { var playUrl = TbPlayUrl.Text; var isAutoPlay = CbIsAutoPlay.Checked; if (isAutoPlay != SiteInfo.Additional.ConfigUEditorAudioIsAutoPlay) { SiteInfo.Additional.ConfigUEditorAudioIsAutoPlay = isAutoPlay; DataProvider.SiteDao.Update(SiteInfo); } var script = "parent." + UEditorUtils.GetInsertAudioScript(_attributeName, playUrl, SiteInfo); LayerUtils.CloseWithoutRefresh(Page, script); }
public override void Submit_OnClick(object sender, EventArgs e) { var playUrl = TbPlayUrl.Text; var isImageUrl = CbIsImageUrl.Checked; var isAutoPlay = CbIsAutoPlay.Checked; var isWidth = CbIsWidth.Checked; var isHeight = CbIsHeight.Checked; var playBy = DdlPlayBy.SelectedValue; var imageUrl = TbImageUrl.Text; var width = TranslateUtils.ToInt(TbWidth.Text); var height = TranslateUtils.ToInt(TbHeight.Text); if (isImageUrl && string.IsNullOrEmpty(imageUrl)) { FailMessage("请上传视频封面图片"); return; } if (isImageUrl != SiteInfo.Additional.ConfigUEditorVideoIsImageUrl || isAutoPlay != SiteInfo.Additional.ConfigUEditorVideoIsAutoPlay || isWidth != SiteInfo.Additional.ConfigUEditorVideoIsWidth || isHeight != SiteInfo.Additional.ConfigUEditorVideoIsHeight || playBy != SiteInfo.Additional.ConfigUEditorVideoPlayBy || width != SiteInfo.Additional.ConfigUEditorVideoWidth || height != SiteInfo.Additional.ConfigUEditorVideoHeight) { SiteInfo.Additional.ConfigUEditorVideoIsImageUrl = isImageUrl; SiteInfo.Additional.ConfigUEditorVideoIsAutoPlay = isAutoPlay; SiteInfo.Additional.ConfigUEditorVideoIsWidth = isWidth; SiteInfo.Additional.ConfigUEditorVideoIsHeight = isHeight; SiteInfo.Additional.ConfigUEditorVideoPlayBy = playBy; SiteInfo.Additional.ConfigUEditorVideoWidth = width; SiteInfo.Additional.ConfigUEditorVideoHeight = height; DataProvider.SiteDao.Update(SiteInfo); } var script = "parent." + UEditorUtils.GetInsertVideoScript(_attributeName, playUrl, imageUrl, SiteInfo); LayerUtils.CloseWithoutRefresh(Page, script); }
public async Task <ActionResult <List <int> > > Edit([FromBody] PutRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.Channels)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(NotFound()); } if (string.IsNullOrEmpty(request.ChannelName)) { return(this.Error("栏目修改失败,必须填写栏目名称!")); } var channel = await _channelRepository.GetAsync(request.Id); if (!StringUtils.Equals(channel.IndexName, request.IndexName) && !string.IsNullOrEmpty(request.IndexName)) { if (await _channelRepository.IsIndexNameExistsAsync(request.SiteId, request.IndexName)) { return(this.Error("栏目修改失败,栏目索引已存在!")); } } if (!StringUtils.Equals(channel.FilePath, request.FilePath) && !string.IsNullOrEmpty(request.FilePath)) { if (!DirectoryUtils.IsDirectoryNameCompliant(request.FilePath)) { return(this.Error("栏目页面路径不符合系统要求!")); } if (PathUtils.IsDirectoryPath(request.FilePath)) { request.FilePath = PageUtils.Combine(request.FilePath, "index.html"); } if (await _channelRepository.IsFilePathExistsAsync(request.SiteId, request.FilePath)) { return(this.Error("栏目修改失败,栏目页面路径已存在!")); } } if (!string.IsNullOrEmpty(request.ChannelFilePathRule)) { var filePathRule = request.ChannelFilePathRule.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { return(this.Error("栏目页面命名规则不符合系统要求!")); } if (PathUtils.IsDirectoryPath(filePathRule)) { return(this.Error("栏目页面命名规则必须包含生成文件的后缀!")); } } if (!string.IsNullOrEmpty(request.ContentFilePathRule)) { var filePathRule = request.ContentFilePathRule.Replace("|", string.Empty); if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule)) { return(this.Error("内容页面命名规则不符合系统要求!")); } if (PathUtils.IsDirectoryPath(filePathRule)) { return(this.Error("内容页面命名规则必须包含生成文件的后缀!")); } } var styles = await GetInputStylesAsync(channel); foreach (var style in styles) { var inputType = style.InputType; if (inputType == InputType.TextEditor) { var value = request.Get(style.AttributeName, string.Empty); value = await _pathManager.EncodeTextEditorAsync(site, value); value = UEditorUtils.TranslateToStlElement(value); channel.Set(style.AttributeName, value); } else if (inputType == InputType.Image || inputType == InputType.Video || inputType == InputType.File) { var count = request.Get(ColumnsManager.GetCountName(style.AttributeName), 0); channel.Set(ColumnsManager.GetCountName(style.AttributeName), count); for (var n = 0; n <= count; n++) { channel.Set(ColumnsManager.GetExtendName(style.AttributeName, n), request.Get(ColumnsManager.GetExtendName(style.AttributeName, n), string.Empty)); } } else if (inputType == InputType.CheckBox || style.InputType == InputType.SelectMultiple) { var list = request.Get <List <object> >(style.AttributeName); channel.Set(style.AttributeName, ListUtils.ToString(list)); } else { var value = request.Get(style.AttributeName, string.Empty); channel.Set(style.AttributeName, value); } } channel.ChannelName = request.ChannelName; channel.IndexName = request.IndexName; channel.GroupNames = request.GroupNames; //channel.Content = request.Content; channel.ChannelTemplateId = request.ChannelTemplateId; channel.ContentTemplateId = request.ContentTemplateId; channel.LinkUrl = request.LinkUrl; channel.LinkType = request.LinkType; channel.DefaultTaxisType = request.DefaultTaxisType; channel.FilePath = request.FilePath; channel.ChannelFilePathRule = request.ChannelFilePathRule; channel.ContentFilePathRule = request.ContentFilePathRule; channel.Keywords = request.Keywords; channel.Description = request.Description; await _channelRepository.UpdateAsync(channel); var expendedChannelIds = new List <int> { request.SiteId }; if (!expendedChannelIds.Contains(channel.ParentId)) { expendedChannelIds.Add(channel.ParentId); } return(expendedChannelIds); }
public async Task <ActionResult <ChannelResult> > Get(int siteId, int channelId) { if (!await _authManager.HasSitePermissionsAsync(siteId, MenuUtils.SitePermissions.Channels)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(siteId); if (site == null) { return(NotFound()); } var channel = await _channelRepository.GetAsync(channelId); var styles = await GetStylesAsync(channel); var entity = new Entity(channel.ToDictionary()); foreach (var style in styles) { if (style.InputType == InputType.Image || style.InputType == InputType.Video || style.InputType == InputType.File) { var count = channel.Get(ColumnsManager.GetCountName(style.AttributeName), 0); entity.Set(ColumnsManager.GetCountName(style.AttributeName), count); for (var n = 0; n <= count; n++) { var extendName = ColumnsManager.GetExtendName(style.AttributeName, n); entity.Set(extendName, channel.Get(extendName)); } } else if (style.InputType == InputType.CheckBox || style.InputType == InputType.SelectMultiple) { var list = ListUtils.GetStringList(channel.Get(style.AttributeName, string.Empty)); entity.Set(style.AttributeName, list); } else if (style.InputType == InputType.TextEditor) { var value = channel.Get(style.AttributeName, string.Empty); value = await _pathManager.DecodeTextEditorAsync(site, value, true); value = UEditorUtils.TranslateToHtml(value); entity.Set(style.AttributeName, value); } else { entity.Set(style.AttributeName, channel.Get(style.AttributeName)); } } var filePath = channel.FilePath; var channelFilePathRule = channel.ChannelFilePathRule; var contentFilePathRule = channel.ContentFilePathRule; return(new ChannelResult { Entity = entity, Styles = styles, FilePath = filePath, ChannelFilePathRule = channelFilePathRule, ContentFilePathRule = contentFilePathRule }); }
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 = Constants.TitleImageAppendix + localFileName; var localSmallFileName = 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." + UEditorUtils.GetEditorInstanceScript() + ") parent." + UEditorUtils.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(SiteInfo siteInfo) { var isAutoCheckKeywords = siteInfo.Additional.IsAutoCheckKeywords.ToString().ToLower(); var url = AjaxCmsService.GetDetectionReplaceUrl(siteInfo.Id); var getPureText = UEditorUtils.GetPureTextScript(BackgroundContentAttribute.Content); var getContent = UEditorUtils.GetContentScript(BackgroundContentAttribute.Content); var setContent = UEditorUtils.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); }