Removing BaseViewModel and ContentItemViewModel for good

--HG--
branch : theming
This commit is contained in:
Nathan Heskew
2010-09-07 13:45:50 -07:00
parent 02e46ba310
commit 3fa536d7a8
20 changed files with 1 additions and 187 deletions

View File

@@ -1,5 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels" %>
<div class="footer group">
<ul class="group">
<li>&copy;2010 <%: Html.SiteName() %>. All rights reserved.</li>

View File

@@ -1,5 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.DisplayManagement.Shapes" %>
<%
@@ -12,7 +11,7 @@
<div id="container">
<%-- Header --%>
<%: Display(Model.Header)) %>
<%: Display(Model.Header) %>
<%-- Main Menu --%>
<div id="nav">

View File

@@ -1,4 +1,3 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<div id="app"><%: Html.ActionLink(T("Project Orchard").ToString(), "Index", new { Area = "", Controller = "Home" })%></div>
<div id="site"><%: Html.ActionLink(T("Your Site").ToString(), "Index", new { Area = "", Controller = "Home" })%></div>

View File

@@ -1,5 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<% if (Model.CurrentUser != null) {
%><div id="login"><%: T("User:")%> <%: Model.CurrentUser.UserName %> | <%: Html.ActionLink(T("Logout").ToString(), "LogOff", new { Area = "Orchard.Users", Controller = "Account" }) %></div><%
} %>

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using Orchard.ContentManagement.Records;
using Orchard.Mvc.ViewModels;
namespace Orchard.ContentManagement {
public static class ContentCreateExtensions {

View File

@@ -11,7 +11,6 @@ using Orchard.ContentManagement.Records;
using Orchard.Data;
using Orchard.DisplayManagement;
using Orchard.Indexing;
using Orchard.Mvc.ViewModels;
namespace Orchard.ContentManagement {
public class DefaultContentManager : IContentManager {

View File

@@ -1,7 +1,6 @@
using System.Linq;
using System.Web.Mvc;
using Orchard.ContentManagement.Handlers;
using Orchard.Mvc.ViewModels;
namespace Orchard.ContentManagement.Drivers {
public class ContentItemTemplateResult<TContent> : DriverResult where TContent : class, IContent {

View File

@@ -1,4 +1,3 @@
using System;
using Orchard.DisplayManagement;
namespace Orchard.ContentManagement.Handlers {

View File

@@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Web.Mvc;
using Orchard.Mvc.ViewModels;
namespace Orchard.ContentManagement.Handlers {
public class ContentItemTemplates<TContent> : TemplateFilterBase<TContent> where TContent : class, IContent {

View File

@@ -1,8 +1,6 @@
using System.Collections.Generic;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.DisplayManagement;
using Orchard.Indexing;
using Orchard.Mvc.ViewModels;
namespace Orchard.ContentManagement {
public interface IContentManager : IDependency {

View File

@@ -1,26 +0,0 @@
using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Orchard.Mvc.ViewModels;
namespace Orchard.Mvc.Html {
#if REFACTORING
public static class ContentItemDisplayExtensions {
public static MvcHtmlString DisplayForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, TItemModel item) where TItemModel : ContentItemViewModel {
return html.DisplayForItem(x => item);
}
public static MvcHtmlString DisplayForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemModel>> expression) where TItemModel : ContentItemViewModel {
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
var model = (TItemModel)metadata.Model;
if (model.Adaptor != null) {
return model.Adaptor(html, model).DisplayForModel(model.TemplateName, model.Prefix ?? "");
}
return html.DisplayFor(expression, model.TemplateName, model.Prefix ?? "");
}
}
#endif
}

View File

@@ -1,26 +0,0 @@
using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Orchard.Mvc.ViewModels;
namespace Orchard.Mvc.Html {
#if REFACTORING
public static class ContentItemEditorExtensions {
public static MvcHtmlString EditorForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, TItemModel item) where TItemModel : ContentItemViewModel {
return html.EditorForItem(x => item);
}
public static MvcHtmlString EditorForItem<TModel, TItemModel>(this HtmlHelper<TModel> html, Expression<Func<TModel, TItemModel>> expression) where TItemModel : ContentItemViewModel {
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
var model = (TItemModel)metadata.Model;
if (model.Adaptor != null) {
return model.Adaptor(html, model).EditorForModel(model.TemplateName, model.Prefix ?? "");
}
return html.EditorFor(expression, model.TemplateName, model.Prefix ?? "");
}
}
#endif
}

View File

@@ -8,7 +8,6 @@ using System.Web.Mvc.Html;
using System.Web.Routing;
using Orchard.Collections;
using Orchard.Localization;
using Orchard.Mvc.ViewModels;
using Orchard.Services;
using Orchard.Settings;
using Orchard.Utility;
@@ -422,40 +421,5 @@ namespace Orchard.Mvc.Html {
}
#endregion
#region AddRenderAction
public static void AddRenderAction(this HtmlHelper html, string location, string actionName) {
AddRenderActionHelper(html, location, actionName, null/*controllerName*/, null);
}
public static void AddRenderAction(this HtmlHelper html, string location, string actionName, object routeValues) {
AddRenderActionHelper(html, location, actionName, null/*controllerName*/, new RouteValueDictionary(routeValues));
}
public static void AddRenderAction(this HtmlHelper html, string location, string actionName, RouteValueDictionary routeValues) {
AddRenderActionHelper(html, location, actionName, null/*controllerName*/, routeValues);
}
public static void AddRenderAction(this HtmlHelper html, string location, string actionName, string controllerName) {
AddRenderActionHelper(html, location, actionName, controllerName, null/*RouteValueDictionary*/);
}
public static void AddRenderAction(this HtmlHelper html, string location, string actionName, string controllerName, object routeValues) {
AddRenderActionHelper(html, location, actionName, controllerName, new RouteValueDictionary(routeValues));
}
public static void AddRenderAction(this HtmlHelper html, string location, string actionName, string controllerName, RouteValueDictionary routeValues) {
AddRenderActionHelper(html, location, actionName, controllerName, routeValues);
}
private static void AddRenderActionHelper(this HtmlHelper html, string location, string actionName, string controllerName, RouteValueDictionary routeValues) {
#if REFACTORING
// Retrieve the "BaseViewModel" for zones if we have one
var baseViewModel = BaseViewModel.From(html.ViewData);
if (baseViewModel == null)
return;
baseViewModel.Zones.AddRenderAction(location, actionName, controllerName, routeValues);
#endif
}
#endregion
}
}

View File

@@ -1,4 +0,0 @@
namespace Orchard.Mvc.ViewModels {
public class BaseViewModel {
}
}

View File

@@ -1,75 +0,0 @@
using System;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.UI.Zones;
namespace Orchard.Mvc.ViewModels {
#if REFACTORING
public class ContentItemViewModel : IZoneContainer {
private ContentItem _item;
public ContentItemViewModel() {
Zones = new ZoneCollection();
}
public ContentItemViewModel(ContentItem item) {
Zones = new ZoneCollection();
Item = item;
}
public ContentItemViewModel(ContentItemViewModel viewModel) {
TemplateName = viewModel.TemplateName;
Prefix = viewModel.Prefix;
Item = viewModel.Item;
Zones = viewModel.Zones;
}
public ContentItem Item {
get { return _item; }
private set { SetItem(value); }
}
protected virtual void SetItem(ContentItem value) {
_item = value;
}
public Func<HtmlHelper, ContentItemViewModel, HtmlHelper> Adaptor { get; set; }
public string TemplateName { get; set; }
public string Prefix { get; set; }
public ZoneCollection Zones { get; private set; }
public bool IsPublished {
get { return Item != null && Item.VersionRecord != null && Item.VersionRecord.Published; }
}
public bool IsLatest {
get { return Item != null && Item.VersionRecord != null && Item.VersionRecord.Latest; }
}
public bool IsDraft {
get { return IsLatest && !IsPublished; }
}
}
public class ContentItemViewModel<TPart> : ContentItemViewModel where TPart : IContent {
private TPart _item;
public ContentItemViewModel() {
}
public ContentItemViewModel(TPart content)
: base(content.ContentItem) {
}
public ContentItemViewModel(ContentItemViewModel viewModel)
: base(viewModel) {
}
public new TPart Item {
get { return _item; }
}
protected override void SetItem(ContentItem value) {
_item = value.As<TPart>();
base.SetItem(value);
}
}
#endif
}

View File

@@ -153,7 +153,6 @@
<Compile Include="Mvc\ViewEngines\ThemeAwareness\ThemeAwareViewEngine.cs" />
<Compile Include="Mvc\ViewEngines\ThemeAwareness\ThemeAwareViewEngineShim.cs" />
<Compile Include="Mvc\ViewEngines\ThemeAwareness\ViewEngineCollectionWrapper.cs" />
<Compile Include="Mvc\ViewModels\BaseViewModel.cs" />
<Compile Include="Caching\Signals.cs" />
<Compile Include="Collections\IPageOfItems.cs" />
<Compile Include="Collections\PageOfItems.cs" />
@@ -659,7 +658,6 @@
<Compile Include="Tasks\Scheduling\IPublishingTaskManager.cs" />
<Compile Include="Tasks\Scheduling\IScheduledTask.cs" />
<Compile Include="Localization\Text.cs" />
<Compile Include="Mvc\ViewModels\ContentItemViewModel.cs" />
<Compile Include="Data\Conventions\AttributeCollectionConvention.cs" />
<Compile Include="Data\Conventions\CascadeAllDeleteOrphanAttribute.cs" />
<Compile Include="Data\TransactionManager.cs" />
@@ -708,8 +706,6 @@
<Compile Include="Logging\NullLoggerFactory.cs" />
<Compile Include="Mvc\Html\ContainerExtensions.cs" />
<Compile Include="Mvc\Html\ContentItemExtensions.cs" />
<Compile Include="Mvc\Html\ContentItemDisplayExtensions.cs" />
<Compile Include="Mvc\Html\ContentItemEditorExtensions.cs" />
<Compile Include="Mvc\Html\LayoutExtensions.cs" />
<Compile Include="Mvc\MvcModule.cs" />
<Compile Include="Mvc\Html\HtmlHelperExtensions.cs" />
@@ -738,7 +734,6 @@
<Compile Include="UI\Resources\ResourceFilter.cs" />
<Compile Include="UI\Resources\ResourceManager.cs" />
<Compile Include="UI\Zones\Obsolete\DelegateZoneItem.cs" />
<Compile Include="UI\Zones\Obsolete\ContentItemDisplayZoneItem.cs" />
<Compile Include="UI\Zones\Obsolete\IZoneManager.cs" />
<Compile Include="UI\Zones\Obsolete\ContentPartDisplayZoneItem.cs" />
<Compile Include="UI\Zones\Obsolete\ContentPartEditorZoneItem.cs" />
@@ -746,7 +741,6 @@
<Compile Include="UI\Zones\Obsolete\RenderActionZoneItem.cs" />
<Compile Include="UI\Zones\Obsolete\RenderPartialZoneItem.cs" />
<Compile Include="UI\Zones\Obsolete\RenderStaticZoneItem.cs" />
<Compile Include="UI\Zones\Obsolete\ZoneCollection.cs" />
<Compile Include="UI\Zones\Obsolete\ZoneEntry.cs" />
<Compile Include="UI\Zones\Obsolete\ZoneItem.cs" />
<Compile Include="Mvc\ViewPage.cs">

View File

@@ -5,9 +5,7 @@ using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Localization;
using Orchard.Mvc.Filters;
using Orchard.Mvc.ViewModels;
using Orchard.Security;
using Orchard.UI.Notify;
namespace Orchard.UI.Admin {
public class AdminFilter : FilterProvider, IAuthorizationFilter {