コード例 #1
0
        public override IDictionary <string, System.Web.UI.Control> AddDefinedEditors(ItemDefinition definition, N2.ContentItem item, System.Web.UI.Control container, System.Security.Principal.IPrincipal user, Type containerTypeFilter, IEnumerable <string> editableNameFilter)
        {
            ItemDefinition cloned = null;

            // add a "wrap in container" checkbox to all parts that are within zones that are not wrapped in a container (BeforeMain, AfterMain).
            if (!definition.IsPage)
            {
                if (!(Defaults.IsContainerWrappable(item.ZoneName) ||
                      Defaults.IsContainerWrappable(System.Web.HttpContext.Current.Request["zoneName"])))
                {
                    cloned = definition.Clone();
                    var isWrappable = cloned.Editables.FirstOrDefault(x => x.Name == "UseContainer");
                    if (isWrappable != null)
                    {
                        cloned.Editables.Remove(isWrappable);
                    }
                }
            }

            if (item is IItemAdapter)
            {
                var result = (item as IItemAdapter).AddDefinedEditors(cloned ?? definition, container, user, containerTypeFilter, editableNameFilter);
                if (result != null)
                {
                    return(result);
                }
            }
            return(base.AddDefinedEditors(cloned ?? definition, item, container, user, containerTypeFilter, editableNameFilter));
        }
コード例 #2
0
ファイル: ModelAdapter.cs プロジェクト: n2cms/N2Bootstrap
        public override IDictionary<string, System.Web.UI.Control> AddDefinedEditors(ItemDefinition definition, N2.ContentItem item, System.Web.UI.Control container, System.Security.Principal.IPrincipal user, Type containerTypeFilter, IEnumerable<string> editableNameFilter)
        {
            ItemDefinition cloned = null;

            // add a "wrap in container" checkbox to all parts that are within zones that are not wrapped in a container (BeforeMain, AfterMain).
            if (!definition.IsPage)
            {
                if (!(Defaults.IsContainerWrappable(item.ZoneName) ||
                      Defaults.IsContainerWrappable(System.Web.HttpContext.Current.Request["zoneName"])))
                {
                    cloned = definition.Clone();
                    var isWrappable = cloned.Editables.FirstOrDefault(x => x.Name == "UseContainer");
                    if (isWrappable != null)
                    {
                        cloned.Editables.Remove(isWrappable);
                    }
                }
            }

            if (item is IItemAdapter)
            {
                var result = (item as IItemAdapter).AddDefinedEditors(cloned ?? definition, container, user, containerTypeFilter, editableNameFilter);
                if (result != null)
                    return result;
            }
            return base.AddDefinedEditors(cloned ?? definition, item, container, user, containerTypeFilter, editableNameFilter);
        }
コード例 #3
0
ファイル: DefinitionMap.cs プロジェクト: amarwadi/n2cms
        private ItemDefinition CreateDefinition(Type contentType, string templateKey)
        {
            ItemDefinition definition = GetDefinition(contentType, null);

            if (definition != null)
            {
                definition = definition.Clone();
            }
            else
            {
                definition = new ItemDefinition(contentType);
            }

            definition.Template = templateKey;
            definition.Initialize(contentType);

            SetDefinition(contentType, templateKey, definition);

            return(definition);
        }
コード例 #4
0
ファイル: DefinitionMap.cs プロジェクト: LordDelacroix/n2cms
        public ItemDefinition CreateDefinition(Type contentType, string templateKey)
        {
            ItemDefinition definition = GetDefinition(contentType, null);

            if (definition != null)
            {
                logger.DebugFormat("Cloning definition for type {0} with template {1}", contentType, templateKey);
                definition = definition.Clone();
            }
            else
            {
                logger.DebugFormat("Creating definition for type {0} with template {1}", contentType, templateKey);
                definition = new ItemDefinition(contentType);
            }

            definition.TemplateKey = templateKey;

            SetDefinition(contentType, templateKey, definition);

            return(definition);
        }
コード例 #5
0
ファイル: StartPage.cs プロジェクト: pauldotknopf/N2Bootstrap
 public IDictionary <string, System.Web.UI.Control> AddDefinedEditors(ItemDefinition definition, System.Web.UI.Control container, System.Security.Principal.IPrincipal user, System.Type containerTypeFilter, IEnumerable <string> editableNameFilter)
 {
     if (containerTypeFilter != null && containerTypeFilter == typeof(RecursiveContainerAttribute))
     {
         // we are rendering the "Site" page
         // the language intersection and startpage both define "host name" depending on how the user structures the site.
         // We want to ensure startpage only uses it when it is NOT defined under the language intersection.
         // Most root item (start/intersection) wins for both ISiteSource and the host name editor
         if (Parent is LanguageIntersection)
         {
             // clone the definition and remove "host name" from it
             var clonedDefinition = definition.Clone();
             var hostName         = clonedDefinition.Editables.SingleOrDefault(x => x.Name == "HostName");
             if (hostName != null)
             {
                 clonedDefinition.Remove(hostName);
             }
             return(new EditableAdapter().AddDefinedEditors(clonedDefinition, this, container, user, containerTypeFilter, editableNameFilter));
         }
     }
     return(null);
 }
コード例 #6
0
		public override void Refine(ItemDefinition currentDefinition, IList<ItemDefinition> allDefinitions)
		{
			Type t = currentDefinition.ItemType;
			foreach (ItemDefinition definition in new List<ItemDefinition>(allDefinitions))
			{
				if (definition.ItemType == t.BaseType)
				{
					if (ReplacementMode == DefinitionReplacementMode.Remove)
					{
						allDefinitions.Remove(definition);
						var shadowDefinition = currentDefinition.Clone();
						shadowDefinition.Discriminator += "Disabled";
						N2.Definitions.Static.DefinitionMap.Instance.SetDefinition(definition.ItemType, definition.TemplateKey, shadowDefinition);

						if (AssumeParentDiscriminator)
							currentDefinition.Discriminator = definition.Discriminator;
					}
					else
						definition.Enabled = false;
					return;
				}
			}
		}
コード例 #7
0
ファイル: StartPage.cs プロジェクト: pauldotknopf/N2Bootstrap
 public IDictionary<string, System.Web.UI.Control> AddDefinedEditors(ItemDefinition definition, System.Web.UI.Control container, System.Security.Principal.IPrincipal user, System.Type containerTypeFilter, IEnumerable<string> editableNameFilter)
 {
     if (containerTypeFilter != null && containerTypeFilter == typeof(RecursiveContainerAttribute))
     {
         // we are rendering the "Site" page
         // the language intersection and startpage both define "host name" depending on how the user structures the site.
         // We want to ensure startpage only uses it when it is NOT defined under the language intersection.
         // Most root item (start/intersection) wins for both ISiteSource and the host name editor
         if (Parent is LanguageIntersection)
         {
             // clone the definition and remove "host name" from it
             var clonedDefinition = definition.Clone();
             var hostName = clonedDefinition.Editables.SingleOrDefault(x => x.Name == "HostName");
             if (hostName != null)
             {
                 clonedDefinition.Remove(hostName);
             }
             return new EditableAdapter().AddDefinedEditors(clonedDefinition, this, container, user, containerTypeFilter, editableNameFilter);
         }
     }
     return null;
 }