Beispiel #1
0
        // 得到发布系统首页地址
        public static string GetIndexPageUrl(SiteInfo siteInfo, bool isLocal)
        {
            var indexTemplateId     = TemplateManager.GetIndexTempalteId(siteInfo.Id);
            var createdFileFullName = TemplateManager.GetCreatedFileFullName(siteInfo.Id, indexTemplateId);

            return(isLocal
                ? ApiRoutePreview.GetSiteUrl(siteInfo.Id)
                : ParseNavigationUrl(siteInfo, createdFileFullName, false));
        }
Beispiel #2
0
 private static void DefaultRedirect(int siteId)
 {
     if (siteId == 0)
     {
         siteId = DataProvider.SiteDao.GetIdByIsRoot();
     }
     if (siteId != 0)
     {
         var siteInfo = SiteManager.GetSiteInfo(siteId);
         var url      = siteInfo.Additional.IsSeparatedWeb
             ? ApiRoutePreview.GetSiteUrl(siteId)
             : siteInfo.Additional.WebUrl;
         PageUtils.Redirect(url);
     }
     else
     {
         var url = PageUtils.ApplicationPath;
         PageUtils.Redirect(url);
     }
 }
Beispiel #3
0
        private string GetTopMenuLinksHtml()
        {
            if (_siteInfo == null || _siteInfo.Id <= 0)
            {
                return(string.Empty);
            }

            var builder = new StringBuilder();

            builder.Append(
                $@"<li><a href=""{PageUtility.GetSiteUrl(_siteInfo, false)}"" target=""_blank"">访问站点</a></li>");
            builder.Append(
                $@"<li><a href=""{ApiRoutePreview.GetSiteUrl(_siteInfo.Id)}"" target=""_blank"">预览站点</a></li>");

            return($@"<li class=""has-submenu"">
              <a href=""javascript:;"">站点链接</a>
              <ul class=""submenu"">
                {builder}
              </ul>
            </li>");
        }
Beispiel #4
0
        private static List <Tab> GetTopMenus(SiteInfo siteInfo, bool isSuperAdmin, List <int> siteIdListLatestAccessed, List <int> siteIdListWithPermissions)
        {
            var menus = new List <Tab>();

            if (siteInfo != null && siteIdListWithPermissions.Contains(siteInfo.Id))
            {
                var siteMenus = new List <Tab>();
                if (siteIdListWithPermissions.Count == 1)
                {
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Children = siteMenus.ToArray()
                    });
                }
                else
                {
                    var siteIdList = AdminManager.GetLatestTop10SiteIdList(siteIdListLatestAccessed, siteIdListWithPermissions);
                    foreach (var siteId in siteIdList)
                    {
                        var site = SiteManager.GetSiteInfo(siteId);
                        if (site == null)
                        {
                            continue;
                        }

                        siteMenus.Add(new Tab
                        {
                            Href   = PageUtils.GetMainUrl(site.Id),
                            Target = "_top",
                            Text   = site.SiteName
                        });
                    }
                    siteMenus.Add(new Tab
                    {
                        Href   = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target = "_layer",
                        Text   = "全部站点..."
                    });
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Href     = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target   = "_layer",
                        Children = siteMenus.ToArray()
                    });
                }

                var linkMenus = new List <Tab>
                {
                    new Tab {
                        Href = PageUtility.GetSiteUrl(siteInfo, false), Target = "_blank", Text = "访问站点"
                    },
                    new Tab {
                        Href = ApiRoutePreview.GetSiteUrl(siteInfo), Target = "_blank", Text = "预览站点"
                    }
                };
                menus.Add(new Tab {
                    Text = "站点链接", Children = linkMenus.ToArray()
                });
            }

            if (isSuperAdmin)
            {
                foreach (var tab in TabManager.GetTopMenuTabs())
                {
                    var tabs = TabManager.GetTabList(tab.Id, 0);
                    tab.Children = tabs.ToArray();

                    menus.Add(tab);
                }
            }

            return(menus);
        }
Beispiel #5
0
        private static List <Tab> GetTopMenus(SiteInfo siteInfo, bool isSuperAdmin, List <int> siteIdListLatestAccessed, List <int> siteIdListWithPermissions, List <string> permissionList)
        {
            var menus = new List <Tab>();

            if (siteInfo != null && siteIdListWithPermissions.Contains(siteInfo.Id))
            {
                var siteMenus = new List <Tab>();
                if (siteIdListWithPermissions.Count == 1)
                {
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Children = siteMenus.ToArray()
                    });
                }
                else
                {
                    var siteIdList = AdminManager.GetLatestTop10SiteIdList(siteIdListLatestAccessed, siteIdListWithPermissions);
                    foreach (var siteId in siteIdList)
                    {
                        var site = SiteManager.GetSiteInfo(siteId);
                        if (site == null)
                        {
                            continue;
                        }

                        siteMenus.Add(new Tab
                        {
                            Href   = PageUtils.GetMainUrl(site.Id),
                            Target = "_top",
                            Text   = site.SiteName
                        });
                    }
                    siteMenus.Add(new Tab
                    {
                        Href   = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target = "_layer",
                        Text   = "全部站点..."
                    });
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Href     = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target   = "_layer",
                        Children = siteMenus.ToArray()
                    });
                }

                var linkMenus = new List <Tab>
                {
                    new Tab {
                        Href = PageUtility.GetSiteUrl(siteInfo, false), Target = "_blank", Text = "访问站点"
                    },
                    new Tab {
                        Href = ApiRoutePreview.GetSiteUrl(siteInfo.Id), Target = "_blank", Text = "预览站点"
                    }
                };
                menus.Add(new Tab {
                    Text = "站点链接", Children = linkMenus.ToArray()
                });
            }

            if (isSuperAdmin)
            {
                foreach (var tab in TabManager.GetTopMenuTabs())
                {
                    var tabs = TabManager.GetTabList(tab.Id, 0);
                    tab.Children = tabs.ToArray();

                    menus.Add(tab);
                }
            }
            else
            {
                foreach (var tab in TabManager.GetTopMenuTabs())
                {
                    if (!TabManager.IsValid(tab, permissionList))
                    {
                        continue;
                    }

                    var tabToAdd = new Tab
                    {
                        Id     = tab.Id,
                        Name   = tab.Name,
                        Text   = tab.Text,
                        Target = tab.Target,
                        Href   = tab.Href
                    };
                    var tabs      = TabManager.GetTabList(tab.Id, 0);
                    var tabsToAdd = new List <Tab>();
                    foreach (var menu in tabs)
                    {
                        if (!TabManager.IsValid(menu, permissionList))
                        {
                            continue;
                        }

                        Tab[] children = null;
                        if (menu.Children != null)
                        {
                            children = menu.Children.Where(child => TabManager.IsValid(child, permissionList))
                                       .ToArray();
                        }

                        var menuToAdd = new Tab
                        {
                            Id       = menu.Id,
                            Name     = menu.Name,
                            Text     = menu.Text,
                            Target   = menu.Target,
                            Href     = menu.Href,
                            Children = children
                        };
                        tabsToAdd.Add(menuToAdd);
                    }
                    tabToAdd.Children = tabsToAdd.ToArray();

                    menus.Add(tabToAdd);
                }
            }

            return(menus);
        }