mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
- Cleaning up/refactoring/removing some obsolete classes/flagged code.
--HG-- branch : dev
This commit is contained in:
@@ -16,20 +16,7 @@ namespace Orchard.Experimental.ViewModels {
|
||||
|
||||
public IEnumerable<TemplateViewModel> Editors {
|
||||
get {
|
||||
#if REFACTORING
|
||||
return EditorModel.Zones
|
||||
.SelectMany(z => z.Value.Items
|
||||
.OfType<ContentPartEditorZoneItem>()
|
||||
.Select(x => new { ZoneName = z.Key, Item = x }))
|
||||
.Select(x => new TemplateViewModel(x.Item.Model, x.Item.Prefix) {
|
||||
Model = x.Item.Model,
|
||||
TemplateName = x.Item.TemplateName,
|
||||
WasUsed = x.Item.WasExecuted,
|
||||
ZoneName = x.ZoneName,
|
||||
});
|
||||
#else
|
||||
return new List<TemplateViewModel>();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,87 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc.Html;
|
||||
using Orchard.Environment.Descriptor;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.Services;
|
||||
using Orchard.UI.Zones;
|
||||
|
||||
namespace Orchard.Themes.DesignerNotes {
|
||||
#if REFACTORING
|
||||
public class ZoneManagerEvents : IZoneManagerEvents {
|
||||
private readonly IThemeService _themeService;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IShellDescriptorManager _shellDescriptorManager;
|
||||
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
|
||||
|
||||
public ZoneManagerEvents(IThemeService themeService,
|
||||
IAuthorizationService authorizationService,
|
||||
IShellDescriptorManager shellDescriptorManager,
|
||||
IEnumerable<IHtmlFilter> htmlFilters) {
|
||||
|
||||
_themeService = themeService;
|
||||
_authorizationService = authorizationService;
|
||||
_shellDescriptorManager = shellDescriptorManager;
|
||||
_htmlFilters = htmlFilters;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public virtual IUser CurrentUser { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public void ZoneRendering(ZoneRenderContext context) {
|
||||
if (context.RenderingItems.Any())
|
||||
return;
|
||||
|
||||
var requestContext = context.Html.ViewContext.RequestContext;
|
||||
var theme = _themeService.GetRequestTheme(requestContext);
|
||||
var virtualPath = "~/Themes/" + theme.ThemeName + "/Zones/" + context.ZoneName + ".html";
|
||||
var physicalPath = requestContext.HttpContext.Server.MapPath(virtualPath);
|
||||
if (!File.Exists(physicalPath))
|
||||
return;
|
||||
|
||||
var accessAdminPanel = _authorizationService.TryCheckAccess(
|
||||
StandardPermissions.AccessAdminPanel, CurrentUser, null);
|
||||
if (accessAdminPanel) {
|
||||
//Temporary: Don't show "edit" button if "Orchard.Widgets" is not enabled.
|
||||
accessAdminPanel = _shellDescriptorManager
|
||||
.GetShellDescriptor()
|
||||
.Features
|
||||
.Any(f => f.Name == "Orchard.Widgets");
|
||||
}
|
||||
|
||||
var writer = context.Html.ViewContext.Writer;
|
||||
if (accessAdminPanel) {
|
||||
writer.Write("<div class=\"managewrapper\"><div class=\"manage\">");
|
||||
writer.Write(context.Html.ActionLink(T("Edit").ToString(), "AddWidget", new {
|
||||
Area = "Orchard.Widgets",
|
||||
Controller = "Admin",
|
||||
context.ZoneName,
|
||||
theme.ThemeName,
|
||||
ReturnUrl = requestContext.HttpContext.Request.RawUrl,
|
||||
}));
|
||||
writer.Write("</div>");
|
||||
}
|
||||
|
||||
var fileText = _htmlFilters
|
||||
.Aggregate(File.ReadAllText(physicalPath), (text, filter) => filter.ProcessContent(text));
|
||||
|
||||
writer.Write(fileText);
|
||||
if (accessAdminPanel) {
|
||||
writer.Write("</div>");
|
||||
}
|
||||
}
|
||||
|
||||
public void ZoneItemRendering(ZoneRenderContext context, ZoneItem item) {
|
||||
}
|
||||
|
||||
public void ZoneItemRendered(ZoneRenderContext context, ZoneItem item) {
|
||||
}
|
||||
|
||||
public void ZoneRendered(ZoneRenderContext context) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -74,7 +74,6 @@
|
||||
<Compile Include="ResourceManifest.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="DesignerNotes\ZoneManagerEvents.cs" />
|
||||
<Compile Include="Handlers\ThemeSiteSettingsPartHandler.cs" />
|
||||
<Compile Include="Models\Theme.cs" />
|
||||
<Compile Include="Models\ThemeSiteSettingsPart.cs" />
|
||||
@@ -88,7 +87,6 @@
|
||||
<Compile Include="Services\SafeModeThemeSelector.cs" />
|
||||
<Compile Include="Services\SiteThemeSelector.cs" />
|
||||
<Compile Include="Services\ThemeService.cs" />
|
||||
<Compile Include="Services\ThemeZoneManagerEvents.cs" />
|
||||
<Compile Include="ViewModels\ThemesIndexViewModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@@ -1,52 +0,0 @@
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Zones;
|
||||
|
||||
namespace Orchard.Themes.Services {
|
||||
#if REFACTORING
|
||||
public class ThemeZoneManagerEvents : IZoneManagerEvents {
|
||||
public ThemeZoneManagerEvents() {
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public void ZoneRendering(ZoneRenderContext context) {
|
||||
#if DEBUG
|
||||
context.Html.ViewContext.Writer.WriteLine(T("<!-- begin zone: {0} -->", LocalizedString.TextOrDefault(context.ZoneName, T("etc. (ZonesAny)"))));
|
||||
#endif
|
||||
}
|
||||
|
||||
public void ZoneItemRendering(ZoneRenderContext context, ZoneItem item) {
|
||||
#if DEBUG
|
||||
//info: doesn't cover all ZoneItem types
|
||||
var writer = context.Html.ViewContext.Writer;
|
||||
if (item is RenderPartialZoneItem)
|
||||
writer.WriteLine(T("<!-- begin: {0} -->", (item as RenderPartialZoneItem).TemplateName));
|
||||
else if (item is ContentPartDisplayZoneItem)
|
||||
writer.WriteLine(T("<!-- begin: {0} -->", (item as ContentPartDisplayZoneItem).TemplateName));
|
||||
else if (item is ContentPartEditorZoneItem)
|
||||
writer.WriteLine(T("<!-- begin: {0} -->", (item as ContentPartEditorZoneItem).TemplateName));
|
||||
#endif
|
||||
}
|
||||
|
||||
public void ZoneItemRendered(ZoneRenderContext context, ZoneItem item) {
|
||||
#if DEBUG
|
||||
//info: doesn't cover all ZoneItem types
|
||||
var writer = context.Html.ViewContext.Writer;
|
||||
if (item is RenderPartialZoneItem)
|
||||
writer.WriteLine(T("<!-- end: {0} -->", (item as RenderPartialZoneItem).TemplateName));
|
||||
else if (item is ContentPartDisplayZoneItem)
|
||||
writer.WriteLine(T("<!-- end: {0} -->", (item as ContentPartDisplayZoneItem).TemplateName));
|
||||
else if (item is ContentPartEditorZoneItem)
|
||||
writer.WriteLine(T("<!-- end: {0} -->", (item as ContentPartEditorZoneItem).TemplateName));
|
||||
#endif
|
||||
}
|
||||
|
||||
public void ZoneRendered(ZoneRenderContext context) {
|
||||
#if DEBUG
|
||||
context.Html.ViewContext.Writer.WriteLine(T("<!-- end zone: {0} -->", LocalizedString.TextOrDefault(context.ZoneName, T("etc. (ZonesAny)"))));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user