--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-09-16 16:46:08 -07:00
21 changed files with 274 additions and 265 deletions

View File

@@ -266,8 +266,8 @@
<Content Include="PublishLater\Content\Admin\images\online.gif" />
<Content Include="PublishLater\Content\Admin\images\published.gif" />
<Content Include="PublishLater\Content\Admin\images\scheduled.gif" />
<Content Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.ascx" />
<Content Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.SummaryAdmin.ascx" />
<None Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.cshtml" />
<None Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.SummaryAdmin.cshtml" />
<None Include="Common\Views\EditorTemplates\Fields\Common.TextField.cshtml" />
<None Include="Common\Views\EditorTemplates\Parts\Common.Container.cshtml" />
<None Include="Common\Views\EditorTemplates\PlainTextEditor.cshtml" />
@@ -300,7 +300,7 @@
<Content Include="PublishLater\Styles\jquery-ui-1.7.2.custom.css" />
<Content Include="PublishLater\Styles\ui.datepicker.css" />
<Content Include="PublishLater\Styles\ui.timepickr.css" />
<Content Include="PublishLater\Views\EditorTemplates\Parts\PublishLater.ascx" />
<None Include="PublishLater\Views\EditorTemplates\Parts\PublishLater.cshtml" />
<Content Include="Reports\Module.txt" />
<None Include="Contents\Views\Items\Content-HomePage.cshtml" />
<None Include="Reports\Views\Admin\Display.cshtml" />

View File

@@ -9,4 +9,4 @@ features:
PublishLater:
Description: Draft creation and scheduled publishing.
Category: Content
Dependencies: Common, Settings
Dependencies: Common, Settings, Scheduling

View File

@@ -1,31 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.PublishLater.ViewModels.PublishLaterViewModel>" %>
<ul class="pageStatus">
<li><%
// Published or not
if (Model.HasPublished) { %>
<img class="icon" src="<%=ResolveUrl("~/Core/PublishLater/Content/Admin/images/online.gif") %>" alt="<%:T("Online") %>" title="<%:T("The page is currently online") %>" /> <%:T("Published") %>&nbsp;&#124;&nbsp;<%
}
else { %>
<img class="icon" src="<%=ResolveUrl("~/Core/PublishLater/Content/Admin/images/offline.gif") %>" alt="<%:T("Offline") %>" title="<%:T("The page is currently offline") %>" /> <%:T("Not Published") %>&nbsp;&#124;&nbsp;<%
} %>
</li>
<li><%
// Does the page have a draft
if (Model.HasDraft) { %>
<img class="icon" src="<%=ResolveUrl("~/Core/PublishLater/Content/Admin/images/draft.gif") %>" alt="<%:T("Draft") %>" title="<%:T("The page has a draft") %>" /><%:T("Draft") %>&nbsp;&#124;&nbsp;<%
}
else { %>
<%:T("No Draft") %>&nbsp;&#124;&nbsp;<%
} %>
</li>
<li><%
if ((Model.ScheduledPublishUtc.HasValue && Model.ScheduledPublishUtc.Value > DateTime.UtcNow) || (Model.IsPublished && Model.VersionPublishedUtc.HasValue)) {
if (Model.IsPublished && Model.VersionPublishedUtc.HasValue) { %>
<%:T("Published: {0}", Html.DateTimeRelative(Model.VersionPublishedUtc.Value, T)) %><%
}
else { %>
<img class="icon" src="<%=ResolveUrl("~/Core/PublishLater/Content/Admin/images/scheduled.gif") %>" alt="<%:T("Scheduled") %>" title="<%:T("The page is scheduled for publishing") %>" /><%:T("Scheduled") %>
<%:Html.DateTime(Model.ScheduledPublishUtc.Value, T("M/d/yyyy h:mm tt")) %><%
} %>&nbsp;&#124;&nbsp;</li><%
} %>
</ul>

View File

