public void OnSaving(BehaviorContext context)
        {
            var item = context.AffectedItem;
            var parent = item.Parent;
            if (parent == null)
                return;

            switch (AccordingTo)
            {
                case SortBy.Expression:
                    Insert(item, parent, SortExpression);
                    break;
                case SortBy.Published:
                    Insert(item, parent, "Published");
                    break;
                case SortBy.PublishedDescending:
                    Insert(item, parent, "Published DESC");
                    break;
                case SortBy.Title:
                    Insert(item, parent, "Title");
                    break;
                case SortBy.Updated:
                    Insert(item, parent, "Updated");
                    break;
                case SortBy.UpdatedDescending:
                    Insert(item, parent, "Updated DESC");
                    break;
                case SortBy.Unordered:
                    // don't add to parnet collection
                    break;
                default:
                    context.AffectedItem.AddTo(context.AffectedItem.Parent);
                    break;
            }
        }
        public void OnRemovingChild(BehaviorContext context)
        {
            var item = context.AffectedItem;
            var parent = context.Parent;
            if (Is(parent.ChildState, CollectionState.Unknown) || Is(parent.ChildState, CollectionState.IsEmpty))
                return;

            bool isParentAdded = false;
            if (Is(parent.ChildState, CollectionState.IsLarge) && parent.Children.Count <= LargeCollecetionThreshold)
            {
                parent.ChildState ^= CollectionState.IsLarge;
                context.UnsavedItems.Add(parent);
                isParentAdded = true;
            }

            var itemState = item.GetCollectionState();

            if (ReduceExistingStates(item, parent, itemState) == CollectionState.Unknown)
                return;

            parent.ChildState ^= itemState;
            if (parent.ChildState == CollectionState.Unknown)
                parent.ChildState = CollectionState.IsEmpty;

            if (!isParentAdded)
                context.UnsavedItems.Add(parent);
        }
		public void OnSavingChild(BehaviorContext context)
		{
			var child = context.AffectedItem;
			var parent = context.Parent;
			
			var initialState = parent.ChildState;
			var childInducedState = child.GetCollectionState();

			if (parent.ChildState == CollectionState.IsEmpty)
			{
				// no previous child state
				parent.ChildState = childInducedState;
				context.UnsavedItems.Add(parent);
				return;
			}
			
			var reducedState = ReduceExistingStates(null, parent, initialState);
			if (reducedState == CollectionExtensions.None)
			{
				if (Is(initialState, childInducedState))
					// unchanged child state
					return;

				// added child state
				parent.ChildState |= childInducedState;
			}
			else
			{
				// changed child state
				parent.ChildState |= childInducedState;
				parent.ChildState ^= reducedState;
			}
				
			context.UnsavedItems.Add(parent);
		}
		public void OnSaving(BehaviorContext context)
		{
            if (!syncEnabled)
                return;

			if (context.AffectedItem.Children.Count == 0)
				context.AffectedItem.ChildState = CollectionState.IsEmpty;
		}
 public void OnAddingChild(BehaviorContext context)
 {
     OnSavingChild(context);
     if (context.Parent.Children.Count >= LargeCollecetionThreshold)
     {
         context.Parent.ChildState |= CollectionState.IsLarge;
         context.UnsavedItems.Add(context.Parent);
     }
 }
Example #6
0
        public void OnSavingChild(BehaviorContext context)
        {
            if (context.AffectedItem.Parent == null)
                return;

            foreach (ContentItem updatedItem in ReorderChildren(context.AffectedItem.Parent))
            {
                context.UnsavedItems.Add(updatedItem);
            }
        }
        public void OnSavingChild(BehaviorContext context)
        {
            if (OrderBy == SortBy.Unordered)
                return;

            var item = context.AffectedItem;

            if (item.Parent == null)
                return;
            
            foreach (ContentItem updatedItem in ReorderChildren(item.Parent))
            {
                context.UnsavedItems.Add(updatedItem);
            }
        }
