Exemple #1
0
        /// <summary>
        /// Get pageId from pagename
        /// </summary>
        /// <returns>PageID</returns>
        public static string GetPageIDFromPageName(string pagepath)
        {
            PagesDB DB       = new PagesDB();
            var     settings = PortalSettings.GetPortalSettingsbyPageID(Portal.PageID, Config.DefaultPortal);

            int portalID = 0;

            if (settings != null)
            {
                portalID = settings.PortalID;
            }

            DataTable dtPages = DB.GetPagesFlatTable(portalID);

            //When friendly URl applied and go to Home page from and sub pages
            if (pagepath.ToLower().Contains("default.aspx"))
            {
                string page_ID = "1";
                return(page_ID);
            }

            // Check requested page url contains the /site when friendly URL is on
            var handlerFlag = System.Configuration.ConfigurationManager.AppSettings["handlerFlag"];

            if (pagepath.Contains("/" + handlerFlag))
            {
                string[] splitpaths       = pagepath.Split('/');
                int      index            = Array.IndexOf(splitpaths, handlerFlag);
                int      requesetedPageId = Convert.ToInt32(splitpaths[index + 1]);
                pagepath = HttpUrlBuilder.BuildUrl(requesetedPageId);
            }

            foreach (DataRow pageRow in dtPages.Rows)
            {
                int    pageId = Convert.ToInt32(pageRow["PageID"]);
                string url    = HttpUrlBuilder.BuildUrl(pageId);
                if (url.ToLower() == pagepath.ToLower())
                {
                    return(pageId.ToString());
                }
            }

            string dynamicPage = DB.GetDynamicPageUrl(pagepath);

            if (!string.IsNullOrEmpty(dynamicPage))
            {
                //-1 for dynamic pages
                return("-1");
            }

            // if page is not found it will throw 404 error
            throw new HttpException(404, "Page not Found", 3);
        }
Exemple #2
0
        private void LoadPageDropDown()
        {
            //load tab names for the dropdown list, then bind them
            // TODO check if this works
            //portalTabs = new PagesDB().GetPagesFlat(portalSettings.PortalID);
            var pgDb = new PagesDB();

            portalTabs = pgDb.GetPagesFlatTable(this.PortalSettings.PortalID);
            ddTabs.DataBind();

            //on initial load, disable the restore button until they make a selection
            restoreButton.Enabled = false;
            if (this._moduleID > 0)
            {
                ddTabs.Items.Insert(0, "--Choose a Page to Restore this Module--");
            }

            if (this._pageID > 0)
            {
                restoreButton.Enabled = true;
                var recyle = pgDb.GetPagesFlat(-1).First(p => p.ID == this._pageID);// get recycle pages
                selecteditem.InnerHtml = "Selected Page : " + recyle.Name.Replace("(Orphan)", string.Empty);
                foreach (DataRow row in portalTabs.Rows)
                {
                    if (recyle.ParentPageId.ToString() == row["PageID"].ToString())
                    {
                        ddTabs.SelectedValue = row["PageID"].ToString();
                        break;
                    }
                }
                ddTabs.Items.Insert(0, new ListItem()
                {
                    Text = "--Root--", Value = "-1"
                });
            }
        }