2012-07-20 01:04:35 +06:00
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
// legacy
|
2012-07-30 22:52:59 +06:00
|
|
|
using Umbraco.Core;
|
|
|
|
|
using Umbraco.Core.Logging;
|
2012-08-10 13:08:47 +06:00
|
|
|
using Umbraco.Core.Models;
|
2012-08-30 08:26:01 +07:00
|
|
|
using umbraco;
|
2012-07-21 00:20:50 +06:00
|
|
|
using umbraco.BusinessLogic;
|
2012-08-08 23:10:34 +06:00
|
|
|
using umbraco.NodeFactory;
|
2012-07-20 01:04:35 +06:00
|
|
|
using umbraco.cms.businesslogic.web;
|
|
|
|
|
using umbraco.cms.businesslogic.template;
|
|
|
|
|
using umbraco.cms.businesslogic.member;
|
2012-08-08 23:10:34 +06:00
|
|
|
using umbraco.interfaces;
|
|
|
|
|
|
2012-07-20 01:04:35 +06:00
|
|
|
namespace Umbraco.Web.Routing
|
|
|
|
|
{
|
2012-08-06 22:40:06 +06:00
|
|
|
/// <summary>
|
|
|
|
|
/// represents a request for one specified Umbraco document to be rendered
|
|
|
|
|
/// by one specified template, using one particular culture.
|
|
|
|
|
/// </summary>
|
2012-10-02 01:40:19 +05:00
|
|
|
internal class PublishedContentRequest
|
2012-07-20 01:04:35 +06:00
|
|
|
{
|
2012-10-02 01:40:19 +05:00
|
|
|
public PublishedContentRequest(Uri uri, RoutingContext routingContext)
|
2012-07-20 01:04:35 +06:00
|
|
|
{
|
2012-07-20 18:54:59 -02:00
|
|
|
this.Uri = uri;
|
2012-08-09 04:15:35 +06:00
|
|
|
RoutingContext = routingContext;
|
2012-09-07 07:57:25 +07:00
|
|
|
RenderingEngine = RenderingEngine.Mvc;
|
2012-07-20 01:04:35 +06:00
|
|
|
}
|
|
|
|
|
|
2012-07-20 23:10:43 +06:00
|
|
|
/// <summary>
|
|
|
|
|
/// the id of the requested node, if any, else zero.
|
|
|
|
|
/// </summary>
|
|
|
|
|
int _nodeId = 0;
|
2012-09-01 07:03:56 +07:00
|
|
|
|
2012-10-02 01:35:39 +05:00
|
|
|
private IPublishedContent _publishedContent = null;
|
2012-07-20 01:04:35 +06:00
|
|
|
|
2012-07-20 23:10:43 +06:00
|
|
|
#region Properties
|
2012-07-20 01:04:35 +06:00
|
|
|
|
2012-07-20 23:10:43 +06:00
|
|
|
/// <summary>
|
2012-07-21 00:20:50 +06:00
|
|
|
/// Returns the current RoutingContext
|
2012-07-20 23:10:43 +06:00
|
|
|
/// </summary>
|
2012-07-21 00:20:50 +06:00
|
|
|
public RoutingContext RoutingContext { get; private set; }
|
2012-08-09 04:15:35 +06:00
|
|
|
|
2012-08-08 23:55:55 +06:00
|
|
|
/// <summary>
|
|
|
|
|
/// The cleaned up Uri used for routing
|
|
|
|
|
/// </summary>
|
2012-07-20 18:54:59 -02:00
|
|
|
public Uri Uri { get; private set; }
|
2012-07-20 01:04:35 +06:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the document request's domain.
|
|
|
|
|
/// </summary>
|
2012-08-09 04:15:35 +06:00
|
|
|
public Domain Domain { get; internal set; }
|
2012-07-20 01:04:35 +06:00
|
|
|
|
2012-08-09 04:15:35 +06:00
|
|
|
public Uri DomainUri { get; internal set; }
|
2012-07-20 18:54:59 -02:00
|
|
|
|
2012-08-29 08:54:29 +07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets whether the rendering engine is MVC or WebForms
|
|
|
|
|
/// </summary>
|
2012-09-07 07:57:25 +07:00
|
|
|
public RenderingEngine RenderingEngine { get; internal set; }
|
2012-08-29 08:54:29 +07:00
|
|
|
|
2012-07-20 01:04:35 +06:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether the document request has a domain.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool HasDomain
|
|
|
|
|
{
|
|
|
|
|
get { return this.Domain != null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the document request's culture
|
|
|
|
|
/// </summary>
|
2012-08-08 23:10:34 +06:00
|
|
|
public CultureInfo Culture { get; set; }
|
2012-07-20 01:04:35 +06:00
|
|
|
|
2012-08-30 08:26:01 +07:00
|
|
|
private page _umbracoPage;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the Umbraco page object
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
2012-09-01 07:03:56 +07:00
|
|
|
/// This value is only used for legacy/webforms code.
|
2012-08-30 08:26:01 +07:00
|
|
|
/// </remarks>
|
2012-09-01 07:03:56 +07:00
|
|
|
internal page UmbracoPage
|
2012-08-30 08:26:01 +07:00
|
|
|
{
|
2012-09-01 07:03:56 +07:00
|
|
|
get
|
2012-08-30 08:26:01 +07:00
|
|
|
{
|
2012-09-01 07:03:56 +07:00
|
|
|
if (_umbracoPage == null)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("The umbraco page object is only available once Finalize()");
|
|
|
|
|
}
|
|
|
|
|
return _umbracoPage;
|
2012-08-30 08:26:01 +07:00
|
|
|
}
|
2012-09-01 07:03:56 +07:00
|
|
|
set { _umbracoPage = value; }
|
2012-08-30 08:26:01 +07:00
|
|
|
}
|
2012-09-01 07:03:56 +07:00
|
|
|
|
2012-08-30 08:26:01 +07:00
|
|
|
// TODO: fixme - do we want to have an ordered list of alternate cultures,
|
2012-07-20 01:04:35 +06:00
|
|
|
// to allow for fallbacks when doing dictionnary lookup and such?
|
|
|
|
|
|
2012-10-02 01:35:39 +05:00
|
|
|
public IPublishedContent PublishedContent
|
2012-08-14 23:35:34 +06:00
|
|
|
{
|
2012-10-02 01:35:39 +05:00
|
|
|
get { return _publishedContent; }
|
2012-08-10 13:08:47 +06:00
|
|
|
set
|
2012-08-08 23:10:34 +06:00
|
|
|
{
|
2012-10-02 01:35:39 +05:00
|
|
|
_publishedContent = value;
|
2012-08-30 08:26:01 +07:00
|
|
|
this.Template = null;
|
2012-10-02 01:35:39 +05:00
|
|
|
_nodeId = _publishedContent != null ? _publishedContent.Id : 0;
|
2012-08-08 23:10:34 +06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-20 01:04:35 +06:00
|
|
|
/// <summary>
|
2012-08-29 08:54:29 +07:00
|
|
|
/// Gets or sets the document request's template lookup
|
2012-07-20 01:04:35 +06:00
|
|
|
/// </summary>
|
2012-08-30 08:26:01 +07:00
|
|
|
public Template Template { get; set; }
|
2012-07-20 01:04:35 +06:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether the document request has a template.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool HasTemplate
|
|
|
|
|
{
|
2012-08-30 08:26:01 +07:00
|
|
|
get { return this.Template != null ; }
|
2012-07-20 01:04:35 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the id of the document.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <exception cref="InvalidOperationException">Thrown when the document request has no document.</exception>
|
2012-08-30 08:26:01 +07:00
|
|
|
public int DocumentId
|
2012-07-20 01:04:35 +06:00
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2012-10-02 01:35:39 +05:00
|
|
|
if (this.PublishedContent == null)
|
2012-10-02 01:40:19 +05:00
|
|
|
throw new InvalidOperationException("PublishedContentRequest has no document.");
|
2012-07-20 01:04:35 +06:00
|
|
|
return _nodeId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether the document request has a document.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool HasNode
|
|
|
|
|
{
|
2012-10-02 01:35:39 +05:00
|
|
|
get { return this.PublishedContent != null; }
|
2012-07-20 01:04:35 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-09-29 07:20:23 +07:00
|
|
|
/// Gets or sets a value indicating whether the requested document could not be found. This is set in the DocumentRequestBuilder.
|
2012-07-20 01:04:35 +06:00
|
|
|
/// </summary>
|
2012-09-29 07:20:23 +07:00
|
|
|
internal bool Is404 { get; set; }
|
2012-07-20 01:04:35 +06:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether the document request triggers a redirect.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsRedirect { get { return !string.IsNullOrWhiteSpace(this.RedirectUrl); } }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the url to redirect to, when the document request triggers a redirect.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RedirectUrl { get; set; }
|
|
|
|
|
|
|
|
|
|
#endregion
|
2012-08-09 04:15:35 +06:00
|
|
|
|
2012-07-20 01:04:35 +06:00
|
|
|
}
|
|
|
|
|
}
|