Adding Template to ContentType and Content objects and updating repositories accordingly.
Removing templates from the mocks for the time being.
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Umbraco.Core.Models
|
||||
public class Content : ContentBase, IContent
|
||||
{
|
||||
private IContentType _contentType;
|
||||
private string _template;
|
||||
private ITemplate _template;
|
||||
private bool _published;
|
||||
private string _language;
|
||||
private DateTime? _releaseDate;
|
||||
@@ -41,8 +41,8 @@ namespace Umbraco.Core.Models
|
||||
|
||||
_contentType = contentType;
|
||||
}
|
||||
|
||||
private static readonly PropertyInfo TemplateSelector = ExpressionHelper.GetPropertyInfo<Content, string>(x => x.Template);
|
||||
|
||||
private static readonly PropertyInfo TemplateSelector = ExpressionHelper.GetPropertyInfo<Content, ITemplate>(x => x.Template);
|
||||
private static readonly PropertyInfo PublishedSelector = ExpressionHelper.GetPropertyInfo<Content, bool>(x => x.Published);
|
||||
private static readonly PropertyInfo LanguageSelector = ExpressionHelper.GetPropertyInfo<Content, string>(x => x.Language);
|
||||
private static readonly PropertyInfo ReleaseDateSelector = ExpressionHelper.GetPropertyInfo<Content, DateTime?>(x => x.ReleaseDate);
|
||||
@@ -50,16 +50,19 @@ namespace Umbraco.Core.Models
|
||||
private static readonly PropertyInfo WriterSelector = ExpressionHelper.GetPropertyInfo<Content, int>(x => x.WriterId);
|
||||
|
||||
/// <summary>
|
||||
/// Path to the template used by this Content
|
||||
/// This is used to override the default one from the ContentType
|
||||
/// Gets or sets the template used by the Content.
|
||||
/// This is used to override the default one from the ContentType.
|
||||
/// </summary>
|
||||
/// <remarks>If no template is explicitly set on the Content object, the Default template from the ContentType will be returned</remarks>
|
||||
/// <remarks>
|
||||
/// If no template is explicitly set on the Content object,
|
||||
/// the Default template from the ContentType will be returned.
|
||||
/// </remarks>
|
||||
[DataMember]
|
||||
public virtual string Template
|
||||
public virtual ITemplate Template
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_template) || _template == null)
|
||||
if (_template == null)
|
||||
return _contentType.DefaultTemplate;
|
||||
|
||||
return _template;
|
||||
@@ -111,8 +114,11 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Language of the data contained within this Content object
|
||||
/// Language of the data contained within this Content object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Left internal until multilingual support is implemented.
|
||||
/// </remarks>
|
||||
[DataMember]
|
||||
internal string Language
|
||||
{
|
||||
|
||||
@@ -13,22 +13,31 @@ namespace Umbraco.Core.Models
|
||||
[DataContract(IsReference = true)]
|
||||
public class ContentType : ContentTypeCompositionBase, IContentType
|
||||
{
|
||||
private string _defaultTemplate;
|
||||
private IEnumerable<string> _allowedTemplates;
|
||||
private int _defaultTemplate;
|
||||
private IEnumerable<ITemplate> _allowedTemplates;
|
||||
|
||||
public ContentType(int parentId) : base(parentId)
|
||||
{
|
||||
_allowedTemplates = new List<string>();
|
||||
_allowedTemplates = new List<ITemplate>();
|
||||
}
|
||||
|
||||
private static readonly PropertyInfo DefaultTemplateSelector = ExpressionHelper.GetPropertyInfo<ContentType, string>(x => x.DefaultTemplate);
|
||||
private static readonly PropertyInfo AllowedTemplatesSelector = ExpressionHelper.GetPropertyInfo<ContentType, IEnumerable<string>>(x => x.AllowedTemplates);
|
||||
private static readonly PropertyInfo DefaultTemplateSelector = ExpressionHelper.GetPropertyInfo<ContentType, int>(x => x.DefaultTemplateId);
|
||||
private static readonly PropertyInfo AllowedTemplatesSelector = ExpressionHelper.GetPropertyInfo<ContentType, IEnumerable<ITemplate>>(x => x.AllowedTemplates);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alias of the default Template.
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public string DefaultTemplate//NOTE Use internal extension method to get Id of the Template
|
||||
public ITemplate DefaultTemplate
|
||||
{
|
||||
get { return AllowedTemplates.FirstOrDefault(x => x.Id == DefaultTemplateId); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal property to store the Id of the default template
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
internal int DefaultTemplateId
|
||||
{
|
||||
get { return _defaultTemplate; }
|
||||
set
|
||||
@@ -39,9 +48,10 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of aliases for allowed Templates
|
||||
/// Gets or Sets a list of Templates which are allowed for the ContentType
|
||||
/// </summary>
|
||||
public IEnumerable<string> AllowedTemplates//NOTE Use internal extension method to get Ids of the Templates
|
||||
[DataMember]
|
||||
public IEnumerable<ITemplate> AllowedTemplates
|
||||
{
|
||||
get { return _allowedTemplates; }
|
||||
set
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
@@ -9,10 +8,10 @@ namespace Umbraco.Core.Models
|
||||
public interface IContent : IContentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Alias of the template used by the Content
|
||||
/// This is used to override the default one from the ContentType
|
||||
/// Gets or sets the template used by the Content.
|
||||
/// This is used to override the default one from the ContentType.
|
||||
/// </summary>
|
||||
string Template { get; set; }
|
||||
ITemplate Template { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean indicating whether the Content is Published or not
|
||||
|
||||
@@ -8,13 +8,13 @@ namespace Umbraco.Core.Models
|
||||
public interface IContentType : IContentTypeComposition
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets the path to the default Template of the ContentType
|
||||
/// Gets the default Template of the ContentType
|
||||
/// </summary>
|
||||
string DefaultTemplate { get; set; }
|
||||
ITemplate DefaultTemplate { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets a list of Template names/paths which are allowed for the ContentType
|
||||
/// Gets or Sets a list of Templates which are allowed for the ContentType
|
||||
/// </summary>
|
||||
IEnumerable<string> AllowedTemplates { get; set; }
|
||||
IEnumerable<ITemplate> AllowedTemplates { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user