2012-08-07 21:40:34 +06:00
|
|
|
using System.Web.Mvc;
|
2012-08-15 21:21:31 +06:00
|
|
|
using Umbraco.Core;
|
2012-08-15 23:20:37 +06:00
|
|
|
using Umbraco.Core.Dictionary;
|
2012-08-25 07:14:23 +07:00
|
|
|
using Umbraco.Core.Dynamics;
|
2012-08-08 23:37:54 +06:00
|
|
|
using Umbraco.Web.Routing;
|
2012-08-07 21:40:34 +06:00
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Mvc
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The View that front-end templates inherit from
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract class RenderViewPage : WebViewPage<RenderModel>
|
|
|
|
|
{
|
2012-08-08 23:37:54 +06:00
|
|
|
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);
|
2012-08-25 07:14:23 +07:00
|
|
|
var dynamicNode = new DynamicDocument(Model.CurrentDocument);
|
|
|
|
|
CurrentPage = dynamicNode.AsDynamic();
|
2012-08-08 23:37:54 +06:00
|
|
|
}
|
|
|
|
|
DocumentRequest = (DocumentRequest)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-doc-request");
|
|
|
|
|
UmbracoContext = (UmbracoContext)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-context");
|
2012-08-25 07:14:23 +07:00
|
|
|
ApplicationContext = UmbracoContext.Application;
|
2012-08-08 23:37:54 +06:00
|
|
|
}
|
|
|
|
|
|
2012-08-28 06:51:01 +07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the current UmbracoContext
|
|
|
|
|
/// </summary>
|
2012-08-08 23:37:54 +06:00
|
|
|
public UmbracoContext UmbracoContext { get; private set; }
|
2012-08-28 06:51:01 +07:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the current ApplicationContext
|
|
|
|
|
/// </summary>
|
2012-08-25 07:14:23 +07:00
|
|
|
public ApplicationContext ApplicationContext { get; private set; }
|
2012-08-08 23:37:54 +06:00
|
|
|
|
2012-08-28 06:51:01 +07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the current DocumentRequest
|
|
|
|
|
/// </summary>
|
2012-08-08 23:37:54 +06:00
|
|
|
internal DocumentRequest DocumentRequest { get; private set; }
|
|
|
|
|
|
2012-08-28 06:51:01 +07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the a DynamicDocument object
|
|
|
|
|
/// </summary>
|
2012-08-08 23:37:54 +06:00
|
|
|
public dynamic CurrentPage { get; private set; }
|
2012-08-07 21:40:34 +06:00
|
|
|
|
2012-08-28 09:20:30 +07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the dictionary value for the key specified
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <returns></returns>
|
2012-08-15 23:20:37 +06:00
|
|
|
public string GetDictionaryValue(string key)
|
2012-08-15 21:21:31 +06:00
|
|
|
{
|
2012-09-27 08:30:35 +07:00
|
|
|
return Umbraco.GetDictionaryValue(key);
|
2012-08-15 21:21:31 +06:00
|
|
|
}
|
2012-08-07 21:40:34 +06:00
|
|
|
|
2012-09-03 07:54:09 +07:00
|
|
|
private UmbracoHelper _helper;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an UmbracoHelper
|
|
|
|
|
/// </summary>
|
2012-09-20 12:47:37 +07:00
|
|
|
public UmbracoHelper Umbraco
|
2012-09-03 07:54:09 +07:00
|
|
|
{
|
|
|
|
|
get { return _helper ?? (_helper = new UmbracoHelper(UmbracoContext)); }
|
|
|
|
|
}
|
2012-08-07 21:40:34 +06:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|