示例#1
0
        private static async Task <string> ParseAsync(IParseManager parseManager, string type, string channelIndex, string channelName, int upLevel, int topLevel, ScopeType scope, string since)
        {
            var databaseManager = parseManager.DatabaseManager;
            var pageInfo        = parseManager.PageInfo;
            var contextInfo     = parseManager.ContextInfo;

            var count = 0;

            var sinceDate = Constants.SqlMinValue;

            if (!string.IsNullOrEmpty(since))
            {
                sinceDate = DateTime.Now.AddHours(-DateUtils.GetSinceHours(since));
            }

            if (string.IsNullOrEmpty(type) || StringUtils.EqualsIgnoreCase(type, TypeContents))
            {
                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 channelIdList = await databaseManager.ChannelRepository.GetChannelIdsAsync(pageInfo.SiteId, channelId, scope);

                foreach (var theChannelId in channelIdList)
                {
                    var tableName = await databaseManager.ChannelRepository.GetTableNameAsync(pageInfo.Site, theChannelId);

                    count += await databaseManager.ContentRepository.GetCountOfContentAddAsync(tableName, pageInfo.SiteId, theChannelId, ScopeType.Self, sinceDate, DateTime.Now.AddDays(1), 0, true);
                }
            }
            else if (StringUtils.EqualsIgnoreCase(type, TypeChannels))
            {
                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 nodeInfo = await databaseManager.ChannelRepository.GetAsync(channelId);

                count = nodeInfo.ChildrenCount;
            }

            return(count.ToString());
        }
示例#2
0
        protected static async Task <List <KeyValuePair <int, Channel> > > GetChannelsDataSourceAsync(IParseManager parseManager, ListInfo listInfo)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;

            var dataManager = new StlDataManager(parseManager.DatabaseManager);
            var channelId   = await dataManager.GetChannelIdByLevelAsync(pageInfo.SiteId, contextInfo.ChannelId, listInfo.UpLevel, listInfo.TopLevel);

            channelId = await dataManager.GetChannelIdByChannelIdOrChannelIndexOrChannelNameAsync(pageInfo.SiteId, channelId, listInfo.ChannelIndex, listInfo.ChannelName);

            var isTotal = TranslateUtils.ToBool(listInfo.Others.Get(nameof(IsTotal)));

            if (TranslateUtils.ToBool(listInfo.Others.Get(nameof(IsAllChildren))))
            {
                listInfo.Scope = ScopeType.Descendant;
            }

            var taxisType = GetChannelTaxisTypeByOrder(listInfo.Order);

            return(await parseManager.DatabaseManager.ChannelRepository.ParserGetChannelsAsync(pageInfo.SiteId, channelId,
                                                                                               listInfo.GroupChannel, listInfo.GroupChannelNot, listInfo.IsImageExists, listInfo.IsImage,
                                                                                               listInfo.StartNum, listInfo.TotalNum, taxisType, listInfo.Scope, isTotal));
        }
示例#3
0
        private static async Task <object> ParseAsync(IParseManager parseManager, NameValueCollection attributes,
                                                      bool isGetPicUrlFromAttribute, string channelIndex, string channelName, int upLevel, int topLevel,
                                                      string type, int no, bool isOriginal, bool isClearTags, string src, string altSrc)
        {
            var databaseManager = parseManager.DatabaseManager;
            var pageInfo        = parseManager.PageInfo;
            var contextInfo     = parseManager.ContextInfo;

            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    = await databaseManager.ChannelRepository.GetSiteIdAsync(targetChannelId);

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

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

                            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);

                    if (no <= 1)
                    {
                        picUrl = channel.Get <string>(type);
                    }
                    else
                    {
                        var extendName = ColumnsManager.GetExtendName(type, no - 1);
                        picUrl = channel.Get <string>(extendName);
                    }
                }
                else if (contextType == ParseType.Each)
                {
                    picUrl = contextInfo.ItemContainer.EachItem.Value as string;
                }
            }

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

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

            var extension = PathUtils.GetExtension(picUrl);

            if (FileUtils.IsFlash(extension))
            {
                return(await StlPdf.ParseAsync(parseManager));
            }

            if (FileUtils.IsPlayer(extension))
            {
                return(await StlPlayer.ParseAsync(parseManager));
            }

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

            if (isClearTags || contextInfo.IsStlEntity)
            {
                return(picUrl);
            }

            attributes["src"] = picUrl;

            var parsedContent = string.Empty;

            if (pageInfo.EditMode == EditMode.Visual)
            {
                var elementId = StringUtils.GetElementId();
                VisualUtility.AddEditableToAttributes(attributes, elementId, contextInfo.ElementName);
                parsedContent = GetParsedContent(attributes);
                VisualUtility.AddEditableToPage(pageInfo, elementId, contextInfo, parsedContent);
            }
            else
            {
                parsedContent = GetParsedContent(attributes);
            }

            return(parsedContent);
        }