@@ -0,0 +1,30 @@
@model Orchard.Core.PublishLater.ViewModels.PublishLaterViewModel
<ul class="pageStatus">
<li>@// Published or not
@if (Model.HasPublished) {
<img class="icon" src="@Href("~/Core/PublishLater/Content/Admin/images/online.gif")" alt="@T("Online")" title="@T("The page is currently online")" /> <text>@T("Published")&nbsp;&#124;&nbsp;</text>
}
else {
<img class="icon" src="@Href("~/Core/PublishLater/Content/Admin/images/offline.gif")" alt="@T("Offline")" title="@T("The page is currently offline")" /> <text>@T("Not Published")&nbsp;&#124;&nbsp;</text>
}
</li>
<li>
@// Does the page have a draft
@if (Model.HasDraft) {
<img class="icon" src="@Href("~/Core/PublishLater/Content/Admin/images/draft.gif")" alt="@T("Draft")" title="@T("The page has a draft")" /><text> @T("Draft")&nbsp;&#124;&nbsp;</text>
}
else {
<text>@T("No Draft")&nbsp;&#124;&nbsp;</text>
}
</li>
@if ((Model.ScheduledPublishUtc.HasValue && Model.ScheduledPublishUtc.Value > DateTime.UtcNow) || (Model.IsPublished && Model.VersionPublishedUtc.HasValue)) {
<li>
@if (Model.IsPublished && Model.VersionPublishedUtc.HasValue) {
@T("Published: {0}", Html.DateTimeRelative(Model.VersionPublishedUtc.Value, T))
}
else {
<img class="icon" src="@Href("~/Core/PublishLater/Content/Admin/images/scheduled.gif")" alt="@T("Scheduled")" title="@T("The page is scheduled for publishing")" /><text> @T("Scheduled") </text>
@Html.DateTime(Model.ScheduledPublishUtc.Value, T("M/d/yyyy h:mm tt"))
}&nbsp;&#124;&nbsp;</li>
}
</ul>

View File

@@ -1 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.PublishLater.ViewModels.PublishLaterViewModel>" %>

View File

@@ -0,0 +1 @@
@model Orchard.Core.PublishLater.ViewModels.PublishLaterViewModel

View File

