AJH.CMS.WEB.UI.SitePathXSL_UC.LoadSitePath C# (CSharp) Method

LoadSitePath() private method

private LoadSitePath ( ) : void
return void
        void LoadSitePath()
        {
            if (base.XSLTemplateID > 0)
            {
                string PageTitle = string.Empty;
                Menu currentMenu = null;
                int MenuId = 0;
                int.TryParse(Request.QueryString[CMSConfig.QueryString.MenuID], out MenuId);
                if (MenuId > 0)
                {
                    currentMenu = MenuManager.GetMenu(MenuId);
                }
                else
                {
                    CMSPageBase cmsPage = this.Page as CMSPageBase;
                    if (cmsPage != null)
                    {
                        CMS.Core.Entities.Page currentPage = cmsPage._CurrentPage;
                        if (currentPage != null)
                        {
                            PageTitle = currentPage.Title;
                            List<Menu> menus = MenuManager.GetMenusByPage(currentPage.ID);
                            if (menus.Count > 0)
                            {
                                currentMenu = menus[0];
                            }
                        }
                    }
                }

                string xslPath = CMSWebHelper.GetXSLTemplateFilePath(base.XSLTemplateID);
                xslPath = XSLTemplateManager.GetXSLTemplatePath(xslPath, base.XSLTemplateID);

                if (currentMenu == null)
                {
                    XsltArgumentList arguments = new XsltArgumentList();
                    arguments.AddExtensionObject("CMS:UserControl", this);

                    xmlSitePath.DocumentContent = MenuManager.GetDefaultSitePath(PageTitle);
                    xmlSitePath.TransformSource = xslPath;
                    xmlSitePath.TransformArgumentList = arguments;
                    xmlSitePath.DataBind();
                }
                else
                {
                    string menuCategoryPath = CMSWebHelper.GetMenuPathByCategory(currentMenu.CategoryID);
                    menuCategoryPath = MenuManager.GetMenuCategoryXMLPath(menuCategoryPath, currentMenu.CategoryID, CMSContext.LanguageID);

                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(menuCategoryPath);

                    string sitePath = string.Empty;

                    XmlNode xmlNode = xmlDoc.SelectSingleNode("descendant-or-self::* [@ID=" + currentMenu.ID.ToString() + "]");
                    if (xmlNode != null)
                    {
                        XmlDocument xmlDocSitePath = new XmlDocument();
                        XmlElement xmlEle = xmlDocSitePath.CreateElement("Menus");
                        xmlDocSitePath.AppendChild(xmlEle);
                        GetParentNode(xmlEle, xmlNode);
                        sitePath = xmlDocSitePath.OuterXml;
                    }

                    if (string.IsNullOrEmpty(sitePath))
                    {
                        sitePath = MenuManager.GetDefaultSitePath(PageTitle);
                    }

                    XsltArgumentList arguments = new XsltArgumentList();
                    arguments.AddExtensionObject("CMS:UserControl", this);

                    xmlSitePath.DocumentContent = sitePath;
                    xmlSitePath.TransformSource = xslPath;
                    xmlSitePath.TransformArgumentList = arguments;
                    xmlSitePath.DataBind();
                }
            }
        }
        #endregion