示例#4
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);
        }
示例#5
0
        private static async Task <string> ParseImplAsync(IParseManager parseManager, NameValueCollection attributes, bool isChannel, string channelIndex, string channelName, int upLevel, int topLevel, string scopeTypeString, string groupChannel, string groupChannelNot, string groupContent, string groupContentNot, string tags, string order, int totalNum, int titleWordNum, string queryString, bool isTop, bool isTopExists, bool isRecommend, bool isRecommendExists, bool isHot, bool isHotExists, bool isColor, bool isColorExists, string displayTitle, bool openWin)
        {
            var databaseManager = parseManager.DatabaseManager;
            var pageInfo        = parseManager.PageInfo;
            var contextInfo     = parseManager.ContextInfo;

            ScopeType scopeType;

            if (!string.IsNullOrEmpty(scopeTypeString))
            {
                scopeType = TranslateUtils.ToEnum(scopeTypeString, ScopeType.Self);
            }
            else
            {
                scopeType = isChannel ? ScopeType.Children : ScopeType.Self;
            }

            var dataManager   = new StlDataManager(parseManager.DatabaseManager);
            var orderByString = isChannel ? order : dataManager.GetContentOrderByString(pageInfo.SiteId, order, TaxisType.OrderByTaxisDesc);

            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);

            var uniqueId = "Select_" + pageInfo.UniqueId;

            attributes["id"] = uniqueId;

            string scriptHtml;

            if (openWin)
            {
                scriptHtml             = $@"
<script language=""javascript"" type=""text/javascript"">
<!--
function {uniqueId}_jumpMenu(targ,selObj)
{"{"} //v3.0
window.open(selObj.options[selObj.selectedIndex].value);
selObj.selectedIndex=0;
{"}"}
//-->
</script>";
                attributes["onchange"] = $"{uniqueId}_jumpMenu('parent',this)";
            }
            else
            {
                scriptHtml =
                    $"<script language=\"JavaScript\">function {uniqueId}_jumpMenu(targ,selObj,restore){{eval(targ+\".location=\'\"+selObj.options[selObj.selectedIndex].value+\"\'\");if (restore) selObj.selectedIndex=0;}}</script>";
                attributes["onchange"] = $"{uniqueId}_jumpMenu('self',this, 0)";
            }

            var htmlBuilder = new StringBuilder();

            using (var htmlSelect = new HtmlSelect(htmlBuilder, attributes))
            {
                if (!string.IsNullOrEmpty(displayTitle))
                {
                    htmlSelect.AddOption(displayTitle, PageUtils.UnClickableUrl, true);
                }

                if (isChannel)
                {
                    var channelIdList = await dataManager.GetChannelIdListAsync(pageInfo.SiteId, channel.Id, orderByString, scopeType, groupChannel, groupChannelNot, false, false, totalNum);

                    if (channelIdList != null && channelIdList.Any())
                    {
                        foreach (var channelIdInSelect in channelIdList)
                        {
                            var nodeInfo = await databaseManager.ChannelRepository.GetAsync(channelIdInSelect);

                            if (nodeInfo != null)
                            {
                                var title = StringUtils.MaxLengthText(nodeInfo.ChannelName, titleWordNum);
                                var url   = await parseManager.PathManager.GetChannelUrlAsync(pageInfo.Site, nodeInfo, pageInfo.IsLocal);

                                if (!string.IsNullOrEmpty(queryString))
                                {
                                    url = PageUtils.AddQueryString(url, queryString);
                                }
                                htmlSelect.AddOption(title, url);
                            }
                        }
                    }
                }
                else
                {
                    var minContentInfoList = await databaseManager.ContentRepository.GetSummariesAsync(parseManager.DatabaseManager, pageInfo.Site, channelId, contextInfo.ContentId, groupContent, groupContentNot, tags, false, false, false, false, false, false, false, 1, totalNum, orderByString, isTopExists, isTop, isRecommendExists, isRecommend, isHotExists, isHot, isColorExists, isColor, scopeType, groupChannel, groupChannelNot, null);

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

                            var title = StringUtils.MaxLengthText(contentInfo.Title, titleWordNum);
                            var url   = await parseManager.PathManager.GetContentUrlAsync(pageInfo.Site, contentInfo, false);

                            if (!string.IsNullOrEmpty(queryString))
                            {
                                url = PageUtils.AddQueryString(url, queryString);
                            }
                            htmlSelect.AddOption(title, url);
                        }
                        //foreach (var dataItem in dataSource)
                        //{
                        //    var contentInfo = new BackgroundContentInfo(dataItem);
                        //    if (contentInfo != null)
                        //    {
                        //        var title = StringUtils.MaxLengthText(contentInfo.Title, titleWordNum);
                        //        var url = PageUtility.GetContentUrl(pageInfo.Site, contentInfo);
                        //        if (!string.IsNullOrEmpty(queryString))
                        //        {
                        //            url = PageUtils.AddQueryString(url, queryString);
                        //        }
                        //        var listitem = new ListItem(title, url);
                        //        selectControl.Items.Add(listitem);
                        //    }
                        //}
                    }
                }
            }

            return(scriptHtml + htmlBuilder);
        }
