2013-02-05 05:00:16 +06:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
|
using System.Web.Routing;
|
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
using Umbraco.Core.Services;
|
2013-04-23 22:39:35 -10:00
|
|
|
|
using Umbraco.Web.Security;
|
2013-02-05 05:00:16 +06:00
|
|
|
|
using umbraco.DataLayer;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.UI.Controls
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A base class for all Presentation UserControls to inherit from
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract class UmbracoUserControl : UserControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Default constructor
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="umbracoContext"></param>
|
|
|
|
|
|
protected UmbracoUserControl(UmbracoContext umbracoContext)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
|
|
|
|
|
|
UmbracoContext = umbracoContext;
|
|
|
|
|
|
InstanceId = Guid.NewGuid();
|
|
|
|
|
|
Umbraco = new UmbracoHelper(umbracoContext);
|
2014-01-28 16:58:55 +11:00
|
|
|
|
_membershipHelper = new MembershipHelper(umbracoContext);
|
2013-02-05 05:00:16 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Empty constructor, uses Singleton to resolve the UmbracoContext
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected UmbracoUserControl()
|
|
|
|
|
|
: this(UmbracoContext.Current)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-01-28 16:58:55 +11:00
|
|
|
|
private readonly MembershipHelper _membershipHelper;
|
|
|
|
|
|
|
2013-02-05 05:00:16 +06:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Useful for debugging
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal Guid InstanceId { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns an UmbracoHelper object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public UmbracoHelper Umbraco { get; private set; }
|
|
|
|
|
|
|
2014-01-28 16:58:55 +11:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns the MemberHelper instance
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public MembershipHelper Members
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _membershipHelper; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-04-23 22:39:35 -10:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns the current WebSecurity instance
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public WebSecurity Security
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return UmbracoContext.Security; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-02-05 05:00:16 +06:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns the current UmbracoContext
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public UmbracoContext UmbracoContext { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns the current ApplicationContext
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ApplicationContext ApplicationContext
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return UmbracoContext.Application; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns a ServiceContext
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ServiceContext Services
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ApplicationContext.Services; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns a DatabaseContext
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DatabaseContext DatabaseContext
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return ApplicationContext.DatabaseContext; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private UrlHelper _url;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns a UrlHelper
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// This URL helper is created without any route data and an empty request context
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
public UrlHelper Url
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _url ?? (_url = new UrlHelper(new RequestContext(new HttpContextWrapper(Context), new RouteData()))); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns the legacy SqlHelper
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected ISqlHelper SqlHelper
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return global::umbraco.BusinessLogic.Application.SqlHelper; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|