private static async Task <object> ParseImplAsync(IParseManager parseManager, string type, string formatString, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, bool isReturnToBr, bool isLower, bool isUpper) { var pageInfo = parseManager.PageInfo; var contextInfo = parseManager.ContextInfo; if (string.IsNullOrEmpty(type)) { return(string.Empty); } string parsedContent; if (contextInfo.ContextType == ParseType.Each) { parsedContent = contextInfo.ItemContainer.EachItem.Value as string; return(parsedContent); } if (StringUtils.EqualsIgnoreCase(type, TypeDate)) { if (!pageInfo.BodyCodes.ContainsKey("datestring.js")) { var jsUrl = parseManager.PathManager.GetSiteFilesUrl(Resources.DateString.Js); pageInfo.BodyCodes.Add("datestring.js", $@"<script charset=""{Resources.DateString.Charset}"" src=""{jsUrl}"" type=""text/javascript""></script>"); } parsedContent = @"<script language=""javascript"" type=""text/javascript"">RunGLNL(false);</script>"; } else if (StringUtils.EqualsIgnoreCase(type, TypeDateOfTraditional)) { if (!pageInfo.BodyCodes.ContainsKey("datestring")) { var jsUrl = parseManager.PathManager.GetSiteFilesUrl(Resources.DateString.Js); pageInfo.BodyCodes.Add("datestring", $@"<script charset=""{Resources.DateString.Charset}"" src=""{jsUrl}"" type=""text/javascript""></script>"); } parsedContent = @"<script language=""javascript"" type=""text/javascript"">RunGLNL(true);</script>"; } else if (pageInfo.Parameters != null && pageInfo.Parameters.ContainsKey(type)) { pageInfo.Parameters.TryGetValue(type, out parsedContent); parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } else { return(await StlSite.ParseAsync(parseManager)); } return(parsedContent); }
private static async Task <object> ParseImplAsync(IParseManager parseManager, string type, string formatString, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, bool isReturnToBr, bool isLower, bool isUpper) { var pageInfo = parseManager.PageInfo; var contextInfo = parseManager.ContextInfo; if (string.IsNullOrEmpty(type)) { return(string.Empty); } var parsedContent = string.Empty; if (contextInfo.ContextType == ParseType.Each) { parsedContent = contextInfo.ItemContainer.EachItem.Value as string; return(parsedContent); } if (StringUtils.EqualsIgnoreCase(type, TypeDate)) { if (!pageInfo.BodyCodes.ContainsKey("datestring.js")) { var jsUrl = parseManager.PathManager.GetSiteFilesUrl(Resources.DateString.Js); pageInfo.BodyCodes.Add("datestring.js", $@"<script charset=""{Resources.DateString.Charset}"" src=""{jsUrl}"" type=""text/javascript""></script>"); } parsedContent = @"<script language=""javascript"" type=""text/javascript"">RunGLNL(false);</script>"; } else if (StringUtils.EqualsIgnoreCase(type, TypeDateOfTraditional)) { if (!pageInfo.BodyCodes.ContainsKey("datestring")) { var jsUrl = parseManager.PathManager.GetSiteFilesUrl(Resources.DateString.Js); pageInfo.BodyCodes.Add("datestring", $@"<script charset=""{Resources.DateString.Charset}"" src=""{jsUrl}"" type=""text/javascript""></script>"); } parsedContent = @"<script language=""javascript"" type=""text/javascript"">RunGLNL(true);</script>"; } else if (StringUtils.EqualsIgnoreCase(TypeRootUrl, type))//系统根目录地址 { parsedContent = parseManager.PathManager.ParseUrl("~"); if (!string.IsNullOrEmpty(parsedContent)) { parsedContent = parsedContent.TrimEnd('/'); } } else if (StringUtils.EqualsIgnoreCase(TypeApiUrl, type))//API地址 { parsedContent = parseManager.PathManager.GetRootUrl(); } else if (StringUtils.EqualsIgnoreCase(TypeSiteId, type))//ID { parsedContent = pageInfo.SiteId.ToString(); } else if (StringUtils.EqualsIgnoreCase(TypeSiteName, type))//名称 { parsedContent = pageInfo.Site.SiteName; } else if (StringUtils.EqualsIgnoreCase(TypeSiteUrl, type))//域名地址 { parsedContent = (await parseManager.PathManager.GetSiteUrlAsync(pageInfo.Site, pageInfo.IsLocal)).TrimEnd('/'); } else if (StringUtils.EqualsIgnoreCase(TypeSiteDir, type))//文件夹 { parsedContent = pageInfo.Site.SiteDir; } else if (StringUtils.EqualsIgnoreCase(TypeCurrentUrl, type))//当前页地址 { var contentInfo = await parseManager.GetContentAsync(); parsedContent = await StlParserUtility.GetStlCurrentUrlAsync(parseManager, pageInfo.Site, contextInfo.ChannelId, contextInfo.ContentId, contentInfo, pageInfo.Template.TemplateType, pageInfo.Template.Id, pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(TypeChannelUrl, type))//栏目页地址 { parsedContent = await parseManager.PathManager.GetChannelUrlAsync(pageInfo.Site, await parseManager.DatabaseManager.ChannelRepository.GetAsync(contextInfo.ChannelId), pageInfo.IsLocal); } else if (StringUtils.EqualsIgnoreCase(TypeHomeUrl, type))//用户中心地址 { parsedContent = parseManager.PathManager.GetHomeUrl(string.Empty).TrimEnd('/'); } else if (StringUtils.EqualsIgnoreCase(TypeLoginUrl, type)) { var contentInfo = await parseManager.GetContentAsync(); var returnUrl = await StlParserUtility.GetStlCurrentUrlAsync(parseManager, pageInfo.Site, contextInfo.ChannelId, contextInfo.ContentId, contentInfo, pageInfo.Template.TemplateType, pageInfo.Template.Id, pageInfo.IsLocal); parsedContent = parseManager.PathManager.GetHomeUrl($"pages/login.html?returnUrl={PageUtils.UrlEncode(returnUrl)}"); } else if (StringUtils.EqualsIgnoreCase(TypeLogoutUrl, type)) { var contentInfo = await parseManager.GetContentAsync(); var returnUrl = await StlParserUtility.GetStlCurrentUrlAsync(parseManager, pageInfo.Site, contextInfo.ChannelId, contextInfo.ContentId, contentInfo, pageInfo.Template.TemplateType, pageInfo.Template.Id, pageInfo.IsLocal); parsedContent = parseManager.PathManager.GetHomeUrl($"pages/logout.html?returnUrl={PageUtils.UrlEncode(returnUrl)}"); } else if (StringUtils.EqualsIgnoreCase(TypeRegisterUrl, type)) { var contentInfo = await parseManager.GetContentAsync(); var returnUrl = await StlParserUtility.GetStlCurrentUrlAsync(parseManager, pageInfo.Site, contextInfo.ChannelId, contextInfo.ContentId, contentInfo, pageInfo.Template.TemplateType, pageInfo.Template.Id, pageInfo.IsLocal); parsedContent = parseManager.PathManager.GetHomeUrl($"pages/register.html?returnUrl={PageUtils.UrlEncode(returnUrl)}"); } else if (StringUtils.StartsWithIgnoreCase(type, "TableFor"))// { if (StringUtils.EqualsIgnoreCase(type, "TableForContent")) { parsedContent = pageInfo.Site.TableName; } } else if (StringUtils.StartsWithIgnoreCase(type, "Site"))// { parsedContent = pageInfo.Site.Get <string>(type.Substring(4)); } else if (pageInfo.Parameters != null && pageInfo.Parameters.ContainsKey(type)) { pageInfo.Parameters.TryGetValue(type, out parsedContent); parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString); } else { return(await StlSite.ParseAsync(parseManager)); } return(parsedContent); }