Files
Umbraco-CMS/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs

186 lines
6.7 KiB
C#
Raw Normal View History

2017-07-20 11:21:28 +02:00
using System;
using System.Collections.Generic;
namespace Umbraco.Core.Models.PublishedContent
{
2017-09-26 14:57:50 +02:00
/// <inheritdoc />
2017-07-20 11:21:28 +02:00
/// <summary>
2018-04-28 16:34:43 +02:00
/// Represents a published content item.
2017-07-20 11:21:28 +02:00
/// </summary>
2018-04-28 16:34:43 +02:00
/// <remarks>
/// <para>Can be a published document, media or member.</para>
/// </remarks>
2017-09-25 08:59:32 +02:00
public interface IPublishedContent : IPublishedElement
{
#region Content
2018-04-28 16:34:43 +02:00
// todo - IPublishedContent properties colliding with models
// we need to find a way to remove as much clutter as possible from IPublishedContent,
// since this is preventing someone from creating a property named 'Path' and have it
// in a model, for instance. we could move them all under one unique property eg
// Infos, so we would do .Infos.SortOrder - just an idea - not going to do it in v8
2017-09-26 14:57:50 +02:00
2018-04-28 16:34:43 +02:00
/// <summary>
/// Gets the unique identifier of the content item.
/// </summary>
int Id { get; }
2018-04-28 16:34:43 +02:00
/// <summary>
/// Gets the name of the content item.
/// </summary>
/// <remarks>
/// <para>The value of this property is contextual. When the content type is multi-lingual,
2018-04-29 20:02:38 +02:00
/// this is the name for the 'current' culture. Otherwise, it is the invariant name.</para>
2018-04-28 16:34:43 +02:00
/// </remarks>
2017-07-20 11:21:28 +02:00
string Name { get; }
2018-04-28 16:34:43 +02:00
/// <summary>
/// Gets the url segment of the content item.
/// </summary>
/// <remarks>
/// <para>The value of this property is contextual. When the content type is multi-lingual,
2018-04-29 20:02:38 +02:00
/// this is the name for the 'current' culture. Otherwise, it is the invariant url segment.</para>
2018-04-28 16:34:43 +02:00
/// </remarks>
2018-04-28 16:35:33 +02:00
string UrlSegment { get; }
2018-04-28 16:34:43 +02:00
/// <summary>
/// Gets the sort order of the content item.
/// </summary>
int SortOrder { get; }
/// <summary>
/// Gets the tree level of the content item.
/// </summary>
int Level { get; }
/// <summary>
/// Gets the tree path of the content item.
/// </summary>
2017-07-20 11:21:28 +02:00
string Path { get; }
2018-04-28 16:34:43 +02:00
/// <summary>
/// Gets the identifier of the template to use to render the content item.
/// </summary>
int TemplateId { get; }
/// <summary>
/// Gets the identifier of the user who created the content item.
/// </summary>
int CreatorId { get; }
/// <summary>
/// Gets the name of the user who created the content item.
/// </summary>
string CreatorName { get; }
/// <summary>
/// Gets the date the content item was created.
/// </summary>
2017-07-20 11:21:28 +02:00
DateTime CreateDate { get; }
2018-04-28 16:34:43 +02:00
/// <summary>
/// Gets the identifier of the user who last updated the content item.
/// </summary>
int WriterId { get; }
/// <summary>
/// Gets the name of the user who last updated the content item.
/// </summary>
string WriterName { get; }
/// <summary>
/// Gets the date the content item was last updated.
/// </summary>
/// <remarks>
/// <para>For published content items, this is also the date the item was published.</para>
2018-04-29 20:02:38 +02:00
/// <para>This date is always global to the content item, see GetCulture().Date for the
/// date each culture was published.</para>
2018-04-28 16:34:43 +02:00
/// </remarks>
2017-07-20 11:21:28 +02:00
DateTime UpdateDate { get; }
2018-04-28 16:34:43 +02:00
/// <summary>
/// Gets the url of the content item.
/// </summary>
/// <remarks>
2018-04-29 20:02:38 +02:00
/// <para>The value of this property is contextual. It depends on the 'current' request uri,
/// if any. In addition, when the content type is multi-lingual, this is the url for the
/// 'current' culture. Otherwise, it is the invariant url.</para>
2018-04-28 16:34:43 +02:00
/// </remarks>
2017-07-20 11:21:28 +02:00
string Url { get; }
2018-04-29 20:02:38 +02:00
/// <summary>
/// Gets the url of the content item.
/// </summary>
/// <remarks>
/// <para>The value of this property is contextual. It depends on the 'current' request uri,
/// if any. In addition, when the content type is multi-lingual, this is the url for the
/// specified culture. Otherwise, it is the invariant url.</para>
/// </remarks>
string GetUrl(string culture = ".");
/// <summary>
/// Gets culture infos for a culture.
/// </summary>
2018-04-28 16:34:43 +02:00
PublishedCultureInfos GetCulture(string culture = ".");
2018-04-29 20:02:38 +02:00
/// <summary>
/// Gets culture infos.
/// </summary>
/// <remarks>
/// <para>Contains only those culture that are available. For a published content, these are
/// the cultures that are published. For a draft content, those that are 'available' ie
/// have a non-empty content name.</para>
/// </remarks>
2018-04-28 16:34:43 +02:00
IReadOnlyDictionary<string, PublishedCultureInfos> Cultures { get; }
/// <summary>
2018-04-28 16:34:43 +02:00
/// Gets the type of the content item (document, media...).
/// </summary>
2017-07-20 11:21:28 +02:00
PublishedItemType ItemType { get; }
/// <summary>
/// Gets a value indicating whether the content is draft.
/// </summary>
/// <remarks>A content is draft when it is the unpublished version of a content, which may
/// have a published version, or not.</remarks>
bool IsDraft { get; }
#endregion
#region Tree
/// <summary>
2018-04-28 16:34:43 +02:00
/// Gets the parent of the content item.
/// </summary>
/// <remarks>The parent of root content is <c>null</c>.</remarks>
2017-07-20 11:21:28 +02:00
IPublishedContent Parent { get; }
/// <summary>
2018-04-28 16:34:43 +02:00
/// Gets the children of the content item.
/// </summary>
/// <remarks>Children are sorted by their sortOrder.</remarks>
2017-07-20 11:21:28 +02:00
IEnumerable<IPublishedContent> Children { get; }
#endregion
#region Properties
/// <summary>
/// Gets a property identified by its alias.
/// </summary>
/// <param name="alias">The property alias.</param>
/// <param name="recurse">A value indicating whether to navigate the tree upwards until a property with a value is found.</param>
/// <returns>The property identified by the alias.</returns>
/// <remarks>
/// <para>Navigate the tree upwards and look for a property with that alias and with a value (ie <c>HasValue</c> is <c>true</c>).
/// If found, return the property. If no property with that alias is found, having a value or not, return <c>null</c>. Otherwise
/// return the first property that was found with the alias but had no value (ie <c>HasValue</c> is <c>false</c>).</para>
/// <para>The alias is case-insensitive.</para>
/// </remarks>
IPublishedProperty GetProperty(string alias, bool recurse);
#endregion
}
2017-07-20 11:21:28 +02:00
}