--HG--
branch : dev
This commit is contained in:
Michael Dorian Bach
2010-10-19 14:20:14 -07:00
22 changed files with 145 additions and 65 deletions

View File

@@ -1,7 +1,7 @@
@model OwnerEditorViewModel @model OwnerEditorViewModel
@using Orchard.Core.Common.ViewModels; @using Orchard.Core.Common.ViewModels;
<fieldset> <fieldset>
@Html.LabelFor(m=>m.Owner) @Html.LabelFor(m => m.Owner, T("Owner"))
@Html.EditorFor(m=>m.Owner) @Html.EditorFor(m=>m.Owner)
@Html.ValidationMessageFor(m=>m.Owner) @Html.ValidationMessageFor(m=>m.Owner)
</fieldset> </fieldset>

View File

@@ -3,7 +3,7 @@
@{ Script.Require("Slugify"); } @{ Script.Require("Slugify"); }
<fieldset> <fieldset>
@Html.LabelFor(m => m.Title) @Html.LabelFor(m => m.Title, T("Title"))
@Html.TextBoxFor(m => m.Title, new { @class = "large text" }) @Html.TextBoxFor(m => m.Title, new { @class = "large text" })
</fieldset> </fieldset>
<fieldset class="permalink"> <fieldset class="permalink">

View File

@@ -1,5 +1,5 @@
@model Orchard.Blogs.Models.BlogPart @model Orchard.Blogs.Models.BlogPart
<fieldset> <fieldset>
@Html.LabelFor(m => m.Description) @Html.LabelFor(m => m.Description, T("Description"))
@Html.TextAreaFor(m => m.Description, 5, 60, null) @Html.TextAreaFor(m => m.Description, 5, 60, null)
</fieldset> </fieldset>

View File

@@ -1,7 +1,7 @@
@model Orchard.Blogs.Models.BlogArchivesPart @model Orchard.Blogs.Models.BlogArchivesPart
<fieldset> <fieldset>
<div> <div>
@Html.LabelFor(m => m.ForBlog) @Html.LabelFor(m => m.ForBlog, T("For Blog"))
@Html.TextBoxFor(m => m.ForBlog) @Html.TextBoxFor(m => m.ForBlog)
<span class="hint">@T("Show the archives for which blog? Note: specify the blog's slug.")</span> <span class="hint">@T("Show the archives for which blog? Note: specify the blog's slug.")</span>
</div> </div>

View File

@@ -1,11 +1,11 @@
@model Orchard.Blogs.Models.RecentBlogPostsPart @model Orchard.Blogs.Models.RecentBlogPostsPart
<fieldset> <fieldset>
<div> <div>
@Html.LabelFor(m => m.ForBlog) @Html.LabelFor(m => m.ForBlog, T("For Blog"))
@Html.TextBoxFor(m => m.ForBlog) @Html.TextBoxFor(m => m.ForBlog)
</div> </div>
<div> <div>
@Html.LabelFor(m => m.Count) @Html.LabelFor(m => m.Count, T("Count"))
@Html.TextBoxFor(m => m.Count) @Html.TextBoxFor(m => m.Count)
</div> </div>
</fieldset> </fieldset>

View File

@@ -12,7 +12,7 @@
</li> </li>
} }
</ul> </ul>
@Html.LabelFor(m => m.CommandLine) @Html.LabelFor(m => m.CommandLine, T("Command Line"))
@Html.TextBoxFor(m => m.CommandLine, new { style = "width:100%;" }) @Html.TextBoxFor(m => m.CommandLine, new { style = "width:100%;" })
@Html.ValidationMessageFor(m => m.CommandLine) @Html.ValidationMessageFor(m => m.CommandLine)
<pre>@Model.Results</pre> <pre>@Model.Results</pre>

View File

