Ejemplo n.º 1
0
        public static string GetInsertVideoScript(string attributeName, string playUrl, string imageUrl, SiteInfo siteInfo)
        {
            if (string.IsNullOrEmpty(playUrl))
            {
                return(string.Empty);
            }

            var dict = new Dictionary <string, string>
            {
                { StlPlayer.PlayUrl, playUrl },
                { StlPlayer.IsAutoPlay, siteInfo.Additional.ConfigUEditorVideoIsAutoPlay.ToString() },
                { StlPlayer.PlayBy, siteInfo.Additional.ConfigUEditorVideoPlayBy },
                { "style", "width: 333px; height: 333px;" }
            };

            if (siteInfo.Additional.ConfigUEditorVideoIsImageUrl && !string.IsNullOrEmpty(imageUrl))
            {
                dict.Add(StlPlayer.ImageUrl, imageUrl);
            }
            if (siteInfo.Additional.ConfigUEditorVideoIsWidth)
            {
                dict.Add(StlPlayer.Width, siteInfo.Additional.ConfigUEditorVideoWidth.ToString());
            }
            if (siteInfo.Additional.ConfigUEditorVideoIsHeight)
            {
                dict.Add(StlPlayer.Height, siteInfo.Additional.ConfigUEditorVideoHeight.ToString());
            }

            return(GetInsertHtmlScript(attributeName,
                                       $@"<img {StlPlayer.EditorPlaceHolder} {TranslateUtils.ToAttributesString(dict)} />"));
        }
Ejemplo n.º 2
0
        public string GetFileHtmlWithoutCount(Site site, string fileUrl, NameValueCollection attributes, string innerHtml, bool isStlEntity, bool isLower, bool isUpper)
        {
            if (site == null || string.IsNullOrEmpty(fileUrl))
            {
                return(string.Empty);
            }

            string retVal;

            if (isStlEntity)
            {
                retVal = _pathManager.GetDownloadApiUrl(site.Id, fileUrl);
            }
            else
            {
                var linkAttributes = new NameValueCollection();
                TranslateUtils.AddAttributesIfNotExists(linkAttributes, attributes);
                linkAttributes["href"] = _pathManager.GetDownloadApiUrl(site.Id, fileUrl);
                innerHtml = string.IsNullOrEmpty(innerHtml) ? PageUtils.GetFileNameFromUrl(fileUrl) : innerHtml;

                if (isLower)
                {
                    innerHtml = StringUtils.ToLower(innerHtml);
                }
                if (isUpper)
                {
                    innerHtml = StringUtils.ToUpper(innerHtml);
                }

                retVal = $@"<a {TranslateUtils.ToAttributesString(linkAttributes)}>{innerHtml}</a>";
            }

            return(retVal);
        }
