diff --git a/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs b/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs index acb37d83c..366d0854d 100644 --- a/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/BodyDriver.cs @@ -28,10 +28,10 @@ namespace Orchard.Core.Common.Drivers { var model = new BodyDisplayViewModel { BodyAspect = part, Text = BbcodeReplace(part.Text) }; return Combined( - Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPre").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5") : null, - Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.Manage").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5") : null, + Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPre").LongestMatch(displayType, "SummaryAdmin").Location("primary", "5") : null, + Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.Manage").LongestMatch(displayType, "SummaryAdmin").Location("primary", "5") : null, ContentPartTemplate(model, TemplateName, Prefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5"), - Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5") : null); + Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Common.Body.ManageWrapperPost").LongestMatch(displayType, "SummaryAdmin").Location("primary", "5") : null); } protected override DriverResult Editor(BodyAspect part) { diff --git a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Publish.SummaryAdmin.ascx b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Publish.SummaryAdmin.ascx index 5cd6df385..637f63204 100644 --- a/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Publish.SummaryAdmin.ascx +++ b/src/Orchard.Web/Core/Common/Views/DisplayTemplates/Parts/Common.Publish.SummaryAdmin.ascx @@ -1,7 +1,7 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> <% // todo: make this all work if (Model.HasPublished) { %> - <%:Html.ActionLink("View", "Item", new { controller = "Page", slug = "foo" /*Model.PublishedSlug*/ }, new { title = T("View") }) %><%:T(" | ") %><% + <%:Html.ItemDisplayLink(T("View").Text, Model.ContentItem) %><%:T(" | ") %><% if (Model.HasDraft) { %> " title="<%:T("Publish Draft") %>"><%:T("Publish Draft") %><%:T(" | ") %><% } %> diff --git a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs index b2836dde6..5a43930d6 100644 --- a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs @@ -162,7 +162,7 @@ namespace Orchard.Core.Contents.Controllers { return RedirectToAction("List"); } - private void PrepareEditorViewModel(ContentItemViewModel itemViewModel) { + private static void PrepareEditorViewModel(ContentItemViewModel itemViewModel) { if (string.IsNullOrEmpty(itemViewModel.TemplateName)) { itemViewModel.TemplateName = "Items/Contents.Item"; } diff --git a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Items/Contents.Item.Summary.ascx b/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Items/Contents.Item.Summary.ascx new file mode 100644 index 000000000..1a4db1a3c --- /dev/null +++ b/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Items/Contents.Item.Summary.ascx @@ -0,0 +1,5 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +

<%:Html.ItemDisplayLink(Model.Item) %>

+
+<% Html.Zone("primary", ":manage :metadata"); %> +
\ No newline at end of file diff --git a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Items/Contents.Item.SummaryAdmin.ascx b/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Items/Contents.Item.SummaryAdmin.ascx index 66722c110..c5f65fbf5 100644 --- a/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Items/Contents.Item.SummaryAdmin.ascx +++ b/src/Orchard.Web/Core/Contents/Views/DisplayTemplates/Items/Contents.Item.SummaryAdmin.ascx @@ -9,7 +9,7 @@
diff --git a/src/Orchard.Web/Core/Localization/Controllers/AdminController.cs b/src/Orchard.Web/Core/Localization/Controllers/AdminController.cs new file mode 100644 index 000000000..e47f32b7c --- /dev/null +++ b/src/Orchard.Web/Core/Localization/Controllers/AdminController.cs @@ -0,0 +1,76 @@ +using System; +using System.Web.Mvc; +using System.Web.Routing; +using Orchard.ContentManagement; +using Orchard.Core.Contents.ViewModels; +using Orchard.Localization; +using Orchard.Mvc.Results; +using Orchard.Mvc.ViewModels; + +namespace Orchard.Core.Localization.Controllers { + public class AdminController : Controller, IUpdateModel { + private readonly IContentManager _contentManager; + + public AdminController(IOrchardServices orchardServices, IContentManager contentManager) { + _contentManager = contentManager; + Services = orchardServices; + } + + public IOrchardServices Services { get; set; } + + public ActionResult Translate(int id, string from) { + var contentItem = _contentManager.Get(id, VersionOptions.Latest); + + if (contentItem == null) + return new NotFoundResult(); + + var model = new EditItemViewModel { + Id = id, + Content = _contentManager.BuildEditorModel(contentItem) + }; + + PrepareEditorViewModel(model.Content); + return View(model); + } + + [HttpPost, ActionName("Translate")] + public ActionResult TranslatePOST(int id) { + var contentItem = _contentManager.Get(id, VersionOptions.DraftRequired); + + if (contentItem == null) + return new NotFoundResult(); + + var viewModel = new EditItemViewModel(); + if (TryUpdateModel(viewModel)) + viewModel.Content = _contentManager.UpdateEditorModel(contentItem, this); + + //todo: create translation here + if (!ModelState.IsValid) { + Services.TransactionManager.Cancel(); + PrepareEditorViewModel(viewModel.Content); + return View(viewModel); + } + _contentManager.Publish(contentItem); + + var metadata = _contentManager.GetItemMetadata(viewModel.Content.Item); + if (metadata.EditorRouteValues == null) + return null; + + return RedirectToRoute(metadata.EditorRouteValues); + } + + private static void PrepareEditorViewModel(ContentItemViewModel itemViewModel) { + if (string.IsNullOrEmpty(itemViewModel.TemplateName)) { + itemViewModel.TemplateName = "Items/Contents.Item"; + } + } + + bool IUpdateModel.TryUpdateModel(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { + return TryUpdateModel(model, prefix, includeProperties, excludeProperties); + } + + void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) { + ModelState.AddModelError(key, errorMessage.ToString()); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs b/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs new file mode 100644 index 000000000..191af1e9c --- /dev/null +++ b/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs @@ -0,0 +1,35 @@ +using JetBrains.Annotations; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.Core.Common; +using Orchard.Core.Localization.Models; +using Orchard.Core.Localization.ViewModels; + +namespace Orchard.Core.Localization.Drivers { + [UsedImplicitly] + public class LocalizationDriver : ContentPartDriver { + public LocalizationDriver(IOrchardServices services) { + Services = services; + } + + public IOrchardServices Services { get; set; } + + protected override DriverResult Display(Localized part, string displayType) { + if (!Services.Authorizer.Authorize(Permissions.ChangeOwner)) { + return null; + } + + var model = new ContentTranslationsViewModel(part); + return ContentPartTemplate(model, "Parts/Localization.ContentTranslations").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5"); + } + + protected override DriverResult Editor(Localized part) { + var model = new LocalizationEditorViewModel(); + //if (part.ContentItem.Is()) + + return ContentPartTemplate(model, "Parts/Localization.IsLocalized").Location("primary", "before.3"); + } + } + + public class LocalizationEditorViewModel {} +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/Drivers/LocalizedDriver.cs b/src/Orchard.Web/Core/Localization/Drivers/LocalizedDriver.cs deleted file mode 100644 index 5dc8d10ae..000000000 --- a/src/Orchard.Web/Core/Localization/Drivers/LocalizedDriver.cs +++ /dev/null @@ -1,24 +0,0 @@ -using JetBrains.Annotations; -using Orchard.ContentManagement.Drivers; -using Orchard.Core.Common; -using Orchard.Core.Localization.Models; -using Orchard.Core.Localization.ViewModels; - -namespace Orchard.Core.Localization.Drivers { - [UsedImplicitly] - public class LocalizedDriver : ContentPartDriver { - public LocalizedDriver(IOrchardServices services) { - Services = services; - } - - public IOrchardServices Services { get; set; } - - protected override DriverResult Display(Localized part, string displayType) { - if (!Services.Authorizer.Authorize(Permissions.ChangeOwner)) - return null; - - var model = new ContentTranslationsViewModel(part); - return ContentPartTemplate(model, "Parts/Localized.ContentTranslations").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5"); - } - } -} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/Handlers/LocalizedHandler.cs b/src/Orchard.Web/Core/Localization/Handlers/LocalizationHandler.cs similarity index 88% rename from src/Orchard.Web/Core/Localization/Handlers/LocalizedHandler.cs rename to src/Orchard.Web/Core/Localization/Handlers/LocalizationHandler.cs index b8a35dd42..04596ba31 100644 --- a/src/Orchard.Web/Core/Localization/Handlers/LocalizedHandler.cs +++ b/src/Orchard.Web/Core/Localization/Handlers/LocalizationHandler.cs @@ -9,11 +9,11 @@ using Orchard.Localization.Services; namespace Orchard.Core.Localization.Handlers { [UsedImplicitly] - public class LocalizedHandler : ContentHandler { + public class LocalizationHandler : ContentHandler { private readonly ICultureManager _cultureManager; private readonly IContentManager _contentManager; - public LocalizedHandler(IRepository localizedRepository, ICultureManager cultureManager, IContentManager contentManager) { + public LocalizationHandler(IRepository localizedRepository, ICultureManager cultureManager, IContentManager contentManager) { _cultureManager = cultureManager; _contentManager = contentManager; T = NullLocalizer.Instance; diff --git a/src/Orchard.Web/Core/Localization/Views/Admin/Translate.ascx b/src/Orchard.Web/Core/Localization/Views/Admin/Translate.ascx new file mode 100644 index 000000000..cc48f9092 --- /dev/null +++ b/src/Orchard.Web/Core/Localization/Views/Admin/Translate.ascx @@ -0,0 +1,7 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %> +

<%:Html.TitleForPage(T("Translate Content").ToString())%>

+<% using (Html.BeginFormAntiForgeryPost()) { %> +<%:Html.ValidationSummary() %> +<%:Html.EditorForItem(m=>m.Content) %> +<%} %> diff --git a/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localized.ContentTranslations.SummaryAdmin.ascx b/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.SummaryAdmin.ascx similarity index 100% rename from src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localized.ContentTranslations.SummaryAdmin.ascx rename to src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.SummaryAdmin.ascx diff --git a/src/Orchard.Web/Core/Localization/Views/EditorTemplates/Parts/Localization.CultureSelection.ascx b/src/Orchard.Web/Core/Localization/Views/EditorTemplates/Parts/Localization.CultureSelection.ascx new file mode 100644 index 000000000..f05cec4a7 --- /dev/null +++ b/src/Orchard.Web/Core/Localization/Views/EditorTemplates/Parts/Localization.CultureSelection.ascx @@ -0,0 +1,4 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +
+ [do the translate content] +
\ No newline at end of file diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index e8bf3efd9..573e12cac 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -82,9 +82,10 @@ + - + @@ -135,7 +136,7 @@ - + @@ -229,11 +230,14 @@ + - + + + @@ -289,9 +293,7 @@ - - - + diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Controllers/AdminController.cs index 7e3fe0e52..50bd9630c 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentTypes/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Controllers/AdminController.cs @@ -364,11 +364,11 @@ namespace Orchard.ContentTypes.Controllers { #endregion - public new bool TryUpdateModel(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) where TModel : class { + bool IUpdateModel.TryUpdateModel(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { return base.TryUpdateModel(model, prefix, includeProperties, excludeProperties); } - public void AddModelError(string key, LocalizedString errorMessage) { + void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) { ModelState.AddModelError(key, errorMessage.ToString()); } } diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.ascx b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.ascx index 0b660d61c..0868b17b0 100644 --- a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.ascx +++ b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.ascx @@ -39,7 +39,7 @@

<%:feature.Descriptor.Name %>

<%:feature.Descriptor.Description %>

<% - if (feature.Descriptor.Dependencies != null) { %> + if (feature.Descriptor.Dependencies != null && feature.Descriptor.Dependencies.Any()) { %>

<%: T("Depends on:")%>

<%: Html.UnorderedList( diff --git a/src/Orchard.Web/Modules/Orchard.Pages/Drivers/PageDriver.cs b/src/Orchard.Web/Modules/Orchard.Pages/Drivers/PageDriver.cs index 9fdcab22a..7c0791fc5 100644 --- a/src/Orchard.Web/Modules/Orchard.Pages/Drivers/PageDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Pages/Drivers/PageDriver.cs @@ -51,14 +51,6 @@ namespace Orchard.Pages.Drivers { }; } - public override RouteValueDictionary GetCreateRouteValues(Page page) { - return new RouteValueDictionary { - {"Area", "Orchard.Pages"}, - {"Controller", "Admin"}, - {"Action", "Create"}, - }; - } - protected override DriverResult Display(Page page, string displayType) { return ContentItemTemplate("Items/Pages.Page").LongestMatch(displayType, "Summary", "SummaryAdmin"); }