an UmbracoHelper property to the PluginController class which will expose any methods needed by devs to retreive media or content. Have updated UmbracoHelper with loads of new helpful methods and moved the Wrap methods to HtmlHelper extensions because this is purely to do with rendering html (have written unit tests for it too). Updated some 'library' methods to proxy calls to UmbracoHelper so we only have to maintain one set of code. Added a convenience property to UmbracoContext to return the current NiceUrlProvider so you don't have to go through the RoutingContext to get it.
75 lines
2.0 KiB
C#
75 lines
2.0 KiB
C#
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the current UmbracoContext
|
|
/// </summary>
|
|
public UmbracoContext UmbracoContext { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Returns the current ApplicationContext
|
|
/// </summary>
|
|
public ApplicationContext ApplicationContext { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Returns the current DocumentRequest
|
|
/// </summary>
|
|
internal DocumentRequest DocumentRequest { get; private set; }
|
|
|
|
/// <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)); }
|
|
}
|
|
|
|
}
|
|
} |