Example #1
0
        private void RedirectToVersionOfSelf(ContentItem versionOfPage)
        {
            var url = Engine.ManagementPaths.GetEditExistingItemUrl(versionOfPage.FindPartVersion(ParentItem), Page.Request["returnUrl"], Page.Request.Url.AbsolutePath);

            //if (Page.Request.Url.AbsolutePath.EndsWith("EditRecursive.aspx"))
            //	Page.Response.Redirect(Page.Request.Url.AbsolutePath + "?" + url.ToUrl().Query);
            Page.Response.Redirect(url);
        }
Example #2
0
        public override bool UpdateItem(ContentItem item, Control editor)
        {
            bool           updated    = false;
            ItemEditorList listEditor = (ItemEditorList)editor;

            for (int i = 0; i < listEditor.ItemEditors.Count; i++)
            {
                ItemEditor childEditor  = listEditor.ItemEditors[i];
                ItemEditor parentEditor = ItemUtility.FindInParents <ItemEditor>(editor.Parent);

                var childItem = childEditor.CurrentItem;
                if (childItem.ID != 0 && item.ID == 0 && !childItem.IsPage)
                {
                    // we may have initialized the editor with the published version but we want to use the draft here
                    childItem = item.FindPartVersion(childItem);
                }

                if (listEditor.DeletedIndexes.Contains(i))
                {
                    if (childItem.ID == 0)
                    {
                        childItem.AddTo(null);
                    }
                    else
                    {
                        Engine.Persister.Delete(childItem);
                    }
                }
                else
                {
                    if (parentEditor != null)
                    {
                        var subContext = parentEditor.BinderContext.CreateNestedContext(childEditor, childItem, childEditor.GetDefinition());
                        if (subContext.Binder.UpdateObject(subContext))
                        {
                            childItem.AddTo(item); // make sure it's on parent's child collection
                            parentEditor.BinderContext.RegisterItemToSave(childItem);
                            updated = true;
                        }
                    }
                    else
                    {
                        IItemEditor fallbackEditor = ItemUtility.FindInParents <IItemEditor>(editor.Parent);
                        if (fallbackEditor != null)
                        {
                            fallbackEditor.Saved += delegate
                            {
                                var cc = childEditor.CreateCommandContext();
                                Engine.Resolve <CommandDispatcher>().Publish(cc);
                            };
                        }
                    }
                }
            }
            return(updated || listEditor.DeletedIndexes.Count > 0 || listEditor.AddedDefinitions.Count > 0);
        }
Example #3
0
        public static ContentItem GetBelowItem(Edit.Navigator navigator, NameValueCollection request, ContentItem page)
        {
            ContentItem item = page.FindDescendantByVersionKey(request["belowVersionKey"]);

            if (item != null)
            {
                return(item);
            }

            var parent = navigator.Navigate(request["below"]);

            return(parent == null ? null : page.FindPartVersion(parent));
        }
Example #4
0
        // locate an item by VersionKey on a page (used for DRAFTs)

        public static ContentItem GetBeforeItem(Edit.Navigator navigator, NameValueCollection request, ContentItem page)
        {
            ContentItem item = page.FindDescendantByVersionKey(request["beforeVersionKey"]);

            if (item != null)
            {
                return(item);
            }

            ContentItem beforeItem = navigator.Navigate(request["before"]);

            return(beforeItem == null ? null : page.FindPartVersion(beforeItem));
        }
		public override bool UpdateItem(ContentItem item, Control editor)
		{
			bool updated = false;
			ItemEditorList listEditor = (ItemEditorList)editor;
			for (int i = 0; i < listEditor.ItemEditors.Count; i++)
			{
                ItemEditor childEditor = listEditor.ItemEditors[i];
                ItemEditor parentEditor = ItemUtility.FindInParents<ItemEditor>(editor.Parent);

                var childItem = childEditor.CurrentItem;
				if (childItem.ID != 0 && item.ID == 0 && !childItem.IsPage)
                    // we may have initialized the editor with the published version but we want to use the draft here
                    childItem = item.FindPartVersion(childItem);

                if (listEditor.DeletedIndexes.Contains(i))
				{
                    if (childItem.ID == 0)
                        childItem.AddTo(null);
					else
                        Engine.Persister.Delete(childItem);
				}
				else
				{
                    if (parentEditor != null)
					{
						var subContext = parentEditor.BinderContext.CreateNestedContext(childEditor, childItem, childEditor.GetDefinition());
						if (subContext.Binder.UpdateObject(subContext))
						{
                            childItem.AddTo(item); // make sure it's on parent's child collection
							parentEditor.BinderContext.RegisterItemToSave(childItem);
							updated = true;
						}
					}
					else
					{
						IItemEditor fallbackEditor = ItemUtility.FindInParents<IItemEditor>(editor.Parent);
						if (fallbackEditor != null)
						{
							fallbackEditor.Saved += delegate
							{
								var cc = childEditor.CreateCommandContext();
								Engine.Resolve<CommandDispatcher>().Publish(cc);
							};
						}
					}
				}
			}
			return updated || listEditor.DeletedIndexes.Count > 0 || listEditor.AddedDefinitions.Count > 0;
		}
Example #6
0
        public static ContentItem GetBelowItem(Edit.Navigator navigator, System.Collections.Specialized.NameValueCollection request, ContentItem page)
        {
            string below           = request["below"];
            string belowVersionKey = request["belowVersionKey"];

            if (!string.IsNullOrEmpty(belowVersionKey))
            {
                return(page.FindDescendantByVersionKey(belowVersionKey));
            }
            else
            {
                var parent = navigator.Navigate(below);
                return(page.FindPartVersion(parent));
            }
        }
