using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Oqtane.Models
{
///
/// Describes a Page in Oqtane
///
public class Page : ModelBase, IDeletable
{
///
/// Id of the Page
///
public int PageId { get; set; }
///
/// Reference to the .
///
public int SiteId { get; set; }
///
/// Path of the page.
/// TODO: todoc relative to what? site root, parent-page, domain?
///
public string Path { get; set; }
///
/// Reference to the parent if it has one.
///
public int? ParentId { get; set; }
///
/// Page Name.
/// TODO: todoc where this is used
///
public string Name { get; set; }
///
/// Page Title which is shown in the browser tab.
///
public string Title { get; set; }
///
/// Sort order in the list of other sibling pages
///
public int Order { get; set; }
///
/// Full URL to this page.
/// TODO: verify that this is the case - does it contain domain etc. or just from domain or alias root?
///
public string Url { get; set; }
///
/// Reference to a which will be used to show this page.
///
public string ThemeType { get; set; }
///
/// Reference to a Container which will be used for modules on this page.
///
public string DefaultContainerType { get; set; }
///
/// Content to be included in the head of the page
///
public string HeadContent { get; set; }
///
/// Content to be included in the body of the page
///
public string BodyContent { get; set; }
///
/// Icon class name for this page
///
public string Icon { get; set; }
///
/// Indicates if this page should be included in navigation menu
///
public bool IsNavigation { get; set; }
///
/// Indicates if this page should be clickable in navigation menu
///
public bool IsClickable { get; set; }
///
/// Indicates if page is personalizable ie. allows users to create custom versions of the page
///
public bool IsPersonalizable { get; set; }
///
/// Reference to the user who owns the personalized page
///
public int? UserId { get; set; }
///
/// Start of when this page is visible. See also
///
public DateTime? EffectiveDate { get; set; }
///
/// End of when this page is visible. See also
///
public DateTime? ExpiryDate { get; set; }
///
/// The hierarchical level of the page
///
[NotMapped]
public int Level { get; set; }
///
/// Determines if there are sub-pages. True if this page has sub-pages.
///
[NotMapped]
public bool HasChildren { get; set; }
///
/// List of permissions for this page
///
[NotMapped]
public List PermissionList { get; set; }
///
/// List of settings for this page
///
[NotMapped]
public Dictionary Settings { get; set; }
#region SiteRouter properties
///
/// List of Pane names for the Theme assigned to this page
///
[NotMapped]
public List Panes { get; set; }
///
/// List of (CSS, JS) which this page needs to render properly.
///
[NotMapped]
public List Resources { get; set; }
#endregion
#region IDeletable Properties
public string DeletedBy { get; set; }
public DateTime? DeletedOn { get; set; }
public bool IsDeleted { get; set; }
#endregion
#region Deprecated Properties
[Obsolete("The EditMode property is deprecated", false)]
[NotMapped]
public bool EditMode { get; set; }
[Obsolete("The LayoutType property is deprecated", false)]
[NotMapped]
public string LayoutType { get; set; }
[Obsolete("The Permissions property is deprecated. Use PermissionList instead", false)]
[NotMapped]
[JsonIgnore] // exclude from API payload
public string Permissions {
get
{
return JsonSerializer.Serialize(PermissionList);
}
set
{
PermissionList = JsonSerializer.Deserialize>(value);
}
}
#endregion
public Page Clone()
{
return new Page
{
PageId = PageId,
SiteId = SiteId,
Path = Path,
ParentId = ParentId,
Name = Name,
Title = Title,
Order = Order,
Url = Url,
ThemeType = ThemeType,
DefaultContainerType = DefaultContainerType,
HeadContent = HeadContent,
BodyContent = BodyContent,
Icon = Icon,
IsNavigation = IsNavigation,
IsClickable = IsClickable,
UserId = UserId,
IsPersonalizable = IsPersonalizable,
EffectiveDate = EffectiveDate,
ExpiryDate = ExpiryDate,
Level = Level,
HasChildren = HasChildren,
CreatedBy = CreatedBy,
CreatedOn = CreatedOn,
ModifiedBy = ModifiedBy,
ModifiedOn = ModifiedOn,
DeletedBy = DeletedBy,
DeletedOn = DeletedOn,
IsDeleted = IsDeleted,
PermissionList = PermissionList.ConvertAll(permission => permission.Clone()),
Settings = Settings.ToDictionary(setting => setting.Key, setting => setting.Value)
};
}
}
}