Ejemplo n.º 1
0
        private async Task AddUrlAsync(string file, PageDefinition page, string canonicalUrl, DateTime?lastMod, PageDefinition.SiteMapPriorityEnum siteMapPriority, PageDefinition.ChangeFrequencyEnum changeFrequency)
        {
            if (!PagesFound.Contains(page.PageGuid)) // keep track of pages so we don't add it as a designed page in case it was dynamic
            {
                PagesFound.Add(page.PageGuid);
            }
            canonicalUrl = Manager.CurrentSite.MakeUrl(canonicalUrl, PagePageSecurity: page.PageSecurity);
            if (!ValidForSiteMap(page))
            {
                return;
            }
            string cf         = GetChangeFrequencyText(changeFrequency);
            float  prio       = GetPriority(siteMapPriority);
            var    w3clastMod = lastMod != null?string.Format("    <lastmod>{0}</lastmod>\r\n", XmlConvert.ToString((DateTime)lastMod, XmlDateTimeSerializationMode.Utc)) : "";

#if MVC6
            canonicalUrl = WebUtility.HtmlEncode(canonicalUrl);
#else
            canonicalUrl = AntiXssEncoder.XmlEncode(canonicalUrl);
#endif
            await FileSystem.FileSystemProvider.AppendAllTextAsync(file, string.Format(
                                                                       "  <url>\r\n" +
                                                                       "    <loc>{0}</loc>\r\n" +
                                                                       "{1}" +
                                                                       "    <changefreq>{2}</changefreq>\r\n" +
                                                                       "    <priority>{3}</priority>\r\n" +
                                                                       "  </url>\r\n", canonicalUrl, w3clastMod, cf, prio)
                                                                   );
        }
