Esempio n. 1
0
        public static string GetContentCommands(PermissionsImpl permissionsImpl, SiteInfo siteInfo, ChannelInfo channelInfo, string pageUrl)
        {
            var builder = new StringBuilder();

            if (permissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentAdd) && channelInfo.Additional.IsContentAddable)
            {
                builder.Append($@"
<a href=""{GetContentAddAddUrl(siteInfo.Id, channelInfo.Id, pageUrl)}"" class=""btn btn-light text-secondary"">
    <i class=""ion-plus""></i>
    添加
</a>");

                builder.Append($@"
<a href=""javascript:;"" class=""btn btn-light text-secondary"" onclick=""{ModalUploadWord.GetOpenWindowString(siteInfo.Id, channelInfo.Id, StringUtils.ValueToUrl(pageUrl))}"">
    导入Word
</a>");
            }

            var adminId = permissionsImpl.GetAdminId(siteInfo.Id, channelInfo.Id);
            var count   = ContentManager.GetCount(siteInfo, channelInfo, adminId);

            if (count > 0 && permissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentDelete))
            {
                builder.Append($@"
<a href=""javascript:;"" class=""btn btn-light text-secondary"" onclick=""{PageContentDelete.GetRedirectClickStringForSingleChannel(siteInfo.Id, channelInfo.Id, false, pageUrl)}"">
    <i class=""ion-trash-a""></i>
    删 除
</a>");
            }

            if (count > 0)
            {
                if (permissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentEdit))
                {
                    builder.Append($@"
<a href=""javascript:;"" class=""btn btn-light text-secondary"" onclick=""{ModalContentAttributes.GetOpenWindowString(siteInfo.Id, channelInfo.Id)}"">
    <i class=""ion-flag""></i>
    属性
</a>");
                    builder.Append($@"
<a href=""javascript:;"" class=""btn btn-light text-secondary"" onclick=""{ModalAddToGroup.GetOpenWindowStringToContent(siteInfo.Id, channelInfo.Id)}"">
    内容组
</a>");
                }
                if (permissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate))
                {
                    var redirectUrl = PageContentTranslate.GetRedirectUrl(siteInfo.Id, channelInfo.Id, pageUrl);
                    var clickString = PageUtils.GetRedirectStringWithCheckBoxValue(redirectUrl, "contentIdCollection", "contentIdCollection", "请选择需要转移的内容!");
                    builder.Append($@"
<a href=""javascript:;"" class=""btn btn-light text-secondary"" onclick=""{clickString}"">
    转 移
</a>");
                }
                if (permissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentEdit))
                {
                    builder.Append($@"
<a href=""javascript:;"" class=""btn btn-light text-secondary"" onclick=""{ModalContentTaxis.GetOpenWindowString(siteInfo.Id, channelInfo.Id, pageUrl)}"">
    排 序
</a>");
                }
                if (permissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentCheck))
                {
                    builder.Append($@"
<a href=""javascript:;"" class=""btn btn-light text-secondary"" onclick=""{ModalContentCheck.GetOpenWindowString(siteInfo.Id, channelInfo.Id, pageUrl)}"">
    审 核
</a>");
                }
                if (permissionsImpl.HasSitePermissions(siteInfo.Id, ConfigManager.WebSitePermissions.Create) || permissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.CreatePage))
                {
                    builder.Append($@"
<a href=""javascript:;"" class=""btn btn-light text-secondary"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateContentsOneByOne(siteInfo.Id, channelInfo.Id)}"">
    <i class=""ion-wand""></i>
    生 成
</a>");
                }
            }

            if (permissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ChannelEdit))
            {
                builder.Append($@"
<a href=""javascript:;"" class=""btn btn-light text-secondary"" onclick=""{ModalSelectColumns.GetOpenWindowString(siteInfo.Id, channelInfo.Id)}"">
    <i class=""ion-ios-list-outline""></i>
    显示项
</a>");
            }

            if (count > 0)
            {
                builder.Append(@"
<a href=""javascript:;;"" class=""btn btn-light text-secondary text-secondary"" onClick=""$('#contentSearch').toggle(); return false"">
    <i class=""ion-search""></i>
    查找
</a>");
            }

            return(builder.ToString());
        }
Esempio n. 2
0
        private static string GetTopMenusHtml(PermissionsImpl permissions, int siteId)
        {
            var topMenuTabs = TabManager.GetTopMenuTabs();

            if (topMenuTabs == null || topMenuTabs.Count == 0)
            {
                return(string.Empty);
            }

            var permissionList = new List <string>();

            if (permissions.HasSitePermissions(siteId))
            {
                var websitePermissionList = permissions.GetSitePermissions(siteId);
                if (websitePermissionList != null)
                {
                    permissionList.AddRange(websitePermissionList);
                }
            }

            permissionList.AddRange(permissions.PermissionList);

            var builder = new StringBuilder();

            foreach (var tab in topMenuTabs)
            {
                if (!permissions.IsConsoleAdministrator && !TabManager.IsValid(tab, permissionList))
                {
                    continue;
                }

                var tabs        = TabManager.GetTabList(tab.Id, 0);
                var tabsBuilder = new StringBuilder();
                foreach (var parent in tabs)
                {
                    if (!permissions.IsConsoleAdministrator && !TabManager.IsValid(parent, permissionList))
                    {
                        continue;
                    }

                    var hasChildren = parent.Children != null && parent.Children.Length > 0;

                    var parentUrl    = !string.IsNullOrEmpty(parent.Href) ? PageUtils.GetLoadingUrl(parent.Href) : "javascript:;";
                    var parentTarget = !string.IsNullOrEmpty(parent.Target) ? parent.Target : "right";

                    if (hasChildren)
                    {
                        tabsBuilder.Append($@"
<li class=""has-submenu"">
    <a href=""{parentUrl}"" target=""{parentTarget}"">{parent.Text}</a>
    <ul class=""submenu"">
");

                        if (parent.Children != null && parent.Children.Length > 0)
                        {
                            foreach (var childTab in parent.Children)
                            {
                                var childTarget = !string.IsNullOrEmpty(childTab.Target) ? childTab.Target : "right";
                                tabsBuilder.Append($@"<li><a href=""{PageUtils.GetLoadingUrl(childTab.Href)}"" target=""{childTarget}"">{childTab.Text}</a></li>");
                            }
                        }

                        tabsBuilder.Append(@"
    </ul>
</li>");
                    }
                    else
                    {
                        tabsBuilder.Append(
                            $@"<li><a href=""{parentUrl}"" target=""{parentTarget}"">{parent.Text}</a></li>");
                    }
                }

                var url    = !string.IsNullOrEmpty(tab.Href) ? PageUtils.ParseNavigationUrl(tab.Href) : "javascript:;";
                var target = !string.IsNullOrEmpty(tab.Target) ? tab.Target : "right";

                builder.Append(
                    $@"<li class=""has-submenu"">
                        <a href=""{url}"" target=""{target}"">{tab.Text}</a>
                        <ul class=""submenu"">
                            {tabsBuilder}
                        </ul>
                       </li>");
            }

            return(builder.ToString());
        }