--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
@using Orchard.Core.Common.ViewModels;
<fieldset>
@Html.LabelFor(m=>m.Owner)
@Html.LabelFor(m => m.Owner, T("Owner"))
@Html.EditorFor(m=>m.Owner)
@Html.ValidationMessageFor(m=>m.Owner)
</fieldset>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -22,7 +22,7 @@
</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.ValidationMessageFor(m=>m.FeedUrl)
</fieldset>

View File

@@ -39,7 +39,7 @@
<a class="button" href="@item.PackageStreamUri">@T("Download")</a>
<h5>@T("By") @author</h5>
<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 />
</p>
</div>

View File

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

View File

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

View File

@@ -5,7 +5,7 @@
@Html.ValidationSummary()
<fieldset>
@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" })
</fieldset>

View File

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

View File

@@ -154,11 +154,11 @@ namespace Orchard.Themes.Services {
foreach (var theme in requestTheme) {
var t = GetThemeByName(theme.ThemeName);
if (t != null)
if (t != null && t.Enabled)
return t;
}
return null;
return GetThemeByName("SafeMode");
}
public ITheme GetThemeByName(string name) {
@@ -221,7 +221,8 @@ namespace Orchard.Themes.Services {
}
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) {

View File

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

View File

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

View File

@@ -7,6 +7,7 @@ using Orchard.Core.Contents.Controllers;
using Orchard.Localization;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
using Orchard.UI.Widgets;
using Orchard.Widgets.Models;
using Orchard.Widgets.Services;
using Orchard.Widgets.ViewModels;
@@ -19,13 +20,16 @@ namespace Orchard.Widgets.Controllers {
private const string NotAuthorizedManageWidgetsLabel = "Not authorized to manage widgets";
private readonly IWidgetsService _widgetsService;
private readonly IRuleManager _ruleManager;
public AdminController(
IOrchardServices services,
IWidgetsService widgetsService) {
IWidgetsService widgetsService,
IRuleManager ruleManager) {
Services = services;
_widgetsService = widgetsService;
_ruleManager = ruleManager;
T = NullLocalizer.Instance;
}
@@ -171,6 +175,9 @@ namespace Orchard.Widgets.Controllers {
return HttpNotFound();
var model = Services.ContentManager.UpdateEditor(layerPart, this);
ValidateLayer(layerPart);
if (!ModelState.IsValid) {
Services.TransactionManager.Cancel();
return View(model);
@@ -216,6 +223,9 @@ namespace Orchard.Widgets.Controllers {
return HttpNotFound();
var model = Services.ContentManager.UpdateEditor(layerPart, this);
ValidateLayer(layerPart);
if (!ModelState.IsValid) {
Services.TransactionManager.Cancel();
return View(model);
@@ -325,6 +335,27 @@ namespace Orchard.Widgets.Controllers {
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) {
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 Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Mvc.Filters;
using Orchard.UI.Admin;
using Orchard.UI.Widgets;
@@ -17,8 +20,13 @@ namespace Orchard.Widgets.Filters {
_contentManager = contentManager;
_workContextAccessor = workContextAccessor;
_ruleManager = ruleManager;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
}
public ILogger Logger { get; set; }
public Localizer T { get; private set; }
public void OnResultExecuting(ResultExecutingContext filterContext) {
// layers and widgets should only run on a full view rendering result
var viewResult = filterContext.Result as ViewResult;
@@ -42,8 +50,14 @@ namespace Orchard.Widgets.Filters {
List<int> activeLayerIds = new List<int>();
foreach (var activeLayer in activeLayers) {
var context = workContext.HttpContext;
if (_ruleManager.Matches(activeLayer.Record.LayerRule)) {
activeLayerIds.Add(activeLayer.ContentItem.Id);
// ignore the rule if it fails to execute
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;
font-weight:bold;
}
.widgets-availableWidgets {
float: right;
float: left;
width: 30%;
margin: 0 0 0 2em;
}
.widgets-availableLayers {
float: left;
margin: 0 0 0 2em;
width: 45%;
width: 60%;
min-width: 40%;
}
.widgets-layerZones {
font-size: 1.4em;
float: left;
width: 70%;
width: 60%;
border: 1px solid #eaeaea;
background: #fff;
border:1px solid #ccc;
background: #fcfcfc;
}
.widgets-layerZones .widgets-zone {
background:#f5f5f5;
border: 1px solid #f1f1f1;
padding: 1em 2em 1em 2em;
margin: 0 0 1em 0;
margin: 0 0 .6em 0;
}
.widgets-layerZones .widgets-zoneWidget {
margin: 0 0 1em 0;
margin: .6em;
padding: 1em 2em 1em 3em;
background:#ffffff;
border: 1px solid #f1f1f1;
vertical-align: middle;
}
.widgets-availableLayers fieldset {
background: #F1F1F1;
padding: .6em;
}
.widgets-availableWidgets fieldset {
padding: 0;
}
.widgets-layers {
font-size: 1.4em;
margin: 1em 0 0 0;
border:1px solid #ccc;
border-left:none;
float: left;
}
@@ -65,4 +84,13 @@
.widgets-layerZones ul li ul {
margin: 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");
}
<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()) {
Html.ValidationSummary();
@@ -13,31 +13,7 @@
<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">
<h2>Widget Zones</h2>
@@ -92,9 +68,39 @@
</li>
}
}
<ul>
</ul>
<div class="new-layer">
@Html.ActionLink(T("+ Add a layer").ToString(), "AddLayer", new { })
</div>
</div>
</fieldset>
</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>
}

View File

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

View File

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

View File

@@ -194,7 +194,7 @@ namespace Orchard.Data.Migration.Interpreters {
}
else {
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"));
}
}