Ejemplo n.º 2
0
        protected override void SetupEditControls()
        {
            Category parentCategory = null;
            var      definition     = PageDefinition.Load(PropertyData.PageDefinitionID);

            if (!string.IsNullOrEmpty(definition.HelpText))
            {
                parentCategory = Category.Find(definition.HelpText);
            }

            if (parentCategory == null)
            {
                parentCategory = Category.Find(Name);
            }

            if (parentCategory == null)
            {
                parentCategory = Category.GetRoot();
            }

            CategorgyIds = GetCategoryIds(PropertyData.Value.ToString());

            foreach (Category category in parentCategory.Categories)
            {
                var li = new ListItem(category.Description, category.ID.ToString(CultureInfo.InvariantCulture));
                li.Selected = CategorgyIds.Any(c => c == category.ID);
                EditControl.Items.Add(li);
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> SetUser(Guid guid)
        {
            using (PageDefinitionDataProvider pageDP = new PageDefinitionDataProvider()) {
                int            adminRole = Resource.ResourceAccess.GetAdministratorRoleId();
                int            userRole  = Resource.ResourceAccess.GetUserRoleId();
                PageDefinition page      = await PageDefinition.LoadAsync(guid);

                if (page == null)
                {
                    throw new InternalError($"Page with Guid {0} not found", guid);
                }
                page.AllowedRoles = new SerializableList <PageDefinition.AllowedRole>();
                page.AllowedUsers = new SerializableList <PageDefinition.AllowedUser>();
                page.AllowedRoles.Add(new PageDefinition.AllowedRole {
                    RoleId = userRole, View = PageDefinition.AllowedEnum.Yes
                });

                foreach (PageDefinition.ModuleEntry modEntry in page.ModuleDefinitions)
                {
                    ModuleDefinition module = await modEntry.GetModuleAsync();

                    if (module != null)
                    {
                        module.AllowedRoles = new SerializableList <ModuleDefinition.AllowedRole>();
                        module.AllowedUsers = new SerializableList <ModuleDefinition.AllowedUser>();
                        module.AllowedRoles.Add(new ModuleDefinition.AllowedRole {
                            RoleId = userRole, View = ModuleDefinition.AllowedEnum.Yes
                        });
                    }
                }
                await page.SaveAsync();
            }
            return(Reload(null, Reload: ReloadEnum.ModuleParts));
        }
        public void Configure(ConfigNode node)
        {
            ConfigNode[] pages = node.GetNodes("PAGE_DEFINITION");

            if (pages != null && pages.Length > 0)
            {
                definitions = new PageDefinition[pages.Length];

                for (int i = 0; i < pages.Length; ++i)
                {
                    string variableName = pages[i].GetValue("variableName");
                    string range = pages[i].GetValue("range");
                    string page = pages[i].GetValue("page");
                    if (string.IsNullOrEmpty(variableName) || string.IsNullOrEmpty(range) || string.IsNullOrEmpty(page))
                    {
                        JUtil.LogErrorMessage(this, "Incorrect page definition for page {0}", i);
                        definitions = null;
                        if (string.IsNullOrEmpty(definitionIn))
                        {
                            // Make sure we aren't crashing later.
                            definitionIn = definitionOut;
                        }
                        return;
                    }
                    definitions[i] = new PageDefinition(variableName, range, page);
                }
            }
        }
Ejemplo n.º 5
0
        public PropertySettingsContainer GetPageDefinitionsPropertySettingsContainer(PageDefinition pageDefinition)
        {
            PropertySettingsContainer container;

            PropertySettingsRepository.TryGetContainer(pageDefinition.SettingsID, out container);
            return(container);
        }
        private void HandleDefaultValues(PageDefinition pageDefinition)
        {
            if (pageDefinition.DefaultValue != null && pageDefinition.DefaultValue == string.Empty)
                pageDefinition.DefaultValue = null;

            if (pageDefinition.DefaultValue != null)
            {
                object value;

                try
                {
                    value = PropertyData.CreatePropertyDataObject(pageDefinition.Type.DataType).ParseToObject(pageDefinition.DefaultValue).Value;
                }
                catch
                {
                    value = null;
                }

                if (value == null)
                {
                    pageDefinition.DefaultValue = null;
                }
            }

            if (pageDefinition.DefaultValue == null && pageDefinition.DefaultValueType == DefaultValueType.Value && pageDefinition.Type.DataType != PropertyDataType.Boolean)
                pageDefinition.DefaultValueType = DefaultValueType.None;
        }
Ejemplo n.º 7
0
        public static void AddContentAreaProperty(PageType pageType, string name, string description)
        {
            Predicate<PageDefinition> match = null;
            if (pageType.Definitions.Find(def => def.Name == name) == null)
            {
                match = delegate(PageDefinition def)
                {
                    return def.Name == name;
                };

                if (pageType.Definitions.Find(match) == null)
                {
                    var item = new PageDefinition();
                    item.PageTypeID = pageType.ID;
                    item.Name = name;
                    item.EditCaption = name;
                    item.HelpText = description;
                    item.DefaultValueType = DefaultValueType.None;
                    item.DefaultValue = "";
                    item.Type = PageTypeManager.ContentAreaPropertyType;
                    item.ID = 0;
                    item.Searchable = true;
                    item.Tab = PageTypeManager.LoadExtensionTab();
                    item.DisplayEditUI = false;
                    item.LanguageSpecific = false;
                    item.LongStringSettings = 0;
                    item.Save();
                    item.ClearCache();
                    pageType.Definitions.Add(item);
                    PageDefinitionType.ClearCache();
                }
            }
        }
Ejemplo n.º 8
0
 public PageDefinitionAction(
     PageDefinition pageDefinition,
     IMigrationContext context)
 {
     this.pageDefinition = pageDefinition;
     this.context        = context;
 }
        protected internal virtual void UpdatePropertySettings(PageTypeDefinition pageTypeDefinition, PageTypePropertyDefinition propertyDefinition, PageDefinition pageDefinition)
        {
            PropertySettingsContainer container = GetPropertySettingsContainer(pageDefinition);

            UpdatePageDefinitionsGlobalPropertySettings(propertyDefinition, pageTypeDefinition, container);
            UpdatePageDefinitionsLocalPropertySettings(propertyDefinition, pageTypeDefinition, container);
        }
Ejemplo n.º 10
0
 public void AddData(PageDefinition page)
 {
     if (page != null)
     {
         SelectedPane_List = page.GetPanes();
     }
 }
Ejemplo n.º 11
0
        public static void AddContentAreaProperty(PageType pageType, string name, string description)
        {
            Predicate <PageDefinition> match = null;

            if (pageType.Definitions.Find(def => def.Name == name) == null)
            {
                match = delegate(PageDefinition def)
                {
                    return(def.Name == name);
                };

                if (pageType.Definitions.Find(match) == null)
                {
                    var item = new PageDefinition();
                    item.PageTypeID       = pageType.ID;
                    item.Name             = name;
                    item.EditCaption      = name;
                    item.HelpText         = description;
                    item.DefaultValueType = DefaultValueType.None;
                    item.DefaultValue     = "";
                    item.Type             = PageTypeManager.ContentAreaPropertyType;
                    item.ID                 = 0;
                    item.Searchable         = true;
                    item.Tab                = PageTypeManager.LoadExtensionTab();
                    item.DisplayEditUI      = false;
                    item.LanguageSpecific   = false;
                    item.LongStringSettings = 0;
                    item.Save();
                    item.ClearCache();
                    pageType.Definitions.Add(item);
                    PageDefinitionType.ClearCache();
                }
            }
        }
Ejemplo n.º 12
0
        public void Configure(ConfigNode node)
        {
            ConfigNode[] pages = node.GetNodes("PAGE_DEFINITION");

            if (pages != null && pages.Length > 0)
            {
                definitions = new PageDefinition[pages.Length];

                for (int i = 0; i < pages.Length; ++i)
                {
                    string variableName = pages[i].GetValue("variableName");
                    string range        = pages[i].GetValue("range");
                    string page         = pages[i].GetValue("page");
                    if (string.IsNullOrEmpty(variableName) || string.IsNullOrEmpty(range) || string.IsNullOrEmpty(page))
                    {
                        JUtil.LogErrorMessage(this, "Incorrect page definition for page {0}", i);
                        definitions = null;
                        if (string.IsNullOrEmpty(definitionIn))
                        {
                            // Make sure we aren't crashing later.
                            definitionIn = definitionOut;
                        }
                        return;
                    }
                    definitions[i] = new PageDefinition(variableName, range, page);
                }
            }
        }
Ejemplo n.º 13
0
        public async Task <ActionResult> AddNewPage_Partial(AddNewPageModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }

            PageDefinition basePage = null;

            if (model.CopyPage)
            {
                basePage = await PageDefinition.LoadAsync(model.CurrentPageGuid);
            }

            PageDefinition.NewPageInfo newPage = await PageDefinition.CreateNewPageAsync(model.Title, model.Description, model.Url, basePage, model.CopyModules);

            PageDefinition page = newPage.Page;

            if (page == null)
            {
                ModelState.AddModelError(nameof(model.Url), newPage.Message);
                return(PartialView(model));
            }

            await page.SaveAsync();

            return(FormProcessed(model, this.__ResStr("okNewPage", "New page created"), NextPage: page.EvaluatedCanonicalUrl));
        }
        private async Task <PageDefinition> CreatePageDefinitionAsync(PageDefinition page)
        {
            using (ILockObject lockObject = await LockDesignedPagesAsync()) {
                PageDefinition.DesignedPage desPage = new PageDefinition.DesignedPage()
                {
                    PageGuid = page.PageGuid, Url = page.Url,
                };
                DesignedPagesDictionaryByUrl designedPagesByUrl = await GetDesignedPagesWithoutLockAsync();

                if (designedPagesByUrl.ContainsKey(desPage.Url.ToLower()))
                {
                    throw new Error(this.__ResStr("pageUrlErr", "A page with Url {0} already exists.", desPage.Url));
                }
                if (!await DataProvider.AddAsync(page))
                {
                    throw new Error(this.__ResStr("pageGuidErr", "A page with Guid {0} already exists.", desPage.PageGuid));
                }
                await SetCachedPageAsync(page);
                await AddDesignedPageAsync(designedPagesByUrl, page.Url.ToLower(), desPage);

                await lockObject.UnlockAsync();
            }
            await Auditing.AddAuditAsync($"{nameof(PageDefinitionDataProvider)}.{nameof(CreatePageDefinitionAsync)}", page.Url, page.PageGuid,
                                         "Create Page",
                                         DataBefore : null,
                                         DataAfter : page,
                                         ExpensiveMultiInstance : true
                                         );

            return(page);
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> UpdateAdminAndEditorAuthorization()
        {
            using (PageDefinitionDataProvider pageDP = new PageDefinitionDataProvider()) {
                int adminRole  = Resource.ResourceAccess.GetAdministratorRoleId();
                int editorRole = Resource.ResourceAccess.GetEditorRoleId();
                DataProviderGetRecords <PageDefinition> pages = await pageDP.GetItemsAsync(0, 0, null, null);

                foreach (PageDefinition genericPage in pages.Data)
                {
                    PageDefinition page = await PageDefinition.LoadAsync(genericPage.PageGuid);

                    if (page != null)
                    {
                        PageDefinition.AllowedRole role;
                        while ((role = PageDefinition.AllowedRole.Find(page.AllowedRoles, adminRole)) != null)
                        {
                            page.AllowedRoles.Remove(role);
                        }
                        page.AllowedRoles.Add(new PageDefinition.AllowedRole {
                            RoleId = adminRole, View = PageDefinition.AllowedEnum.Yes, Edit = PageDefinition.AllowedEnum.Yes, Remove = PageDefinition.AllowedEnum.Yes,
                        });
                        while ((role = PageDefinition.AllowedRole.Find(page.AllowedRoles, editorRole)) != null)
                        {
                            page.AllowedRoles.Remove(role);
                        }
                        page.AllowedRoles.Add(new PageDefinition.AllowedRole {
                            RoleId = editorRole, View = PageDefinition.AllowedEnum.Yes, Edit = PageDefinition.AllowedEnum.Yes,
                        });
                        await page.SaveAsync();
                    }
                }
            }
            return(Reload(null, Reload: ReloadEnum.ModuleParts));
        }
Ejemplo n.º 16
0
        private bool TryPageTitle(PageDefinition page, List <string> lines)
        {
            if (lines.Count() <= 0)
            {
                return(false);
            }
            string line = lines.First();

            string[] parts = line.Split(new char[] { '=' }, 2);
            if (parts.Length < 1)
            {
                return(false);
            }
            string cmd = parts[0].Trim();

            if (string.IsNullOrWhiteSpace(cmd))
            {
                return(false);
            }
            if (cmd != "Title")
            {
                return(false);
            }
            page.Title = page.Description = parts[1].Trim();
            ++_LineCounter; lines.RemoveAt(0);
            return(true);
        }
Ejemplo n.º 17
0
        private string GetImage(PageDefinition pageDef)
        {
            string image;
            string type;

            if (pageDef.FavIcon != null)
            {
                type  = PageDefinition.ImageType;
                image = pageDef.FavIcon;
            }
            else if (Module.DefaultImage != null)
            {
                type  = ModuleImageSupport.ImageType;
                image = Module.DefaultImage;
            }
            else
            {
                type  = PageDefinition.ImageType;
                image = Guid.Empty.ToString();
            }
            int size;

            switch (Module.Style)
            {
            default:
            case PageBarModule.PanelStyleEnum.Vertical:
                size = 32;
                break;

            case PageBarModule.PanelStyleEnum.Horizontal:
                size = 32;
                break;
            }
            return(ImageHTML.FormatUrl(type, null, image, size, size, Stretch: true));
        }
Ejemplo n.º 18
0
        protected internal virtual string SerializeValues(PageDefinition pageDefinition)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(pageDefinition.EditCaption);
            builder.Append("|");
            builder.Append(pageDefinition.HelpText);
            builder.Append("|");
            builder.Append(pageDefinition.Required);
            builder.Append("|");
            builder.Append(pageDefinition.Searchable);
            builder.Append("|");
            builder.Append(pageDefinition.DefaultValue);
            builder.Append("|");
            builder.Append(pageDefinition.DefaultValueType);
            builder.Append("|");
            builder.Append(pageDefinition.LanguageSpecific);
            builder.Append("|");
            builder.Append(pageDefinition.DisplayEditUI);
            builder.Append("|");
            builder.Append(pageDefinition.FieldOrder);
            builder.Append("|");
            builder.Append(pageDefinition.LongStringSettings);
            builder.Append("|");
            builder.Append(pageDefinition.Tab.ID);
            builder.Append("|");

            return(builder.ToString());
        }
Ejemplo n.º 19
0
        public static void AddExtensionPageProperty(PageType pageType)
        {
            if (pageType.Definitions.Find(def => def.Name == "ExtensionPageProperty") == null)
            {
                if (pageType.Definitions.Find(def => def.Name == "ExtensionPageProperty") == null)
                {
                    var item = new PageDefinition();
                    item.PageTypeID       = pageType.ID;
                    item.Name             = "ExtensionPageProperty";
                    item.EditCaption      = "ExtensionPageProperty";
                    item.HelpText         = "Specialized For Extension Added By Extension (Do not remove)";
                    item.DefaultValueType = DefaultValueType.None;
                    item.DefaultValue     = "";
                    item.Type             = PageTypeManager.ExtensionPageDefinitionType;
                    item.ID                 = 0;
                    item.Searchable         = true;
                    item.Tab                = PageTypeManager.LoadExtensionTab();
                    item.DisplayEditUI      = true;
                    item.LanguageSpecific   = true;
                    item.LongStringSettings = 0;
                    item.Save();
                    item.ClearCache();
                    pageType.Definitions.Add(item);
                }
            }

            PageDefinitionType.ClearCache();
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Create a page list for the current site.
        /// </summary>
        public async Task <string> CreateAsync()
        {
            StringBuilder sb = new StringBuilder();

            // Designed pages (only)
            List <Guid> pageGuids = await PageDefinition.GetDesignedGuidsAsync();

            List <string> pages = new List <string>();

            foreach (Guid guid in pageGuids)
            {
                PageDefinition page = await PageDefinition.LoadPageDefinitionAsync(guid);

                if (page != null)
                {
                    pages.Add(page.EvaluatedCanonicalUrl);
                }
            }
            pages = pages.OrderBy(s => s).ToList();
            foreach (string page in pages)
            {
                sb.AppendLine(Manager.CurrentSite.MakeFullUrl(page));
            }
            return(sb.ToString());
        }
Ejemplo n.º 21
0
        public async Task <ActionResult> PageEdit_Partial(EditModel model)
        {
            PageDefinition page = await PageDefinition.LoadAsync(model.PageGuid);

            if (page == null)
            {
                throw new Error(this.__ResStr("alreadyDeleted", "This page has been removed and can no longer be updated."));
            }

            model.UpdateData(page);
            ObjectSupport.CopyData(page, model.Page, ReadOnly: true); // update read only properties in model in case there is an error
            model.Page.FavIcon_Data = page.FavIcon_Data;              // copy favicon
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }
            page = model.GetData(page);  // merge new data into original
            model.SetData(page);         // and all the data back into model for final display

            await page.SaveAsync();      // this handles changing the Url automatically

            MenuList.ClearCachedMenus(); // page changes may affect all menus so clear the menu cache (this only clears current session)
            // if we're in a popup and the parent page is the page we're editing, then force a reload

            //$$$$ rename with querystring doesn't work
            OnPopupCloseEnum popupClose = OnPopupCloseEnum.ReloadModule;

            if (PageDefinition.IsSamePage(Manager.QueryReturnToUrl.Url, model.Page.Url))
            {
                popupClose = OnPopupCloseEnum.ReloadParentPage;
            }
            return(FormProcessed(model, this.__ResStr("okSaved", "Page settings saved"), OnPopupClose: popupClose));
        }
        protected internal virtual string SerializeValues(PageDefinition pageDefinition)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(pageDefinition.EditCaption);
            builder.Append("|");
            builder.Append(pageDefinition.HelpText);
            builder.Append("|");
            builder.Append(pageDefinition.Required);
            builder.Append("|");
            builder.Append(pageDefinition.Searchable);
            builder.Append("|");
            builder.Append(pageDefinition.DefaultValue);
            builder.Append("|");
            builder.Append(pageDefinition.DefaultValueType);
            builder.Append("|");
            builder.Append(pageDefinition.LanguageSpecific);
            builder.Append("|");
            builder.Append(pageDefinition.DisplayEditUI);
            builder.Append("|");
            builder.Append(pageDefinition.FieldOrder);
            builder.Append("|");
            builder.Append(pageDefinition.LongStringSettings);
            builder.Append("|");
            builder.Append(pageDefinition.Tab.ID);
            builder.Append("|");

            return builder.ToString();
        }