@@ -22,7 +22,7 @@
</fieldset> </fieldset>
} }
<fieldset> <fieldset>
@Html.LabelFor(m=>m.FeedUrl) @Html.LabelFor(m => m.FeedUrl, T("Feed Url"))
@Html.DropDownListFor(m => m.FeedUrl, new[]{new SelectListItem{Text=T("Download").ToString(),Value="Download"}}.Concat( Model.Sources.Select(x => new SelectListItem { Text = T("Push to {0}", x.FeedUrl).ToString(), Value = x.FeedUrl }))) @Html.DropDownListFor(m => m.FeedUrl, new[]{new SelectListItem{Text=T("Download").ToString(),Value="Download"}}.Concat( Model.Sources.Select(x => new SelectListItem { Text = T("Push to {0}", x.FeedUrl).ToString(), Value = x.FeedUrl })))
@Html.ValidationMessageFor(m=>m.FeedUrl) @Html.ValidationMessageFor(m=>m.FeedUrl)
</fieldset> </fieldset>

View File

@@ -39,7 +39,7 @@
<a class="button" href="@item.PackageStreamUri">@T("Download")</a> <a class="button" href="@item.PackageStreamUri">@T("Download")</a>
<h5>@T("By") @author</h5> <h5>@T("By") @author</h5>
<p> <p>
@T("Version: {0}", "1.0")<br /> @T("Version: {0}", item.SyndicationItem.ElementExtensions.ReadElementExtensions<string>("Version", "http://orchardproject.net").FirstOrDefault() ?? T("N/A").Text)<br />
@(item.SyndicationItem.Summary == null ? T("(No description").Text : item.SyndicationItem.Summary.Text)<br /> @(item.SyndicationItem.Summary == null ? T("(No description").Text : item.SyndicationItem.Summary.Text)<br />
</p> </p>
</div> </div>

View File

@@ -1,4 +1,4 @@
<Placement> <Placement>
<Place Parts_Tags_ShowTags="Header:after.7"/> <Place Parts_Tags_ShowTags="Header:after.7"/>
<Place Parts_Tags_Editor="Primary:7"/> <Place Parts_Tags_Edit="Primary:7"/>
</Placement> </Placement>

View File

@@ -5,7 +5,7 @@
@Html.ValidationSummary() @Html.ValidationSummary()
<fieldset> <fieldset>
@Html.LabelFor(m=>m.TagName) @Html.LabelFor(m => m.TagName, T("Tag Name"))
@Html.TextBoxFor(m=>m.TagName, new { @class = "text" }) @Html.TextBoxFor(m=>m.TagName, new { @class = "text" })
</fieldset> </fieldset>

View File

@@ -5,7 +5,7 @@
@Html.ValidationSummary() @Html.ValidationSummary()
<fieldset> <fieldset>
@Html.HiddenFor(m=>m.Id) @Html.HiddenFor(m=>m.Id)
@Html.LabelFor(m=>m.TagName) @Html.LabelFor(m => m.TagName, T("Tag Name"))
@Html.TextBoxFor(m=>m.TagName, new { @class = "text" }) @Html.TextBoxFor(m=>m.TagName, new { @class = "text" })
</fieldset> </fieldset>

View File

@@ -1,6 +1,6 @@
@model Orchard.Tags.ViewModels.EditTagsViewModel @model Orchard.Tags.ViewModels.EditTagsViewModel
<fieldset> <fieldset>
@Html.LabelFor(m => m.Tags) @Html.LabelFor(m => m.Tags, T("Tags"))
@Html.TextBoxFor(m => m.Tags, new { @class = "large text" }) @Html.TextBoxFor(m => m.Tags, new { @class = "large text" })
</fieldset> </fieldset>

View File

