Esempio n. 1
0
        private void RptTopMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var ltlMenuLi   = (Literal)e.Item.FindControl("ltlMenuLi");
            var ltlMenuName = (Literal)e.Item.FindControl("ltlMenuName");
            var ltlMenues   = (Literal)e.Item.FindControl("ltlMenues");
            var index       = e.Item.ItemIndex;

            if (index == 0)
            {
                if (_publishmentSystemInfo != null && _publishmentSystemInfo.PublishmentSystemId > 0)
                {
                    ltlMenuLi.Text   = @"<li class=""active"">";
                    ltlMenuName.Text =
                        $@"{EPublishmentSystemTypeUtils.GetIconHtml(_publishmentSystemInfo.PublishmentSystemType)}&nbsp;{_publishmentSystemInfo
                            .PublishmentSystemName}";
                }
                else
                {
                    ltlMenuLi.Text   = @"<li>";
                    ltlMenuName.Text = "站点管理";
                }

                var builder = new StringBuilder();

                builder.Append(@"<ul class=""dropdown-menu"">");

                var isPublishmentSystemList = GetPublishmentSystemListHtml(builder);

                builder.Append(@"</ul>");

                if (isPublishmentSystemList)
                {
                    ltlMenues.Text = builder.ToString();
                }
                else
                {
                    e.Item.Visible = false;
                }
            }
            else if (index == 1)
            {
                if (_publishmentSystemInfo != null && _publishmentSystemInfo.PublishmentSystemId > 0)
                {
                    ltlMenuLi.Text   = @"<li>";
                    ltlMenuName.Text = "站点访问地址";

                    var builder = new StringBuilder();

                    builder.Append(@"<ul class=""dropdown-menu"">");

                    if (_publishmentSystemInfo.Additional.IsMultiDeployment)
                    {
                        builder.Append(
                            $@"<li><a href=""{_publishmentSystemInfo.Additional.OuterUrl}"" target=""_blank""><i class=""icon-external-link""></i> 进入站点外网地址</a></li>");
                        builder.Append(
                            $@"<li><a href=""{_publishmentSystemInfo.Additional.InnerUrl}"" target=""_blank""><i class=""icon-external-link""></i> 进入站点内网地址</a></li>");
                    }
                    else
                    {
                        var publishmentSystemUrl = PageUtility.GetPublishmentSystemUrl(_publishmentSystemInfo, string.Empty);

                        builder.Append(
                            $@"<li><a href=""{publishmentSystemUrl}"" target=""_blank""><i class=""icon-external-link""></i> 进入站点</a></li>");
                    }

                    builder.Append(
                        $@"<li><a href=""{HomeUtils.GetUrl(_publishmentSystemInfo.Additional.HomeUrl, string.Empty)}"" target=""_blank""><i class=""icon-external-link""></i> 进入用户中心</a></li>");

                    builder.Append(@"</ul>");

                    ltlMenues.Text = builder.ToString();
                }
                else
                {
                    e.Item.Visible = false;
                }
            }
            else if (index == 2)
            {
                ltlMenuLi.Text = @"<li>";

                var tabArrayList = ProductFileUtils.GetMenuTopArrayList();

                var builder = new StringBuilder();
                foreach (Tab tab in tabArrayList)
                {
                    if (TabManager.IsValid(tab, _permissions.PermissionList))
                    {
                        var loadingUrl = GetRedirectUrl(0, tab.Id);
                        if (!string.IsNullOrEmpty(tab.Href))
                        {
                            loadingUrl = PageUtils.ParseNavigationUrl(tab.Href);
                        }

                        var target = "_self";
                        if (!string.IsNullOrEmpty(tab.Target))
                        {
                            target = tab.Target;
                        }

                        //菜单平铺,update by sessionliang at 20151207
                        builder.Append(
                            $@"<span><a href=""{loadingUrl}"" target=""{target}"" style=""padding: 10px 15px;color: #fff;"">{tab
                                .Text}</a></span>");
                    }
                }

                if (builder.Length == 0)
                {
                    e.Item.Visible = false;
                }
                else
                {
                    ltlMenues.Text = builder.ToString();
                }
            }
        }