Ejemplo n.º 3
0
        public static void RewriteSubmitButton(StringBuilder builder, string clickString)
        {
            var submitElement = GetHtmlElementBySRole(builder.ToString(), "submit");

            if (string.IsNullOrEmpty(submitElement))
            {
                submitElement = GetHtmlElementById(builder.ToString(), "submit");
            }
            if (!string.IsNullOrEmpty(submitElement))
            {
                var     document    = StlParserUtility.GetXmlDocument(submitElement, false);
                XmlNode elementNode = document.DocumentElement;
                if (elementNode != null)
                {
                    elementNode = elementNode.FirstChild;
                    if (elementNode.Attributes != null)
                    {
                        var elementIe  = elementNode.Attributes.GetEnumerator();
                        var attributes = new StringDictionary();
                        while (elementIe.MoveNext())
                        {
                            var attr          = (XmlAttribute)elementIe.Current;
                            var attributeName = attr.Name.ToLower();
                            if (attributeName == "href")
                            {
                                attributes.Add(attr.Name, PageUtils.UnclickedUrl);
                            }
                            else if (attributeName != "onclick")
                            {
                                attributes.Add(attr.Name, attr.Value);
                            }
                        }
                        attributes.Add("onclick", clickString);
                        attributes.Remove("id");
                        attributes.Remove("name");

                        //attributes.Add("id", "submit_" + styleID);

                        if (StringUtils.EqualsIgnoreCase(elementNode.Name, "a"))
                        {
                            attributes.Remove("href");
                            attributes.Add("href", PageUtils.UnclickedUrl);
                        }

                        if (!string.IsNullOrEmpty(elementNode.InnerXml))
                        {
                            builder.Replace(submitElement,
                                            $@"<{elementNode.Name} {TranslateUtils.ToAttributesString(attributes)}>{elementNode.InnerXml}</{elementNode
                                    .Name}>");
                        }
                        else
                        {
                            builder.Replace(submitElement,
                                            $@"<{elementNode.Name} {TranslateUtils.ToAttributesString(attributes)}/>");
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 protected void AddOptionalAttributes(NameValueCollection attributes)
 {
     if (attributes != null && attributes.Count > 0)
     {
         _sb.Append(" ");
         _sb.Append(TranslateUtils.ToAttributesString(attributes));
     }
     _sb.Append(">");
 }
Ejemplo n.º 5
0
        private static async Task <string> ParseAsync(IParseManager parseManager, string type, string elementId, string callback, NameValueCollection attributes)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;

            var parsedContent = string.Empty;

            if (string.IsNullOrEmpty(elementId))
            {
                elementId        = StringUtils.GetElementId();
                attributes["id"] = elementId;

                var html = string.Empty;
                if (!string.IsNullOrEmpty(contextInfo.InnerHtml))
                {
                    var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                    await parseManager.ParseInnerContentAsync(innerBuilder);

                    html = innerBuilder.ToString();
                }

                parsedContent = $@"<span {TranslateUtils.ToAttributesString(attributes)}>{html}</span>";
            }

            var builder = new StringBuilder();

            builder.Append($@"
<script type=""text/javascript"" language=""javascript"">
$(document).ready(function(){{
    try
    {{
        var queryString = document.location.search;
        if (queryString == null || queryString.length <= 1) return;
        var reg = new RegExp(""(^|&){type}=([^&]*)(&|$)""); 
        var r = queryString.substring(1).match(reg);
        var v = decodeURI(decodeURI(r[2]));
        if (r) $(""#{elementId}"").text(v);");

            if (!string.IsNullOrEmpty(callback))
            {
                builder.Append($@"{callback}(v);");
            }

            builder.Append(@"
    }catch(e){}
});
</script>
");

            if (!pageInfo.FootCodes.ContainsKey($"{ElementName}_{elementId}"))
            {
                pageInfo.FootCodes.Add($"{ElementName}_{elementId}", builder.ToString());
            }

            return(parsedContent);
        }
Ejemplo n.º 6
0
        public static string GetStlElement(string stlElementName, NameValueCollection attributes, string innerContent)
        {
            if (string.IsNullOrEmpty(innerContent))
            {
                return($@"<{stlElementName} {TranslateUtils.ToAttributesString(attributes)}></{stlElementName}>");
            }
            return($@"<{stlElementName} {TranslateUtils.ToAttributesString(attributes)}>
{innerContent}
</{stlElementName}>");
        }
Ejemplo n.º 7
0
        public override string ToString()
        {
            var attributes = TranslateUtils.ToAttributesString(Attributes);

            if (!string.IsNullOrEmpty(attributes))
            {
                attributes = " " + attributes;
            }
            return($"<{Name}{attributes}>{InnerHtml}</{Name}>");
        }
Ejemplo n.º 8
0
        public async Task <string> GetImageOrFlashHtmlAsync(Site site, string imageUrl, NameValueCollection attributes, bool isStlEntity)
        {
            var retVal = string.Empty;

            if (!string.IsNullOrEmpty(imageUrl))
            {
                imageUrl = await _pathManager.ParseSiteUrlAsync(site, imageUrl, false);

                if (isStlEntity)
                {
                    retVal = imageUrl;
                }
                else
                {
                    if (!imageUrl.ToUpper().Trim().EndsWith(".SWF"))
                    {
                        var imageAttributes = new NameValueCollection();
                        TranslateUtils.AddAttributesIfNotExists(imageAttributes, attributes);
                        imageAttributes["src"] = imageUrl;

                        retVal = $@"<img {TranslateUtils.ToAttributesString(imageAttributes)}>";
                    }
                    else
                    {
                        var width  = 100;
                        var height = 100;
                        if (attributes != null)
                        {
                            if (!string.IsNullOrEmpty(attributes["width"]))
                            {
                                width = TranslateUtils.ToInt(attributes["width"]);
                            }
                            if (!string.IsNullOrEmpty(attributes["height"]))
                            {
                                height = TranslateUtils.ToInt(attributes["height"]);
                            }
                        }
                        retVal = $@"
<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"" width=""{width}"" height=""{height}"">
                <param name=""movie"" value=""{imageUrl}"">
                <param name=""quality"" value=""high"">
                <param name=""wmode"" value=""transparent"">
                <embed src=""{imageUrl}"" width=""{width}"" height=""{height}"" quality=""high"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" type=""application/x-shockwave-flash"" wmode=""transparent""></embed></object>
";
                    }
                }
            }
            return(retVal);
        }
Ejemplo n.º 9
0
        private static async Task <string> ParseAsync(IParseManager parseManager, NameValueCollection attributes, string zoomId, int fontSize)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;

            if (string.IsNullOrEmpty(zoomId))
            {
                zoomId = "content";
            }

            if (!pageInfo.BodyCodes.ContainsKey(ParsePage.Const.JsAeStlZoom))
            {
                pageInfo.BodyCodes.Add(ParsePage.Const.JsAeStlZoom, @"
<script language=""JavaScript"" type=""text/javascript"">
function stlDoZoom(zoomId, size){
    var artibody = document.getElementById(zoomId);
    if(!artibody){
        return;
    }
    var artibodyChild = artibody.childNodes;
    artibody.style.fontSize = size + 'px';
    for(var i = 0; i < artibodyChild.length; i++){
        if(artibodyChild[i].nodeType == 1){
            artibodyChild[i].style.fontSize = size + 'px';
        }
    }
}
</script>
");
            }

            string innerHtml;

            if (string.IsNullOrEmpty(contextInfo.InnerHtml))
            {
                innerHtml = "缩放";
            }
            else
            {
                var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                await parseManager.ParseInnerContentAsync(innerBuilder);

                innerHtml = innerBuilder.ToString();
            }

            attributes["href"] = $"javascript:stlDoZoom('{zoomId}', {fontSize});";

            return($@"<a {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</a>");
        }
Ejemplo n.º 10
0
        public static string ReWriteOnClick(string originalHtml, string id, string clickString)
        {
            var rewriteHtml   = originalHtml;
            var submitElement = GetStlInputElementByID(rewriteHtml, id);

            if (!string.IsNullOrEmpty(submitElement))
            {
                var     document    = StlParserUtility.GetXmlDocument(submitElement, false);
                XmlNode elementNode = document.DocumentElement;
                elementNode = elementNode.FirstChild;
                var elementIE  = elementNode.Attributes.GetEnumerator();
                var attributes = new StringDictionary();
                while (elementIE.MoveNext())
                {
                    var attr          = (XmlAttribute)elementIE.Current;
                    var attributeName = attr.Name.ToLower();
                    if (attributeName == "href")
                    {
                        attributes.Add(attr.Name, PageUtils.UnclickedUrl);
                    }
                    else if (attributeName != "onclick")
                    {
                        attributes.Add(attr.Name, attr.Value);
                    }
                }
                attributes.Add("onclick", clickString);
                attributes.Remove("id");
                attributes.Remove("name");
                if (StringUtils.EqualsIgnoreCase(elementNode.Name, "a"))
                {
                    attributes.Remove("href");
                    attributes.Add("href", PageUtils.UnclickedUrl);
                }

                if (!string.IsNullOrEmpty(elementNode.InnerXml))
                {
                    rewriteHtml = rewriteHtml.Replace(submitElement,
                                                      $@"<{elementNode.Name} {TranslateUtils.ToAttributesString(attributes)}>{elementNode.InnerXml}</{elementNode
                            .Name}>");
                }
                else
                {
                    rewriteHtml = rewriteHtml.Replace(submitElement,
                                                      $@"<{elementNode.Name} {TranslateUtils.ToAttributesString(attributes)}/>");
                }
            }
            return(rewriteHtml);
        }
Ejemplo n.º 11
0
        public static string GetInsertAudioScript(string attributeName, string playUrl, SiteInfo siteInfo)
        {
            if (string.IsNullOrEmpty(playUrl))
            {
                return(string.Empty);
            }

            var dict = new Dictionary <string, string>
            {
                { StlAudio.PlayUrl, playUrl },
                { StlAudio.IsAutoPlay, siteInfo.Additional.ConfigUEditorAudioIsAutoPlay.ToString() },
                { "style", "width: 400px; height: 40px;" }
            };

            return(GetInsertHtmlScript(attributeName,
                                       $@"<img {StlAudio.EditorPlaceHolder} {TranslateUtils.ToAttributesString(dict)} />"));
        }
Ejemplo n.º 12
0
        private static async Task <string> ParseImplAsync(IParseManager parseManager, string type, int no, string src, string fallbackLink, bool forceIframe, string height, int page, string width, bool full, NameValueCollection attributes)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;
            var elementId   = StringUtils.GetElementId();

            var contentInfo = await parseManager.GetContentAsync();

            var fileUrl = string.Empty;

            if (!string.IsNullOrEmpty(src))
            {
                fileUrl = src;
            }
            else
            {
                if (contextInfo.ContextType == ParseType.Undefined)
                {
                    contextInfo.ContextType = ParseType.Content;
                }
                if (contextInfo.ContextType == ParseType.Content)
                {
                    if (contextInfo.ContentId != 0)
                    {
                        if (!string.IsNullOrEmpty(contentInfo?.Get <string>(type)))
                        {
                            if (no <= 1)
                            {
                                fileUrl = contentInfo.Get <string>(type);
                            }
                            else
                            {
                                var extendName = ColumnsManager.GetExtendName(type, no - 1);
                                fileUrl = contentInfo.Get <string>(extendName);
                            }
                        }
                    }
                }
                else if (contextInfo.ContextType == ParseType.Each)
                {
                    fileUrl = contextInfo.ItemContainer.EachItem.Value as string;
                }
            }

            await pageInfo.AddPageBodyCodeIfNotExistsAsync(ParsePage.Const.PdfObject);

            dynamic options = new { };

            if (!string.IsNullOrEmpty(fallbackLink))
            {
                options.fallbackLink = fallbackLink;
            }
            options.forceIframe = forceIframe;
            if (page > 0)
            {
                options.page = page;
            }

            if (full)
            {
                return($@"<script>PDFObject.embed(""{fileUrl}"", document.body, {JsonConvert.SerializeObject(options)});</script>");
            }

            if (!string.IsNullOrEmpty(height))
            {
                options.height = height;
            }
            if (!string.IsNullOrEmpty(width))
            {
                options.width = width;
            }

            attributes["id"] = elementId;
            return($@"<div {TranslateUtils.ToAttributesString(attributes)}></div><script>PDFObject.embed(""{fileUrl}"", ""#{elementId}"", {JsonConvert.SerializeObject(options)});</script>");
        }
Ejemplo n.º 13
0
 private static string GetParsedContent(NameValueCollection attributes)
 {
     return($@"<img {TranslateUtils.ToAttributesString(attributes)}>");
 }
Ejemplo n.º 14
0
        private static async Task <string> ParseImplAsync(IParseManager parseManager, string channelIndex,
                                                          string channelName, int upLevel, int topLevel, bool removeTarget, string href, string queryString,
                                                          string host, Dictionary <string, string> attributes)
        {
            var databaseManager = parseManager.DatabaseManager;
            var pageInfo        = parseManager.PageInfo;
            var contextInfo     = parseManager.ContextInfo;

            attributes.TryGetValue("id", out var htmlId);

            if (!string.IsNullOrEmpty(htmlId) && !string.IsNullOrEmpty(contextInfo.ContainerClientId))
            {
                htmlId = contextInfo.ContainerClientId + "_" + htmlId;
            }

            if (!string.IsNullOrEmpty(htmlId))
            {
                attributes["id"] = htmlId;
            }

            var innerHtml = string.Empty;

            var url     = string.Empty;
            var onclick = string.Empty;

            if (!string.IsNullOrEmpty(href))
            {
                url = await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, href, pageInfo.IsLocal);

                var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                await parseManager.ParseInnerContentAsync(innerBuilder);

                innerHtml = innerBuilder.ToString();
            }
            else
            {
                if (contextInfo.ContextType == ParseType.Undefined)
                {
                    contextInfo.ContextType = contextInfo.ContentId != 0 ? ParseType.Content : ParseType.Channel;
                }

                if (contextInfo.ContextType == ParseType.Content) //获取内容Url
                {
                    var contentInfo = await parseManager.GetContentAsync();

                    if (contentInfo != null)
                    {
                        url = await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, contentInfo, pageInfo.IsLocal);
                    }
                    else
                    {
                        var nodeInfo = await databaseManager.ChannelRepository.GetAsync(contextInfo.ChannelId);

                        url = await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, nodeInfo, contextInfo.ContentId,
                                                                                pageInfo.IsLocal);
                    }

                    if (string.IsNullOrEmpty(contextInfo.InnerHtml))
                    {
                        var title = contentInfo?.Title;
                        title = ContentUtility.FormatTitle(
                            contentInfo?.Get <string>("BackgroundContentAttribute.TitleFormatString"), title);

                        if (pageInfo.Site.IsContentTitleBreakLine)
                        {
                            title = title.Replace("  ", string.Empty);
                        }

                        innerHtml = title;
                    }
                    else
                    {
                        var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                        await parseManager.ParseInnerContentAsync(innerBuilder);

                        innerHtml = innerBuilder.ToString();
                    }
                }
                else if (contextInfo.ContextType == ParseType.Channel) //获取栏目Url
                {
                    var dataManager = new StlDataManager(parseManager.DatabaseManager);
                    contextInfo.ChannelId =
                        await dataManager.GetChannelIdByLevelAsync(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel);

                    contextInfo.ChannelId =
                        await databaseManager.ChannelRepository.GetChannelIdAsync(pageInfo.SiteId,
                                                                                  contextInfo.ChannelId, channelIndex, channelName);

                    var channel = await databaseManager.ChannelRepository.GetAsync(contextInfo.ChannelId);

                    url = await parseManager.PathManager.GetChannelUrlAsync(pageInfo.Site, channel, pageInfo.IsLocal);

                    if (string.IsNullOrWhiteSpace(contextInfo.InnerHtml))
                    {
                        innerHtml = channel.ChannelName;
                    }
                    else
                    {
                        var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                        await parseManager.ParseInnerContentAsync(innerBuilder);

                        innerHtml = innerBuilder.ToString();
                    }
                }
            }

            if (url.Equals(PageUtils.UnClickableUrl))
            {
                removeTarget = true;
            }
            else
            {
                if (!string.IsNullOrEmpty(host))
                {
                    url = PageUtils.AddProtocolToUrl(url, host);
                }

                if (!string.IsNullOrEmpty(queryString))
                {
                    url = PageUtils.AddQueryString(url, queryString);
                }
            }

            attributes["href"] = url;

            if (!string.IsNullOrEmpty(onclick))
            {
                attributes["onclick"] = onclick;
            }

            if (removeTarget)
            {
                attributes["target"] = string.Empty;
            }

            // 如果是实体标签,则只返回url
            if (contextInfo.IsStlEntity)
            {
                return(url);
            }

            return($@"<a {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</a>");
        }
Ejemplo n.º 15
0
        private static async Task <string> ParseAsync(IParseManager parseManager, NameValueCollection attributes, string channelIndex, string channelName, ScopeType scopeType, string groupChannel, string groupChannelNot, string groupContent, string groupContentNot, string tags, string orderByString, int startNum, int totalNum, bool isShowText, string isTopText, int titleWordNum, bool isTop, bool isTopExists, bool isRecommend, bool isRecommendExists, bool isHot, bool isHotExists, bool isColor, bool isColorExists, string theme, int imageWidth, int imageHeight, int textHeight, string bgColor)
        {
            var databaseManager = parseManager.DatabaseManager;
            var pageInfo        = parseManager.PageInfo;
            var contextInfo     = parseManager.ContextInfo;

            var parsedContent = string.Empty;

            var dataManager = new StlDataManager(parseManager.DatabaseManager);
            var channelId   = await dataManager.GetChannelIdByChannelIdOrChannelIndexOrChannelNameAsync(pageInfo.SiteId, contextInfo.ChannelId, channelIndex, channelName);

            var minContentInfoList = await databaseManager.ContentRepository.GetSummariesAsync(parseManager.DatabaseManager, pageInfo.Site, channelId, 0, groupContent, groupContentNot, tags, true, true, false, false, false, false, false, startNum, totalNum, orderByString, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor, scopeType, groupChannel, groupChannelNot, null);

            if (minContentInfoList != null)
            {
                if (StringUtils.EqualsIgnoreCase(theme, ThemeStyle2))
                {
                    await pageInfo.AddPageBodyCodeIfNotExistsAsync(ParsePage.Const.JsAcSwfObject);

                    var imageUrls       = new List <string>();
                    var navigationUrls  = new List <string>();
                    var titleCollection = new List <string>();

                    foreach (var minContentInfo in minContentInfoList)
                    {
                        var contentInfo = await databaseManager.ContentRepository.GetAsync(pageInfo.Site, minContentInfo.ChannelId, minContentInfo.Id);

                        var imageUrl = contentInfo.ImageUrl;

                        if (!string.IsNullOrEmpty(imageUrl))
                        {
                            if (StringUtils.EndsWithIgnoreCase(imageUrl, ".jpg") || StringUtils.EndsWithIgnoreCase(imageUrl, ".jpeg") || StringUtils.EndsWithIgnoreCase(imageUrl, ".png") || StringUtils.EndsWithIgnoreCase(imageUrl, ".pneg"))
                            {
                                titleCollection.Add(StringUtils.ToJsString(PageUtils.UrlEncode(StringUtils.MaxLengthText(StringUtils.StripTags(contentInfo.Title), titleWordNum))));
                                navigationUrls.Add(PageUtils.UrlEncode(await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, contentInfo, pageInfo.IsLocal)));
                                imageUrls.Add(PageUtils.UrlEncode(await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, imageUrl, pageInfo.IsLocal)));
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(bgColor))
                    {
                        bgColor = "0xDADADA";
                    }
                    else
                    {
                        bgColor = bgColor.TrimStart('#');
                        if (!bgColor.StartsWith("0x"))
                        {
                            bgColor = "0x" + bgColor;
                        }
                    }

                    if (string.IsNullOrEmpty(isTopText))
                    {
                        isTopText = "0";
                    }
                    else
                    {
                        isTopText = (TranslateUtils.ToBool(isTopText)) ? "0" : "1";
                    }

                    var elementId    = StringUtils.GetElementId();
                    var paramBuilder = new StringBuilder();
                    paramBuilder.Append(
                        $@"so_{elementId}.addParam(""quality"", ""high"");").Append(Constants.ReturnAndNewline);
                    paramBuilder.Append(
                        $@"so_{elementId}.addParam(""wmode"", ""transparent"");").Append(Constants.ReturnAndNewline);
                    paramBuilder.Append(
                        $@"so_{elementId}.addParam(""menu"", ""false"");").Append(Constants.ReturnAndNewline);
                    paramBuilder.Append(
                        $@"so_{elementId}.addParam(""FlashVars"", ""bcastr_file=""+files_uniqueID+""&bcastr_link=""+links_uniqueID+""&bcastr_title=""+texts_uniqueID+""&AutoPlayTime=5&TitleBgPosition={isTopText}&TitleBgColor={bgColor}&BtnDefaultColor={bgColor}"");").Append(Constants.ReturnAndNewline);

                    var bcastrUrl = parseManager.PathManager.GetSiteFilesUrl(pageInfo.Site, Resources.Flashes.Bcastr);

                    string scriptHtml = $@"
<div id=""flashcontent_{elementId}""></div>
<script type=""text/javascript"">
var files_uniqueID='{ListUtils.ToString(imageUrls, "|")}';
var links_uniqueID='{ListUtils.ToString(navigationUrls, "|")}';
var texts_uniqueID='{ListUtils.ToString(titleCollection, "|")}';

var so_{elementId} = new SWFObject(""{bcastrUrl}"", ""flash_{elementId}"", ""{imageWidth}"", ""{imageHeight}"", ""7"", """");
{paramBuilder}
so_{elementId}.write(""flashcontent_{elementId}"");
</script>
";
                    scriptHtml = scriptHtml.Replace("uniqueID", elementId);

                    parsedContent = scriptHtml;
                }
                else if (StringUtils.EqualsIgnoreCase(theme, ThemeStyle3))
                {
                    await pageInfo.AddPageBodyCodeIfNotExistsAsync(ParsePage.Const.JsAcSwfObject);

                    var imageUrls       = new List <string>();
                    var navigationUrls  = new List <string>();
                    var titleCollection = new List <string>();

                    foreach (var minContentInfo in minContentInfoList)
                    {
                        var contentInfo = await databaseManager.ContentRepository.GetAsync(pageInfo.Site, minContentInfo.ChannelId, minContentInfo.Id);

                        var imageUrl = contentInfo.ImageUrl;

                        if (!string.IsNullOrEmpty(imageUrl))
                        {
                            if (StringUtils.EndsWithIgnoreCase(imageUrl, ".jpg") || StringUtils.EndsWithIgnoreCase(imageUrl, ".jpeg") || StringUtils.EndsWithIgnoreCase(imageUrl, ".png") || StringUtils.EndsWithIgnoreCase(imageUrl, ".pneg"))
                            {
                                titleCollection.Add(StringUtils.ToJsString(PageUtils.UrlEncode(StringUtils.MaxLengthText(StringUtils.StripTags(contentInfo.Title), titleWordNum))));
                                navigationUrls.Add(PageUtils.UrlEncode(await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, contentInfo, pageInfo.IsLocal)));
                                imageUrls.Add(PageUtils.UrlEncode(await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, imageUrl, pageInfo.IsLocal)));
                            }
                        }
                    }

                    var elementId    = StringUtils.GetElementId();
                    var paramBuilder = new StringBuilder();
                    paramBuilder.Append($@"so_{elementId}.addParam(""quality"", ""high"");").Append(Constants.ReturnAndNewline);
                    paramBuilder.Append($@"so_{elementId}.addParam(""wmode"", ""transparent"");").Append(Constants.ReturnAndNewline);
                    paramBuilder.Append($@"so_{elementId}.addParam(""allowFullScreen"", ""true"");").Append(Constants.ReturnAndNewline);
                    paramBuilder.Append($@"so_{elementId}.addParam(""allowScriptAccess"", ""always"");").Append(Constants.ReturnAndNewline);
                    paramBuilder.Append($@"so_{elementId}.addParam(""menu"", ""false"");").Append(Constants.ReturnAndNewline);
                    paramBuilder.Append(
                        $@"so_{elementId}.addParam(""flashvars"", ""pw={imageWidth}&ph={imageHeight}&Times=4000&sizes=14&umcolor=16777215&btnbg=12189697&txtcolor=16777215&urls=""+urls_uniqueID+""&imgs=""+imgs_uniqueID+""&titles=""+titles_uniqueID);").Append(Constants.ReturnAndNewline);

                    var aliUrl = parseManager.PathManager.GetSiteFilesUrl(pageInfo.Site, Resources.Flashes.Ali);

                    string scriptHtml = $@"
<div id=""flashcontent_{elementId}""></div>
<script type=""text/javascript"">
var urls_uniqueID='{ListUtils.ToString(navigationUrls, "|")}';
var imgs_uniqueID='{ListUtils.ToString(imageUrls, "|")}';
var titles_uniqueID='{ListUtils.ToString(titleCollection, "|")}';

var so_{elementId} = new SWFObject(""{aliUrl}"", ""flash_{elementId}"", ""{imageWidth}"", ""{imageHeight}"", ""7"", """");
{paramBuilder}
so_{elementId}.write(""flashcontent_{elementId}"");
</script>
";
                    scriptHtml = scriptHtml.Replace("uniqueID", elementId);

                    parsedContent = scriptHtml;
                }
                else if (StringUtils.EqualsIgnoreCase(theme, ThemeStyle4))
                {
                    var imageUrls      = new StringCollection();
                    var navigationUrls = new StringCollection();

                    foreach (var minContentInfo in minContentInfoList)
                    {
                        var contentInfo = await databaseManager.ContentRepository.GetAsync(pageInfo.Site, minContentInfo.ChannelId, minContentInfo.Id);

                        var imageUrl = contentInfo.ImageUrl;

                        if (!string.IsNullOrEmpty(imageUrl))
                        {
                            navigationUrls.Add(await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, contentInfo, pageInfo.IsLocal));
                            imageUrls.Add(await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, imageUrl, pageInfo.IsLocal));
                        }
                    }

                    //foreach (var dataItem in dataSource)
                    //{
                    //    var contentInfo = new BackgroundContentInfo(dataItem);
                    //    if (!string.IsNullOrEmpty(contentInfo?.ImageUrl))
                    //    {
                    //        navigationUrls.Add(PageUtility.GetContentUrl(pageInfo.Site, contentInfo));
                    //        imageUrls.Add(PageUtility.ParseNavigationUrl(pageInfo.Site, contentInfo.ImageUrl));
                    //    }
                    //}

                    var imageBuilder = new StringBuilder();
                    var numBuilder   = new StringBuilder();

                    imageBuilder.Append($@"
<div style=""display:block""><a href=""{navigationUrls[0]}"" target=""_blank""><img src=""{imageUrls[0]}"" width=""{imageWidth}"" height=""{imageHeight}"" border=""0"" onMouseOver=""fv_clearAuto();"" onMouseOut=""fv_setAuto()"" /></a></div>
");

                    if (navigationUrls.Count > 1)
                    {
                        for (var i = 1; i < navigationUrls.Count; i++)
                        {
                            imageBuilder.Append($@"
<div style=""display:none""><a href=""{navigationUrls[i]}"" target=""_blank""><img src=""{imageUrls[i]}"" width=""{imageWidth}"" height=""{imageHeight}"" border=""0"" onMouseOver=""fv_clearAuto();"" onMouseOut=""fv_setAuto()"" /></a></div>
");
                        }
                    }

                    numBuilder.Append(@"
<td width=""18"" height=""16"" class=""fv_bigon"" onmouseover=""fv_clearAuto();fv_Mea(0);"" onmouseout=""fv_setAuto()"">1</td>
");

                    if (navigationUrls.Count > 1)
                    {
                        for (var i = 1; i < navigationUrls.Count; i++)
                        {
                            numBuilder.Append($@"
<td width=""18"" class=""fv_bigoff"" onmouseover=""fv_clearAuto();fv_Mea({i});"" onmouseout=""fv_setAuto()"">{i + 1}</td>
");
                        }
                    }

                    var bgUrl = await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site,
                                                                                 "@/images/focusviewerbg.png", pageInfo.IsLocal);

                    var scriptHtml = $@"
<style type=""text/css"">
.fv_adnum{{ position:absolute; z-index:1005; width:{imageWidth - 24}px; height:24px; padding:5px 3px 0 0; left:21px; top:{imageHeight -
                                                                                                                                                                                                  29}px; }}
.fv_bigon{{ background:#E59948; font-family:Arial; color:#fff; font-size:12px; text-align:center; cursor:pointer}}
.fv_bigoff{{ background:#7DCABD; font-family:Arial; color:#fff; font-size:12px; text-align:center; cursor:pointer}}
</style>
<div style=""position:relative; left:0; top:0; width:{imageWidth}px; height:{imageHeight}px; background:#000"">
	<div id=""fv_filbox"" style=""position:absolute; z-index:999; left:0; top:0; width:{imageWidth}px; height:{imageHeight}px; filter:progid:DXImageTransform.Microsoft.Fade( duration=0.5,overlap=1.0 );"">
		{imageBuilder}
    </div>
    <div class=""fv_adnum"" style=""background:url({bgUrl}) no-repeat !important; background:none ;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src='{bgUrl}')""></div>
    <div class=""fv_adnum"">
        <table border=""0"" cellspacing=""1"" cellpadding=""0"" align=""right"" id=""fv_num"">
          <tr>
            {numBuilder}
          </tr>
        </table>
    </div>
</div>
<script language=""javascript""> 
    var fv_n=0;
    var fv_nums={navigationUrls.Count};
    var fv_showNum = document.getElementById(""fv_num"");
    var is_IE=(navigator.appName==""Microsoft Internet Explorer"");
    function fv_Mea(value){{
        fv_n=value;
        for(var i=0;i<fv_nums;i++)
            if(value==i){{
                fv_showNum.getElementsByTagName(""td"")[i].setAttribute('className', 'fv_bigon');
                fv_showNum.getElementsByTagName(""td"")[i].setAttribute('class', 'fv_bigon');
            }}
            else{{	
                fv_showNum.getElementsByTagName(""td"")[i].setAttribute('className', 'fv_bigoff');
                fv_showNum.getElementsByTagName(""td"")[i].setAttribute('class', 'fv_bigoff');
            }}
        var divs = document.getElementById(""fv_filbox"").getElementsByTagName(""div""); 
		if (is_IE){{
            document.getElementById(""fv_filbox"").filters[0].Apply();
		}}
		for(i=0;i<fv_nums;i++)i==value?divs[i].style.display=""block"":divs[i].style.display=""none"";
		if (is_IE){{
			document.getElementById(""fv_filbox"").filters[0].play();
		}}
    }}
    function fv_clearAuto(){{clearInterval(autoStart)}}
    function fv_setAuto(){{autoStart=setInterval(""auto(fv_n)"", 5000)}}
    function auto(){{
        fv_n++;
        if(fv_n>(fv_nums-1))fv_n=0;
        fv_Mea(fv_n);
    }}
    fv_setAuto(); 
</script>
";

                    parsedContent = scriptHtml.Replace("fv_", $"fv{StringUtils.GetElementId()}_");
                }
                else
                {
                    var imageUrls       = new List <string>();
                    var navigationUrls  = new List <string>();
                    var titleCollection = new List <string>();

                    foreach (var minContentInfo in minContentInfoList)
                    {
                        var contentInfo = await databaseManager.ContentRepository.GetAsync(pageInfo.Site, minContentInfo.ChannelId, minContentInfo.Id);

                        var imageUrl = contentInfo.ImageUrl;

                        if (!string.IsNullOrEmpty(imageUrl))
                        {
                            //这里使用png图片不管用
                            if (StringUtils.EndsWithIgnoreCase(imageUrl, ".jpg") || StringUtils.EndsWithIgnoreCase(imageUrl, ".jpeg"))
                            {
                                titleCollection.Add(StringUtils.ToJsString(PageUtils.UrlEncode(StringUtils.MaxLengthText(StringUtils.StripTags(contentInfo.Title), titleWordNum))));
                                navigationUrls.Add(PageUtils.UrlEncode(await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, contentInfo, pageInfo.IsLocal)));
                                imageUrls.Add(PageUtils.UrlEncode(await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, imageUrl, pageInfo.IsLocal)));
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(bgColor))
                    {
                        bgColor = "#DADADA";
                    }
                    var titles = string.Empty;
                    if (isShowText == false)
                    {
                        textHeight = 0;
                    }
                    else
                    {
                        titles = ListUtils.ToString(titleCollection, "|");
                    }
                    var elementId = StringUtils.GetElementId();
                    attributes["id"] = elementId;
                    var divHtml = $@"<div {TranslateUtils.ToAttributesString(attributes)}>&nbsp;</div>";

                    var jsUrl          = parseManager.PathManager.GetSiteFilesUrl(pageInfo.Site, Resources.BaiRongFlash.Js);
                    var focusViewerUrl = parseManager.PathManager.GetSiteFilesUrl(pageInfo.Site, Resources.Flashes.FocusViewer);

                    var scriptHtml = $@"
<script type=""text/javascript"" src=""{jsUrl}""></script>
<script type=""text/javascript"">
	var uniqueID_focus_width={imageWidth}
	var uniqueID_focus_height={imageHeight}
	var uniqueID_text_height={textHeight}
	var uniqueID_swf_height = uniqueID_focus_height + uniqueID_text_height
	
	var uniqueID_pics='{ListUtils.ToString(imageUrls, "|")}'
	var uniqueID_links='{ListUtils.ToString(navigationUrls, "|")}'
	var uniqueID_texts='{titles}'
	
	var uniqueID_FocusFlash = new bairongFlash(""{focusViewerUrl}"", ""focusflash"", uniqueID_focus_width, uniqueID_swf_height, ""7"", ""{bgColor}"", false, ""High"");
	uniqueID_FocusFlash.addParam(""allowScriptAccess"", ""sameDomain"");
	uniqueID_FocusFlash.addParam(""menu"", ""false"");
	uniqueID_FocusFlash.addParam(""wmode"", ""transparent"");

	uniqueID_FocusFlash.addVariable(""pics"", uniqueID_pics);
	uniqueID_FocusFlash.addVariable(""links"", uniqueID_links);
	uniqueID_FocusFlash.addVariable(""texts"", uniqueID_texts);
	uniqueID_FocusFlash.addVariable(""borderwidth"", uniqueID_focus_width);
	uniqueID_FocusFlash.addVariable(""borderheight"", uniqueID_focus_height);
	uniqueID_FocusFlash.addVariable(""textheight"", uniqueID_text_height);
	uniqueID_FocusFlash.write(""uniqueID"");
</script>
";
                    scriptHtml = scriptHtml.Replace("uniqueID", elementId);

                    parsedContent = divHtml + scriptHtml;
                }
            }

            return(parsedContent);
        }
Ejemplo n.º 16
0
        private static async Task <object> ParseImplAsync(IParseManager parseManager, NameValueCollection attributes, bool isGetPicUrlFromAttribute, string channelIndex, string channelName, int upLevel, int topLevel, string type, int no, bool isOriginal, string src, string altSrc)
        {
            var databaseManager = parseManager.DatabaseManager;
            var pageInfo        = parseManager.PageInfo;
            var contextInfo     = parseManager.ContextInfo;

            object parsedContent = null;

            var contentId = 0;

            //判断是否图片地址由标签属性获得
            if (!isGetPicUrlFromAttribute)
            {
                contentId = contextInfo.ContentId;
            }
            var contextType = contextInfo.ContextType;

            var picUrl = string.Empty;

            if (!string.IsNullOrEmpty(src))
            {
                picUrl = src;
            }
            else
            {
                if (contextType == ParseType.Undefined)
                {
                    contextType = contentId != 0 ? ParseType.Content : ParseType.Channel;
                }

                if (contextType == ParseType.Content)//获取内容图片
                {
                    var contentInfo = await parseManager.GetContentAsync();

                    if (isOriginal)
                    {
                        if (contentInfo != null && contentInfo.ReferenceId > 0 && contentInfo.SourceId > 0)
                        {
                            var targetChannelId = contentInfo.SourceId;
                            //var targetSiteId = databaseManager.ChannelRepository.GetSiteId(targetChannelId);
                            var targetSiteId = await databaseManager.ChannelRepository.GetSiteIdAsync(targetChannelId);

                            var targetSite = await databaseManager.SiteRepository.GetAsync(targetSiteId);

                            var targetNodeInfo = await databaseManager.ChannelRepository.GetAsync(targetChannelId);

                            //var targetContentInfo = databaseManager.ContentRepository.GetContentInfo(tableStyle, tableName, contentInfo.ReferenceId);
                            var targetContentInfo = await databaseManager.ContentRepository.GetAsync(targetSite, targetNodeInfo, contentInfo.ReferenceId);

                            if (targetContentInfo != null && targetContentInfo.ChannelId > 0)
                            {
                                contentInfo = targetContentInfo;
                            }
                        }
                    }

                    if (contentInfo == null)
                    {
                        contentInfo = await databaseManager.ContentRepository.GetAsync(pageInfo.Site, contextInfo.ChannelId, contentId);
                    }

                    if (contentInfo != null)
                    {
                        if (no <= 1)
                        {
                            picUrl = contentInfo.Get <string>(type);
                        }
                        else
                        {
                            var extendName = ColumnsManager.GetExtendName(type, no - 1);
                            picUrl = contentInfo.Get <string>(extendName);
                        }
                    }
                }
                else if (contextType == ParseType.Channel)//获取栏目图片
                {
                    var dataManager = new StlDataManager(parseManager.DatabaseManager);
                    var channelId   = await dataManager.GetChannelIdByLevelAsync(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel);

                    channelId = await dataManager.GetChannelIdByChannelIdOrChannelIndexOrChannelNameAsync(pageInfo.SiteId, channelId, channelIndex, channelName);

                    var channel = await databaseManager.ChannelRepository.GetAsync(channelId);

                    picUrl = channel.ImageUrl;
                }
                else if (contextType == ParseType.Each)
                {
                    picUrl = contextInfo.ItemContainer.EachItem.Value as string;
                }
            }

            if (string.IsNullOrEmpty(picUrl))
            {
                picUrl = altSrc;
            }

            if (!string.IsNullOrEmpty(picUrl))
            {
                var extension = PathUtils.GetExtension(picUrl);
                if (FileUtils.IsFlash(extension))
                {
                    parsedContent = await StlFlash.ParseAsync(parseManager);
                }
                else if (FileUtils.IsPlayer(extension))
                {
                    parsedContent = await StlPlayer.ParseAsync(parseManager);
                }
                else
                {
                    attributes["src"] = await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, picUrl, pageInfo.IsLocal);

                    parsedContent = $@"<img {TranslateUtils.ToAttributesString(attributes)}>";
                }
            }

            return(parsedContent);
        }
Ejemplo n.º 17
0
        private static async Task <string> ParseAsync(IParseManager parseManager, string separator, string target, string linkClass, int wordNum, bool isContainSelf)
        {
            var databaseManager = parseManager.DatabaseManager;
            var pageInfo        = parseManager.PageInfo;
            var contextInfo     = parseManager.ContextInfo;

            if (!string.IsNullOrEmpty(contextInfo.InnerHtml))
            {
                separator = contextInfo.InnerHtml;
            }

            var channel = await databaseManager.ChannelRepository.GetAsync(contextInfo.ChannelId);

            var builder = new StringBuilder();

            var parentsCount = channel.ParentsCount;
            var nodePath     = ListUtils.GetIntList(channel.ParentsPath);

            if (isContainSelf)
            {
                nodePath.Add(contextInfo.ChannelId);
            }
            foreach (var currentId in nodePath.Distinct())
            {
                var currentNodeInfo = await databaseManager.ChannelRepository.GetAsync(currentId);

                if (currentId == pageInfo.SiteId)
                {
                    var attributes = new NameValueCollection();
                    if (!string.IsNullOrEmpty(target))
                    {
                        attributes["target"] = target;
                    }
                    if (!string.IsNullOrEmpty(linkClass))
                    {
                        attributes["class"] = linkClass;
                    }
                    var url = await parseManager.PathManager.GetIndexPageUrlAsync(pageInfo.Site, pageInfo.IsLocal);

                    if (url.Equals(PageUtils.UnClickableUrl))
                    {
                        attributes["target"] = string.Empty;
                    }
                    attributes["href"] = url;
                    var innerHtml = StringUtils.MaxLengthText(currentNodeInfo.ChannelName, wordNum);

                    TranslateUtils.AddAttributesIfNotExists(attributes, contextInfo.Attributes);

                    builder.Append($@"<a {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</a>");

                    if (parentsCount > 0)
                    {
                        builder.Append(separator);
                    }
                }
                else if (currentId == contextInfo.ChannelId)
                {
                    var attributes = new NameValueCollection();
                    if (!string.IsNullOrEmpty(target))
                    {
                        attributes["target"] = target;
                    }
                    if (!string.IsNullOrEmpty(linkClass))
                    {
                        attributes["class"] = linkClass;
                    }
                    var url = await parseManager.PathManager.GetChannelUrlAsync(pageInfo.Site, currentNodeInfo, pageInfo.IsLocal);

                    if (url.Equals(PageUtils.UnClickableUrl))
                    {
                        attributes["target"] = string.Empty;
                    }
                    attributes["href"] = url;
                    var innerHtml = StringUtils.MaxLengthText(currentNodeInfo.ChannelName, wordNum);

                    TranslateUtils.AddAttributesIfNotExists(attributes, contextInfo.Attributes);

                    builder.Append($@"<a {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</a>");
                }
                else
                {
                    var attributes = new NameValueCollection();
                    if (!string.IsNullOrEmpty(target))
                    {
                        attributes["target"] = target;
                    }
                    if (!string.IsNullOrEmpty(linkClass))
                    {
                        attributes["class"] = linkClass;
                    }
                    var url = await parseManager.PathManager.GetChannelUrlAsync(pageInfo.Site, currentNodeInfo, pageInfo.IsLocal);

                    if (url.Equals(PageUtils.UnClickableUrl))
                    {
                        attributes["target"] = string.Empty;
                    }
                    attributes["href"] = url;
                    var innerHtml = StringUtils.MaxLengthText(currentNodeInfo.ChannelName, wordNum);

                    TranslateUtils.AddAttributesIfNotExists(attributes, contextInfo.Attributes);

                    builder.Append($@"<a {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</a>");

                    if (parentsCount > 0)
                    {
                        builder.Append(separator);
                    }
                }
            }

            return(builder.ToString());
        }
Ejemplo n.º 18
0
        private static async Task <string> ParseImplAsync(IParseManager parseManager, string tabName, string type, string action, string classActive, string classNormal, int current)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;

            await pageInfo.AddPageBodyCodeIfNotExistsAsync(ParsePage.Const.Jquery);

            var builder  = new StringBuilder();
            var uniqueId = pageInfo.UniqueId;
            var isHeader = StringUtils.EqualsIgnoreCase(type, TypeHead);

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(contextInfo.InnerHtml);

            var htmlNodes = htmlDoc.DocumentNode.ChildNodes;

            if (htmlNodes != null && htmlNodes.Count > 0)
            {
                if (isHeader)
                {
                    builder.Append($@"
<script language=javascript>
function stl_tab_{uniqueId}(tabName, no){{
	for ( i = 1; i <= {htmlNodes.Count}; i++){{
		var el = jQuery('#{tabName}_tabContent_' + i);
		var li = $('#{tabName}_tabHeader_' + i);
		if (i == no){{
            try{{
			    el.show();
            }}catch(e){{}}
            li.removeClass('{classNormal}');
            li.addClass('{classActive}');
		}}else{{
            try{{
			    el.hide();
            }}catch(e){{}}
            li.removeClass('{classActive}');
            li.addClass('{classNormal}');
		}}
	}}
}}
</script>
");
                }

                var count = 0;
                foreach (var htmlNode in htmlNodes)
                {
                    if (htmlNode.NodeType != HtmlNodeType.Element)
                    {
                        continue;
                    }

                    var attributes = new NameValueCollection();
                    if (htmlNode.Attributes != null)
                    {
                        foreach (var attr in htmlNode.Attributes)
                        {
                            if (attr == null)
                            {
                                continue;
                            }

                            var attributeName = StringUtils.ToLower(attr.Name);
                            if (!StringUtils.EqualsIgnoreCase(attr.Name, "id") && !StringUtils.EqualsIgnoreCase(attr.Name, "onmouseover") && !StringUtils.EqualsIgnoreCase(attr.Name, "onclick"))
                            {
                                attributes[attributeName] = attr.Value;
                            }
                        }
                    }

                    count++;
                    if (isHeader)
                    {
                        attributes["id"] = $"{tabName}_tabHeader_{count}";
                        if (StringUtils.EqualsIgnoreCase(action, ActionMouseOver))
                        {
                            attributes["onmouseover"] = $"stl_tab_{uniqueId}('{tabName}', {count});return false;";
                        }
                        else
                        {
                            attributes["onclick"] = $"stl_tab_{uniqueId}('{tabName}', {count});return false;";
                        }
                        if (current != 0)
                        {
                            if (count == current)
                            {
                                attributes["class"] = classActive;
                            }
                            else
                            {
                                attributes["class"] = classNormal;
                            }
                        }
                    }
                    else
                    {
                        attributes["id"] = $"{tabName}_tabContent_{count}";
                        if (current != 0)
                        {
                            if (count != current)
                            {
                                attributes["style"] = $"display:none;{attributes["style"]}";
                            }
                        }
                    }

                    var innerHtml = string.Empty;
                    if (!string.IsNullOrEmpty(htmlNode.InnerHtml))
                    {
                        var innerBuilder = new StringBuilder(htmlNode.InnerHtml);
                        await parseManager.ParseInnerContentAsync(innerBuilder);

                        innerHtml = innerBuilder.ToString();
                    }

                    builder.Append(
                        $"<{htmlNode.Name} {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</{htmlNode.Name}>");
                }
            }

            return(builder.ToString());
        }
Ejemplo n.º 19
0
        public string ReplacePlaceHolder(string template, bool isLoadValues, string successTemplateString, string failureTemplateString)
        {
            var parsedContent = new StringBuilder();

            parsedContent.Append($@"
<div id=""inputSuccess_{_inputInfo.InputId}"" class=""is_success"" style=""display:none""></div>
<div id=""inputFailure_{_inputInfo.InputId}"" class=""is_failure"" style=""display:none""></div>
<div id=""inputContainer_{_inputInfo.InputId}"">");

            //添加遮罩层
            parsedContent.Append($@"
<div id=""inputModal_{_inputInfo.InputId}"" times=""2"" id=""xubox_shade2"" class=""xubox_shade"" style=""z-index:19891016; background-color: #FFF; opacity: 0.5; filter:alpha(opacity=10);top: 0;left: 0;width: 100%;height: 100%;position: fixed;display:none;""></div>
<div id=""inputModalMsg_{_inputInfo.InputId}"" times=""2"" showtime=""0"" style=""z-index: 19891016; left: 50%; top: 206px; width: 500px; height: 360px; margin-left: -250px;position: fixed;text-align: center;display:none;"" id=""xubox_layer2"" class=""xubox_layer"" type=""iframe""><img src = ""{SiteFilesAssets.GetUrl(_publishmentSystemInfo.Additional.ApiUrl, SiteFilesAssets.FileWaiting)}"" style="""">
<br>
<span style=""font-size:10px;font-family:Microsoft Yahei"">正在提交...</span>
</div>
<script>
		function openModal()
        {{
			document.getElementById(""inputModal_{_inputInfo.InputId}"").style.display = '';
            document.getElementById(""inputModalMsg_{_inputInfo.InputId}"").style.display = '';
        }}
        function closeModal()
        {{
			document.getElementById(""inputModal_{_inputInfo.InputId}"").style.display = 'none';
            document.getElementById(""inputModalMsg_{_inputInfo.InputId}"").style.display = 'none';
        }}
</script>");

            var actionUrl = ActionsInputAdd.GetUrl(_publishmentSystemInfo.Additional.ApiUrl, _publishmentSystemInfo.PublishmentSystemId, _inputInfo.InputId);

            parsedContent.Append($@"
<form id=""frmInput_{_inputInfo.InputId}"" name=""frmInput_{_inputInfo.InputId}"" style=""margin:0;padding:0"" method=""post"" enctype=""multipart/form-data"" action=""{actionUrl}"" target=""loadInput_{_inputInfo.InputId}"">
");

            if (!string.IsNullOrEmpty(successTemplateString))
            {
                parsedContent.AppendFormat(@"<input type=""hidden"" id=""successTemplateString"" value=""{0}"" />", TranslateUtils.EncryptStringBySecretKey(successTemplateString));
            }
            if (!string.IsNullOrEmpty(failureTemplateString))
            {
                parsedContent.AppendFormat(@"<input type=""hidden"" id=""failureTemplateString"" value=""{0}"" />", TranslateUtils.EncryptStringBySecretKey(failureTemplateString));
            }

            parsedContent.Append(template);

            parsedContent.AppendFormat(@"
</form>
<iframe id=""loadInput_{0}"" name=""loadInput_{0}"" width=""0"" height=""0"" frameborder=""0""></iframe>
</div>", _inputInfo.InputId);

            var pageScripts = new NameValueCollection();

            GetAttributesHtml(pageScripts, _publishmentSystemInfo, _styleInfoList);

            foreach (string key in pageScripts.Keys)
            {
                parsedContent.Append(pageScripts[key]);
            }

            if (_inputInfo.Additional.IsCtrlEnter)
            {
                parsedContent.AppendFormat(@"
<script>document.body.onkeydown=function(e)
{{e=e?e:window.event;var tagname=e.srcElement?e.srcElement.tagName:e.target.tagName;if(tagname=='INPUT'||tagname=='TEXTAREA'){{if(e!=null&&e.ctrlKey&&e.keyCode==13){{document.getElementById('submit_{0}').click();}}}}}}</script>", _inputInfo.InputId);
            }

            string clickString =
                $@"if (checkFormValueById('frmInput_{HolderInputId}')){{openModal(); document.getElementById('frmInput_{HolderInputId}').submit();}}";

            StlHtmlUtility.ReWriteSubmitButton(parsedContent, clickString);

            var stlFormElements = StlHtmlUtility.GetStlFormElementsArrayList(parsedContent.ToString());

            if (stlFormElements != null && stlFormElements.Count > 0)
            {
                foreach (string stlFormElement in stlFormElements)
                {
                    XmlNode             elementNode;
                    NameValueCollection attributes;
                    StlHtmlUtility.ReWriteFormElements(stlFormElement, out elementNode, out attributes);

                    var validateAttributes = string.Empty;
                    var validateHtmlString = string.Empty;

                    if (!string.IsNullOrEmpty(attributes["id"]))
                    {
                        foreach (var styleInfo in _styleInfoList)
                        {
                            if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, attributes["id"]))
                            {
                                validateHtmlString = InputParserUtility.GetValidateHtmlString(styleInfo, out validateAttributes);
                                attributes["id"]   = styleInfo.AttributeName;
                            }
                        }
                    }

                    if (StringUtils.EqualsIgnoreCase(elementNode.Name, "input"))
                    {
                        parsedContent.Replace(stlFormElement,
                                              $@"<{elementNode.Name} {TranslateUtils.ToAttributesString(attributes)} {validateAttributes}/>{validateHtmlString}");
                    }
                    else
                    {
                        parsedContent.Replace(stlFormElement,
                                              $@"<{elementNode.Name} {TranslateUtils.ToAttributesString(attributes)} {validateAttributes}>{elementNode
                                .InnerXml}</{elementNode.Name}>{validateHtmlString}");
                    }
                }
            }

            parsedContent.Replace(HolderInputId, _inputInfo.InputId.ToString());

            if (isLoadValues)
            {
                parsedContent.AppendFormat(@"
<script type=""text/javascript"">stlInputLoadValues('frmInput_{0}');</script>
", _inputInfo.InputId);
            }

            return(parsedContent.ToString());
        }
Ejemplo n.º 20
0
        private static async Task <string> ParseImplAsync(IParseManager parseManager, NameValueCollection attributes, string titleId, string bodyId, string logoId, string locationId)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;

            var jsUrl   = parseManager.PathManager.GetSiteFilesUrl(pageInfo.Site, Resources.Print.Js);
            var iconUrl = parseManager.PathManager.GetSiteFilesUrl(pageInfo.Site, Resources.Print.IconUrl);

            if (!pageInfo.BodyCodes.ContainsKey(ParsePage.Const.JsAfStlPrinter))
            {
                pageInfo.BodyCodes.Add(ParsePage.Const.JsAfStlPrinter, $@"
<script language=""JavaScript"" type=""text/javascript"">
function stlLoadPrintJsCallBack()
{{
    if(typeof forSPrint == ""object"" && forSPrint.Print)
    {{
        forSPrint.data.titleId = ""{titleId}"";
        forSPrint.data.artiBodyId = ""{bodyId}"";
        forSPrint.data.pageLogoId = ""{logoId}"";
        forSPrint.data.pageWayId = ""{locationId}"";
        forSPrint.data.iconUrl = ""{iconUrl}"";
        forSPrint.Print();
    }}
}}

function stlPrintGetBrowser()
{{
    if (navigator.userAgent.indexOf(""MSIE"") != -1)
    {{
        return 1; 
    }}
    else if (navigator.userAgent.indexOf(""Firefox"") != -1)
    {{
        return 2; 
    }}
    else if (navigator.userAgent.indexOf(""Navigator"") != -1)
    {{
        return 3;
    }}
    else if (navigator.userAgent.indexOf(""Opera"") != -1 )
    {{
        return 4;
    }}
    else
    {{
        return 5;
    }}
}}

function stlLoadPrintJs()
{{
    var myBrowser = stlPrintGetBrowser();
    if(myBrowser == 1)
    {{
        var js_url = ""{jsUrl}"";
        var js = document.createElement( ""script"" ); 
        js.setAttribute( ""type"", ""text/javascript"" );
        js.setAttribute( ""src"", js_url);
        js.setAttribute( ""id"", ""printJsUrl"");
        document.body.insertBefore( js, null);
        document.getElementById(""printJsUrl"").onreadystatechange = stlLoadPrintJsCallBack;
    }}
    else
    {{
        var js_url = ""{jsUrl}"";
        var js = document.createElement( ""script"" ); 
        js.setAttribute( ""type"", ""text/javascript"" );
        js.setAttribute( ""src"", js_url);
        js.setAttribute( ""id"", ""printJsUrl"");
        js.setAttribute( ""onload"", ""stlLoadPrintJsCallBack()"");
        document.body.insertBefore( js, null);					
    }}
}}	
</script>
");
            }

            string innerHtml;

            if (string.IsNullOrEmpty(contextInfo.InnerHtml))
            {
                innerHtml = "打印";
            }
            else
            {
                var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                await parseManager.ParseInnerContentAsync(innerBuilder);

                innerHtml = innerBuilder.ToString();
            }


            attributes["href"] = "javascript:stlLoadPrintJs();";

            return($@"<a {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</a>");
        }
Ejemplo n.º 21
0
Archivo: StlUser.cs Proyecto: z-kf/cms
        private static async Task <string> ParseImplAsync(IParseManager parseManager, string type, NameValueCollection attributes)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;

            var parsedContent = string.Empty;

            if (pageInfo?.User == null)
            {
                return(string.Empty);
            }

            if (!string.IsNullOrEmpty(contextInfo.InnerHtml))
            {
                var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                await parseManager.ParseInnerContentAsync(innerBuilder);
            }

            try
            {
                if (StringUtils.EqualsIgnoreCase(nameof(User.Id), type))
                {
                    parsedContent = pageInfo.User.Id.ToString();
                }
                else if (StringUtils.EqualsIgnoreCase(nameof(User.UserName), type))
                {
                    parsedContent = pageInfo.User.UserName;
                }
                else if (StringUtils.EqualsIgnoreCase(nameof(User.CreatedDate), type))
                {
                    parsedContent = DateUtils.Format(pageInfo.User.CreatedDate, string.Empty);
                }
                else if (StringUtils.EqualsIgnoreCase(nameof(User.LastActivityDate), type))
                {
                    parsedContent = DateUtils.Format(pageInfo.User.LastActivityDate, string.Empty);
                }
                else if (StringUtils.EqualsIgnoreCase(nameof(User.CountOfLogin), type))
                {
                    parsedContent = pageInfo.User.CountOfLogin.ToString();
                }
                else if (StringUtils.EqualsIgnoreCase(nameof(User.DisplayName), type))
                {
                    parsedContent = pageInfo.User.DisplayName;
                }
                else if (StringUtils.EqualsIgnoreCase(nameof(User.Email), type))
                {
                    parsedContent = pageInfo.User.Email;
                }
                else if (StringUtils.EqualsIgnoreCase(nameof(User.Mobile), type))
                {
                    parsedContent = pageInfo.User.Mobile;
                }
                else if (StringUtils.EqualsIgnoreCase(nameof(User.AvatarUrl), type))
                {
                    parsedContent = parseManager.PathManager.GetUserAvatarUrl(pageInfo.User);
                    if (!contextInfo.IsStlEntity)
                    {
                        attributes["src"] = parsedContent;
                        parsedContent     = $@"<img {TranslateUtils.ToAttributesString(attributes)}>";
                    }
                }
                else
                {
                    parsedContent = pageInfo.User.Get <string>(type);
                }
            }
            catch
            {
                // ignored
            }

            return(parsedContent);
        }
Ejemplo n.º 22
0
        private static async Task <string> ParseImplAsync(IParseManager parseManager, string type, string playUrl, string imageUrl, string width, string height, bool isAutoPlay, bool isControls, bool isLoop)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;

            var videoUrl = string.Empty;

            if (!string.IsNullOrEmpty(playUrl))
            {
                videoUrl = playUrl;
            }
            else
            {
                var contentId = contextInfo.ContentId;
                if (contextInfo.ContextType == ParseType.Content)
                {
                    if (contentId != 0)//获取内容视频
                    {
                        var contentInfo = await parseManager.GetContentAsync();

                        if (contentInfo != null)
                        {
                            videoUrl = contentInfo.Get <string>(type);
                            if (string.IsNullOrEmpty(videoUrl))
                            {
                                videoUrl = contentInfo.VideoUrl;
                            }
                        }
                    }
                }
                else if (contextInfo.ContextType == ParseType.Each)
                {
                    videoUrl = contextInfo.ItemContainer.EachItem.Value as string;
                }
            }

            if (string.IsNullOrEmpty(videoUrl))
            {
                return(string.Empty);
            }

            videoUrl = await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, videoUrl, pageInfo.IsLocal);

            imageUrl = await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, imageUrl, pageInfo.IsLocal);

            await pageInfo.AddPageBodyCodeIfNotExistsAsync(ParsePage.Const.JsAcVideoJs);

            var dict = new Dictionary <string, string>
            {
                { "class", "video-js vjs-default-skin" },
                { "src", videoUrl }
            };

            if (isAutoPlay)
            {
                dict.Add("autoplay", null);
            }
            if (isControls)
            {
                dict.Add("controls", null);
            }
            if (isLoop)
            {
                dict.Add("loop", null);
            }
            if (!string.IsNullOrEmpty(imageUrl))
            {
                dict.Add("poster", imageUrl);
            }
            if (!string.IsNullOrEmpty(width))
            {
                dict.Add("width", width);
            }
            dict.Add("height", string.IsNullOrEmpty(height) ? "280" : height);

            return($@"<video {TranslateUtils.ToAttributesString(dict)}></video>");
        }
Ejemplo n.º 23
0
        private static async Task <string> ParseAsync(IParseManager parseManager, string type)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;

            var attributes = new NameValueCollection();

            foreach (var attributeName in contextInfo.Attributes.AllKeys)
            {
                attributes[attributeName] = contextInfo.Attributes[attributeName];
            }

            string htmlId  = attributes["id"];
            var    url     = PageUtils.UnClickableUrl;
            var    onclick = string.Empty;

            var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
            await parseManager.ParseInnerContentAsync(innerBuilder);

            var innerHtml = innerBuilder.ToString();

            //计算动作开始
            if (!string.IsNullOrEmpty(type))
            {
                if (StringUtils.EqualsIgnoreCase(type, TypeTranslate))
                {
                    await pageInfo.AddPageBodyCodeIfNotExistsAsync(ParsePage.Const.JsAhTranslate);

                    var msgToTraditionalChinese = "繁體";
                    var msgToSimplifiedChinese  = "简体";
                    if (!string.IsNullOrEmpty(innerHtml))
                    {
                        if (innerHtml.IndexOf(",", StringComparison.Ordinal) != -1)
                        {
                            msgToTraditionalChinese = innerHtml.Substring(0, innerHtml.IndexOf(",", StringComparison.Ordinal));
                            msgToSimplifiedChinese  = innerHtml.Substring(innerHtml.IndexOf(",", StringComparison.Ordinal) + 1);
                        }
                        else
                        {
                            msgToTraditionalChinese = innerHtml;
                        }
                    }
                    innerHtml = msgToTraditionalChinese;

                    if (string.IsNullOrEmpty(htmlId))
                    {
                        htmlId = "translateLink";
                    }

                    pageInfo.FootCodes[TypeTranslate] = $@"
<script type=""text/javascript""> 
var defaultEncoding = 0;
var translateDelay = 0;
var cookieDomain = ""/"";
var msgToTraditionalChinese = ""{msgToTraditionalChinese}"";
var msgToSimplifiedChinese = ""{msgToSimplifiedChinese}"";
var translateButtonId = ""{htmlId}"";
translateInitilization();
</script>
";
                }
                else if (StringUtils.EqualsIgnoreCase(type, TypeClose))
                {
                    url = "javascript:window.close()";
                }
            }
            //计算动作结束

            attributes["href"] = url;
            if (!string.IsNullOrEmpty(htmlId))
            {
                attributes["id"] = htmlId;
            }

            if (!string.IsNullOrEmpty(onclick))
            {
                attributes["onclick"] = onclick;
            }

            // 如果是实体标签,则只返回url
            return(contextInfo.IsStlEntity
                ? url
                : $@"<a {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</a>");
        }
Ejemplo n.º 24
0
        public async Task <string> ParseAsync(IParseStlContext context)
        {
            var url                = string.Empty;
            var source             = string.Empty;
            var title              = string.Empty;
            var origin             = string.Empty;
            var description        = string.Empty;
            var image              = string.Empty;
            var sites              = "weibo, qq, qzone, douban";
            var disabled           = string.Empty;
            var wechatQrcodeTitle  = string.Empty;
            var wechatQrcodeHelper = string.Empty;
            var attributes         = new NameValueCollection();

            foreach (var name in context.StlAttributes.AllKeys)
            {
                var value = context.StlAttributes[name];

                if (StringUtils.EqualsIgnoreCase(name, AttributeUrl))
                {
                    url = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeSource))
                {
                    source = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeTitle))
                {
                    title = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeOrigin))
                {
                    origin = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeDescription))
                {
                    description = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeImage))
                {
                    image = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeSites))
                {
                    sites = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeDisabled))
                {
                    disabled = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeWechatQrcodeTitle))
                {
                    wechatQrcodeTitle = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeWechatQrcodeHelper))
                {
                    wechatQrcodeHelper = await context.ParseAsync(value);
                }
                else
                {
                    attributes[name] = await context.ParseAsync(value);
                }
            }

            var settings = await _shareManager.GetSettingsAsync(context.SiteId);

            var site = await _siteRepository.GetAsync(context.SiteId);

            if (settings.IsWxShare)
            {
                sites += ",wechat";
            }

            var cssUrl = _pathManager.GetApiHostUrl(site, "/assets/share/css/share.min.css");
            var jsUrl  = _pathManager.GetApiHostUrl(site, "/assets/share/js/social-share.min.js");

            context.HeadCodes[ShareManager.PluginId] = @$ "<link rel=" "stylesheet" " href=" "{cssUrl}" ">";
            context.FootCodes[ShareManager.PluginId] = @$ "<script type=" "text/javascript" " src=" "{jsUrl}" "></script>";

            Content content = null;

            if (context.ContentId > 0)
            {
                if (string.IsNullOrEmpty(title))
                {
                    if (content == null)
                    {
                        content = await _contentRepository.GetAsync(site, context.ChannelId, context.ContentId);
                    }

                    if (content != null)
                    {
                        title = content.Title;
                    }
                }
                if (string.IsNullOrEmpty(image))
                {
                    if (content == null)
                    {
                        content = await _contentRepository.GetAsync(site, context.ChannelId, context.ContentId);
                    }

                    if (content != null && !string.IsNullOrEmpty(content.ImageUrl))
                    {
                        image = await _pathManager.ParseSiteUrlAsync(site, content.ImageUrl, false);

                        image = PageUtils.AddProtocolToUrl(image);
                    }
                }
                if (string.IsNullOrEmpty(description))
                {
                    if (content == null)
                    {
                        content = await _contentRepository.GetAsync(site, context.ChannelId, context.ContentId);
                    }

                    if (content != null)
                    {
                        description = content.Summary;
                        if (string.IsNullOrEmpty(description))
                        {
                            description = StringUtils.MaxLengthText(StringUtils.StripTags(content.Body), 50);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(title))
            {
                title = settings.DefaultTitle;
            }
            if (string.IsNullOrEmpty(image) && !string.IsNullOrEmpty(settings.DefaultImageUrl))
            {
                image = await _pathManager.ParseSiteUrlAsync(site, settings.DefaultImageUrl, false);

                image = PageUtils.AddProtocolToUrl(image);
            }
            if (string.IsNullOrEmpty(description))
            {
                description = settings.DefaultDescription;
            }

            if (!string.IsNullOrEmpty(url))
            {
                attributes["data-url"] = url;
            }
            if (!string.IsNullOrEmpty(source))
            {
                attributes["data-source"] = source;
            }
            if (!string.IsNullOrEmpty(title))
            {
                attributes["data-title"] = title;
            }
            if (!string.IsNullOrEmpty(origin))
            {
                attributes["data-origin"] = origin;
            }
            if (!string.IsNullOrEmpty(description))
            {
                attributes["data-description"] = description;
            }
            if (!string.IsNullOrEmpty(image))
            {
                attributes["data-image"] = image;
            }
            if (!string.IsNullOrEmpty(sites))
            {
                attributes["data-sites"] = sites;
            }
            if (!string.IsNullOrEmpty(disabled))
            {
                attributes["data-disabled"] = disabled;
            }
            if (!string.IsNullOrEmpty(wechatQrcodeTitle))
            {
                attributes["data-wechat-qrcode-title"] = wechatQrcodeTitle;
            }
            if (!string.IsNullOrEmpty(wechatQrcodeHelper))
            {
                attributes["data-data-wechat-qrcode-helper"] = wechatQrcodeHelper;
            }

            return($@"<div class=""social-share"" {TranslateUtils.ToAttributesString(attributes)}></div>");
        }
Ejemplo n.º 25
0
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string tabName, bool isHeader, string action, string classActive, string classNormal, int current)
        {
            pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery);

            var builder  = new StringBuilder();
            var uniqueId = pageInfo.UniqueId;

            if (contextInfo.ChildNodes.Count > 0)
            {
                if (isHeader)
                {
                    builder.Append($@"
<SCRIPT language=javascript>
function stl_tab_{uniqueId}(tabName, no){{
	for ( i = 1; i <= {contextInfo.ChildNodes.Count}; i++){{
		var el = jQuery('#{tabName}_tabContent_' + i);
		var li = $('#{tabName}_tabHeader_' + i);
		if (i == no){{
            try{{
			    el.show();
            }}catch(e){{}}
            li.removeClass('{classNormal}');
            li.addClass('{classActive}');
		}}else{{
            try{{
			    el.hide();
            }}catch(e){{}}
            li.removeClass('{classActive}');
            li.addClass('{classNormal}');
		}}
	}}
}}
</SCRIPT>
");
                }

                var count = 0;
                foreach (XmlNode xmlNode in contextInfo.ChildNodes)
                {
                    if (xmlNode.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    var attributes = new NameValueCollection();
                    if (xmlNode.Attributes != null)
                    {
                        var xmlIe = xmlNode.Attributes.GetEnumerator();
                        while (xmlIe.MoveNext())
                        {
                            var attr = (XmlAttribute)xmlIe.Current;
                            if (attr == null)
                            {
                                continue;
                            }

                            var attributeName = attr.Name.ToLower();
                            if (!StringUtils.EqualsIgnoreCase(attr.Name, "id") && !StringUtils.EqualsIgnoreCase(attr.Name, "onmouseover") && !StringUtils.EqualsIgnoreCase(attr.Name, "onclick"))
                            {
                                attributes[attributeName] = attr.Value;
                            }
                        }
                    }

                    count++;
                    if (isHeader)
                    {
                        attributes["id"] = $"{tabName}_tabHeader_{count}";
                        if (StringUtils.EqualsIgnoreCase(action, ActionMouseOver))
                        {
                            attributes["onmouseover"] = $"stl_tab_{uniqueId}('{tabName}', {count});return false;";
                        }
                        else
                        {
                            attributes["onclick"] = $"stl_tab_{uniqueId}('{tabName}', {count});return false;";
                        }
                        if (current != 0)
                        {
                            if (count == current)
                            {
                                attributes["class"] = classActive;
                            }
                            else
                            {
                                attributes["class"] = classNormal;
                            }
                        }
                    }
                    else
                    {
                        attributes["id"] = $"{tabName}_tabContent_{count}";
                        if (current != 0)
                        {
                            if (count != current)
                            {
                                attributes["style"] = $"display:none;{attributes["style"]}";
                            }
                        }
                    }

                    var innerXml = string.Empty;
                    if (!string.IsNullOrEmpty(xmlNode.InnerXml))
                    {
                        var innerBuilder = new StringBuilder(xmlNode.InnerXml);
                        StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                        StlParserUtility.XmlToHtml(innerBuilder);
                        innerXml = innerBuilder.ToString();
                    }

                    builder.Append(
                        $"<{xmlNode.Name} {TranslateUtils.ToAttributesString(attributes)}>{innerXml}</{xmlNode.Name}>");
                }
            }

            return(builder.ToString());
        }
Ejemplo n.º 26
0
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, InputInfo inputInfo, NameValueCollection pageScripts, List <TableStyleInfo> styleInfoList, string template, string loading, string yes, string no)
        {
            pageInfo.AddPageScriptsIfNotExists(PageInfo.Components.Jquery);
            var stlContainerId = $"stl_input_{inputInfo.InputId}";
            var stlFormId      = $"stl_form_{inputInfo.InputId}";

            template = StlParserManager.ParseInnerContent(template, pageInfo, contextInfo);
            loading  = StlParserManager.ParseInnerContent(loading, pageInfo, contextInfo);
            yes      = StlParserManager.ParseInnerContent(yes, pageInfo, contextInfo);
            no       = StlParserManager.ParseInnerContent(no, pageInfo, contextInfo);

            var templateBuilder = new StringBuilder();

            templateBuilder.Append($@"
<script type=""text/javascript"" src=""{SiteFilesAssets.Input.GetScriptUrl(pageInfo.ApiUrl)}""></script>
<form id=""{stlFormId}"" name=""{stlFormId}"" style=""margin:0;padding:0"" method=""post"" enctype=""multipart/form-data"" action=""{ActionsInputAdd.GetUrl(pageInfo.ApiUrl, pageInfo.PublishmentSystemId, inputInfo.InputId)}"" target=""stl_iframe_{inputInfo.InputId}"">
    {template}
</form>
<iframe id=""stl_iframe_{inputInfo.InputId}"" name=""stl_iframe_{inputInfo.InputId}"" width=""0"" height=""0"" frameborder=""0""></iframe>
");

            foreach (string key in pageScripts.Keys)
            {
                templateBuilder.Append(pageScripts[key]);
            }

            var idList       = new List <string>();
            var formElements = StlHtmlUtility.GetHtmlFormElements(templateBuilder.ToString());

            if (formElements != null && formElements.Count > 0)
            {
                foreach (var formElement in formElements)
                {
                    string tagName;
                    string innerXml;
                    NameValueCollection attributes;
                    StlHtmlUtility.ParseHtmlElement(formElement, out tagName, out innerXml, out attributes);

                    if (string.IsNullOrEmpty(attributes["id"]))
                    {
                        continue;
                    }

                    foreach (var styleInfo in styleInfoList)
                    {
                        if (!StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, attributes["id"]))
                        {
                            continue;
                        }

                        string validateAttributes;
                        var    validateHtmlString = GetValidateHtmlString(styleInfo, out validateAttributes);
                        attributes["id"]   = styleInfo.AttributeName;
                        attributes["name"] = styleInfo.AttributeName;

                        var replace = StringUtils.EqualsIgnoreCase(tagName, "input")
                            ? $@"<{tagName} {TranslateUtils.ToAttributesString(attributes)} {validateAttributes} />{validateHtmlString}"
                            : $@"<{tagName} {TranslateUtils.ToAttributesString(attributes)} {validateAttributes} >{innerXml}</{tagName}>{validateHtmlString}";

                        templateBuilder.Replace(formElement, replace);

                        idList.Add(styleInfo.AttributeName);
                    }
                }
            }

            StlHtmlUtility.RewriteSubmitButton(templateBuilder, $"inputSubmit(this, '{stlFormId}', '{stlContainerId}', [{TranslateUtils.ToSqlInStringWithQuote(idList)}]);return false;");

            StlParserManager.ParseInnerContent(templateBuilder, pageInfo, contextInfo);

            return($@"
<div id=""{stlContainerId}"">
    <div class=""stl_input_template"">{templateBuilder}</div>
    <div class=""stl_input_loading"" style=""display:none"">{loading}</div>
    <div class=""stl_input_yes"" style=""display:none"">{yes}</div>
    <div class=""stl_input_no"" style=""display:none"">{no}</div>
</div>
");
        }
Ejemplo n.º 27
0
        public async Task <string> ParseAsync(IParseStlContext context)
        {
            var type        = string.Empty;
            var url         = string.Empty;
            var redirectUrl = await context.GetCurrentUrlAsync();

            var attributes = new NameValueCollection();

            foreach (var name in context.StlAttributes.AllKeys)
            {
                var value = context.StlAttributes[name];
                if (StringUtils.EqualsIgnoreCase(name, AttributeType))
                {
                    type = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeUrl))
                {
                    url = await context.ParseAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeRedirectUrl))
                {
                    redirectUrl = await context.ParseAsync(value);
                }
                else
                {
                    attributes.Add(name, await context.ParseAsync(value));
                }
            }

            var site = await _siteRepository.GetAsync(context.SiteId);

            var apiUrl = _pathManager.GetApiHostUrl(site, Constants.ApiPrefix);

            if (!string.IsNullOrEmpty(url))
            {
                var parsedUrl = string.Empty;

                if (StringUtils.EqualsIgnoreCase(url, OAuthType.Weibo.Value))
                {
                    parsedUrl = $"{ApiUtils.GetAuthUrl(OAuthType.Weibo)}?redirectUrl={HttpUtility.UrlEncode(redirectUrl)}";
                }
                else if (StringUtils.EqualsIgnoreCase(url, OAuthType.Weixin.Value))
                {
                    parsedUrl = $"{ApiUtils.GetAuthUrl(OAuthType.Weixin)}?redirectUrl={HttpUtility.UrlEncode(redirectUrl)}";
                }
                else if (StringUtils.EqualsIgnoreCase(url, OAuthType.Qq.Value))
                {
                    parsedUrl = $"{ApiUtils.GetAuthUrl(OAuthType.Qq)}?redirectUrl={HttpUtility.UrlEncode(redirectUrl)}";
                }
                else if (StringUtils.EqualsIgnoreCase(url, "logout"))
                {
                    parsedUrl = _pathManager.GetApiHostUrl(site, $"assets/login/templates/logout/index.html?apiUrl={HttpUtility.UrlEncode(apiUrl)}&redirectUrl={HttpUtility.UrlEncode(redirectUrl)}");
                }

                if (!string.IsNullOrEmpty(parsedUrl))
                {
                    if (context.IsStlEntity)
                    {
                        return(parsedUrl);
                    }

                    attributes["href"] = parsedUrl;

                    return($@"<a {TranslateUtils.ToAttributesString(attributes)}>{context.StlInnerHtml}</a>");
                }
            }

            if (string.IsNullOrEmpty(type))
            {
                type = "login-account";
            }

            var elementId = $"iframe_{StringUtils.GetShortGuid(false)}";
            var libUrl    = _pathManager.GetApiHostUrl(site, "assets/login/lib/iframe-resizer-3.6.3/iframeResizer.min.js");
            var pageUrl   = _pathManager.GetApiHostUrl(site, $"assets/login/templates/{type}/index.html?apiUrl={HttpUtility.UrlEncode(apiUrl)}&redirectUrl={HttpUtility.UrlEncode(redirectUrl)}");

            return($@"
<iframe id=""{elementId}"" frameborder=""0"" scrolling=""no"" src=""{pageUrl}"" style=""width: 1px;min-width: 100%;""></iframe>
<script type=""text/javascript"" src=""{libUrl}""></script>
<script type=""text/javascript"">iFrameResize({{log: false}}, '#{elementId}')</script>
");
        }
Ejemplo n.º 28
0
Archivo: StlA.cs Proyecto: yunxb/cms
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string channelIndex,
                                        string channelName, int upLevel, int topLevel, bool removeTarget, string href, string queryString,
                                        string host, Dictionary <string, string> attributes)
        {
            string htmlId;

            attributes.TryGetValue("id", out htmlId);

            if (!string.IsNullOrEmpty(htmlId) && !string.IsNullOrEmpty(contextInfo.ContainerClientId))
            {
                htmlId = contextInfo.ContainerClientId + "_" + htmlId;
            }

            if (!string.IsNullOrEmpty(htmlId))
            {
                attributes["id"] = htmlId;
            }

            var innerHtml = string.Empty;

            var url     = string.Empty;
            var onclick = string.Empty;

            if (!string.IsNullOrEmpty(href))
            {
                url = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, href, pageInfo.IsLocal);

                var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                innerHtml = innerBuilder.ToString();
            }
            else
            {
                if (contextInfo.ContextType == EContextType.Undefined)
                {
                    contextInfo.ContextType = contextInfo.ContentId != 0 ? EContextType.Content : EContextType.Channel;
                }

                if (contextInfo.ContextType == EContextType.Content) //获取内容Url
                {
                    if (contextInfo.ContentInfo != null)
                    {
                        url = PageUtility.GetContentUrl(pageInfo.SiteInfo, contextInfo.ContentInfo, pageInfo.IsLocal);
                    }
                    else
                    {
                        var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId);
                        url = PageUtility.GetContentUrl(pageInfo.SiteInfo, nodeInfo, contextInfo.ContentId,
                                                        pageInfo.IsLocal);
                    }

                    if (string.IsNullOrEmpty(contextInfo.InnerHtml))
                    {
                        var title = contextInfo.ContentInfo?.Title;
                        title = ContentUtility.FormatTitle(
                            contextInfo.ContentInfo?.GetString("BackgroundContentAttribute.TitleFormatString"), title);

                        if (pageInfo.SiteInfo.Additional.IsContentTitleBreakLine)
                        {
                            title = title.Replace("  ", string.Empty);
                        }

                        innerHtml = title;
                    }
                    else
                    {
                        var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                        StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                        innerHtml = innerBuilder.ToString();
                    }
                }
                else if (contextInfo.ContextType == EContextType.Channel) //获取栏目Url
                {
                    contextInfo.ChannelId =
                        StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel);
                    contextInfo.ChannelId =
                        ChannelManager.GetChannelId(pageInfo.SiteId,
                                                    contextInfo.ChannelId, channelIndex, channelName);
                    var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId);

                    url = PageUtility.GetChannelUrl(pageInfo.SiteInfo, channel, pageInfo.IsLocal);
                    if (string.IsNullOrWhiteSpace(contextInfo.InnerHtml))
                    {
                        innerHtml = channel.ChannelName;
                    }
                    else
                    {
                        var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                        StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                        innerHtml = innerBuilder.ToString();
                    }
                }
            }

            if (url.Equals(PageUtils.UnclickedUrl))
            {
                removeTarget = true;
            }
            else
            {
                if (!string.IsNullOrEmpty(host))
                {
                    url = PageUtils.AddProtocolToUrl(url, host);
                }

                if (!string.IsNullOrEmpty(queryString))
                {
                    url = PageUtils.AddQueryString(url, queryString);
                }
            }

            attributes["href"] = url;

            if (!string.IsNullOrEmpty(onclick))
            {
                attributes["onclick"] = onclick;
            }

            if (removeTarget)
            {
                attributes["target"] = string.Empty;
            }

            // 如果是实体标签,则只返回url
            if (contextInfo.IsStlEntity)
            {
                return(url);
            }

            return($@"<a {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</a>");
        }
Ejemplo n.º 29
0
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string type, string playUrl, string imageUrl, int width, int height, bool isAutoPlay, bool isControls, bool isLoop)
        {
            var videoUrl = string.Empty;

            if (!string.IsNullOrEmpty(playUrl))
            {
                videoUrl = playUrl;
            }
            else
            {
                var contentId = contextInfo.ContentId;
                if (contextInfo.ContextType == EContextType.Content)
                {
                    if (contentId != 0)//获取内容视频
                    {
                        if (contextInfo.ContentInfo == null)
                        {
                            videoUrl = Content.GetValue(pageInfo.SiteInfo.TableName, contentId, type);
                            if (string.IsNullOrEmpty(videoUrl))
                            {
                                if (!StringUtils.EqualsIgnoreCase(type, BackgroundContentAttribute.VideoUrl))
                                {
                                    videoUrl = Content.GetValue(pageInfo.SiteInfo.TableName, contentId, BackgroundContentAttribute.VideoUrl);
                                }
                            }
                        }
                        else
                        {
                            videoUrl = contextInfo.ContentInfo.GetString(type);
                            if (string.IsNullOrEmpty(videoUrl))
                            {
                                videoUrl = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.VideoUrl);
                            }
                        }
                    }
                }
                else if (contextInfo.ContextType == EContextType.Each)
                {
                    videoUrl = contextInfo.ItemContainer.EachItem.DataItem as string;
                }
            }

            if (string.IsNullOrEmpty(videoUrl))
            {
                return(string.Empty);
            }

            videoUrl = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, videoUrl, pageInfo.IsLocal);
            imageUrl = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, imageUrl, pageInfo.IsLocal);

            pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.JsAcVideoJs);

            var dict = new Dictionary <string, string>
            {
                { "class", "video-js vjs-default-skin" },
                { "src", videoUrl }
            };

            if (isAutoPlay)
            {
                dict.Add("autoplay", null);
            }
            if (isControls)
            {
                dict.Add("controls", null);
            }
            if (isLoop)
            {
                dict.Add("loop", null);
            }
            if (!string.IsNullOrEmpty(imageUrl))
            {
                dict.Add("poster", imageUrl);
            }
            if (width > 0)
            {
                dict.Add("width", width.ToString());
            }
            if (height > 0)
            {
                dict.Add("height", height.ToString());
            }

            return($@"<video {TranslateUtils.ToAttributesString(dict)}></video>");
        }
Ejemplo n.º 30
0
        private static async Task <string> ParseImplAsync(IParseManager parseManager, NameValueCollection attributes, string type, string emptyText, string tipText, int wordNum, bool isKeyboard)
        {
            var databaseManager = parseManager.DatabaseManager;
            var pageInfo        = parseManager.PageInfo;
            var contextInfo     = parseManager.ContextInfo;

            string parsedContent;

            var innerHtml = string.Empty;

            StlParserUtility.GetYesNo(contextInfo.InnerHtml, out var successTemplateString, out var failureTemplateString);

            var contentInfo = await parseManager.GetContentAsync();

            if (string.IsNullOrEmpty(successTemplateString))
            {
                var nodeInfo = await databaseManager.ChannelRepository.GetAsync(contextInfo.ChannelId);

                if (StringUtils.EqualsIgnoreCase(type, TypePreviousChannel) || StringUtils.EqualsIgnoreCase(type, TypeNextChannel))
                {
                    var taxis         = nodeInfo.Taxis;
                    var isNextChannel = !StringUtils.EqualsIgnoreCase(type, TypePreviousChannel);
                    //var siblingChannelId = databaseManager.ChannelRepository.GetIdByParentIdAndTaxis(node.ParentId, taxis, isNextChannel);
                    var siblingChannelId = await databaseManager.ChannelRepository.GetIdByParentIdAndTaxisAsync(pageInfo.SiteId, nodeInfo.ParentId, taxis, isNextChannel);

                    if (siblingChannelId != 0)
                    {
                        var siblingNodeInfo = await databaseManager.ChannelRepository.GetAsync(siblingChannelId);

                        var url = await parseManager.PathManager.GetChannelUrlAsync(pageInfo.Site, siblingNodeInfo, pageInfo.IsLocal);

                        if (url.Equals(PageUtils.UnClickableUrl))
                        {
                            attributes["target"] = string.Empty;
                        }
                        attributes["href"] = url;

                        if (string.IsNullOrEmpty(contextInfo.InnerHtml))
                        {
                            innerHtml = await databaseManager.ChannelRepository.GetChannelNameAsync(pageInfo.SiteId, siblingChannelId);

                            if (wordNum > 0)
                            {
                                innerHtml = StringUtils.MaxLengthText(innerHtml, wordNum);
                            }
                        }
                        else
                        {
                            contextInfo.ChannelId = siblingChannelId;
                            var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                            await parseManager.ParseInnerContentAsync(innerBuilder);

                            innerHtml = innerBuilder.ToString();
                        }
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(type, TypePreviousContent) || StringUtils.EqualsIgnoreCase(type, TypeNextContent))
                {
                    if (contextInfo.ContentId != 0)
                    {
                        var taxis         = contentInfo.Taxis;
                        var isNextContent = !StringUtils.EqualsIgnoreCase(type, TypePreviousContent);
                        var tableName     = await databaseManager.ChannelRepository.GetTableNameAsync(pageInfo.Site, contextInfo.ChannelId);

                        var siblingContentId = await databaseManager.ContentRepository.GetContentIdAsync(tableName, contextInfo.ChannelId, taxis, isNextContent);

                        if (siblingContentId != 0)
                        {
                            var siblingContentInfo = await databaseManager.ContentRepository.GetAsync(pageInfo.Site, contextInfo.ChannelId, siblingContentId);

                            var url = await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, siblingContentInfo, pageInfo.IsLocal);

                            if (url.Equals(PageUtils.UnClickableUrl))
                            {
                                attributes["target"] = string.Empty;
                            }
                            attributes["href"] = url;

                            if (isKeyboard)
                            {
                                var keyCode       = isNextContent ? 39 : 37;
                                var scriptContent = new StringBuilder();
                                await pageInfo.AddPageHeadCodeIfNotExistsAsync(ParsePage.Const.Jquery);

                                scriptContent.Append($@"<script language=""javascript"" type=""text/javascript""> 
      $(document).keydown(function(event){{
        if(event.keyCode=={keyCode}){{location = '{url}';}}
      }});
</script> 
");
                                var nextOrPrevious = isNextContent ? "nextContent" : "previousContent";

                                pageInfo.BodyCodes[nextOrPrevious] = scriptContent.ToString();
                            }

                            if (string.IsNullOrEmpty(contextInfo.InnerHtml))
                            {
                                innerHtml = siblingContentInfo.Title;
                                if (wordNum > 0)
                                {
                                    innerHtml = StringUtils.MaxLengthText(innerHtml, wordNum);
                                }
                            }
                            else
                            {
                                var innerBuilder = new StringBuilder(contextInfo.InnerHtml);
                                contextInfo.ContentId = siblingContentId;
                                await parseManager.ParseInnerContentAsync(innerBuilder);

                                innerHtml = innerBuilder.ToString();
                            }
                        }
                    }
                }

                parsedContent = string.IsNullOrEmpty(attributes["href"]) ? emptyText : $@"<a {TranslateUtils.ToAttributesString(attributes)}>{innerHtml}</a>";
            }
            else
            {
                var context = parseManager.ContextInfo;

                var nodeInfo = await databaseManager.ChannelRepository.GetAsync(contextInfo.ChannelId);

                var isSuccess = false;
                parseManager.ContextInfo = contextInfo.Clone();

                if (StringUtils.EqualsIgnoreCase(type, TypePreviousChannel) || StringUtils.EqualsIgnoreCase(type, TypeNextChannel))
                {
                    var taxis         = nodeInfo.Taxis;
                    var isNextChannel = !StringUtils.EqualsIgnoreCase(type, TypePreviousChannel);
                    //var siblingChannelId = databaseManager.ChannelRepository.GetIdByParentIdAndTaxis(node.ParentId, taxis, isNextChannel);
                    var siblingChannelId = await databaseManager.ChannelRepository.GetIdByParentIdAndTaxisAsync(pageInfo.SiteId, nodeInfo.ParentId, taxis, isNextChannel);

                    if (siblingChannelId != 0)
                    {
                        isSuccess = true;
                        parseManager.ContextInfo.ContextType = ParseType.Channel;
                        parseManager.ContextInfo.ChannelId   = siblingChannelId;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(type, TypePreviousContent) || StringUtils.EqualsIgnoreCase(type, TypeNextContent))
                {
                    if (contextInfo.ContentId != 0)
                    {
                        var taxis         = contentInfo.Taxis;
                        var isNextContent = !StringUtils.EqualsIgnoreCase(type, TypePreviousContent);
                        var tableName     = await databaseManager.ChannelRepository.GetTableNameAsync(pageInfo.Site, contextInfo.ChannelId);

                        var siblingContentId = await databaseManager.ContentRepository.GetContentIdAsync(tableName, contextInfo.ChannelId, taxis, isNextContent);

                        if (siblingContentId != 0)
                        {
                            isSuccess = true;
                            parseManager.ContextInfo.ContextType = ParseType.Content;
                            parseManager.ContextInfo.ContentId   = siblingContentId;
                            parseManager.ContextInfo.SetContent(null);
                        }
                    }
                }

                parsedContent = isSuccess ? successTemplateString : failureTemplateString;

                if (!string.IsNullOrEmpty(parsedContent))
                {
                    var innerBuilder = new StringBuilder(parsedContent);
                    await parseManager.ParseInnerContentAsync(innerBuilder);

                    parsedContent = innerBuilder.ToString();
                }

                parseManager.ContextInfo = context;
            }

            parsedContent = tipText + parsedContent;

            return(parsedContent);
        }