@@ -1,47 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.PublishLater.ViewModels.PublishLaterViewModel>" %>
<% Html.RegisterStyle("datetime.css"); %>
<% Html.RegisterStyle("jquery-ui-1.7.2.custom.css"); %>
<% Html.RegisterStyle("ui.datepicker.css"); %>
<% Html.RegisterStyle("ui.timepickr.css"); %>
<% Html.RegisterFootScript("jquery.ui.core.js"); %>
<% Html.RegisterFootScript("jquery.ui.widget.js"); %>
<% Html.RegisterFootScript("jquery.ui.datepicker.js"); %>
<% Html.RegisterFootScript("jquery.utils.js"); %>
<% Html.RegisterFootScript("ui.timepickr.js"); %>
<fieldset>
<legend><%: T("Publish Settings")%></legend>
<div>
<%: Html.RadioButton("Command", "SaveDraft", Model.ContentItem.VersionRecord == null || !Model.ContentItem.VersionRecord.Published, new { id = ViewData.TemplateInfo.GetFullHtmlFieldId("Command_SaveDraft") })%>
<label class="forcheckbox" for="<%:ViewData.TemplateInfo.GetFullHtmlFieldId("Command_SaveDraft") %>"><%: T("Save Draft")%></label>
</div>
<div>
<%: Html.RadioButton("Command", "PublishNow", Model.ContentItem.VersionRecord != null && Model.ContentItem.VersionRecord.Published, new { id = ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishNow") })%>
<label class="forcheckbox" for="<%:ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishNow") %>"><%: T("Publish Now")%></label>
</div>
<div>
<%: Html.RadioButton("Command", "PublishLater", Model.ScheduledPublishUtc != null, new { id = ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishLater") }) %>
<label class="forcheckbox" for="<%:ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishLater") %>"><%: T("Publish Later")%></label>
</div>
<div>
<label class="forpicker" for="<%:ViewData.TemplateInfo.GetFullHtmlFieldId("ScheduledPublishUtcDate") %>"><%: T("Date")%></label>
<%: Html.EditorFor(m => m.ScheduledPublishUtcDate)%>
<label class="forpicker" for="<%:ViewData.TemplateInfo.GetFullHtmlFieldId("ScheduledPublishUtcTime") %>"><%: T("Time")%></label>
<%: Html.EditorFor(m => m.ScheduledPublishUtcTime)%>
</div>
</fieldset>
<script type="text/javascript"> $(function () {
//todo: (heskew) make a plugin
$("label.forpicker").each(function () {
var $this = $(this);
var pickerInput = $("#" + $this.attr("for"));
pickerInput.data("hint", $this.text());
if (!pickerInput.val()) {
pickerInput.addClass("hinted")
.val(pickerInput.data("hint"))
.focus(function () { var $this = $(this); if ($this.val() == $this.data("hint")) { $this.removeClass("hinted").val("") } })
.blur(function () { var $this = $(this); setTimeout(function () { if (!$this.val()) { $this.addClass("hinted").val($this.data("hint")) } }, 300) });
}
});
$(<%=string.Format("\"#{0}\"", ViewData.TemplateInfo.GetFullHtmlFieldId("ScheduledPublishUtcDate")) %>).datepicker({ showAnim: "" }).focus(function () { $(<%=string.Format("\"#{0}\"", ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishLater")) %>).attr("checked", "checked") });
$(<%=string.Format("\"#{0}\"", ViewData.TemplateInfo.GetFullHtmlFieldId("ScheduledPublishUtcTime")) %>).timepickr().focus(function () { $(<%=string.Format("\"#{0}\"", ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishLater")) %>).attr("checked", "checked") });
})</script>

View File

@@ -0,0 +1,49 @@
@model Orchard.Core.PublishLater.ViewModels.PublishLaterViewModel
@{
Html.RegisterStyle("datetime.css");
Html.RegisterStyle("jquery-ui-1.7.2.custom.css");
Html.RegisterStyle("ui.datepicker.css");
Html.RegisterStyle("ui.timepickr.css");
Html.RegisterFootScript("jquery.ui.core.js");
Html.RegisterFootScript("jquery.ui.widget.js");
Html.RegisterFootScript("jquery.ui.datepicker.js");
Html.RegisterFootScript("jquery.utils.js");
Html.RegisterFootScript("ui.timepickr.js");
}
<fieldset>
<legend>@T("Publish Settings")</legend>
<div>
@Html.RadioButton("Command", "SaveDraft", Model.ContentItem.VersionRecord == null || !Model.ContentItem.VersionRecord.Published, new { id = ViewData.TemplateInfo.GetFullHtmlFieldId("Command_SaveDraft") })
<label class="forcheckbox" for="@ViewData.TemplateInfo.GetFullHtmlFieldId("Command_SaveDraft")">@T("Save Draft")</label>
</div>
<div>
@Html.RadioButton("Command", "PublishNow", Model.ContentItem.VersionRecord != null && Model.ContentItem.VersionRecord.Published, new { id = ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishNow") })
<label class="forcheckbox" for="@ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishNow")">@T("Publish Now")</label>
</div>
<div>
@Html.RadioButton("Command", "PublishLater", Model.ScheduledPublishUtc != null, new { id = ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishLater") })
<label class="forcheckbox" for="@ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishLater")">@T("Publish Later")</label>
</div>
<div>
<label class="forpicker" for="@ViewData.TemplateInfo.GetFullHtmlFieldId("ScheduledPublishUtcDate")">@T("Date")</label>
@Html.EditorFor(m => m.ScheduledPublishUtcDate)
<label class="forpicker" for="@ViewData.TemplateInfo.GetFullHtmlFieldId("ScheduledPublishUtcTime")">@T("Time")</label>
@Html.EditorFor(m => m.ScheduledPublishUtcTime)
</div>
</fieldset>
<script type="text/javascript"> $(function () {
@//todo: (heskew) make a plugin
$("label.forpicker").each(function () {
var $this = $(this);
var pickerInput = $("#" + $this.attr("for"));
pickerInput.data("hint", $this.text());
if (!pickerInput.val()) {
pickerInput.addClass("hinted")
.val(pickerInput.data("hint"))
.focus(function () { var $this = $(this); if ($this.val() == $this.data("hint")) { $this.removeClass("hinted").val("") } })
.blur(function () { var $this = $(this); setTimeout(function () { if (!$this.val()) { $this.addClass("hinted").val($this.data("hint")) } }, 300) });
}
});
$(@(new HtmlString(string.Format("\"#{0}\"", ViewData.TemplateInfo.GetFullHtmlFieldId("ScheduledPublishUtcDate"))))).datepicker({ showAnim: "" }).focus(function () { $(@(new HtmlString(string.Format("\"#{0}\"", ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishLater"))))).attr("checked", "checked") });
$(@(new HtmlString(string.Format("\"#{0}\"", ViewData.TemplateInfo.GetFullHtmlFieldId("ScheduledPublishUtcTime"))))).timepickr().focus(function () { $(@(new HtmlString(string.Format("\"#{0}\"", ViewData.TemplateInfo.GetFullHtmlFieldId("Command_PublishLater"))))).attr("checked", "checked") });
})</script>

View File

@@ -18,7 +18,7 @@ namespace Orchard.Themes.Controllers {
public AdminController(
IOrchardServices services,
IThemeService themeService,
PreviewTheme previewTheme,
IPreviewTheme previewTheme,
IAuthorizer authorizer,
INotifier notifier,
IShapeHelperFactory shapeHelperFactory) {
@@ -37,11 +37,11 @@ namespace Orchard.Themes.Controllers {
var themes = _themeService.GetInstalledThemes();
var currentTheme = _themeService.GetSiteTheme();
var model = new ThemesIndexViewModel { CurrentTheme = currentTheme, Themes = themes };
return View(Shape.Model(model));
return View(model);
}
catch (Exception exception) {
Services.Notifier.Error(T("Listing themes failed: " + exception.Message));
return View(Shape.Model(new ThemesIndexViewModel()));
return View(new ThemesIndexViewModel());
}
}
@@ -102,6 +102,10 @@ namespace Orchard.Themes.Controllers {
}
}
public ActionResult Install() {
return View();
}
[HttpPost]
public ActionResult Install(FormCollection input) {
try {

View File

@@ -78,20 +78,20 @@
<Compile Include="Preview\IPreviewTheme.cs" />
<Compile Include="Preview\PreviewTheme.cs" />
<Compile Include="Preview\PreviewThemeFilter.cs" />
<Compile Include="Preview\PreviewThemeSelector.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\SafeModeThemeSelector.cs" />
<Compile Include="Services\SiteThemeSelector.cs" />
<Compile Include="Services\ThemeService.cs" />
<Compile Include="Services\ThemeZoneManagerEvents.cs" />
<Compile Include="ViewModels\PreviewViewModel.cs" />
<Compile Include="ViewModels\ThemesIndexViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\orchard.ico" />
<Content Include="Styles\admin.css" />
<Content Include="Views\Admin\Index.aspx" />
<Content Include="Views\Admin\Install.aspx" />
<Content Include="Views\Admin\ThemePreview.ascx" />
<None Include="Views\Admin\Index.cshtml" />
<None Include="Views\Admin\Install.cshtml" />
<None Include="Views\ThemePreview.cshtml" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,36 +1,29 @@
using System;
using System.Web;
using System.Web.Routing;
using Orchard.Mvc;
namespace Orchard.Themes.Preview {
public class PreviewTheme : IPreviewTheme, IThemeSelector {
public class PreviewTheme : IPreviewTheme {
private readonly IHttpContextAccessor _httpContextAccessor;
private static readonly string PreviewThemeKey = typeof(PreviewTheme).FullName;
private readonly HttpContextBase _httpContext;
public PreviewTheme(HttpContextBase httpContext) {
_httpContext = httpContext;
public PreviewTheme(IHttpContextAccessor httpContextAccessor) {
_httpContextAccessor = httpContextAccessor;
}
public string GetPreviewTheme() {
return Convert.ToString(_httpContext.Session[PreviewThemeKey]);
var httpContext = _httpContextAccessor.Current();
return Convert.ToString(httpContext.Session[PreviewThemeKey]);
}
public void SetPreviewTheme(string themeName) {
var httpContext = _httpContextAccessor.Current();
if (string.IsNullOrEmpty(themeName)) {
_httpContext.Session.Remove(PreviewThemeKey);
httpContext.Session.Remove(PreviewThemeKey);
}
else {
_httpContext.Session[PreviewThemeKey] = themeName;
httpContext.Session[PreviewThemeKey] = themeName;
}
}
public ThemeSelectorResult GetTheme(RequestContext context) {
var previewThemeName = GetPreviewTheme();
if (string.IsNullOrEmpty(previewThemeName))
return null;
return new ThemeSelectorResult { Priority = 90, ThemeName = previewThemeName };
}
}
}

View File

@@ -23,19 +23,20 @@ namespace Orchard.Themes.Preview {
if (string.IsNullOrEmpty(previewThemeName))
return;
var themes = _themeService.GetInstalledThemes();
var model = new PreviewViewModel {
Themes = themes.Select(theme => new SelectListItem {
Text = theme.DisplayName,
Value = theme.ThemeName,
Selected = theme.ThemeName == previewThemeName
})
};
var installedThemes = _themeService.GetInstalledThemes();
var themeListItems = installedThemes
.Select(theme => new SelectListItem {
Text = theme.DisplayName,
Value = theme.ThemeName,
Selected = theme.ThemeName == previewThemeName
})
.ToList();
var shape = _shapeHelperFactory.CreateHelper();
_workContextAccessor.GetContext(filterContext).Page.Zones["Body"].Add(shape.ThemePreview(model), ":before");
_workContextAccessor.GetContext(filterContext).Page.Zones["Body"].Add(shape.ThemePreview(Themes: themeListItems), ":before");
}
public void OnResultExecuted(ResultExecutedContext filterContext) {}
public void OnResultExecuted(ResultExecutedContext filterContext) { }
}
}

View File

@@ -0,0 +1,19 @@
using System.Web.Routing;
namespace Orchard.Themes.Preview {
public class PreviewThemeSelector : IThemeSelector {
private readonly IPreviewTheme _previewTheme;
public PreviewThemeSelector(IPreviewTheme previewTheme) {
_previewTheme = previewTheme;
}
public ThemeSelectorResult GetTheme(RequestContext context) {
var previewThemeName = _previewTheme.GetPreviewTheme();
if (string.IsNullOrEmpty(previewThemeName))
return null;
return new ThemeSelectorResult { Priority = 90, ThemeName = previewThemeName };
}
}
}

View File

@@ -1,8 +0,0 @@
using System.Collections.Generic;
using System.Web.Mvc;
namespace Orchard.Themes.ViewModels {
public class PreviewViewModel {
public IEnumerable<SelectListItem> Themes { get; set; }
}
}

View File

@@ -1,53 +0,0 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<ThemesIndexViewModel>" %>
<%@ Import Namespace="Orchard.Mvc.Html"%>
<%@ Import Namespace="Orchard.Themes.ViewModels"%><%
Html.RegisterStyle("admin.css"); %>
<h1><%: Html.TitleForPage(T("Manage Themes").ToString()) %></h1>
<% if (Model.CurrentTheme == null) {
%><p><%: T("There is no current theme in the application. The built-in theme will be used.")
%><br /><%: Html.ActionLink(T("Install a new Theme").ToString(), "Install") %></p><%
} else {
%><h3><%: T("Current Theme")%> - <%: Model.CurrentTheme.DisplayName %></h3>
<%: Html.Image(Html.ThemePath(Model.CurrentTheme, "/Theme.png"), Html.Encode(Model.CurrentTheme.DisplayName), new { @class = "themePreviewImage" })%>
<h5><%: T("By") %> <%: Model.CurrentTheme.Author %></h5>
<p>
<%: T("Version:") %> <%: Model.CurrentTheme.Version %><br />
<%: Model.CurrentTheme.Description %><br />
<%: Model.CurrentTheme.HomePage %>
</p>
<%: Html.ActionLink(T("Install a new Theme").ToString(), "Install", null, new { @class = "button primaryAction" })%>
<% } %>
<h2><%: T("Available Themes")%></h2>
<ul class="templates">
<% foreach (var theme in Model.Themes) {
if (Model.CurrentTheme == null || theme.ThemeName != Model.CurrentTheme.ThemeName) {
%> <li>
<div>
<h3><%: theme.DisplayName %></h3>
<%: Html.Image(Html.ThemePath(theme, "/Theme.png"), Html.Encode(theme.DisplayName), null)%>
<% using (Html.BeginFormAntiForgeryPost(Url.Action("Activate"), FormMethod.Post, new { @class = "inline" })) { %>
<%: Html.Hidden("themeName", theme.ThemeName)%>
<button type="submit" title="<%: T("Activate") %>"><%: T("Activate") %></button>
<% } %>
<% using (Html.BeginFormAntiForgeryPost(Url.Action("Preview"), FormMethod.Post, new { @class = "inline" })) { %>
<%: Html.Hidden("themeName", theme.ThemeName)%>
<button type="submit" title="<%: T("Preview") %>"><%: T("Preview") %></button>
<% } %>
<h5><%: T("By") %> <%: theme.Author %></h5>
<p>
<%: T("Version:") %> <%: theme.Version %><br />
<%: theme.Description %><br />
<%: theme.HomePage %>
</p>
<% using (Html.BeginFormAntiForgeryPost(Url.Action("Uninstall"), FormMethod.Post, new { @class = "inline link" })) { %>
<%: Html.Hidden("themeName", theme.ThemeName)%>
<button type="submit" class="uninstall" title="<%: T("Uninstall") %>"><%: T("Uninstall")%></button>
<% } %>
</div>
</li>
<% }
} %>
</ul>

View File

@@ -0,0 +1,57 @@
@model Orchard.Themes.ViewModels.ThemesIndexViewModel
@{
Html.RegisterStyle("admin.css");
}
<h1>@Html.TitleForPage(T("Manage Themes").ToString())</h1>
@if (Model.CurrentTheme == null) {
<p>
@T("There is no current theme in the application. The built-in theme will be used.")<br />
@Html.ActionLink(T("Install a new Theme").ToString(), "Install")
</p>
} else {
<h3>@T("Current Theme") - @Model.CurrentTheme.DisplayName</h3>
@Html.Image(Href(Html.ThemePath(Model.CurrentTheme, "/Theme.png")), Html.Encode(Model.CurrentTheme.DisplayName), new { @class = "themePreviewImage" })
<h5>@T("By") @Model.CurrentTheme.Author</h5>
<p>
@T("Version:") @Model.CurrentTheme.Version<br />
@Model.CurrentTheme.Description<br />
@Model.CurrentTheme.HomePage
</p>
@Html.ActionLink(T("Install a new Theme").ToString(), "Install", null, new { @class = "button primaryAction" })
}
<h2>@T("Available Themes")</h2>
<ul class="templates">
@foreach (var theme in Model.Themes) {
if (Model.CurrentTheme == null || theme.ThemeName != Model.CurrentTheme.ThemeName) {
<li>
<div>
<h3>@theme.DisplayName</h3>
@Html.Image(Href(Html.ThemePath(theme, "/Theme.png")), Html.Encode(theme.DisplayName), null)
@using (Html.BeginFormAntiForgeryPost(Url.Action("Activate"), FormMethod.Post, new { @class = "inline" })) {
@Html.Hidden("themeName", theme.ThemeName)
<button type="submit" title="@T("Activate")">@T("Activate")</button>
}
@using (Html.BeginFormAntiForgeryPost(Url.Action("Preview"), FormMethod.Post, new { @class = "inline" })) {
@Html.Hidden("themeName", theme.ThemeName)
<button type="submit" title="@T("Preview")">@T("Preview")</button>
}
<h5>@T("By") @theme.Author</h5>
<p>
@T("Version:") @theme.Version<br />
@theme.Description<br />
@theme.HomePage
</p>
@using (Html.BeginFormAntiForgeryPost(Url.Action("Uninstall"), FormMethod.Post, new { @class = "inline link" })) {
@Html.Hidden("themeName", theme.ThemeName)
<button type="submit" class="uninstall" title="@T("Uninstall")">@T("Uninstall")</button>
}
</div>
</li>
}
}
</ul>

View File

@@ -1,12 +0,0 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<object>" %>
<%@ Import Namespace="Orchard.Mvc.Html"%>
<h1><%: Html.TitleForPage(T("Install Theme").ToString()) %></h1>
<% using (Html.BeginForm("Install", "Admin", FormMethod.Post, new { enctype = "multipart/form-data" })) {%>
<%: Html.ValidationSummary() %>
<fieldset>
<label for="ThemeZipPath"><%: T("File Path to the zip file:")%></label>
<input id="ThemeZipPath" name="ThemeZipPath" type="file" class="text" value="<%: T("Browse") %>" size="64" /><br />
<input type="submit" class="button" value="<%: T("Install") %>" />
<%: Html.AntiForgeryTokenOrchard() %>
</fieldset>
<% } %>

View File

@@ -0,0 +1,10 @@
<h1>@Html.TitleForPage(T("Install Theme").ToString())</h1>
@using (Html.BeginForm("Install", "Admin", FormMethod.Post, new { enctype = "multipart/form-data" })) {
@Html.ValidationSummary()
<fieldset>
<label for="ThemeZipPath">@T("File Path to the zip file:")</label>
<input id="ThemeZipPath" name="ThemeZipPath" type="file" class="text" value="@T("Browse")" size="64" /><br />
<input type="submit" class="button" value="@T("Install")" />
@Html.AntiForgeryTokenOrchard()
</fieldset>
}

View File

@@ -1,70 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<PreviewViewModel>" %>
<%@ Import Namespace="Orchard.Mvc.Html"%>
<%@ Import Namespace="Orchard.Themes.ViewModels"%>
<style type="text/css">
body {
margin-top:40px;
}
#themepreview {
background:#2D2F25 url('<%=ResolveUrl("../../Styles/Images/toolBarBackground.gif") %>') repeat-x left top;
border-bottom:1px solid #494d4d;
font-size:15px;
left:0;
height:30px;
margin:0;
position:absolute;
overflow:hidden;
padding:5px 0;
top:0;
width:100%;
}
#themepreview fieldset,
#themepreview span, #themepreview input,
#themepreview select, #themepreview button {
border:none;
color:#000;
font:1em/1em Frutiger,"Frutiger Linotype",Univers,Calibri,"Gill Sans","Gill Sans MT","Myriad Pro",Myriad,"DejaVu Sans Condensed","Liberation Sans","Nimbus Sans L",Tahoma,Geneva,"Helvetica Neue",Helvetica,Arial,sans-serif;
margin:0;
padding:0;
width:auto;
}
#themepreview span { color: #ccc; padding-right:5px; }
#themepreview fieldset { padding:3px 8px; }
html.dyn #themepreview button.preview { display:none; }
#themepreview fieldset * { float:left; }
#themepreview fieldset span { line-height:1.6em; }
#themepreview button.cancel { float:right; }
/* Button styles */
#themepreview button {
background:#2a2626 url('<%=ResolveUrl("../../Styles/Images/toolBarActiveButtonBackground.gif") %>') repeat-x left center;
border:1px solid;
border-top-color:#191d1d;
border-right-color:#494d4d;
border-bottom-color:#494d4d;
border-left-color:#202626;
color:#f1f1f1;
line-height:1.22em;
margin: 0 0 0 10px;
padding:0 4px 1px;
text-align:center;
}
#themepreview button:hover {
background:#2a2626 url('<%=ResolveUrl("../../Styles/Images/toolBarHoverButtonBackground.gif") %>') repeat-x left center;
border-color:#545959;
color:#fdcc64;
cursor:pointer;
}
</style>
<div id="themepreview">
<% using(Html.BeginFormAntiForgeryPost(Url.Action("Preview", new{Controller="Admin", Area="Orchard.Themes"}), FormMethod.Post, new { @class = "inline" })) { %>
<fieldset>
<span><%: T("You are previewing: ")%></span>
<%: Html.Hidden("ReturnUrl", Context.Request.RawUrl)%>
<%: Html.DropDownList("ThemeName", Model.Themes, new {onChange = "this.form.submit();"})%>
<button type="submit" class="preview" title="<%: T("Preview")%>" name="submit.Preview" value="<%: T("Preview")%>"><%: T("Preview")%></button>
<button type="submit" title="<%: T("Apply")%>" name="submit.Apply" value="<%: T("Apply")%>"><%: T("Apply this theme") %></button>
<button type="submit" class="cancel" title="<%: T("Cancel")%>" name="submit.Cancel" value="<%: T("Cancel")%>"><%: T("Cancel")%></button>
</fieldset>
<% } %>
</div>

View File

@@ -0,0 +1,71 @@
@{
var themes = (IEnumerable<SelectListItem>)Model.Themes;
}
<style type="text/css">
body {
margin-top:40px;
}
#themepreview {
background:#2D2F25 url('@Href("../Styles/Images/toolBarBackground.gif")') repeat-x left top;
border-bottom:1px solid #494d4d;
font-size:15px;
left:0;
height:30px;
margin:0;
position:absolute;
overflow:hidden;
padding:5px 0;
top:0;
width:100%;
}
#themepreview fieldset,
#themepreview span, #themepreview input,
#themepreview select, #themepreview button {
border:none;
color:#000;
font:1em/1em Frutiger,"Frutiger Linotype",Univers,Calibri,"Gill Sans","Gill Sans MT","Myriad Pro",Myriad,"DejaVu Sans Condensed","Liberation Sans","Nimbus Sans L",Tahoma,Geneva,"Helvetica Neue",Helvetica,Arial,sans-serif;
margin:0;
padding:0;
width:auto;
}
#themepreview span { color: #ccc; padding-right:5px; }
#themepreview fieldset { padding:3px 8px; }
html.dyn #themepreview button.preview { display:none; }
#themepreview fieldset * { float:left; }
#themepreview fieldset span { line-height:1.6em; }
#themepreview button.cancel { float:right; }
/* Button styles */
#themepreview button {
background:#2a2626 url('@Href("../Styles/Images/toolBarBackground.gif")') repeat-x left center;
border:1px solid;
border-top-color:#191d1d;
border-right-color:#494d4d;
border-bottom-color:#494d4d;
border-left-color:#202626;
color:#f1f1f1;
line-height:1.22em;
margin: 0 0 0 10px;
padding:0 4px 1px;
text-align:center;
}
#themepreview button:hover {
background:#2a2626 url('@Href("../../Styles/Images/toolBarHoverButtonBackground.gif")') repeat-x left center;
border-color:#545959;
color:#fdcc64;
cursor:pointer;
}
</style>
<div id="themepreview">
@using(Html.BeginFormAntiForgeryPost(Url.Action("Preview", new{Controller="Admin", Area="Orchard.Themes"}), FormMethod.Post, new { @class = "inline" })) {
<fieldset>
<span>@T("You are previewing: ")</span>
@Html.DropDownList("ThemeName", themes, new {onChange = "this.form.submit();"})
@Html.Hidden("ReturnUrl", Context.Request.RawUrl)
<button type="submit" class="preview" title="@T("Preview")" name="submit.Preview" value="@T("Preview")">@T("Preview")</button>
<button type="submit" title="@T("Apply")" name="submit.Apply" value="@T("Apply")">@T("Apply this theme")</button>
<button type="submit" class="cancel" title="@T("Cancel")" name="submit.Cancel" value="@T("Cancel")">@T("Cancel")</button>
</fieldset>
}
</div>

View File

@@ -20,11 +20,7 @@ namespace Orchard.Mvc.Html {
}
public static string ThemePath(this HtmlHelper helper, ITheme theme, string path) {
Control parent = helper.ViewDataContainer as Control;
Argument.ThrowIfNull(parent, "helper.ViewDataContainer");
return parent.ResolveUrl(helper.Resolve<IExtensionManager>().GetThemeLocation(theme) + path);
return helper.Resolve<IExtensionManager>().GetThemeLocation(theme) + path;
}
}
}