Esempio n. 2
0
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, XmlNode node, NameValueCollection attributes, string type, string returnUrl)
        {
            var stlAnchor = new HtmlAnchor();

            foreach (string attributeName in attributes.Keys)
            {
                stlAnchor.Attributes.Add(attributeName, attributes[attributeName]);
            }

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

            var innerBuilder = new StringBuilder(node.InnerXml);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
            stlAnchor.InnerHtml = innerBuilder.ToString();

            //计算动作开始
            if (!string.IsNullOrEmpty(type))
            {
                if (StringUtils.EqualsIgnoreCase(type, TypeLogin))
                {
                    if (string.IsNullOrEmpty(returnUrl))
                    {
                        returnUrl = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo);
                    }

                    url = HomeUtils.GetLoginUrl(pageInfo.HomeUrl, returnUrl);
                }
                else if (StringUtils.EqualsIgnoreCase(type, TypeRegister))
                {
                    if (string.IsNullOrEmpty(returnUrl))
                    {
                        returnUrl = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo);
                    }

                    url = HomeUtils.GetRegisterUrl(pageInfo.HomeUrl, returnUrl);
                }
                else if (StringUtils.EqualsIgnoreCase(type, TypeLogout))
                {
                    if (string.IsNullOrEmpty(returnUrl))
                    {
                        returnUrl = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo);
                    }

                    url = HomeUtils.GetLogoutUrl(pageInfo.HomeUrl, returnUrl);
                }
                else if (StringUtils.EqualsIgnoreCase(type, TypeAddFavorite))
                {
                    pageInfo.SetPageScripts(TypeAddFavorite, @"
<script type=""text/javascript""> 
    function AddFavorite(){  
        if (document.all) {
            window.external.addFavorite(window.location.href, document.title);
        } 
        else if (window.sidebar) {
            window.sidebar.addPanel(document.title, window.location.href, """");
        }
    }
</script>
", true);
                    stlAnchor.Attributes["onclick"] = "AddFavorite();";
                }
                else if (StringUtils.EqualsIgnoreCase(type, TypeSetHomePage))
                {
                    url = pageInfo.PublishmentSystemInfo.PublishmentSystemUrl;
                    pageInfo.AddPageEndScriptsIfNotExists(TypeAddFavorite, $@"
<script type=""text/javascript""> 
    function SetHomepage(){{   
        if (document.all) {{
            document.body.style.behavior = 'url(#default#homepage)';
            document.body.setHomePage(""{url}"");
        }}
        else if (window.sidebar) {{
            if (window.netscape) {{
                try {{
                    netscape.security.PrivilegeManager.enablePrivilege(""UniversalXPConnect"");
                 }}
                catch(e) {{
                    alert(""该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true"");
                }}
             }}
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', ""{url}"");
        }}
    }}
</script>
");
                    stlAnchor.Attributes["onclick"] = "SetHomepage();";
                }
                else if (StringUtils.EqualsIgnoreCase(type, TypeTranslate))
                {
                    pageInfo.AddPageScriptsIfNotExists(PageInfo.JsAhTranslate);

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

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

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

            stlAnchor.HRef = url;

            if (!string.IsNullOrEmpty(onclick))
            {
                stlAnchor.Attributes.Add("onclick", onclick);
            }

            return(ControlUtils.GetControlRenderHtml(stlAnchor));
        }
Esempio n. 3
0
        internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo)
        {
            var parsedContent = string.Empty;

            try
            {
                var entityName    = StlParserUtility.GetNameFromEntity(stlEntity);
                var attributeName = entityName.Substring(5, entityName.Length - 6);

                if (StringUtils.EqualsIgnoreCase(PoweredBy, attributeName))//支持信息
                {
                    parsedContent = @"Powered by <a href=""http://www.siteserver.cn"" target=""_blank"">SiteServer CMS</a>";
                }
                else if (StringUtils.EqualsIgnoreCase(RootUrl, attributeName))//系统根目录地址
                {
                    parsedContent = PageUtils.ParseConfigRootUrl("~");
                    if (!string.IsNullOrEmpty(parsedContent))
                    {
                        parsedContent = parsedContent.TrimEnd('/');
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(ApiUrl, attributeName))//API地址
                {
                    parsedContent = pageInfo.ApiUrl.TrimEnd('/');
                }
                else if (StringUtils.EqualsIgnoreCase(SiteId, attributeName))//ID
                {
                    parsedContent = pageInfo.PublishmentSystemId.ToString();
                }
                else if (StringUtils.EqualsIgnoreCase(SiteName, attributeName))//名称
                {
                    parsedContent = pageInfo.PublishmentSystemInfo.PublishmentSystemName;
                }
                else if (StringUtils.EqualsIgnoreCase(SiteUrl, attributeName))//域名地址
                {
                    if (!string.IsNullOrEmpty(pageInfo.PublishmentSystemInfo.PublishmentSystemUrl))
                    {
                        parsedContent = pageInfo.PublishmentSystemInfo.PublishmentSystemUrl.TrimEnd('/');
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(SiteDir, attributeName))//文件夹
                {
                    parsedContent = pageInfo.PublishmentSystemInfo.PublishmentSystemDir;
                }
                else if (StringUtils.EqualsIgnoreCase(CurrentUrl, attributeName))//当前页地址
                {
                    parsedContent = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(ChannelUrl, attributeName))//栏目页地址
                {
                    parsedContent = PageUtility.GetChannelUrl(pageInfo.PublishmentSystemInfo, NodeManager.GetNodeInfo(pageInfo.PublishmentSystemId, contextInfo.ChannelId));
                }
                else if (StringUtils.EqualsIgnoreCase(HomeUrl, attributeName))//用户中心地址
                {
                    parsedContent = pageInfo.HomeUrl.TrimEnd('/');
                }
                else if (StringUtils.EqualsIgnoreCase(attributeName, LoginUrl))
                {
                    var returnUrl = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo);
                    parsedContent = HomeUtils.GetLoginUrl(pageInfo.HomeUrl, returnUrl);
                }
                else if (StringUtils.EqualsIgnoreCase(attributeName, LogoutUrl))
                {
                    var returnUrl = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo);
                    parsedContent = HomeUtils.GetLogoutUrl(pageInfo.HomeUrl, returnUrl);
                }
                else if (StringUtils.EqualsIgnoreCase(attributeName, RegisterUrl))
                {
                    var returnUrl = StlUtility.GetStlCurrentUrl(pageInfo, contextInfo.ChannelId, contextInfo.ContentId, contextInfo.ContentInfo);
                    parsedContent = HomeUtils.GetRegisterUrl(pageInfo.HomeUrl, returnUrl);
                }
                else if (StringUtils.StartsWithIgnoreCase(attributeName, "TableFor"))//
                {
                    if (StringUtils.EqualsIgnoreCase(attributeName, "TableForContent"))
                    {
                        parsedContent = pageInfo.PublishmentSystemInfo.AuxiliaryTableForContent;
                    }
                    else if (StringUtils.EqualsIgnoreCase(attributeName, "TableForGovInteract"))
                    {
                        parsedContent = pageInfo.PublishmentSystemInfo.AuxiliaryTableForGovInteract;
                    }
                    else if (StringUtils.EqualsIgnoreCase(attributeName, "TableForGovPublic"))
                    {
                        parsedContent = pageInfo.PublishmentSystemInfo.AuxiliaryTableForGovPublic;
                    }
                    else if (StringUtils.EqualsIgnoreCase(attributeName, "TableForJob"))
                    {
                        parsedContent = pageInfo.PublishmentSystemInfo.AuxiliaryTableForJob;
                    }
                    else if (StringUtils.EqualsIgnoreCase(attributeName, "TableForVote"))
                    {
                        parsedContent = pageInfo.PublishmentSystemInfo.AuxiliaryTableForVote;
                    }
                }
                else if (StringUtils.StartsWithIgnoreCase(attributeName, "Site"))//
                {
                    parsedContent = pageInfo.PublishmentSystemInfo.Additional.GetExtendedAttribute(attributeName.Substring(4));
                }
                else
                {
                    if (pageInfo.PublishmentSystemInfo.Additional.ContainsKey(attributeName))
                    {
                        parsedContent = pageInfo.PublishmentSystemInfo.Additional.GetExtendedAttribute(attributeName);
                        if (parsedContent.StartsWith("@"))
                        {
                            parsedContent = PageUtility.ParseNavigationUrl(pageInfo.PublishmentSystemId, parsedContent);
                        }
                    }
                    else
                    {
                        var stlTagInfo = DataProvider.StlTagDao.GetStlTagInfo(pageInfo.PublishmentSystemId, attributeName) ??
                                         DataProvider.StlTagDao.GetStlTagInfo(0, attributeName);
                        if (!string.IsNullOrEmpty(stlTagInfo?.TagContent))
                        {
                            var innerBuilder = new StringBuilder(stlTagInfo.TagContent);
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            parsedContent = innerBuilder.ToString();
                        }
                    }
                }
            }
            catch
            {
                // ignored
            }

            return(parsedContent);
        }