Show the widget layer creation hint only when a "Page" type is taken from an unpublished -> published state.

The hint won't appear with subsequent publishes of the page *but* it will appear if the page is unpublished then later published.

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2011-03-24 14:52:04 -07:00
parent 7914afdb28
commit 12e1769cd3

View File

@@ -1,27 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Routable.Models;
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.UI.Notify;
namespace Orchard.Widgets.Drivers {
namespace Orchard.Widgets.Handlers {
[OrchardFeature("Orchard.Widgets.PageLayerHinting")]
public class LayerHintHandler : ContentHandler {
public LayerHintHandler(IOrchardServices services, RequestContext requestContext) {
T = NullLocalizer.Instance;
OnPublished<RoutePart>((context, part) => {
if (string.IsNullOrWhiteSpace(part.Path)) // only going to help in creating a layer if the content has a path
// only going to help in creating a layer if the content is a page with no previous version and a path
if (!(context.ContentType == "Page" && context.PreviousItemVersionRecord == null && !string.IsNullOrWhiteSpace(part.Path)))
return;
var urlHelper = new UrlHelper(requestContext);