Ejemplo n.º 23
0
 public void AddData(PageDefinition page)
 {
     if (page != null)
     {
         ExistingModulePane_List = page.GetPanes();
     }
 }
Ejemplo n.º 24
0
 private async Task SearchPageAsync(SearchWords searchWords, PageDefinition page)
 {
     if (!searchWords.WantPage(page))
     {
         return;
     }
     if (await searchWords.SetUrlAsync(page.Url, page.PageSecurity, page.Title, page.Description, page.Created, page.Updated, page.IsAuthorized_View_Anonymous(), page.IsAuthorized_View_AnyUser()))
     {
         searchWords.AddKeywords(page.Keywords);
         foreach (var m in page.ModuleDefinitions)
         {
             Guid             modGuid = m.ModuleGuid;
             ModuleDefinition mod     = null;
             try {
                 mod = await ModuleDefinition.LoadAsync(m.ModuleGuid);
             } catch (Exception ex) {
                 Logging.AddErrorLog("An error occurred retrieving module {0} in page {1}", m.ModuleGuid, page.Url, ex);
             }
             if (mod != null)
             {
                 SearchModule(searchWords, mod);
             }
         }
         await searchWords.SaveAsync();
     }
 }
Ejemplo n.º 25
0
        public static void AddExtensionPageProperty(PageType pageType)
        {
            if (pageType.Definitions.Find(def => def.Name == "ExtensionPageProperty") == null)
            {
                if (pageType.Definitions.Find(def => def.Name == "ExtensionPageProperty") == null)
                {
                    var item = new PageDefinition();
                    item.PageTypeID = pageType.ID;
                    item.Name = "ExtensionPageProperty";
                    item.EditCaption = "ExtensionPageProperty";
                    item.HelpText = "Specialized For Extension Added By Extension (Do not remove)";
                    item.DefaultValueType = DefaultValueType.None;
                    item.DefaultValue = "";
                    item.Type = PageTypeManager.ExtensionPageDefinitionType;
                    item.ID = 0;
                    item.Searchable = true;
                    item.Tab = PageTypeManager.LoadExtensionTab();
                    item.DisplayEditUI = true;
                    item.LanguageSpecific = true;
                    item.LongStringSettings = 0;
                    item.Save();
                    item.ClearCache();
                    pageType.Definitions.Add(item);
                }
            }

            PageDefinitionType.ClearCache();
        }
