コード例 #1
0
        public static BaseCmsAdminTool[] GetAllCachedAdminToolInstances()
        {
            string cacheKey = "GetAllCachedAdminToolInstances";

            if (PerRequestCache.CacheContains(cacheKey))
            {
                return((BaseCmsAdminTool[])PerRequestCache.GetFromCache(cacheKey, new BaseCmsAdminTool[0]));
            }

            Type[] allAdminTypes = Hatfield.Web.Portal.AssemblyHelpers.LoadAllAssembliesAndGetAllSubclassesOf(typeof(BaseCmsAdminTool));

            List <BaseCmsAdminTool> ret = new List <BaseCmsAdminTool>();

            foreach (Type t in allAdminTypes)
            {
                BaseCmsAdminTool tool = (BaseCmsAdminTool)t.Assembly.CreateInstance(t.FullName);
                if (tool != null)
                {
                    ret.Add(tool);
                }
            }

            PerRequestCache.AddToCache(cacheKey, ret.ToArray());

            return(ret.ToArray());
        }
コード例 #2
0
        private string getToolRunUrl(CmsPage page, BaseCmsAdminTool toolToRun)
        {
            NameValueCollection urlParams = new NameValueCollection();

            urlParams.Add("RunTool", toolToRun.GetType().Name);
            return(page.getUrl(urlParams));
        }
コード例 #3
0
        public override string Render()
        {
            StringBuilder html            = new StringBuilder();
            CmsPage       page            = CmsContext.currentPage;
            CmsLanguage   langToRenderFor = CmsContext.currentLanguage;

            page.HeadSection.AddEmbeddedCSSFile(CSSGroup.ControlOrPlaceholder, typeof(AdminMenu).Assembly, "AdminTools.css");

            BaseCmsAdminTool toolToRun = getToolToRun();

            BaseCmsAdminTool.AdminMenuTab selectedMenuTab = getMenuTabToDisplay(toolToRun);
            BaseCmsAdminTool[]            allTools        = BaseCmsAdminTool.GetAllCachedAdminToolInstances();

            Dictionary <BaseCmsAdminTool.CmsAdminToolCategory, List <BaseCmsAdminTool> > toolsToDisplay = getToolsForTab(selectedMenuTab, allTools);

            html.Append("<table class=\"AdminMenu\">");
            html.Append("<tr>");
            switch (selectedMenuTab)
            {
            case AdminMenuTab.Reports:
                html.Append("<td class=\"MenuSel\"><a href=\"" + getTabUrl(page, AdminMenuTab.Reports) + "\">Reports</a></td>");
                html.Append("<td class=\"MenuNotSel\"><a href=\"" + getTabUrl(page, AdminMenuTab.Tools) + "\">Tools</a></td>");
                break;

            case AdminMenuTab.Tools:
                html.Append("<td class=\"MenuNotSel\"><a href=\"" + getTabUrl(page, AdminMenuTab.Reports) + "\">Reports</a></td>");
                html.Append("<td class=\"MenuSel\"><a href=\"" + getTabUrl(page, AdminMenuTab.Tools) + "\">Tools</a></td>");
                break;
            }
            html.Append("</tr>");
            html.Append("<tr><td colspan=\"2\">");
            foreach (BaseCmsAdminTool.CmsAdminToolCategory category in toolsToDisplay.Keys)
            {
                string catDisplayTitle = getCategoryDisplayTitle(category);
                html.Append("<div class=\"AdminTool menu\"><strong>" + catDisplayTitle + ":</strong> ");
                List <string> toolLinks = new List <string>();
                foreach (BaseCmsAdminTool tool in toolsToDisplay[category])
                {
                    CmsAdminToolInfo toolInfo     = tool.getToolInfo();
                    string           toolMenuText = toolInfo.MenuDisplayText[langToRenderFor];
                    string           url          = getToolRunUrl(page, tool);
                    string           link         = "<a href=\"" + url + "\">" + toolMenuText + "</a>";
                    toolLinks.Add(link);
                } // foreach

                html.Append(String.Join(" | ", toolLinks.ToArray()));

                html.Append("</div>");
            } // foreach category

            html.Append("</tr></td>");
            html.Append("</table>");



            return(html.ToString());
        }
コード例 #4
0
        private AdminMenuTab getMenuTabToDisplay(BaseCmsAdminTool toolToRun)
        {
            CmsAdminToolInfo toolInfo = toolToRun.getToolInfo();

            if (toolInfo.MenuTab != AdminMenuTab._AdminMenu)
            {
                return(toolInfo.MenuTab);
            }

            return((AdminMenuTab)PageUtils.getFromForm("tab", typeof(AdminMenuTab), AdminMenuTab.Reports));
        }
コード例 #5
0
        public static BaseCmsAdminTool getToolToRun()
        {
            string name = PageUtils.getFromForm("RunTool", Guid.NewGuid().ToString());

            if (BaseCmsAdminTool.AdminToolExists(name))
            {
                BaseCmsAdminTool ret = BaseCmsAdminTool.getAdminToolInstanceByName(name);
                if (ret != null)
                {
                    return(ret);
                }
            }
            return(new AdminMenu());
        }
コード例 #6
0
 public static string renderAdminTool(BaseCmsAdminTool tool)
 {
     return(tool.Render());
 }