Files
Umbraco-CMS/src/Umbraco.Web/Mvc/RenderViewPage.cs

75 lines
2.0 KiB
C#
Raw Normal View History

using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Dynamics;
using Umbraco.Web.Routing;
namespace Umbraco.Web.Mvc
{
/// <summary>
/// The View that front-end templates inherit from
/// </summary>
public abstract class RenderViewPage : WebViewPage<RenderModel>
{
protected RenderViewPage()
{
}
protected override void InitializePage()
{
//set the model to the current node if it is not set, this is generally not the case
if (Model != null)
{
////this.ViewData.Model = Model;
//var backingItem = new DynamicBackingItem(Model.CurrentNode);
var dynamicNode = new DynamicDocument(Model.CurrentDocument);
CurrentPage = dynamicNode.AsDynamic();
}
DocumentRequest = (DocumentRequest)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-doc-request");
UmbracoContext = (UmbracoContext)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-context");
ApplicationContext = UmbracoContext.Application;
}
2012-08-28 06:51:01 +07:00
/// <summary>
/// Returns the current UmbracoContext
/// </summary>
public UmbracoContext UmbracoContext { get; private set; }
2012-08-28 06:51:01 +07:00
/// <summary>
/// Returns the current ApplicationContext
/// </summary>
public ApplicationContext ApplicationContext { get; private set; }
2012-08-28 06:51:01 +07:00
/// <summary>
/// Returns the current DocumentRequest
/// </summary>
internal DocumentRequest DocumentRequest { get; private set; }
2012-08-28 06:51:01 +07:00
/// <summary>
/// Returns the a DynamicDocument object
/// </summary>
public dynamic CurrentPage { get; private set; }
/// <summary>
/// Returns the dictionary value for the key specified
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public string GetDictionaryValue(string key)
{
return Umbraco.GetDictionaryValue(key);
}
private UmbracoHelper _helper;
/// <summary>
/// Gets an UmbracoHelper
/// </summary>
public UmbracoHelper Umbraco
{
get { return _helper ?? (_helper = new UmbracoHelper(UmbracoContext)); }
}
}
}