Ejemplo n.º 26
0
        public async Task <ActionResult> AddNewModule_Partial(AddNewModuleModel model)
        {
            PageDefinition page = await PageDefinition.LoadAsync(model.CurrentPageGuid);

            if (page == null)
            {
                throw new Error("Can't edit this page");
            }
            model.AddData(page);
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }

            ModuleDefinition module = ModuleDefinition.CreateNewDesignedModule(model.SelectedModule, model.ModuleName, model.ModuleTitle);

            if (!module.IsModuleUnique)
            {
                module.ModuleGuid = Guid.NewGuid();
            }
            page.AddModule(model.SelectedPane, module, model.ModuleLocation == Location.Top);
            await page.SaveAsync();

            return(Reload(model, PopupText: this.__ResStr("okNew", "New module added")));
        }
Ejemplo n.º 27
0
        public static void AddContentAreaProperty(PageType pageType, string name, string description)
        {
            Predicate<PageDefinition> match = null;
            if (pageType.Definitions.Find(def => def.Name == name) == null)
            {
                match = delegate(PageDefinition def)
                {
                    return def.Name == name;
                };

                if (pageType.Definitions.Find(match) == null)
                {
                    var item = new PageDefinition
                               	{
                               		PageTypeID = pageType.ID,
                               		Name = name,
                               		EditCaption = name,
                               		HelpText = string.IsNullOrEmpty(description) ? string.Empty : description,
                               		DefaultValueType = DefaultValueType.None,
                               		DefaultValue = "",
                               		Type = PageTypeManager.ContentAreaPropertyType,
                               		ID = 0,
                               		Searchable = true,
                               		Tab = PageTypeManager.LoadExtensionTab(),
                               		DisplayEditUI = false,
                               		LanguageSpecific = false,
                               		LongStringSettings = 0
                               	};
                    item.Save();
                    item.ClearCache();
                    pageType.Definitions.Add(item);
                    PageDefinitionType.ClearCache();
                }
            }
        }
Ejemplo n.º 28
0
        public async Task <ActionResult> ExportPage(Guid pageGuid, long cookieToReturn)
        {
            PageDefinition page = await PageDefinition.LoadAsync(pageGuid);

            YetaWFZipFile zipFile = await page.ExportAsync();

            return(new ZippedFileResult(zipFile, cookieToReturn));
        }
Ejemplo n.º 29
0
 private IObservable <FrameworkElement> SetPageDataContext(PageDefinition pageDefinition, IViewModel viewModel)
 {
     return(Observable.FromEventPattern <NavigatedEventHandler, NavigationEventArgs>(h => _frame.Navigated += h, h => _frame.Navigated -= h, _dispatcherScheduler)
            .Where(args => args.EventArgs.SourcePageType == pageDefinition.PageType)
            .Select(args => ((FrameworkElement)args.EventArgs.Content))
            .Do(page => page.DataContext = viewModel)
            .Take(1));
 }