Example #7
0
        public static ContentItem GetBelowItem(Edit.Navigator navigator, Func <string, string> requestValueAccessor, ContentItem page)
        {
            string below           = requestValueAccessor("below");
            string belowVersionKey = requestValueAccessor("belowVersionKey");

            if (!string.IsNullOrEmpty(belowVersionKey))
            {
                return(page.FindDescendantByVersionKey(belowVersionKey));
            }
            else
            {
                var parent = navigator.Navigate(below);
                return(page.FindPartVersion(parent));
            }
        }
Example #8
0
        public static ContentItem GetBeforeItem(Edit.Navigator navigator, System.Collections.Specialized.NameValueCollection request, ContentItem page)
        {
            string before           = request["before"];
            string beforeVersionKey = request["beforeVersionKey"];

            if (!string.IsNullOrEmpty(before))
            {
                ContentItem beforeItem = navigator.Navigate(before);
                return(page.FindPartVersion(beforeItem));
            }
            else if (!string.IsNullOrEmpty(beforeVersionKey))
            {
                return(page.FindDescendantByVersionKey(beforeVersionKey));
            }
            return(null);
        }
        public override bool UpdateItem(ContentItem parentItem, Control editor)
        {
            ItemEditor childEditor  = editor as ItemEditor;
            ItemEditor parentEditor = ItemUtility.FindInParents <ItemEditor>(editor.Parent);

            var childItem = childEditor.CurrentItem;

            if (childItem.ID != 0 && parentItem.ID == 0)
            {
                // we may have initialized the editor with the published version but we want to use the draft here
                childItem = parentItem.FindPartVersion(childItem);
            }

            if (childEditor.UpdateObject(parentEditor.BinderContext.CreateNestedContext(childEditor, childItem, childEditor.GetDefinition())))
            {
                parentItem[Name] = childItem;
                return(true);
            }

            return(false);
        }
Example #10
0
        public static ContentItem GetBeforeItem(Edit.Navigator navigator, Func <string, string> requestValueAccessor, ContentItem page)
        {
            string before           = requestValueAccessor("before");
            string beforeVersionKey = requestValueAccessor("beforeVersionKey");


            if (!string.IsNullOrEmpty(beforeVersionKey))
            {
                ContentItem beforeItem = page.FindDescendantByVersionKey(beforeVersionKey);
                if (beforeItem != null)
                {
                    return(beforeItem);
                }
            }
            if (!string.IsNullOrEmpty(before))
            {
                ContentItem beforeItem = navigator.Navigate(before);
                return(page.FindPartVersion(beforeItem));
            }
            return(null);
        }
Example #11
0
        public static ContentItem FindPartVersion(this ContentItem parent, ContentItem part)
        {
            if (!part.VersionOf.HasValue && part.ID == 0)
            {
                if (part.Parent != null && part.Parent.ID != 0)
                {
                    part.Parent = parent.FindPartVersion(part.Parent);
                }
                return(part);
            }
            if (parent.ID != 0 && part.ID == parent.ID)
            {
                return(parent);
            }
            if (part.ID == parent.VersionOf.ID)
            {
                return(parent);
            }
            if (part.VersionOf.HasValue && part.VersionOf.ID == parent.VersionOf.ID)
            {
                return(parent);
            }
            if (parent.ID == 0 && parent.GetVersionKey() == part.GetVersionKey())
            {
                return(parent);
            }

            foreach (var child in parent.Children)
            {
                var grandChild = child.FindPartVersion(part);
                if (grandChild != null)
                {
                    return(grandChild);
                }
            }
            return(null);
        }
Example #12
0
		private void RedirectToVersionOfSelf(ContentItem versionOfPage)
		{
			var url = Engine.ManagementPaths.GetEditExistingItemUrl(versionOfPage.FindPartVersion(ParentItem), Page.Request["returnUrl"]);
			Page.Response.Redirect(url);
		}
Example #13
0
        private void RedirectToVersionOfSelf(ContentItem versionOfPage)
        {
            var url = Engine.ManagementPaths.GetEditExistingItemUrl(versionOfPage.FindPartVersion(ParentItem), Page.Request["returnUrl"]);

            Page.Response.Redirect(url);
        }
		public override bool UpdateItem(ContentItem parentItem, Control editor)
		{
			ItemEditor childEditor = editor as ItemEditor;
			ItemEditor parentEditor = ItemUtility.FindInParents<ItemEditor>(editor.Parent);

            var childItem = childEditor.CurrentItem;
            if (childItem.ID != 0 && parentItem.ID == 0)
                // we may have initialized the editor with the published version but we want to use the draft here
                childItem = parentItem.FindPartVersion(childItem);

			if (childEditor.UpdateObject(parentEditor.BinderContext.CreateNestedContext(childEditor, childItem, childEditor.GetDefinition())))
			{
				parentItem[Name] = childItem;
				return true;
			}
			
			return false;
		}
Example #15
0
		private void RedirectToVersionOfSelf(ContentItem versionOfPage)
		{
			var url = Engine.ManagementPaths.GetEditExistingItemUrl(versionOfPage.FindPartVersion(ParentItem), Page.Request["returnUrl"], Page.Request.Url.AbsolutePath);
			//if (Page.Request.Url.AbsolutePath.EndsWith("EditRecursive.aspx"))
			//	Page.Response.Redirect(Page.Request.Url.AbsolutePath + "?" + url.ToUrl().Query);
			Page.Response.Redirect(url);
		}