Exemple #1
0
        public static Page LoadOrCreatePageCode(System.String pageCodeValue)
        {
            Page page = PageCache.GetByPageCode(pageCodeValue);

            if (page == null || page.IsNewRecord)
            {
                page = new Page()
                {
                    PageCode        = pageCodeValue,
                    TemplateCode    = "special",
                    DateAdded       = DateTime.Now,
                    PublishDate     = DateTime.Now,
                    Title           = Fmt.SplitTitleCase(pageCodeValue),
                    BodyTextHtml    = "Copy to be written for [" + pageCodeValue + "]<br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat. Ut wisis enim ad minim veniam, quis nostrud exerci tution ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis te feugifacilisi. Duis autem dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto.",
                    RevisionStatus  = "Live",
                    PageIsALink     = false,
                    ShowInMainNav   = false,
                    ShowInFooterNav = false,
                    SortPosition    = 999
                };
                page.Save();
                PageCache.Rebuild();
            }

            return(page);
        }
Exemple #2
0
        //private bool IsRouteFree(string url) {
        //  // make sure URL is unique and does not conflict with a controller
        //  foreach (Route route in RouteTable.Routes) {
        //    if (url == route.Defaults["controller"].ToString().ToLower())
        //      return false;
        //    if (url == route.Defaults["action"].ToString().ToLower())
        //      return false;
        //  }
        //  return true;
        //}


        private void Save(Models.Page record, bool isNew)
        {
            // add any code to update other fields/tables here

            //record.Fields.Picture.MetaData = record.GetMetaData();
            record.Save();
            //record.Resources.Save();
            CheckLock(record);
            lockobj.UnLockTable(record.GetTableName(), record.ID);
            PageCache.Rebuild();
#if AutocompletePhrase
            AutocompletePhrase.AddPagePhrase(record);
#endif
            // save subform or related checkboxes here eg record.Lines.Save();
        }
Exemple #3
0
        protected ActionResult ProcessForm(Models.Page record)
        {
            try {
                record.UpdateFromRequest();
                //record.RelatedPages.UpdateFromRequestSubForm();
                // read subform or related checkboxes here eg record.Lines.UpdateFromRequest();
                //ifsubform: record.example.UpdateFromRequest();
#if PageRevisions
                record.RevisionStatus = "Live";
#endif

                Validate(record);
                if (ModelState.IsValid)
                {
                    Save(record, record.IsNewRecord);
                    record.RelatedPages.Save();
                    Web.InfoMessage += "Page " + record.GetName() + " saved.";
                }
            } catch (UserErrorException e) {
                ModelState.AddModelError("Record", e.Message);
            }

            if (!ModelState.IsValid)
            {
                // invalid so redisplay form with validation message(s)
#if PageRevisions
                return(View("PageEditRevisions", record));
#else
                return(View("PageEdit", record));
#endif
            }
            else if (Web.Request["SaveAndRefreshButton"] != null)
            {
                return(RedirectToEdit(record.ID));
            }
            else if (Web.Request["DuplicateButton"] != null)
            {
                var newRecord = new Models.Page();
                newRecord.UpdateFrom(record);
                newRecord.Save();
                Web.InfoMessage += "Copy of Page " + record.GetName() + " created. You are now editing the new copy.";
                return(RedirectToEdit(newRecord.ID));
            }
            else
            {
                return(RedirectToReturnPage());
            }
        }