Ejemplo n.º 30
0
 private void ModifyComposerPropertyTypes(PageDefinition pageDefinition, PropertyDefinition propertyDefinition)
 {
     if (pageDefinition.Type.TypeName == ComposerPropertyTypes.ContentArea)
     {
         propertyDefinition.DisplayEditUI    = true;
         propertyDefinition.Searchable       = false;
         propertyDefinition.LanguageSpecific = true;
     }
 }
        public PageRenderItemDefinitionContext(PageDefinition pageDefinition, Item item, DisplayMode exteriorDisplayMode)
        {
            Assert.ArgumentNotNull(pageDefinition, nameof(pageDefinition));
            Assert.ArgumentNotNull(item, nameof(item));

            Definition = pageDefinition;
            Item       = item;
            PageMode   = exteriorDisplayMode;
        }
 private IEnumerable<PageDefinition> MapRecordsToExposedObjects(IEnumerable<PageDefinition> internalRecords)
 {
     return internalRecords.Select(pd =>
         {
             var exposedPageDefinition = new PageDefinition();
             Mapper.Map(pd, exposedPageDefinition);
             return exposedPageDefinition;
         });
 }
 private IEnumerable <PageDefinition> MapRecordsToExposedObjects(IEnumerable <PageDefinition> internalRecords)
 {
     return(internalRecords.Select(pd =>
     {
         var exposedPageDefinition = new PageDefinition();
         Mapper.Map(pd, exposedPageDefinition);
         return exposedPageDefinition;
     }));
 }
Ejemplo n.º 34
0
        public void GivenPageTypePropertyDefinition_CreateNewPageDefinition_CallsSetPageDefinitionTypeMethod()
        {
            PageTypePropertyUpdater    partiallyMockedUtility     = CreatePageTypePropertyUpdaterWithFakePageDefinitionFactoryAndFakedSetPageDefinitionTypeMethod();
            PageTypePropertyDefinition pageTypePropertyDefinition = PageTypePropertyUpdaterTestsUtility.CreatePageTypePropertyDefinition();

            PageDefinition returnedPageDefintion = partiallyMockedUtility.CreateNewPageDefinition(pageTypePropertyDefinition);

            partiallyMockedUtility.AssertWasCalled(utility => utility.SetPageDefinitionType(returnedPageDefintion, pageTypePropertyDefinition));
        }
        protected internal virtual void UpdatePageDefinition(PageDefinition pageDefinition, PageTypePropertyDefinition pageTypePropertyDefinition)
        {
            string oldValues = SerializeValues(pageDefinition);

            UpdatePageDefinitionValues(pageDefinition, pageTypePropertyDefinition);

            if(SerializeValues(pageDefinition) != oldValues)
                PageDefinitionFactory.Save(pageDefinition);
        }
Ejemplo n.º 36
0
        public void GivenPageTypePropertyDefinition_CreateNewPageDefinition_SavesPageDefinition()
        {
            PageTypePropertyUpdater    utility    = CreatePageTypePropertyUpdaterWithFakePageDefinitionFactoryAndFakedSetPageDefinitionTypeMethod();
            PageTypePropertyDefinition definition = PageTypePropertyUpdaterTestsUtility.CreatePageTypePropertyDefinition();

            PageDefinition returnedPageDefinition = utility.CreateNewPageDefinition(definition);

            utility.PageDefinitionFactory.AssertWasCalled(factory => factory.Save(returnedPageDefinition));
        }
Ejemplo n.º 37
0
        public void GivenPageTypePropertyDefinition_CreateNewPageDefinition_ReturnsPageDefinitionWithCorrectName()
        {
            PageTypePropertyUpdater    utility    = CreatePageTypePropertyUpdaterWithFakePageDefinitionFactoryAndFakedSetPageDefinitionTypeMethod();
            PageTypePropertyDefinition definition = PageTypePropertyUpdaterTestsUtility.CreatePageTypePropertyDefinition();

            PageDefinition returnedPageDefintion = utility.CreateNewPageDefinition(definition);

            Assert.Equal <string>(definition.Name, returnedPageDefintion.Name);
        }
Ejemplo n.º 38
0
 public void AddData(PageDefinition page, PageControlModule mod)
 {
     UploadFile = new FileUpload1 {
         SelectButtonText = this.__ResStr("btnImportPage", "Import Page Data..."),
         SaveURL          = Utility.UrlFor(typeof(PageControlModuleController), nameof(PageControlModuleController.ImportPage), new { __ModuleGuid = mod.ModuleGuid }),
         RemoveURL        = Utility.UrlFor(typeof(PageControlModuleController), nameof(PageControlModuleController.RemovePage), new { __ModuleGuid = mod.ModuleGuid }),
         SerializeForm    = true,
     };
 }
        public void GivenPropertyDefinitionWithNoHelpText_UpdatePageDefinition_SetsHelpTextToEmptyString()
        {
            var pageDefinitionUpdater = GetPageDefinitionUpdater();
            PageDefinition pageDefinitionToUpdate = new PageDefinition();
            PageTypePropertyDefinition propertyDefinition = CreatePageTypePropertyDefinition();

            pageDefinitionUpdater.UpdateExistingPageDefinition(pageDefinitionToUpdate, propertyDefinition);

            Assert.Equal<string>(string.Empty, pageDefinitionToUpdate.HelpText);
        }
