--HG--
branch : 1.x
This commit is contained in:
bertrandleroy
2012-01-05 16:15:05 -08:00
43 changed files with 418 additions and 112 deletions

View File

@@ -23,12 +23,12 @@ namespace Orchard.Core.Common {
}
[Shape]
public IHtmlString PublishedState(HtmlHelper html, DateTime createdDateTimeUtc, DateTime? publisheddateTimeUtc) {
public IHtmlString PublishedState(dynamic Display, DateTime createdDateTimeUtc, DateTime? publisheddateTimeUtc) {
if (!publisheddateTimeUtc.HasValue) {
return T("Draft");
}
return html.DateTime(createdDateTimeUtc);
return Display.DateTime(DateTimeUtc: createdDateTimeUtc);
}
[Shape]

View File

@@ -1,4 +1,5 @@
using System.Net;
using System.Linq;
using System.Net;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
@@ -44,7 +45,8 @@ namespace Orchard.Core.Settings.Drivers {
var model = new SiteSettingsPartViewModel {
Site = site,
SiteCultures = _cultureManager.ListCultures()
SiteCultures = _cultureManager.ListCultures(),
TimeZones = TimeZoneInfo.GetSystemTimeZones()
};
return ContentShape("Parts_Settings_SiteSettingsPart",
@@ -55,7 +57,8 @@ namespace Orchard.Core.Settings.Drivers {
var site = _siteService.GetSiteSettings().As<SiteSettingsPart>();
var model = new SiteSettingsPartViewModel {
Site = site,
SiteCultures = _cultureManager.ListCultures()
SiteCultures = _cultureManager.ListCultures(),
TimeZones = TimeZoneInfo.GetSystemTimeZones()
};
var previousBaseUrl = model.Site.BaseUrl;

View File

@@ -91,9 +91,16 @@ namespace Orchard.Core.Settings {
.Column<string>("SiteCulture")
.Column<string>("ResourceDebugMode", c => c.WithDefault("FromAppSetting"))
.Column<int>("PageSize")
.Column<string>("SiteTimeZone")
);
return 1;
SchemaBuilder.CreateTable("SiteSettings2PartRecord",
table => table
.ContentPartRecord()
.Column<string>("BaseUrl", c => c.Unlimited())
);
return 3;
}
public int UpdateFrom1() {
@@ -105,5 +112,14 @@ namespace Orchard.Core.Settings {
return 2;
}
public int UpdateFrom2() {
SchemaBuilder.AlterTable("SiteSettingsPartRecord",
table => table
.AddColumn<string>("SiteTimeZone")
);
return 3;
}
}
}

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement;
using Orchard.Data.Conventions;
using Orchard.Settings;
@@ -45,6 +46,11 @@ namespace Orchard.Core.Settings.Models {
set { Record.PageSize = value; }
}
public string SiteTimeZone {
get { return Record.SiteTimeZone; }
set { Record.SiteTimeZone = value; }
}
[StringLengthMax]
public string BaseUrl {
get {

View File

@@ -1,4 +1,5 @@
using Orchard.ContentManagement.Records;
using System;
using Orchard.ContentManagement.Records;
using Orchard.Settings;
namespace Orchard.Core.Settings.Models {
@@ -24,5 +25,7 @@ namespace Orchard.Core.Settings.Models {
public virtual ResourceDebugMode ResourceDebugMode { get; set; }
public virtual int PageSize { get; set; }
public virtual string SiteTimeZone { get; set; }
}
}

View File

@@ -36,6 +36,7 @@ namespace Orchard.Core.Settings.Services {
item.Record.SiteSalt = Guid.NewGuid().ToString("N");
item.Record.SiteName = "My Orchard Project Application";
item.Record.PageTitleSeparator = " - ";
item.Record.SiteTimeZone = TimeZoneInfo.Local.Id;
}).ContentItem;
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Orchard.Core.Settings.Models;
using Orchard.Settings;
@@ -7,6 +8,7 @@ namespace Orchard.Core.Settings.ViewModels {
public class SiteSettingsPartViewModel {
public SiteSettingsPart Site { get; set; }
public IEnumerable<string> SiteCultures { get; set; }
public IEnumerable<TimeZoneInfo> TimeZones { get; set; }
[HiddenInput(DisplayValue = false)]
public int Id {
@@ -47,5 +49,10 @@ namespace Orchard.Core.Settings.ViewModels {
get { return Site.BaseUrl; }
set { Site.BaseUrl = value; }
}
public string TimeZone {
get { return Site.SiteTimeZone; }
set { Site.SiteTimeZone = value; }
}
}
}

View File

@@ -26,6 +26,12 @@
@Html.ValidationMessage("SiteCulture", "*")
<p>@Html.ActionLink(T("Add or remove supported cultures for the site.").ToString(), "Culture")</p>
</div>
<div>
<label for="TimeZone">@T("Default Time Zone")</label>
@Html.DropDownList("TimeZone", new[] { new SelectListItem { Text = T("Local to server").Text, Value = "" } }.Union(new SelectList(Model.TimeZones, "Id", "", Model.TimeZone)))
@Html.ValidationMessage("TimeZone", "*")
<span class="hint">@T("Determines the default time zone which will should be used to display date and times.")</span>
</div>
<div>
<label for="PageTitleSeparator">@T("Page title separator")</label>
@Html.EditorFor(x => x.PageTitleSeparator)

View File

@@ -7,22 +7,27 @@ using Orchard.Mvc.Html;
using Orchard.Services;
namespace Orchard.Core.Shapes {
public class DateTimeShapes : ISingletonDependency {
public class DateTimeShapes : IDependency {
private readonly IClock _clock;
private readonly IWorkContextAccessor _workContextAccessor;
public DateTimeShapes(IClock clock) {
public DateTimeShapes(
IClock clock,
IWorkContextAccessor workContextAccessor
) {
_clock = clock;
_workContextAccessor = workContextAccessor;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
[Shape]
public IHtmlString DateTimeRelative(HtmlHelper Html, DateTime dateTimeUtc) {
public IHtmlString DateTimeRelative(dynamic Display, DateTime dateTimeUtc) {
var time = _clock.UtcNow - dateTimeUtc;
if (time.TotalDays > 7)
return Html.DateTime(dateTimeUtc.ToLocalTime(), T("'on' MMM d yyyy 'at' h:mm tt"));
return Display.DateTime(DateTimeUtc: dateTimeUtc, CustomFormat: T("'on' MMM d yyyy 'at' h:mm tt"));
if (time.TotalHours > 24)
return T.Plural("1 day ago", "{0} days ago", time.Days);
if (time.TotalMinutes > 60)
@@ -34,5 +39,30 @@ namespace Orchard.Core.Shapes {
return T("a moment ago");
}
[Shape]
public IHtmlString DateTime(DateTime DateTimeUtc, LocalizedString CustomFormat) {
//using a LocalizedString forces the caller to use a localizable format
if (CustomFormat == null || String.IsNullOrWhiteSpace(CustomFormat.Text)) {
return DateTime(DateTimeUtc, T("MMM d yyyy h:mm tt"));
}
return new MvcHtmlString(ConvertToDisplayTime(DateTimeUtc).ToString(CustomFormat.Text));
}
/// <summary>
/// Converts a Coordinated Universal Time (UTC) to the time in the current time zone.
/// </summary>
/// <param name="dateTimeUtc">The Coordinated Universal Time (UTC).</param>
/// <returns>The date and time in the selected time zone. Its System.DateTime.Kind property is System.DateTimeKind.Utc if the current zone is System.TimeZoneInfo.Utc; otherwise, its System.DateTime.Kind property is System.DateTimeKind.Unspecified.</returns>
private DateTime ConvertToDisplayTime(DateTime dateTimeUtc) {
// get the time zone for the current request
var timeZone = _workContextAccessor.GetContext().CurrentTimeZone;
return TimeZoneInfo.ConvertTimeFromUtc(dateTimeUtc, timeZone);
}
}
}

View File

@@ -4,7 +4,7 @@
<ul class="pageStatus">
<li>
<img class="icon" src="@Href("~/Modules/Orchard.ArchiveLater/Content/Admin/images/scheduled.gif")" alt="@T("Scheduled")" title="@T("The page is scheduled for archiving")" />@T("Unpublish on")
@Html.DateTime((DateTime)Model.ScheduledArchiveUtc.ToLocalTime(), T("M/d/yyyy h:mm tt"))
@Display.DateTime(DateTimeUtc: (DateTime)Model.ScheduledArchiveUtc.ToLocalTime(), CustomFormat: T("M/d/yyyy h:mm tt"))
&nbsp;&#124;&nbsp;
</li>
</ul>

View File

@@ -83,7 +83,7 @@
@text
}
</td>
<td>@Html.DateTime(commentEntry.Comment.CommentDateUtc.GetValueOrDefault())</td>
<td>@Display.DateTime(DateTimeUtc: commentEntry.Comment.CommentDateUtc.GetValueOrDefault())</td>
<td>
<ul class="actions">
<li class="construct">

View File

@@ -77,7 +77,7 @@
</td>
<td>
@* would ideally have permalinks for individual comments *@
<p><a href="@Url.ItemDisplayUrl(commentEntry.CommentedOn)#comments"><time>@Html.DateTime(commentEntry.Comment.CommentDateUtc.GetValueOrDefault())</time></a></p>
<p><a href="@Url.ItemDisplayUrl(commentEntry.CommentedOn)#comments"><time>@Display.DateTime(DateTimeUtc: commentEntry.Comment.CommentDateUtc.GetValueOrDefault())</time></a></p>
@if (commentEntry.Comment.CommentText != null) {
var ellipsized = Html.Ellipsize(commentEntry.Comment.CommentText, 500);
var paragraphed = new HtmlString(ellipsized.ToHtmlString().Replace("\r\n", "</p><p>"));

View File

@@ -2,8 +2,8 @@
<fieldset class="manage-field">
<h3>@Model.DisplayName <span>(@Model.FieldDefinition.Name)</span></h3>
<div class="manage">
@Html.ActionLink(T("Edit").Text, "EditField", new { area = "Orchard.ContentTypes", id = Model.Part.Name, Model.Name }, new { itemprop = "RemoveUrl UnsafeUrl" }) |
@Html.ActionLink(T("Remove").Text, "RemoveFieldFrom", new { area = "Orchard.ContentTypes", id = Model.Part.Name, Model.Name }, new { itemprop = "RemoveUrl UnsafeUrl" }) @* <- some experimentation *@
@Html.ActionLink(T("Edit").Text, "EditField", new { area = "Orchard.ContentTypes", id = Model.Part.Name, Model.Name }) |
@Html.ActionLink(T("Remove").Text, "RemoveFieldFrom", new { area = "Orchard.ContentTypes", id = Model.Part.Name, Model.Name }, new { itemprop = "RemoveUrl UnsafeUrl" })
</div>
<div class="details">
@{Html.RenderTemplates(Model.Templates);}

View File

@@ -72,7 +72,7 @@ namespace Orchard.Modules.Services {
/// <param name="force">Boolean parameter indicating if the feature should enable it's dependencies if required or fail otherwise.</param>
public void EnableFeatures(IEnumerable<string> featureIds, bool force) {
foreach (string featureId in _featureManager.EnableFeatures(featureIds, force)) {
var featureName = _featureManager.GetAvailableFeatures().Where(f => f.Id == featureId).First().Name;
var featureName = _featureManager.GetAvailableFeatures().First(f => f.Id.Equals(featureId, StringComparison.OrdinalIgnoreCase)).Name;
Services.Notifier.Information(T("{0} was enabled", featureName));
}
}

View File

@@ -49,16 +49,17 @@
}
var dependencies = (from d in feature.Descriptor.Dependencies
select (from f in Model.Features where f.Descriptor.Id == d select f).SingleOrDefault()).Where(f => f != null).OrderBy(f => f.Descriptor.Name);
select (from f in Model.Features where f.Descriptor.Id.Equals(d, StringComparison.OrdinalIgnoreCase) select f).SingleOrDefault()).Where(f => f != null).OrderBy(f => f.Descriptor.Name);
var missingDependencies = feature.Descriptor.Dependencies
.Where(d => !Model.Features.Any(f => f.Descriptor.Id == d));
.Where(d => !Model.Features.Any(f => f.Descriptor.Id.Equals(d, StringComparison.OrdinalIgnoreCase)));
showDisable = categoryName.ToString() != "Core";
showEnable = missingDependencies.Count() == 0 && feature.Descriptor.Id != "Orchard.Setup";
showEnable = !missingDependencies.Any() && feature.Descriptor.Id != "Orchard.Setup";
<li class="@featureClassName" id="@featureId" title="@T("{0} is {1}", Html.AttributeEncode(featureName), featureState)">
<div class="summary">
<div class="properties">
<h3>@featureName</h3>
<p class="description">@feature.Descriptor.Description</p>@if (feature.Descriptor.Dependencies != null && feature.Descriptor.Dependencies.Any()) {
<p class="description">@feature.Descriptor.Description</p>
@if (feature.Descriptor.Dependencies != null && feature.Descriptor.Dependencies.Any()) {
<div class="dependencies">
<h4>@T("Depends on:")</h4>
@Html.UnorderedList(dependencies,

View File

@@ -48,7 +48,7 @@ namespace Orchard.MultiTenancy.Services {
ExtensionDescriptor theme = descriptor;
if (!theme.Tags.Contains("hidden")) {
if (theme.Tags == null || !theme.Tags.Contains("hidden")) {
themes.Add(theme);
}
}

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Web.Hosting;
using System.Web.Mvc;
using System.Xml.Linq;
using NuGet;
using Orchard.Environment.Configuration;
using Orchard.Environment.Extensions.Models;
@@ -227,8 +228,17 @@ namespace Orchard.Packaging.Controllers {
.Where(feature => feature.Enable)
.Select(feature => feature.FeatureDescriptor.Id);
// Enable the features and its dependencies
_moduleService.EnableFeatures(featureIds, true);
// Enable the features and its dependencies using recipes, so that they are run after the module's recipes
var recipe = new Recipe {
RecipeSteps = featureIds.Select(
x => new RecipeStep {
Name = "Feature",
Step = new XElement("Feature", new XAttribute("enable", x))
})
};
_recipeManager.Execute(recipe);
}
} catch (Exception exception) {
Services.Notifier.Error(T("Post installation steps failed with error: {0}", exception.Message));

View File

@@ -30,7 +30,7 @@
}
else {
<img class="icon" src="@Href("~/Modules/Orchard.PublishLater/Content/Admin/images/scheduled.gif")" alt="@T("Scheduled")" title="@T("The page is scheduled for publishing")" /><text> @T("Scheduled") </text>
@Html.DateTime(((DateTime?)Model.ScheduledPublishUtc).Value.ToLocalTime(), T("M/d/yyyy h:mm tt"))
@Display.DateTime(((DateTime?)Model.ScheduledPublishUtc).Value.ToLocalTime(), T("M/d/yyyy h:mm tt"))
}&nbsp;&#124;&nbsp;</li>
}
</ul>

View File

@@ -188,6 +188,10 @@ namespace Orchard.Setup {
public string BaseUrl {
get { return ""; }
}
public string SiteTimeZone {
get { return TimeZoneInfo.Local.Id; }
}
}
}
}

View File

@@ -50,10 +50,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\autofac\Autofac.Integration.Web.dll</HintPath>
</Reference>
<Reference Include="Autofac.Integration.Web.Mvc, Version=2.1.13.813, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\autofac\Autofac.Integration.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\aspnetmvc\Microsoft.Web.Infrastructure.dll</HintPath>