示例#6
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);
        }
示例#7
0
        private static async Task <object> ParseImplAsync(IParseManager parseManager, bool isGetPicUrlFromAttribute, string channelIndex, string channelName, int upLevel, int topLevel, string type, string src, string altSrc, string width, string height)
        {
            var pageInfo    = parseManager.PageInfo;
            var contextInfo = parseManager.ContextInfo;

            object parsedContent = null;

            var contentId = 0;

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

            var flashUrl = string.Empty;

            if (!string.IsNullOrEmpty(src))
            {
                flashUrl = src;
            }
            else
            {
                if (contentId != 0)//获取内容Flash
                {
                    if (contentInfo != null)
                    {
                        flashUrl = contentInfo.Get <string>(type);
                    }
                }
                else//获取栏目Flash
                {
                    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 parseManager.DatabaseManager.ChannelRepository.GetAsync(channelId);

                    flashUrl = channel.ImageUrl;
                }
            }

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

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

            if (!string.IsNullOrEmpty(flashUrl))
            {
                var extension = PathUtils.GetExtension(flashUrl);
                if (FileUtils.IsImage(extension))
                {
                    parsedContent = await StlImage.ParseAsync(parseManager);
                }
                else if (FileUtils.IsPlayer(extension))
                {
                    parsedContent = await StlPlayer.ParseAsync(parseManager);
                }
                else
                {
                    flashUrl = await parseManager.PathManager.ParseSiteUrlAsync(pageInfo.Site, flashUrl, pageInfo.IsLocal);

                    parsedContent = $@"
<embed src=""{flashUrl}"" allowfullscreen=""true"" width=""{width}"" height=""{height}"" align=""middle"" allowscriptaccess=""always"" type=""application/x-shockwave-flash"" />
";
                }
            }

            return(parsedContent);
        }
示例#8
0
        public static async Task <object> ParseAsync(IParseManager parseManager)
        {
            var contextInfo = parseManager.ContextInfo;

            if (contextInfo.IsStlEntity || string.IsNullOrWhiteSpace(contextInfo.InnerHtml))
            {
                return(string.Empty);
            }

            var channelIndex = string.Empty;
            var channelName  = string.Empty;
            var upLevel      = 0;
            var topLevel     = -1;
            var context      = contextInfo.ContextType;

            foreach (var name in contextInfo.Attributes.AllKeys)
            {
                var value = contextInfo.Attributes[name];

                if (StringUtils.EqualsIgnoreCase(name, ChannelIndex))
                {
                    channelIndex = await parseManager.ReplaceStlEntitiesForAttributeValueAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, ChannelName))
                {
                    channelName = await parseManager.ReplaceStlEntitiesForAttributeValueAsync(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, Parent))
                {
                    if (TranslateUtils.ToBool(value))
                    {
                        upLevel = 1;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, UpLevel))
                {
                    upLevel = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, TopLevel))
                {
                    topLevel = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, Context))
                {
                    context = TranslateUtils.ToEnum(value, ParseType.Undefined);
                }
            }

            var dataManager = new StlDataManager(parseManager.DatabaseManager);
            var channelId   = await dataManager.GetChannelIdByLevelAsync(parseManager.PageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel);

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

            contextInfo.ContextType = context;
            contextInfo.ChannelId   = channelId;

            var innerHtml = RegexUtils.GetInnerContent(ElementName, contextInfo.OuterHtml);

            var builder = new StringBuilder(innerHtml);
            await parseManager.ParseInnerContentAsync(builder);

            return(builder.ToString());
        }