Ejemplo n.º 40
0
        private async Task <PageDefinition> LoadPageAsync(Guid pageGuid)
        {
            PageDefinition page = await PageDefinition.LoadAsync(pageGuid);

            if (page == null)
            {
                throw new Error(this.__ResStr("pageNotFound", "Page {0} doesn't exist"), pageGuid.ToString());
            }
            return(page);
        }
        public void GivenPageDefinitionWithSpecifiedLongStringSetting_UpdatePageDefinition_ReturnsDifferentStringThanWhenCalledWithPageDefinitionWithNoLongStringSettings()
        {
            PageTypePropertyUpdater pageTypePropertyUpdater = PageTypePropertyUpdaterFactory.Create();
            PageDefinition pageDefinition = new PageDefinition();
            string valuesWithOutClearAllLongStringSettings = pageTypePropertyUpdater.SerializeValues(pageDefinition);
            pageDefinition.LongStringSettings = EditorToolOption.Bold;

            string returnedValue = pageTypePropertyUpdater.SerializeValues(pageDefinition);

            Assert.NotEqual<string>(valuesWithOutClearAllLongStringSettings, returnedValue);
        }
        public void GivenPropertyDefinition_UpdatePageDefinition_CallsUpdatePageDefinitionValues()
        {
            PageTypePropertyUpdater pageTypePropertyUpdater = 
                CreatePageTypePropertyUpdaterWithFakePageDefinitionFactoryAndFakeUpdatePageDefinitionValuesMethod();
            PageDefinition pageDefinitionToUpdate = new PageDefinition();
            PageTypePropertyDefinition propertyDefinition = CreatePageTypePropertyDefinition();

            pageTypePropertyUpdater.UpdatePageDefinition(pageDefinitionToUpdate, propertyDefinition);

            pageTypePropertyUpdater.AssertWasCalled(
                utility => utility.UpdatePageDefinitionValues(pageDefinitionToUpdate, propertyDefinition));
        }
        protected internal virtual PageDefinition CreateNewPageDefinition(PageTypePropertyDefinition propertyDefinition)
        {
            PageDefinition pageDefinition = new PageDefinition();
            pageDefinition.PageTypeID = propertyDefinition.PageType.ID;
            pageDefinition.Name = propertyDefinition.Name;
            pageDefinition.EditCaption = propertyDefinition.GetEditCaptionOrName();
            SetPageDefinitionType(pageDefinition, propertyDefinition);

            PageDefinitionFactory.Save(pageDefinition);
            
            return pageDefinition;
        }
        public virtual void CreateNewPageDefinition(PageTypePropertyDefinition propertyDefinition)
        {
            PageDefinition pageDefinition = new PageDefinition();
            pageDefinition.PageTypeID = propertyDefinition.PageType.ID;
            pageDefinition.Name = propertyDefinition.Name;
            pageDefinition.EditCaption = propertyDefinition.GetEditCaptionOrName();
            SetPageDefinitionType(pageDefinition, propertyDefinition);

            UpdatePageDefinitionValues(pageDefinition, propertyDefinition);

            pageDefinitionRepository.Save(pageDefinition);
        }
        public virtual void UpdateExistingPageDefinition(PageDefinition pageDefinition, PageTypePropertyDefinition pageTypePropertyDefinition)
        {
            string oldValues = SerializeValues(pageDefinition);

            UpdatePageDefinitionValues(pageDefinition, pageTypePropertyDefinition);

            string updatedValues = SerializeValues(pageDefinition);
            if (updatedValues != oldValues)
            {
                log.Debug(string.Format("Updating PageDefintion, old values: {0}, new values: {1}.", oldValues, updatedValues));
                pageDefinitionRepository.Save(pageDefinition);
            }
        }
        public void GivenPropertyDefinitionWithNoEditCaptionAndNameOtherThanPageDefinitionEditCaption_UpdatedPageDefinitionEditCaption()
        {
            PageTypePropertyUpdater pageTypePropertyUpdater = CreatePageTypePropertyUpdaterWithFakeUpdatePageDefinitionTabMethod();
            PageDefinition pageDefinitionToUpdate = new PageDefinition();
            pageDefinitionToUpdate.EditCaption = TestValueUtility.CreateRandomString();
            string newEditCaption = TestValueUtility.CreateRandomString();
            PageTypePropertyDefinition propertyDefinition = CreatePageTypePropertyDefinition();
            propertyDefinition.Name = newEditCaption;

            pageTypePropertyUpdater.UpdatePageDefinitionValues(pageDefinitionToUpdate, propertyDefinition);

            Assert.Equal<string>(newEditCaption, pageDefinitionToUpdate.EditCaption);
        }
        public void GivenPropertyDefinitionWithNewEditCaption_UpdatePageDefinitionValues_UpdatedPageDefinitionEditCaption()
        {
            var pageDefinitionUpdater = GetPageDefinitionUpdater();
            PageDefinition pageDefinitionToUpdate = new PageDefinition();
            pageDefinitionToUpdate.EditCaption = TestValueUtility.CreateRandomString();
            string newEditCaption = TestValueUtility.CreateRandomString();
            PageTypePropertyDefinition propertyDefinition = CreatePageTypePropertyDefinition();
            propertyDefinition.PageTypePropertyAttribute.EditCaption = newEditCaption;

            pageDefinitionUpdater.UpdateExistingPageDefinition(pageDefinitionToUpdate, propertyDefinition);

            Assert.Equal<string>(newEditCaption, pageDefinitionToUpdate.EditCaption);
        }
        protected internal virtual void UpdatePropertySettings(PageTypeDefinition pageTypeDefinition, PageTypePropertyDefinition propertyDefinition, PageDefinition pageDefinition)
        {
            PropertySettingsContainer container = GetPropertySettingsContainer(pageDefinition);

            object[] attributes = GetPropertyAttributes(propertyDefinition, pageTypeDefinition);
            var useGlobalSettingsAttribute = attributes.OfType<UseGlobalSettingsAttribute>().FirstOrDefault();
            if(useGlobalSettingsAttribute != null)
            {
                //TODO: Should validate not null and valid type at startup
                var globalSettingsUpdater = globalPropertySettingsLocator.GetGlobalPropertySettingsUpdaters().Where(u => u.WrappedInstanceType == useGlobalSettingsAttribute.Type).First();
                var wrapper =_propertySettingsRepository.GetGlobals(globalSettingsUpdater.SettingsType)
                    .Where(w => globalSettingsUpdater.Match(w))
                    .First();
                container.Settings[globalSettingsUpdater.SettingsType.FullName] = wrapper;
                //TODO: Add spec validating that exception is thrown with the below uncommented (An item with the same key has already been added.)
                //container.Settings.Add(globalSettingsUpdater.SettingsType.FullName, wrapper);
                _propertySettingsRepository.Save(container);
            }

            List<PropertySettingsUpdater> settingsUpdaters = GetPropertySettingsUpdaters(pageTypeDefinition, propertyDefinition, pageDefinition);
            settingsUpdaters.ForEach(updater =>
                {
                    var wrapper = container.GetSetting(updater.SettingsType);
                    if (wrapper == null)
                    {
                        wrapper = new PropertySettingsWrapper();
                        container.Settings[updater.SettingsType.FullName] = wrapper;
                        //TODO: Add spec validating that exception is thrown with the below uncommented (An item with the same key has already been added.)
                        //container.Settings.Add(updater.SettingsType.FullName, wrapper);
                    }

                    bool settingsAlreadyExists = true;
                    if (wrapper.PropertySettings == null)
                    {
                        wrapper.PropertySettings = ((IPropertySettings)Activator.CreateInstance(updater.SettingsType)).GetDefaultValues();
                        settingsAlreadyExists = false;
                    }

                    if (settingsAlreadyExists && !updater.OverWriteExisting)
                        return;

                    int hashBeforeUpdate = updater.GetSettingsHashCode(wrapper.PropertySettings);
                    updater.UpdateSettings(wrapper.PropertySettings);
                    int hashAfterUpdate = updater.GetSettingsHashCode(wrapper.PropertySettings);
                    if (hashBeforeUpdate != hashAfterUpdate || !settingsAlreadyExists)
                    {
                        _propertySettingsRepository.Save(container);
                    }
                });
        }
        public void GivenPageTypeWithPropertyAndCorrespondingPropertyDefition_GetExistingPropertyDefinition_ReturnsPageDefinition()
        {
            PageTypePropertyUpdater utility = PageTypePropertyUpdaterFactory.Create();
            IPageType pageType = new NativePageType();
            string name = TestValueUtility.CreateRandomString();
            Type type = typeof(string);
            PageTypePropertyAttribute attribute = new PageTypePropertyAttribute();
            PageTypePropertyDefinition pageTypePropertyDefinition = new PageTypePropertyDefinition(name, type, pageType, attribute);
            PageDefinition pageDefinition = new PageDefinition();
            pageDefinition.Name = name;
            pageType.Definitions.Add(pageDefinition);

            PageDefinition returnedPageDefinition = utility.GetExistingPageDefinition(pageType, pageTypePropertyDefinition);

            Assert.Equal<PageDefinition>(pageDefinition, returnedPageDefinition);
        }
