mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-08-24 06:38:32 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
commit
e6649327e2
@ -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) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Common.ViewModels.CommonMetadataViewModel>" %>
|
||||
<% // 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) { %>
|
||||
<a href="<%:Html.AntiForgeryTokenGetUrl(Url.Action("Publish", new {id = Model.ContentItem.Id})) %>" title="<%:T("Publish Draft") %>"><%:T("Publish Draft") %></a><%:T(" | ") %><%
|
||||
} %>
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Mvc.ViewModels.ContentItemViewModel>" %>
|
||||
<h3><%:Html.ItemDisplayLink(Model.Item) %></h3>
|
||||
<div class="content">
|
||||
<% Html.Zone("primary", ":manage :metadata"); %>
|
||||
</div>
|
@ -9,7 +9,7 @@
|
||||
</div>
|
||||
<div class="related"><%
|
||||
Html.Zone("secondary"); %>
|
||||
<%:Html.ActionLink(T("Edit").ToString(), "Edit", new { id = Model.Item.Id }, new { title = T("Edit Page").ToString() })%><%:T(" | ") %>
|
||||
<%:Html.ItemEditLink(T("Edit").Text, Model.Item) %><%:T(" | ") %>
|
||||
<a href="<%:Html.AntiForgeryTokenGetUrl(Url.Action("Delete", new {id = Model.Item.Id})) %>" title="<%:T("Remove Page") %>"><%:T("Remove") %></a>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
|
@ -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>(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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Localized> {
|
||||
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<Localized>())
|
||||
|
||||
return ContentPartTemplate(model, "Parts/Localization.IsLocalized").Location("primary", "before.3");
|
||||
}
|
||||
}
|
||||
|
||||
public class LocalizationEditorViewModel {}
|
||||
}
|
@ -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<Localized> {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
@ -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<LocalizedRecord> localizedRepository, ICultureManager cultureManager, IContentManager contentManager) {
|
||||
public LocalizationHandler(IRepository<LocalizedRecord> localizedRepository, ICultureManager cultureManager, IContentManager contentManager) {
|
||||
_cultureManager = cultureManager;
|
||||
_contentManager = contentManager;
|
||||
T = NullLocalizer.Instance;
|
@ -0,0 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<EditItemViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
||||
<h1><%:Html.TitleForPage(T("Translate Content").ToString())%></h1>
|
||||
<% using (Html.BeginFormAntiForgeryPost()) { %>
|
||||
<%:Html.ValidationSummary() %>
|
||||
<%:Html.EditorForItem(m=>m.Content) %>
|
||||
<%} %>
|
@ -0,0 +1,4 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Localization.Drivers.LocalizationEditorViewModel>" %>
|
||||
<fieldset class="content-translations">
|
||||
[do the translate content]
|
||||
</fieldset>
|
@ -82,9 +82,10 @@
|
||||
<Compile Include="Contents\ViewModels\EditItemViewModel.cs" />
|
||||
<Compile Include="Contents\ViewModels\ListContentsViewModel.cs" />
|
||||
<Compile Include="Contents\ViewModels\ListContentTypesViewModel.cs" />
|
||||
<Compile Include="Localization\Controllers\AdminController.cs" />
|
||||
<Compile Include="Localization\DataMigrations\LocalizationDataMigration.cs" />
|
||||
<Compile Include="Localization\ViewModels\ContentTranslationsViewModel.cs" />
|
||||
<Compile Include="Localization\Drivers\LocalizedDriver.cs" />
|
||||
<Compile Include="Localization\Drivers\LocalizationDriver.cs" />
|
||||
<Compile Include="Navigation\DataMigrations\NavigationDataMigration.cs" />
|
||||
<Compile Include="Routable\Controllers\ItemController.cs" />
|
||||
<Compile Include="Routable\Drivers\RoutableDriver.cs" />
|
||||
@ -135,7 +136,7 @@
|
||||
<Compile Include="Feeds\Rss\RssResult.cs" />
|
||||
<Compile Include="HomePage\Controllers\HomeController.cs" />
|
||||
<Compile Include="HomePage\Routes.cs" />
|
||||
<Compile Include="Localization\Handlers\LocalizedHandler.cs" />
|
||||
<Compile Include="Localization\Handlers\LocalizationHandler.cs" />
|
||||
<Compile Include="Localization\Models\Localized.cs" />
|
||||
<Compile Include="Localization\Models\LocalizedRecord.cs" />
|
||||
<Compile Include="Navigation\AdminMenu.cs" />
|
||||
@ -229,11 +230,14 @@
|
||||
<Content Include="Contents\Views\Admin\List.ascx" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Items\Contents.Item.ascx" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Items\Contents.Item.SummaryAdmin.ascx" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Items\Contents.Item.Summary.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\Items\Contents.Item.ascx" />
|
||||
<Content Include="Contents\Views\Item\Preview.aspx" />
|
||||
<Content Include="Contents\Views\Item\Display.aspx" />
|
||||
<Content Include="Localization\Module.txt" />
|
||||
<Content Include="Localization\Views\DisplayTemplates\Parts\Localized.ContentTranslations.SummaryAdmin.ascx" />
|
||||
<Content Include="Localization\Views\Admin\Translate.ascx" />
|
||||
<Content Include="Localization\Views\DisplayTemplates\Parts\Localization.ContentTranslations.SummaryAdmin.ascx" />
|
||||
<Content Include="Localization\Views\EditorTemplates\Parts\Localization.CultureSelection.ascx" />
|
||||
<Content Include="Routable\Module.txt" />
|
||||
<Content Include="Routable\Scripts\jquery.slugify.js" />
|
||||
<Content Include="Routable\Views\EditorTemplates\Parts\Routable.IsRoutable.ascx" />
|
||||
@ -289,9 +293,7 @@
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Body.Manage.ascx" />
|
||||
<Content Include="Dashboard\Views\Web.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Notification\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<None Include="App_Data\Localization\en-US\orchard.core.po" />
|
||||
<None Include="App_Data\Localization\fr-FR\orchard.core.po" />
|
||||
|
@ -106,9 +106,8 @@
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<UseCustomServer>True</UseCustomServer>
|
||||
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
|
@ -364,11 +364,11 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
|
||||
#endregion
|
||||
|
||||
public new bool TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) where TModel : class {
|
||||
bool IUpdateModel.TryUpdateModel<TModel>(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());
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
<div class="properties">
|
||||
<h3><%:feature.Descriptor.Name %></h3>
|
||||
<p class="description"><%:feature.Descriptor.Description %></p><%
|
||||
if (feature.Descriptor.Dependencies != null) { %>
|
||||
if (feature.Descriptor.Dependencies != null && feature.Descriptor.Dependencies.Any()) { %>
|
||||
<div class="dependencies">
|
||||
<h4><%: T("Depends on:")%></h4>
|
||||
<%: Html.UnorderedList(
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user