@@ -154,11 +154,11 @@ namespace Orchard.Themes.Services {
foreach (var theme in requestTheme) { foreach (var theme in requestTheme) {
var t = GetThemeByName(theme.ThemeName); var t = GetThemeByName(theme.ThemeName);
if (t != null) if (t != null && t.Enabled)
return t; return t;
} }
return null; return GetThemeByName("SafeMode");
} }
public ITheme GetThemeByName(string name) { public ITheme GetThemeByName(string name) {
@@ -221,7 +221,8 @@ namespace Orchard.Themes.Services {
} }
private bool IsThemeEnabled(ExtensionDescriptor descriptor) { private bool IsThemeEnabled(ExtensionDescriptor descriptor) {
return _shellDescriptorManager.GetShellDescriptor().Features.Any(sf => sf.Name == descriptor.Name); return (descriptor.Name == "TheAdmin" || descriptor.Name == "SafeMode") ||
_shellDescriptorManager.GetShellDescriptor().Features.Any(sf => sf.Name == descriptor.Name);
} }
private ITheme CreateTheme(ExtensionDescriptor descriptor) { private ITheme CreateTheme(ExtensionDescriptor descriptor) {

View File

@@ -5,25 +5,25 @@
@Html.ValidationSummary() @Html.ValidationSummary()
<fieldset> <fieldset>
@Html.LabelFor(m=>m.UserName) @Html.LabelFor(m => m.UserName, T("User Name"))
@Html.TextBoxFor(m=>m.UserName, new { @class = "textMedium" }) @Html.TextBoxFor(m=>m.UserName, new { @class = "textMedium" })
@Html.ValidationMessageFor(m=>m.UserName, "*") @Html.ValidationMessageFor(m=>m.UserName, "*")
</fieldset> </fieldset>
<fieldset> <fieldset>
@Html.LabelFor(m=>m.Email) @Html.LabelFor(m => m.Email, T("Email"))
@Html.TextBoxFor(m=>m.Email, new { @class = "textMedium" }) @Html.TextBoxFor(m=>m.Email, new { @class = "textMedium" })
@Html.ValidationMessageFor(m=>m.Email, "*") @Html.ValidationMessageFor(m=>m.Email, "*")
</fieldset> </fieldset>
<fieldset> <fieldset>
@Html.LabelFor(m=>m.Password) @Html.LabelFor(m => m.Password, T("Password"))
@Html.PasswordFor(m=>m.Password, new { @class = "textMedium" }) @Html.PasswordFor(m=>m.Password, new { @class = "textMedium" })
@Html.ValidationMessageFor(m=>m.Password, "*") @Html.ValidationMessageFor(m=>m.Password, "*")
</fieldset> </fieldset>
<fieldset> <fieldset>
@Html.LabelFor(m=>m.ConfirmPassword) @Html.LabelFor(m => m.ConfirmPassword, T("Confirm Password"))
@Html.PasswordFor(m=>m.ConfirmPassword, new { @class = "textMedium" }) @Html.PasswordFor(m=>m.ConfirmPassword, new { @class = "textMedium" })
@Html.ValidationMessageFor(m=>m.ConfirmPassword, "*") @Html.ValidationMessageFor(m=>m.ConfirmPassword, "*")
</fieldset> </fieldset>

View File

@@ -5,13 +5,13 @@
@Html.ValidationSummary() @Html.ValidationSummary()
@Html.EditorFor(m=>m.Id) @Html.EditorFor(m=>m.Id)
<fieldset> <fieldset>
@Html.LabelFor(m=>m.UserName) @Html.LabelFor(m => m.UserName, T("User Name"))
@Html.TextBoxFor(m=>m.UserName, new { @class = "textMedium" }) @Html.TextBoxFor(m=>m.UserName, new { @class = "textMedium" })
@Html.ValidationMessageFor(m=>m.UserName, "*") @Html.ValidationMessageFor(m=>m.UserName, "*")
</fieldset> </fieldset>
<fieldset> <fieldset>
@Html.LabelFor(m=>m.Email) @Html.LabelFor(m => m.Email, T("Email"))
@Html.TextBoxFor(m=>m.Email, new { @class = "textMedium" }) @Html.TextBoxFor(m=>m.Email, new { @class = "textMedium" })
@Html.ValidationMessageFor(m=>m.Email, "*") @Html.ValidationMessageFor(m=>m.Email, "*")
</fieldset> </fieldset>

View File

@@ -7,6 +7,7 @@ using Orchard.Core.Contents.Controllers;
using Orchard.Localization; using Orchard.Localization;
using Orchard.UI.Admin; using Orchard.UI.Admin;
using Orchard.UI.Notify; using Orchard.UI.Notify;
using Orchard.UI.Widgets;
using Orchard.Widgets.Models; using Orchard.Widgets.Models;
using Orchard.Widgets.Services; using Orchard.Widgets.Services;
using Orchard.Widgets.ViewModels; using Orchard.Widgets.ViewModels;
@@ -19,13 +20,16 @@ namespace Orchard.Widgets.Controllers {
private const string NotAuthorizedManageWidgetsLabel = "Not authorized to manage widgets"; private const string NotAuthorizedManageWidgetsLabel = "Not authorized to manage widgets";
private readonly IWidgetsService _widgetsService; private readonly IWidgetsService _widgetsService;
private readonly IRuleManager _ruleManager;
public AdminController( public AdminController(
IOrchardServices services, IOrchardServices services,
IWidgetsService widgetsService) { IWidgetsService widgetsService,
IRuleManager ruleManager) {
Services = services; Services = services;
_widgetsService = widgetsService; _widgetsService = widgetsService;
_ruleManager = ruleManager;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
} }
@@ -171,6 +175,9 @@ namespace Orchard.Widgets.Controllers {
return HttpNotFound(); return HttpNotFound();
var model = Services.ContentManager.UpdateEditor(layerPart, this); var model = Services.ContentManager.UpdateEditor(layerPart, this);
ValidateLayer(layerPart);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
return View(model); return View(model);
@@ -216,6 +223,9 @@ namespace Orchard.Widgets.Controllers {
return HttpNotFound(); return HttpNotFound();
var model = Services.ContentManager.UpdateEditor(layerPart, this); var model = Services.ContentManager.UpdateEditor(layerPart, this);
ValidateLayer(layerPart);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {
Services.TransactionManager.Cancel(); Services.TransactionManager.Cancel();
return View(model); return View(model);
@@ -325,6 +335,27 @@ namespace Orchard.Widgets.Controllers {
RedirectToAction("Index"); RedirectToAction("Index");
} }
public bool ValidateLayer(LayerPart layer) {
if ( String.IsNullOrWhiteSpace(layer.LayerRule) ) {
layer.LayerRule = "true";
}
if(_widgetsService.GetLayers().Any(l => String.CompareOrdinal(l.Name, layer.Name) == 0)) {
ModelState.AddModelError("Name", T("A Layer with the same name already exists").Text);
return false;
}
try {
_ruleManager.Matches(layer.LayerRule);
}
catch ( Exception e ) {
ModelState.AddModelError("Description", T("The rule is not valid: {0}", e.Message).Text);
return false;
}
return true;
}
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
return base.TryUpdateModel(model, prefix, includeProperties, excludeProperties); return base.TryUpdateModel(model, prefix, includeProperties, excludeProperties);
} }

View File

@@ -1,7 +1,10 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Web.Mvc; using System.Web.Mvc;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Aspects;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Mvc.Filters; using Orchard.Mvc.Filters;
using Orchard.UI.Admin; using Orchard.UI.Admin;
using Orchard.UI.Widgets; using Orchard.UI.Widgets;
@@ -17,8 +20,13 @@ namespace Orchard.Widgets.Filters {
_contentManager = contentManager; _contentManager = contentManager;
_workContextAccessor = workContextAccessor; _workContextAccessor = workContextAccessor;
_ruleManager = ruleManager; _ruleManager = ruleManager;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
} }
public ILogger Logger { get; set; }
public Localizer T { get; private set; }
public void OnResultExecuting(ResultExecutingContext filterContext) { public void OnResultExecuting(ResultExecutingContext filterContext) {
// layers and widgets should only run on a full view rendering result // layers and widgets should only run on a full view rendering result
var viewResult = filterContext.Result as ViewResult; var viewResult = filterContext.Result as ViewResult;
@@ -42,8 +50,14 @@ namespace Orchard.Widgets.Filters {
List<int> activeLayerIds = new List<int>(); List<int> activeLayerIds = new List<int>();
foreach (var activeLayer in activeLayers) { foreach (var activeLayer in activeLayers) {
var context = workContext.HttpContext; var context = workContext.HttpContext;
if (_ruleManager.Matches(activeLayer.Record.LayerRule)) { // ignore the rule if it fails to execute
activeLayerIds.Add(activeLayer.ContentItem.Id); try {
if (_ruleManager.Matches(activeLayer.Record.LayerRule)) {
activeLayerIds.Add(activeLayer.ContentItem.Id);
}
}
catch(Exception e) {
Logger.Debug(e, T("An error occured during layer evaluation on: {0}", activeLayer.Name).Text);
} }
} }

View File

@@ -1,45 +1,64 @@
.widgetsbag-editor h5 { #main #widgets h2
{
border-bottom:none;
}
.widgetsbag-editor h5 {
color:#4c4c4c; color:#4c4c4c;
font-weight:bold; font-weight:bold;
} }
.widgets-availableWidgets { .widgets-availableWidgets {
float: right;
float: left; float: left;
width: 30%; width: 30%;
margin: 0 0 0 2em;
} }
.widgets-availableLayers { .widgets-availableLayers {
float: left; float: left;
margin: 0 0 0 2em; margin: 0 0 0 2em;
width: 45%; width: 60%;
min-width: 40%;
} }
.widgets-layerZones { .widgets-layerZones {
font-size: 1.4em; font-size: 1.4em;
float: left; float: left;
width: 70%; width: 60%;
border: 1px solid #eaeaea; border: 1px solid #eaeaea;
background: #fff; border:1px solid #ccc;
background: #fcfcfc;
} }
.widgets-layerZones .widgets-zone { .widgets-layerZones .widgets-zone {
background:#f5f5f5; background:#f5f5f5;
border: 1px solid #f1f1f1; border: 1px solid #f1f1f1;
padding: 1em 2em 1em 2em; padding: 1em 2em 1em 2em;
margin: 0 0 1em 0; margin: 0 0 .6em 0;
} }
.widgets-layerZones .widgets-zoneWidget { .widgets-layerZones .widgets-zoneWidget {
margin: 0 0 1em 0; margin: .6em;
padding: 1em 2em 1em 3em; padding: 1em 2em 1em 3em;
background:#ffffff; background:#ffffff;
border: 1px solid #f1f1f1; border: 1px solid #f1f1f1;
vertical-align: middle; vertical-align: middle;
} }
.widgets-availableLayers fieldset {
background: #F1F1F1;
padding: .6em;
}
.widgets-availableWidgets fieldset {
padding: 0;
}
.widgets-layers { .widgets-layers {
font-size: 1.4em; font-size: 1.4em;
margin: 1em 0 0 0; border:1px solid #ccc;
border-left:none;
float: left; float: left;
} }
@@ -65,4 +84,13 @@
.widgets-layerZones ul li ul { .widgets-layerZones ul li ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
}
.new-layer {
padding: .6em;
}
.new-layer a {
text-decoration: none;
font-weight: 600;
} }

View File

@@ -5,7 +5,7 @@
Style.Require("WidgetsAdmin"); Style.Require("WidgetsAdmin");
} }
<h1>@Html.TitleForPage(T("Manage Widgets").ToString())</h1> <h1>@Html.TitleForPage(T("Manage Widgets").ToString())</h1>
<div class="manage">@Html.ActionLink(T("Add a layer").ToString(), "AddLayer", new { }, new { @class = "button primaryAction" })</div>
@using(Html.BeginFormAntiForgeryPost()) { @using(Html.BeginFormAntiForgeryPost()) {
Html.ValidationSummary(); Html.ValidationSummary();
@@ -13,31 +13,7 @@
<div id="widgets"> <div id="widgets">
<div class="widgets-availableWidgets">
<h2>Available Widgets</h2>
<fieldset>
<table class="items" summary="@T("This is a table of the widgets currently available for use in your application.")">
<colgroup>
<col id="Col1" />
<col id="Col2" />
</colgroup>
<thead>
<tr>
<th scope="col">@T("Name")</th>
<th scope="col"></th>
</tr>
</thead>
@foreach (string widget in Model.WidgetTypes) {
<tr>
<td>@widget</td>
<td>@Html.ActionLink(T("Add").ToString(), "AddWidget", new { layerId = Model.CurrentLayer.Id, widgetType = widget })</td>
</tr>
}
</table>
</fieldset>
</div>
<div class="widgets-availableLayers"> <div class="widgets-availableLayers">
<h2>Widget Zones</h2> <h2>Widget Zones</h2>
@@ -92,9 +68,39 @@
</li> </li>
} }
} }
<ul> </ul>
<div class="new-layer">
@Html.ActionLink(T("+ Add a layer").ToString(), "AddLayer", new { })
</div>
</div> </div>
</fieldset> </fieldset>
</div> </div>
<div class="widgets-availableWidgets">
<h2>Available Widgets</h2>
<fieldset>
<table class="items" summary="@T("This is a table of the widgets currently available for use in your application.")">
<colgroup>
<col id="Col1" />
<col id="Col2" />
</colgroup>
<thead>
<tr>
<th scope="col">@T("Name")</th>
<th scope="col"></th>
</tr>
</thead>
@foreach (string widget in Model.WidgetTypes) {
<tr>
<td>@widget</td>
<td>@Html.ActionLink(T("Add").ToString(), "AddWidget", new { layerId = Model.CurrentLayer.Id, widgetType = widget })</td>
</tr>
}
</table>
</fieldset>
</div>
</div> </div>
} }

