public void DeletePage(string PageName)
        {
            try
            {
                string path = Path.Combine(WebContext.Server.MapPath(WebContext.StartDir), ConfigCte.StaticContentFolder);

                path = Path.Combine(path, PageName.Trim() + ".htm");

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                PagesDS.PagesRow row = GetPage(PageName);
                if (row.Table.Rows.Count > 0)
                {
                    row.Delete();
                    row.Table.AcceptChanges();
                    AcceptChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }
        public string GetPagePath(int PageId)
        {
            PagesDS.PagesRow page = GetPage(PageId);

            if (page != null)
            {
                if (page["Url"] != System.DBNull.Value)
                {
                    return(WebContext.Root + "/" + page["Url"].ToString());
                }
                if (page["GroupId"] != System.DBNull.Value)
                {
                    PagesDS.GroupsRow group     = GetGroup(page.GroupId);
                    string            groupPath = GetGroupPath(group);

                    string pagePath = page.Name.Replace(StringUtils.ToURL(groupPath) + "-", "");

                    return(groupPath + "/" + pagePath);
                }

                return(null);
            }

            ErrorContext.Add("page-not-found", new Exception("The Id supplied does not exist"));
            return(null);
        }
        public bool AddPage(string Name, string Title, string Description, bool Virtual, string content, Languages language)
        {
            if (StringUtils.IsNullOrWhiteSpace(Name))
            {
                return(false);
            }

            if (this.GetPages("Name='" + StringUtils.SQLEncode(Name) + "'").Count > 0)
            {
                ErrorContext.Add("validation", "Another page with the same name already exists");
                return(false);
            }

            PagesDS.PagesRow row = DS.Pages.NewPagesRow();

            row.Name         = Name;
            row.Title        = Title;
            row.Description  = Description;
            row.Virtual      = Virtual;
            row.LastModified = DateTime.Now;
            row.Keywords     = "";

            DS.Pages.Rows.Add(row);

            AcceptChanges();

            CreatePageFile(Name, content, language);

            return(true);
        }
Exemple #4
0
        public override void DataBind()
        {
            if (_bound)
            {
                return;
            }
            _bound = true;

            CustomPage thisPage = this.Page as CustomPage;

            if (thisPage == null)
            {
                thisPage = new CustomPage();
            }

            ContentManager pagesMgr = new ContentManager();

            PagesDS.PagesRow page = pagesMgr.GetPage(PageName, thisPage.Language);

            if (page == null && CreatePage)
            {
                pagesMgr.AddPage(pageName, pageName, "", false, ContentManager.Content(pageName), thisPage.Language);
                page = pagesMgr.GetPage(pageName, thisPage.Language);
            }
            if (page == null)
            {
                return;
            }

            string str = page.Content;

            str = str.Replace("<sup>&amp;reg;</sup>", "®");
            str = str.Replace("<sup>®</sup>", "®");
            str = str.Replace("&amp;reg;", "&reg;");
            str = str.Replace("&reg;", "<sup>&reg;</sup>");
            str = str.Replace("®", "<sup>&reg;</sup>");


            this.Text = str;

            if (OverridePageProperties)
            {
                if (thisPage != null)
                {
                    Config cfg = new Config();
                    thisPage.Title = page.Title;
                    thisPage.AddDescription(page.Description);
                    thisPage.AddKeywords(page.Keywords);
                }
            }

            base.DataBind();
        }
        public PagesDS.PagesRow GetPage(int PageId, string PageName, bool GetContent, Languages language)
        {
            if (StringUtils.IsNullOrWhiteSpace(PageName) && PageId <= 0)
            {
                return(null);
            }

            //if (language != Languages.Default)
            //PageName = EnumHelper.GetDescription(language) + "-" + PageName;

            string cond = "";

            if (PageId > 0)
            {
                cond = "PageId=" + PageId.ToString();
            }
            else
            {
                cond = "Name='" + StringUtils.SQLEncode(PageName) + "'";
            }

            DataView pages = GetPages(cond);

            if (pages.Count > 0)
            {
                PagesDS.PagesRow page = (PagesDS.PagesRow)pages[0].Row;
                if (GetContent)
                {
                    string fileName = page.Name;

                    if (page["FileName"] != System.DBNull.Value)
                    {
                        if (!StringUtils.IsNullOrWhiteSpace(page.FileName))
                        {
                            fileName = page.FileName;
                        }
                    }

                    page.Content = Content(fileName, language);
                }
                return(page);
            }
            return(null);
        }
        public bool UpdatePageProperties(int PageId, string Name, string Title, string Description, string Keywords)
        {
            if (this.GetPages(string.Format("Name='{0}' And PageId<>{1}", Name, PageId)).Count > 0)
            {
                ErrorContext.Add("validation", "Another page with the same name already exists");
                return(false);
            }

            PagesDS.PagesRow row = GetPage(PageId);

            row.Name         = Name;
            row.Title        = Title;
            row.Description  = Description;
            row.LastModified = DateTime.Now;
            row.Keywords     = Keywords;

            row.Table.AcceptChanges();
            AcceptChanges();

            return(true);
        }