Ejemplo n.º 50
0
        private PageDefinition CreateDefinition(PageDefinitionStore pageDefinitionStore, string name)
        {
            var def = new PageDefinition();
            def.Name = name;
            
            var container = new ContentItem { Name = "container", Type = "container"};
            var row = new ContentItem { Name = "row1", Type = "row" };
            var column = new ContentItem { Name = "col-1", Type = "column" };

            row.Items.Add(column);
            container.Items.Add(row);
            def.Items.Add(container);

            pageDefinitionStore.Add(def);

            return def;
        }
        protected internal virtual void UpdatePropertySettings(PageTypeDefinition pageTypeDefinition, PageTypePropertyDefinition propertyDefinition, PageDefinition pageDefinition)
        {
            var prop =
                pageTypeDefinition.Type.GetProperties().Where(p => p.Name == propertyDefinition.Name).FirstOrDefault
                    ();
                
            var attributes = prop.GetCustomAttributes(typeof(PropertySettingsAttribute), true);
            foreach (var attribute in attributes)
            {
                PropertySettingsContainer container;

                if (pageDefinition.SettingsID == Guid.Empty)
                {
                    pageDefinition.SettingsID = Guid.NewGuid();
                    PageDefinitionFactory.Save(pageDefinition);
                    container = new PropertySettingsContainer(pageDefinition.SettingsID);
                }
                else
                {
                    if (!_propertySettingsRepository.TryGetContainer(pageDefinition.SettingsID, out container))
                    {
                        container = new PropertySettingsContainer(pageDefinition.SettingsID);
                    }
                }
                var settingsAttribute = (PropertySettingsAttribute) attribute;
                var wrapper = container.GetSetting(settingsAttribute.SettingType);
                if (wrapper == null)
                {
                    wrapper = new PropertySettingsWrapper();
                    container.Settings.Add(settingsAttribute.SettingType.FullName, wrapper);
                }

                bool settingsAlreadyExists = true;
                if (wrapper.PropertySettings == null)
                {
                    wrapper.PropertySettings = (IPropertySettings) Activator.CreateInstance(settingsAttribute.SettingType);
                    settingsAlreadyExists = false;
                }

                if(settingsAlreadyExists && !settingsAttribute.OverWriteExistingSettings)
                    return;

                if(settingsAttribute.UpdateSettings(wrapper.PropertySettings) || !settingsAlreadyExists)
                    _propertySettingsRepository.Save(container);
            }
        }
 void UpdatePageDefinitionsGlobalPropertySettings(PageTypePropertyDefinition propertyDefinition, PageTypeDefinition pageTypeDefinition, PageDefinition pageDefinition)
 {
     object[] attributes = GetPropertyAttributes(propertyDefinition, pageTypeDefinition);
     var useGlobalSettingsAttribute = attributes.OfType<UseGlobalSettingsAttribute>().FirstOrDefault();
     if (useGlobalSettingsAttribute != null)
     {
         var container = GetPropertySettingsContainer(pageDefinition);
         //TODO: Should validate not null and valid type at startup
         var globalSettingsUpdater = globalPropertySettingsLocator.GetGlobalPropertySettingsUpdaters().Where(u => u.WrappedInstanceType == useGlobalSettingsAttribute.Type).First();
         var wrapper = propertySettingsRepository.GetGlobals(globalSettingsUpdater.SettingsType)
             .Where(w => globalSettingsUpdater.Match(w))
             .First();
         container.Settings[globalSettingsUpdater.SettingsType.FullName] = wrapper;
         //TODO: Add spec validating that exception is thrown with the below uncommented (An item with the same key has already been added.)
         //container.Settings.Add(globalSettingsUpdater.SettingsType.FullName, wrapper);
         propertySettingsRepository.Save(container);
     }
 }
        protected virtual string SerializeValues(PageDefinition pageDefinition)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("Name: ");
            builder.Append(pageDefinition.Name);
            builder.Append("|");
            builder.Append("Type: ");
            builder.Append(pageDefinition.Type.TypeName);
            builder.Append("|");
            builder.Append("EditCaption:");
            builder.Append(pageDefinition.EditCaption);
            builder.Append("|");
            builder.Append("HelpText:");
            builder.Append(pageDefinition.HelpText);
            builder.Append("|");
            builder.Append("Required:");
            builder.Append(pageDefinition.Required);
            builder.Append("|");
            builder.Append("Searchable:");
            builder.Append(pageDefinition.Searchable);
            builder.Append("|");
            builder.Append("DefaultValue:");
            builder.Append(pageDefinition.DefaultValue);
            builder.Append("|");
            builder.Append("DefaultValueType:");
            builder.Append(pageDefinition.DefaultValueType);
            builder.Append("|");
            builder.Append("LanguageSpecific:");
            builder.Append(pageDefinition.LanguageSpecific);
            builder.Append("|");
            builder.Append("DisplayEditUI:");
            builder.Append(pageDefinition.DisplayEditUI);
            builder.Append("|");
            builder.Append("FieldOrder:");
            builder.Append(pageDefinition.FieldOrder);
            builder.Append("|");
            builder.Append("Tab.ID:");
            builder.Append(pageDefinition.Tab.ID);
            builder.Append("|"); 

            return builder.ToString();
        }
		public virtual void UpdateExistingPageDefinition(PageDefinition pageDefinition, PageTypePropertyDefinition pageTypePropertyDefinition)
		{
			string oldValues = SerializeValues(pageDefinition);

			UpdatePageDefinitionValues(pageDefinition, pageTypePropertyDefinition);

			string updatedValues = SerializeValues(pageDefinition);
			if (updatedValues != oldValues)
			{
				string diff = ValueDiff(oldValues, updatedValues);
				log.DebugFormat(
					"Updating PageDefintion for page {0}({1}), diff: {2}, old values: {3}, new values: {4}.",
					pageTypePropertyDefinition.PageType.ID,
					pageTypePropertyDefinition.PageType.Name,
					diff,
					oldValues,
					updatedValues);
				pageDefinitionRepository.Save(pageDefinition);
			}
		}
        public void Save(PageDefinition pageDefinition)
        {
            if (string.IsNullOrEmpty(pageDefinition.Name) || string.IsNullOrEmpty(pageDefinition.EditCaption))
            {
                throw new DataAbstractionException("Cannot save a type without name and caption");
            }

            if(pageDefinition.ID <= 0)
            {
                pageDefinition.ID = nextId++;
                var pageDefinitionRecord = new PageDefinition();
                Mapper.Map(pageDefinition, pageDefinitionRecord);
                pageDefinitions.Add(pageDefinitionRecord);
            }
            else
            {
                var pageDefinitionRecord = pageDefinitions.First(p => p.ID == pageDefinition.ID);
                Mapper.Map(pageDefinition, pageDefinitionRecord);
            }
        }
        public void GivenUpdatedPropertyDefinition_UpdatePageDefinition_CallsPageDefinitionFactorySave()
        {
            PageDefinition pageDefinitionToUpdate = new PageDefinition();
            MockRepository fakes = new MockRepository();
            PageTypePropertyUpdater pageTypePropertyUpdater = PageTypePropertyUpdaterFactory.PartialMock(fakes);
            pageTypePropertyUpdater.Stub(
                utility => utility.UpdatePageDefinitionValues(
                               Arg<PageDefinition>.Is.Anything, Arg<PageTypePropertyDefinition>.Is.Anything));
            PageDefinitionFactory fakeFactory = fakes.Stub<PageDefinitionFactory>();
            fakeFactory.Stub(factory => factory.Save(Arg<PageDefinition>.Is.Anything));
            fakeFactory.Replay();
            pageTypePropertyUpdater.PageDefinitionFactory = fakeFactory;
            pageTypePropertyUpdater.Stub(updater => updater.SerializeValues(pageDefinitionToUpdate)).Return(Guid.NewGuid().ToString()).Repeat.Once();
            pageTypePropertyUpdater.Stub(updater => updater.SerializeValues(pageDefinitionToUpdate)).Return(Guid.NewGuid().ToString());
            pageTypePropertyUpdater.Replay();
            PageTypePropertyDefinition propertyDefinition = CreatePageTypePropertyDefinition();

            pageTypePropertyUpdater.UpdatePageDefinition(pageDefinitionToUpdate, propertyDefinition);

            pageTypePropertyUpdater.PageDefinitionFactory.AssertWasCalled(factory => factory.Save(pageDefinitionToUpdate));
        }
        void UpdatePageDefinitionsLocalPropertySettings(PageTypePropertyDefinition propertyDefinition, PageTypeDefinition pageTypeDefinition, PageDefinition pageDefinition)
        {
            List<PropertySettingsUpdater> settingsUpdaters = GetPropertySettingsUpdaters(pageTypeDefinition, propertyDefinition);
            if(!settingsUpdaters.Any())
            {
                return;
            }
            var container = GetPropertySettingsContainer(pageDefinition);
            settingsUpdaters.ForEach(updater =>
                {
                    var wrapper = container.GetSetting(updater.SettingsType);
                    if (wrapper == null)
                    {
                        wrapper = new PropertySettingsWrapper();
                        container.Settings[updater.SettingsType.FullName] = wrapper;
                        //TODO: Add spec validating that exception is thrown with the below uncommented (An item with the same key has already been added.)
                        //container.Settings.Add(updater.SettingsType.FullName, wrapper);
                    }

                    bool settingsAlreadyExists = true;
                    if (wrapper.PropertySettings == null)
                    {
                        wrapper.PropertySettings = ((IPropertySettings)Activator.CreateInstance(updater.SettingsType)).GetDefaultValues();
                        settingsAlreadyExists = false;
                    }

                    if (settingsAlreadyExists && !updater.OverWriteExisting)
                        return;

                    int hashBeforeUpdate = updater.GetSettingsHashCode(wrapper.PropertySettings);
                    updater.UpdateSettings(wrapper.PropertySettings);
                    int hashAfterUpdate = updater.GetSettingsHashCode(wrapper.PropertySettings);
                    if (hashBeforeUpdate != hashAfterUpdate || !settingsAlreadyExists)
                    {
                        _propertySettingsRepositoryMethod().Save(container);
                        AddToUpdatedCacheKeys(container);
                    }
                });
        }
 void UpdatePageDefinitionsGlobalPropertySettings(PageTypePropertyDefinition propertyDefinition, PageTypeDefinition pageTypeDefinition, PageDefinition pageDefinition)
 {
     IEnumerable<object> attributes = GetPropertyAttributes(propertyDefinition, pageTypeDefinition);
     var useGlobalSettingsAttribute = attributes.OfType<UseGlobalSettingsAttribute>().FirstOrDefault();
     if (useGlobalSettingsAttribute != null)
     {
         var container = GetPropertySettingsContainer(pageDefinition);
         //TODO: Should validate not null and valid type at startup
         var globalSettingsUpdater = globalPropertySettingsLocator.GetGlobalPropertySettingsUpdaters().First(u => u.WrappedInstanceType == useGlobalSettingsAttribute.Type);
         var wrapper = _propertySettingsRepositoryMethod().GetGlobals(globalSettingsUpdater.SettingsType)
             .First(w => globalSettingsUpdater.Match(w));
         PropertySettingsWrapper existingWrapper = container.Settings.ContainsKey(globalSettingsUpdater.SettingsType.FullName)
             ? container.Settings[globalSettingsUpdater.SettingsType.FullName]
             : null;
         if (existingWrapper == null || existingWrapper.Id != wrapper.Id)
         {
             container.Settings[globalSettingsUpdater.SettingsType.FullName] = wrapper;
             //TODO: Add spec validating that exception is thrown with the below uncommented (An item with the same key has already been added.)
             //container.Settings.Add(globalSettingsUpdater.SettingsType.FullName, wrapper);
             _propertySettingsRepositoryMethod().Save(container);
             AddToUpdatedCacheKeys(container);
         }
     }
 }
 protected internal virtual void SetPageDefinitionType(PageDefinition pageDefinition, PageTypePropertyDefinition propertyDefinition)
 {
     pageDefinition.Type = GetPageDefinitionType(propertyDefinition);
 }
 private void UpdateLongStringSettings(PageDefinition pageDefinition, PageTypePropertyAttribute propertyAttribute)
 {
     EditorToolOption longStringSettings = propertyAttribute.LongStringSettings;
     if (longStringSettings == default(EditorToolOption) && !propertyAttribute.ClearAllLongStringSettings)
     {
         longStringSettings = EditorToolOption.All;
     }
     pageDefinition.LongStringSettings = longStringSettings;
 }