View File

@@ -1,16 +1,16 @@
@model Orchard.Widgets.Models.LayerPart @model Orchard.Widgets.Models.LayerPart
<fieldset> <fieldset>
@Html.LabelFor(layer => layer.Name) @Html.LabelFor(layer => layer.Name, T("Name"))
@Html.TextBoxFor(layer => layer.Name) @Html.TextBoxFor(layer => layer.Name)
</fieldset> </fieldset>
<fieldset> <fieldset>
@Html.LabelFor(layer => layer.Description) @Html.LabelFor(layer => layer.Description, T("Description"))
@Html.TextAreaFor(layer => layer.Description) @Html.TextAreaFor(layer => layer.Description)
</fieldset> </fieldset>
<fieldset> <fieldset>
@Html.LabelFor(layer => layer.LayerRule) @Html.LabelFor(layer => layer.LayerRule, T("Layer Rule"))
@Html.TextAreaFor(layer => layer.LayerRule) @Html.TextAreaFor(layer => layer.LayerRule)
</fieldset> </fieldset>

View File

@@ -1,11 +1,11 @@
@model Orchard.Widgets.Models.WidgetPart @model Orchard.Widgets.Models.WidgetPart
<fieldset> <fieldset>
@Html.LabelFor(widget => widget.Zone) @Html.LabelFor(widget => widget.Zone, T("Zone"))
@Html.DropDownListFor(widget => widget.Zone, new SelectList(Model.AvailableZones)) @Html.DropDownListFor(widget => widget.Zone, new SelectList(Model.AvailableZones))
</fieldset> </fieldset>
<fieldset> <fieldset>
@Html.LabelFor(widget => widget.Title) @Html.LabelFor(widget => widget.Title, T("Title"))
@Html.TextBoxFor(widget => widget.Title) @Html.TextBoxFor(widget => widget.Title)
</fieldset> </fieldset>

View File

@@ -194,7 +194,7 @@ namespace Orchard.Data.Migration.Interpreters {
} }
else { else {
if(command.Length > 0 || command.Precision > 0 || command.Scale > 0) { if(command.Length > 0 || command.Precision > 0 || command.Scale > 0) {
throw new OrchardException(T("Error while executing data migration: you need to specify the field's type in order to change it's properies")); throw new OrchardException(T("Error while executing data migration: you need to specify the field's type in order to change its properties"));
} }
} }