Example #8
0
        public void OnSaving(BehaviorContext context)
        {
            var item = context.AffectedItem;
            var parent = item.Parent;
            if (parent == null)
                return;

            switch (AccordingTo)
            {
                case SortBy.Expression:
                    Insert(item, parent, SortExpression);
                    break;
                case SortBy.Published:
                    Insert(item, parent, "Published");
                    break;
                case SortBy.PublishedDescending:
                    Insert(item, parent, "Published DESC");
                    break;
                case SortBy.Title:
                    Insert(item, parent, "Title");
                    break;
                case SortBy.Updated:
                    Insert(item, parent, "Updated");
                    break;
                case SortBy.UpdatedDescending:
                    Insert(item, parent, "Updated DESC");
                    break;
                case SortBy.Unordered:
                    // don't add to parent collection
                    break;
                case SortBy.Append:
                    if (context.AffectedItem.ID == 0 && context.AffectedItem.SortOrder == 0 && context.AffectedItem.Parent != null)
                    {
                        var siblingWithGreatestOrder = context.AffectedItem.Parent
                            .Children.Find(new ParameterCollection().OrderBy("SortOrder DESC").Take(1)).FirstOrDefault();
                        if (siblingWithGreatestOrder != null)
                            context.AffectedItem.SortOrder = siblingWithGreatestOrder.SortOrder + 10;
                    }
                    break;
                default:
                    context.AffectedItem.AddTo(context.AffectedItem.Parent);
                    break;
            }
        }
Example #9
0
 void ISavingBehavior.OnSavingChild(BehaviorContext context)
 {
 }
Example #10
0
		void ISavingBehavior.OnSaving(BehaviorContext context)
		{
		}
 public void OnRemoving(BehaviorContext context)
 {
 }
 public void OnAdding(BehaviorContext context)
 {
 }
		public void OnSavingChild(BehaviorContext context)
        {
            if (!syncEnabled)
                return;

			var child = context.AffectedItem;
			var parent = context.Parent;
			
			var initialState = parent.ChildState;
			var childInducedState = child.GetCollectionState();

			if (parent.ChildState == CollectionState.IsEmpty)
			{
				// no previous child state
				parent.ChildState = childInducedState;
				context.UnsavedItems.Add(parent);
				return;
			}

			if (Is(initialState, CollectionState.IsLarge))
			{
				CollectionState newState = CollectionState.IsLarge;
				if (parent.Children.FindCount(Parameter.IsNull("ZoneName") & Parameter.Equal("Visible", true) & Parameter.Equal("AlteredPermissions", Permission.None)) > 0)
					newState |= CollectionState.ContainsVisiblePublicPages;
				if (parent.Children.FindCount(Parameter.IsNull("ZoneName") & Parameter.Equal("Visible", false) & Parameter.Equal("AlteredPermissions", Permission.None)) > 0)
					newState |= CollectionState.ContainsHiddenPublicPages;
				if (parent.Children.FindCount(Parameter.IsNull("ZoneName") & Parameter.Equal("Visible", true) & Parameter.NotEqual("AlteredPermissions", Permission.None)) > 0)
					newState |= CollectionState.ContainsVisibleSecuredPages;
				if (parent.Children.FindCount(Parameter.IsNull("ZoneName") & Parameter.Equal("Visible", false) & Parameter.NotEqual("AlteredPermissions", Permission.None)) > 0)
					newState |= CollectionState.ContainsHiddenSecuredPages;

				if (parent.Children.FindCount(Parameter.IsNotNull("ZoneName") & Parameter.Equal("AlteredPermissions", Permission.None)) > 0)
					newState |= CollectionState.ContainsPublicParts;
				if (parent.Children.FindCount(Parameter.IsNotNull("ZoneName") & Parameter.NotEqual("AlteredPermissions", Permission.None)) > 0)
					newState |= CollectionState.ContainsSecuredParts;

				if (newState != initialState)
				{
					parent.ChildState = newState;
					context.UnsavedItems.Add(parent);
				}
				return;
			}

			var reducedState = ReduceExistingStates(null, parent, initialState);
			if (reducedState == CollectionExtensions.None)
			{
				if (Is(initialState, childInducedState))
					// unchanged child state
					return;

				// added child state
				parent.ChildState |= childInducedState;
			}
			else
			{
				// changed child state
				parent.ChildState ^= reducedState;
				parent.ChildState |= childInducedState;
			}
				
			context.UnsavedItems.Add(parent);
		}