Example #1
0
		private static List<ItemDefinition> GetPossibleDefinitions(PartsAdapter adapter, IEnumerable<Zone> pageZones, IPrincipal user)
		{
			var availableDefinitions = new List<ItemDefinition>();
			foreach (Zone z in pageZones)
			{
				ContentItem item = z.CurrentItem;
				string zoneName = z.ZoneName;
				if (item == null || string.IsNullOrEmpty(zoneName)) continue;

				foreach (ItemDefinition definition in adapter.GetAllowedDefinitions(item, zoneName, user))
				{
					if (!availableDefinitions.Contains(definition))
						availableDefinitions.Add(definition);
				}
			}
			return availableDefinitions;
		}
Example #2
0
		/// <summary>Gets part definitions that can be added to the given page.</summary>
		/// <param name="adapter"></param>
		/// <param name="item"></param>
		/// <param name="pageZones"></param>
		/// <param name="user"></param>
		/// <returns></returns>
		public static IEnumerable<ItemDefinition> GetPartDefinitions(PartsAdapter adapter, ContentItem item, IEnumerable<Zone> pageZones, IPrincipal user)
		{
			IEnumerable<ItemDefinition> availableDefinitions;

			if (pageZones == null)
				availableDefinitions = adapter.GetAllowedDefinitions(item, user);
			else
				availableDefinitions = GetPossibleDefinitions(adapter, pageZones, user);

			var sortedDefinitions = new List<ItemDefinition>();
			sortedDefinitions.AddRange(availableDefinitions);
			sortedDefinitions.Sort();
			return sortedDefinitions;
		}
Example #3
0
		/// <summary>Gets part definitions that can be added to the given page.</summary>
		/// <param name="adapter"></param>
		/// <param name="item"></param>
		/// <param name="pageZones"></param>
		/// <param name="user"></param>
		/// <returns></returns>
		public static IEnumerable<ItemDefinition> GetPartDefinitions(PartsAdapter adapter, ContentItem item, IEnumerable<Zone> pageZones, IPrincipal user)
		{
			IEnumerable<ItemDefinition> availableDefinitions;

			if (pageZones == null)
				availableDefinitions = adapter.GetAllowedDefinitions(item, user);
			else
				availableDefinitions = GetPossibleDefinitions(adapter, pageZones, user);

			return from x in availableDefinitions
				orderby x ascending, x.SortOrder ascending
				select x;
		}
Example #4
0
        /// <summary>Gets part definitions that can be added to the given page.</summary>
        /// <param name="adapter"></param>
        /// <param name="item"></param>
        /// <param name="pageZones"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static IEnumerable<ItemDefinition> GetPartDefinitions(PartsAdapter adapter, ContentItem item, IEnumerable<Zone> pageZones, IPrincipal user)
        {
            IEnumerable<ItemDefinition> availableDefinitions;

            if (pageZones == null)
                availableDefinitions = adapter.GetAllowedDefinitions(item, user);
            else
                availableDefinitions = GetPossibleDefinitions(adapter, pageZones, user);

			return availableDefinitions
				.OrderBy(d => d.SortOrder)
				.ThenBy(d => d.Title);
        }