mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
commit
1024a7809a
@ -79,7 +79,7 @@ namespace Orchard.Core.Common.Drivers {
|
||||
}
|
||||
}
|
||||
|
||||
return ContentPartTemplate(model, "Parts/Common.Owner", TemplatePrefix).Location("primary", "10");
|
||||
return ContentPartTemplate(model, "Parts/Common.Owner", TemplatePrefix).Location("primary", "20");
|
||||
}
|
||||
|
||||
DriverResult ContainerEditor(CommonAspect part, IUpdateModel updater) {
|
||||
@ -106,7 +106,7 @@ namespace Orchard.Core.Common.Drivers {
|
||||
}
|
||||
}
|
||||
}
|
||||
return ContentPartTemplate(model, "Parts/Common.Container", TemplatePrefix).Location("primary", "10.1");
|
||||
return ContentPartTemplate(model, "Parts/Common.Container", TemplatePrefix).Location("primary", "20.1");
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ using Orchard.Localization;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Mvc.Results;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Core.Localization.Controllers {
|
||||
[ValidateInput(false)]
|
||||
@ -32,9 +31,15 @@ namespace Orchard.Core.Localization.Controllers {
|
||||
public ActionResult Translate(int id, string to) {
|
||||
var contentItem = _contentManager.Get(id, VersionOptions.Latest);
|
||||
|
||||
// only support translations from the site culture, at the moment at least
|
||||
if (contentItem == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
if (!contentItem.Is<Localized>() || contentItem.As<Localized>().MasterContentItem != null) {
|
||||
var metadata = _contentManager.GetItemMetadata(contentItem);
|
||||
return RedirectToAction(Convert.ToString(metadata.EditorRouteValues["action"]), metadata.EditorRouteValues);
|
||||
}
|
||||
|
||||
var siteCultures = _cultureManager.ListCultures().Where(s => s != _localizationService.GetContentCulture(contentItem));
|
||||
var model = new AddLocalizationViewModel {
|
||||
Id = id,
|
||||
|
@ -4,40 +4,67 @@ using System.Web;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Common;
|
||||
using Orchard.Core.Localization.Models;
|
||||
using Orchard.Core.Localization.Services;
|
||||
using Orchard.Core.Localization.ViewModels;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Core.Localization.Drivers {
|
||||
[UsedImplicitly]
|
||||
public class LocalizationDriver : ContentPartDriver<Localized> {
|
||||
private const string TemplatePrefix = "Localization";
|
||||
private readonly ICultureManager _cultureManager;
|
||||
private readonly ILocalizationService _localizationService;
|
||||
|
||||
public LocalizationDriver(IOrchardServices services, ICultureManager cultureManager, ILocalizationService localizationService) {
|
||||
public LocalizationDriver(ICultureManager cultureManager, ILocalizationService localizationService) {
|
||||
_cultureManager = cultureManager;
|
||||
_localizationService = localizationService;
|
||||
Services = services;
|
||||
}
|
||||
|
||||
protected virtual ISite CurrentSite { get; private set; }
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
protected override DriverResult Display(Localized part, string displayType) {
|
||||
var model = new ContentLocalizationsViewModel(part) {
|
||||
Localizations = _localizationService.GetLocalizations(part.ContentItem)
|
||||
.Select(c => {
|
||||
var localized = c.ContentItem.As<Localized>();
|
||||
if (localized.Culture == null)
|
||||
localized.Culture = _cultureManager.GetCultureByName(_cultureManager.GetCurrentCulture(new HttpContextWrapper(HttpContext.Current)));
|
||||
return c;
|
||||
}).ToList()
|
||||
Localizations = GetDisplayLocalizations(part)
|
||||
};
|
||||
|
||||
return ContentPartTemplate(model, "Parts/Localization.ContentTranslations").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5");
|
||||
|
||||
return ContentPartTemplate(model, "Parts/Localization.ContentTranslations", TemplatePrefix).LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(Localized part) {
|
||||
var localizations = GetEditorLocalizations(part).ToList();
|
||||
var model = new EditLocalizationViewModel {
|
||||
SelectedCulture = part.Culture != null ? part.Culture.Culture : null,
|
||||
SiteCultures = _cultureManager.ListCultures().Where(s => s != _cultureManager.GetSiteCulture() && !localizations.Select(l => l.Culture.Culture).Contains(s)),
|
||||
MasterContentItem = part.MasterContentItem,
|
||||
ContentLocalizations = new ContentLocalizationsViewModel(part) { Localizations = localizations }
|
||||
};
|
||||
|
||||
return ContentPartTemplate(model, "Parts/Localization.Translation", TemplatePrefix).Location("primary", "1");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(Localized part, IUpdateModel updater) {
|
||||
var model = new EditLocalizationViewModel();
|
||||
if (updater != null && updater.TryUpdateModel(model, TemplatePrefix, null, null)) {
|
||||
_localizationService.SetContentCulture(part, model.SelectedCulture);
|
||||
}
|
||||
|
||||
return Editor(part);
|
||||
}
|
||||
|
||||
private IEnumerable<Localized> GetDisplayLocalizations(Localized part) {
|
||||
return _localizationService.GetLocalizations(part.ContentItem)
|
||||
.Select(c => {
|
||||
var localized = c.ContentItem.As<Localized>();
|
||||
if (localized.Culture == null) {
|
||||
localized.Culture = _cultureManager.GetCultureByName(_cultureManager.GetCurrentCulture(new HttpContextWrapper(HttpContext.Current)));
|
||||
}
|
||||
return c;
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
private IEnumerable<Localized> GetEditorLocalizations(Localized part) {
|
||||
return _localizationService.GetLocalizations(part.ContentItem)
|
||||
.Select(c => c.ContentItem.As<Localized>())
|
||||
.Where(l => l.MasterContentItem != null).ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -22,8 +22,6 @@ namespace Orchard.Core.Localization.Handlers {
|
||||
|
||||
OnInitializing<Localized>(InitializePart);
|
||||
|
||||
OnLoaded<Localized>(LazyLoadHandlers);
|
||||
|
||||
OnIndexed<Localized>((context, localized) => context.DocumentIndex
|
||||
.Add("culture", CultureInfo.GetCultureInfo(localized.Culture != null ? localized.Culture.Culture : _cultureManager.GetSiteCulture()).LCID)
|
||||
.Store()
|
||||
@ -32,11 +30,6 @@ namespace Orchard.Core.Localization.Handlers {
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
void LazyLoadHandlers(LoadContentContext context, Localized localized) {
|
||||
localized.CultureField.Loader(ctx => _cultureManager.GetCultureById(localized.Record.CultureId));
|
||||
localized.MasterContentItemField.Loader(ctx => _contentManager.Get(localized.Record.MasterContentItemId));
|
||||
}
|
||||
|
||||
void InitializePart(InitializingContentContext context, Localized localized) {
|
||||
localized.CultureField.Setter(cultureRecord => {
|
||||
localized.Record.CultureId = cultureRecord.Id;
|
||||
@ -46,6 +39,8 @@ namespace Orchard.Core.Localization.Handlers {
|
||||
localized.Record.MasterContentItemId = masterContentItem.ContentItem.Id;
|
||||
return masterContentItem;
|
||||
});
|
||||
localized.CultureField.Loader(ctx => _cultureManager.GetCultureById(localized.Record.CultureId));
|
||||
localized.MasterContentItemField.Loader(ctx => _contentManager.Get(localized.Record.MasterContentItemId));
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ namespace Orchard.Core.Localization.Services {
|
||||
public interface ILocalizationService : IDependency {
|
||||
Localized GetLocalizedContentItem(IContent masterContentItem, string culture);
|
||||
string GetContentCulture(IContent contentItem);
|
||||
void SetContentCulture(IContent contentItem, string culture);
|
||||
IEnumerable<Localized> GetLocalizations(IContent contentItem);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Localization.Models;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Tasks.Scheduling;
|
||||
|
||||
namespace Orchard.Core.Localization.Services {
|
||||
public class LocalizationService : ILocalizationService {
|
||||
@ -25,11 +24,20 @@ namespace Orchard.Core.Localization.Services {
|
||||
}
|
||||
|
||||
string ILocalizationService.GetContentCulture(IContent content) {
|
||||
return content.Is<Localized>() && content.As<Localized>().Culture != null
|
||||
? content.As<Localized>().Culture.Culture
|
||||
var localized = content.As<Localized>();
|
||||
return localized != null && localized.Culture != null
|
||||
? localized.Culture.Culture
|
||||
: _cultureManager.GetSiteCulture();
|
||||
}
|
||||
|
||||
void ILocalizationService.SetContentCulture(IContent content, string culture) {
|
||||
var localized = content.As<Localized>();
|
||||
if (localized == null || localized.MasterContentItem == null)
|
||||
return;
|
||||
|
||||
localized.Culture = _cultureManager.GetCultureByName(culture);
|
||||
}
|
||||
|
||||
IEnumerable<Localized> ILocalizationService.GetLocalizations(IContent content) {
|
||||
var localized = content.As<Localized>();
|
||||
|
||||
|
@ -1,25 +1,45 @@
|
||||
.content-localization {
|
||||
margin:1.44em 0 0;
|
||||
}
|
||||
.content-localization .content-localizations li,
|
||||
.content-localization .content-localizations li,
|
||||
.content-localization .add-localization {
|
||||
font-size:1.4em;
|
||||
}
|
||||
.content-localization .culture-selected {
|
||||
margin-bottom:.5em;
|
||||
}
|
||||
.content-localization .content-localizations {
|
||||
font-size:.9em;
|
||||
}
|
||||
.content-localization .content-localizations>* {
|
||||
display:inline;
|
||||
}
|
||||
.content-localization .content-localizations li {
|
||||
.content-localization .content-localizations .localizations li {
|
||||
border-bottom:0;
|
||||
display:inline;
|
||||
margin-left:.5em;
|
||||
padding:0;
|
||||
}
|
||||
.content-localization .content-localizations li::after {
|
||||
content:", ";
|
||||
content:",";
|
||||
}
|
||||
.content-localization .content-localizations li:last-child::after {
|
||||
content:"";
|
||||
}
|
||||
.culture-selection fieldset {
|
||||
padding-top:0;
|
||||
}
|
||||
.culture-selection div {
|
||||
font-size:1.4em;
|
||||
}
|
||||
.culture-selection dl {
|
||||
margin:.2em 0;
|
||||
}
|
||||
.culture-selection dt {
|
||||
color:#4C4C4C;
|
||||
font-weight:bold;
|
||||
}
|
||||
.culture-selection dt, .culture-selection dd, .culture-selection ul {
|
||||
display:inline;
|
||||
}
|
||||
.culture-selection .content-localization .content-localizations {
|
||||
clear:none;
|
||||
float:none;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Localization.Models;
|
||||
|
||||
namespace Orchard.Core.Localization.ViewModels {
|
||||
public class ContentLocalizationsViewModel {
|
||||
public ContentLocalizationsViewModel(IContent part) {
|
||||
Id = part.ContentItem.Id;
|
||||
public ContentLocalizationsViewModel(Localized part) {
|
||||
MasterId = part.MasterContentItem != null
|
||||
? part.MasterContentItem.ContentItem.Id
|
||||
: part.Id;
|
||||
}
|
||||
|
||||
public int Id { get; private set; }
|
||||
public int? MasterId { get; private set; }
|
||||
public IEnumerable<Localized> Localizations { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Core.Localization.ViewModels {
|
||||
public class EditLocalizationViewModel : BaseViewModel {
|
||||
public string SelectedCulture { get; set; }
|
||||
public IEnumerable<string> SiteCultures { get; set; }
|
||||
public IContent MasterContentItem { get; set; }
|
||||
public ContentLocalizationsViewModel ContentLocalizations { get; set; }
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
using Orchard.Core.Localization.Models;
|
||||
|
||||
namespace Orchard.Core.Localization.ViewModels {
|
||||
public class SelectLocalizationsViewModel {
|
||||
public SelectLocalizationsViewModel(Localized part) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
<div class="content-localization"><%
|
||||
if (Model.Localizations.Count() > 0) { %>
|
||||
<%--//todo: need this info in the view model--%>
|
||||
<div class="content-localizations"><h4><%:T("Translations:") %></h4><%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations") %></div><%
|
||||
<div class="content-localizations"><h4><%:T("Translations:") %></h4><%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemEditLink(c.Culture.Culture, c), "localizations") %></div><%
|
||||
} %>
|
||||
<div class="add-localization"><%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.Id }, null)%></div>
|
||||
<div class="add-localization"><%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.MasterId }, null)%></div>
|
||||
</div>
|
@ -1,10 +1 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Localization.ViewModels.ContentLocalizationsViewModel>" %>
|
||||
<%
|
||||
Html.RegisterStyle("base.css"); %>
|
||||
<div class="content-localization"><%
|
||||
if (Model.Localizations.Count() > 0) { %>
|
||||
<%--//todo: need this info in the view model--%>
|
||||
<div class="content-localizations"><%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations") %></div><%
|
||||
} %>
|
||||
<div class="add-localization"><%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.Id }, null)%></div>
|
||||
</div>
|
@ -0,0 +1,24 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Localization.ViewModels.EditLocalizationViewModel>" %>
|
||||
<%
|
||||
Html.RegisterStyle("admin.css");
|
||||
Html.RegisterStyle("base.css");
|
||||
if (Model.ContentLocalizations.MasterId > 0) { %>
|
||||
<fieldset class="localization culture-selection"><%
|
||||
if (Model.MasterContentItem != null) { %>
|
||||
<fieldset class="culture-selected">
|
||||
<label for="SelectedCulture"><%:T("Content Localization") %></label>
|
||||
<div><%:T("This is the {0} variation of {1}.",
|
||||
Html.DropDownList("SelectedCulture", new SelectList(Model.SiteCultures, Model.SelectedCulture)),
|
||||
Html.ItemEditLink(Model.MasterContentItem)) %></div>
|
||||
</fieldset><%
|
||||
}
|
||||
if (Model.ContentLocalizations.Localizations.Count() > 0) { //todo: find a good place for this info on the content edit page %>
|
||||
<dl class="content-localization">
|
||||
<dt><%:Model.MasterContentItem != null ? T("Other translations:") : T("Translations:") %></dt>
|
||||
<dd class="content-localizations">
|
||||
<%:Html.UnorderedList(Model.ContentLocalizations.Localizations, (c, i) => Html.ItemEditLink(c.Culture.Culture, c), "localizations") %>
|
||||
</dd>
|
||||
</dl><%
|
||||
} %>
|
||||
</fieldset><%
|
||||
} %>
|
@ -82,6 +82,7 @@
|
||||
<Compile Include="Contents\Permissions.cs" />
|
||||
<Compile Include="Contents\Routes.cs" />
|
||||
<Compile Include="Contents\ViewModels\PublishContentViewModel.cs" />
|
||||
<Compile Include="Localization\ViewModels\EditLocalizationViewModel.cs" />
|
||||
<Compile Include="PublishLater\Drivers\PublishLaterPartDriver.cs" />
|
||||
<Compile Include="PublishLater\Models\PublishLaterPart.cs" />
|
||||
<Compile Include="PublishLater\Handlers\PublishLaterPartHandler.cs" />
|
||||
@ -95,7 +96,6 @@
|
||||
<Compile Include="Localization\Services\ILocalizationService.cs" />
|
||||
<Compile Include="Localization\Services\LocalizationService.cs" />
|
||||
<Compile Include="Localization\ViewModels\ContentLocalizationsViewModel.cs" />
|
||||
<Compile Include="Localization\ViewModels\SelectLocalizationsViewModel.cs" />
|
||||
<Compile Include="Reports\AdminMenu.cs" />
|
||||
<Compile Include="Reports\Controllers\AdminController.cs" />
|
||||
<Compile Include="Reports\Routes.cs" />
|
||||
@ -237,6 +237,7 @@
|
||||
<Content Include="Common\Views\DisplayTemplates\Parts\Common.Metadata.SummaryAdmin.ascx" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.SummaryAdmin.ascx" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Parts\Contents.Publish.ascx" />
|
||||
<Content Include="Localization\Views\EditorTemplates\Parts\Localization.Translation.ascx" />
|
||||
<Content Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.ascx" />
|
||||
<Content Include="PublishLater\Views\DisplayTemplates\Parts\PublishLater.Metadata.SummaryAdmin.ascx" />
|
||||
<Content Include="Common\Views\EditorTemplates\Fields\Common.TextField.ascx" />
|
||||
|
@ -35,12 +35,12 @@ namespace Orchard.Comments.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(HasComments part) {
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "99");
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "10");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(HasComments part, IUpdateModel updater) {
|
||||
updater.TryUpdateModel(part, Prefix, null, null);
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "99");
|
||||
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location("primary", "10");
|
||||
}
|
||||
}
|
||||
}
|
@ -69,7 +69,7 @@ namespace Orchard.DevTools.Commands {
|
||||
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("</ItemGroup>"), itemGroupReference);
|
||||
}
|
||||
File.WriteAllText(moduleCsProjPath, projectFileText);
|
||||
|
||||
TouchSolution();
|
||||
Context.Output.WriteLine(T("Data migration created successfully in Module {0}", extension.Name));
|
||||
return;
|
||||
}
|
||||
@ -89,7 +89,7 @@ namespace Orchard.DevTools.Commands {
|
||||
}
|
||||
|
||||
IntegrateModule(moduleName);
|
||||
|
||||
TouchSolution();
|
||||
Context.Output.WriteLine(T("Module {0} created successfully", moduleName));
|
||||
}
|
||||
|
||||
@ -128,6 +128,7 @@ namespace Orchard.DevTools.Commands {
|
||||
}
|
||||
File.WriteAllText(moduleCsProjPath, projectFileText);
|
||||
Context.Output.WriteLine(T("Controller {0} created successfully in Module {1}", controllerName, moduleName));
|
||||
TouchSolution();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -189,6 +190,12 @@ namespace Orchard.DevTools.Commands {
|
||||
templateText = templateText.Replace("$$ModuleProjectGuid$$", projectGuid);
|
||||
File.WriteAllText(modulePath + "\\" + moduleName + ".csproj", templateText);
|
||||
}
|
||||
|
||||
private static void TouchSolution() {
|
||||
string rootWebProjectPath = HostingEnvironment.MapPath("~/Orchard.Web.csproj");
|
||||
string solutionPath = Directory.GetParent(rootWebProjectPath).Parent.FullName + "\\Orchard.sln";
|
||||
File.SetLastWriteTime(solutionPath, DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,10 @@ using Orchard.UI.Notify;
|
||||
namespace Orchard.DevTools.Controllers {
|
||||
[ValidateInput(false)]
|
||||
[Admin]
|
||||
public class DataMigrationController : Controller {
|
||||
public class DatabaseUpdateController : Controller {
|
||||
private readonly ISchemaCommandGenerator _schemaCommandGenerator;
|
||||
|
||||
public DataMigrationController(ISchemaCommandGenerator schemaCommandGenerator, IOrchardServices orchardServices) {
|
||||
public DatabaseUpdateController(ISchemaCommandGenerator schemaCommandGenerator, IOrchardServices orchardServices) {
|
||||
_schemaCommandGenerator = schemaCommandGenerator;
|
||||
Services = orchardServices;
|
||||
}
|
@ -74,7 +74,7 @@
|
||||
<Compile Include="Commands\ScaffoldingCommands.cs" />
|
||||
<Compile Include="Controllers\CommandsController.cs" />
|
||||
<Compile Include="Controllers\ContentController.cs" />
|
||||
<Compile Include="Controllers\DataMigrationController.cs" />
|
||||
<Compile Include="Controllers\DatabaseUpdateController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\MetadataController.cs" />
|
||||
<Compile Include="Handlers\DebugLinkHandler.cs" />
|
||||
@ -99,7 +99,7 @@
|
||||
<Content Include="ScaffoldingTemplates\ModuleWebConfig.txt" />
|
||||
<Content Include="ScaffoldingTemplates\ViewsWebConfig.txt" />
|
||||
<Content Include="Views\Commands\Execute.ascx" />
|
||||
<Content Include="Views\DataMigration\Index.aspx" />
|
||||
<Content Include="Views\DatabaseUpdate\Index.aspx" />
|
||||
<Content Include="Views\DefinitionTemplates\DevToolsSettings.ascx" />
|
||||
<Content Include="Views\Home\_RenderableAction.ascx" />
|
||||
<Content Include="Views\Home\Simple.aspx" />
|
||||
|
@ -1,5 +1,10 @@
|
||||
name: $$ModuleName$$
|
||||
antiforgery: enabled
|
||||
author: The Orchard Team
|
||||
website: http://orchardproject.net
|
||||
version: 0.5.0
|
||||
orchardversion: 0.5.0
|
||||
description: Description for the module
|
||||
features:
|
||||
$$ModuleName$$:
|
||||
Description: Description for feature $$ModuleName$$.
|
@ -1,5 +1,5 @@
|
||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<BaseViewModel>"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<h1><%: Html.TitleForPage(T("Data Migration").ToString()) %></h1>
|
||||
<p><%: Html.ActionLink(T("Update Database").ToString(), "UpdateDatabase", "DataMigration") %></p>
|
||||
<p><%: Html.ActionLink(T("Update Database").ToString(), "UpdateDatabase", "DatabaseUpdate") %></p>
|
||||
|
@ -4,4 +4,4 @@
|
||||
<p><%: Html.ActionLink(T("Contents").ToString(), "Index", "Content") %></p>
|
||||
<p><%: Html.ActionLink(T("Metadata").ToString(), "Index", "Metadata") %></p>
|
||||
<p><%: Html.ActionLink(T("Test Unauthorized Request").ToString(), "NotAuthorized", "Home")%></p>
|
||||
<p><%: Html.ActionLink(T("Data migration").ToString(), "Index", "DataMigration")%></p>
|
||||
<p><%: Html.ActionLink(T("Database Update").ToString(), "Index", "DatabaseUpdate")%></p>
|
||||
|
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Indexing.Settings;
|
||||
|
||||
namespace Orchard.Indexing.Handlers {
|
||||
public class InfosetFieldIndexingHandler : ContentHandler {
|
||||
|
||||
public InfosetFieldIndexingHandler() {
|
||||
|
||||
OnIndexing<InfosetPart>(
|
||||
(context, cp) => {
|
||||
var infosetPart = context.ContentItem.As<InfosetPart>();
|
||||
if ( infosetPart != null ) {
|
||||
foreach ( var part in infosetPart.ContentItem.Parts ) {
|
||||
foreach ( var field in part.PartDefinition.Fields ) {
|
||||
if ( field.Settings.GetModel<FieldIndexing>().Included ) {
|
||||
var fieldName = field.Name;
|
||||
var value = part.Fields.Where(f => f.Name == fieldName).First().Storage.Get<string>(null);
|
||||
context.DocumentIndex.Add(String.Format("{0}-{1}", infosetPart.TypeDefinition.Name, fieldName.ToLower()), value).RemoveTags().Analyze();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -63,6 +63,7 @@
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="DataMigrations\IndexingDataMigration.cs" />
|
||||
<Compile Include="Handlers\CreateIndexingTaskHandler.cs" />
|
||||
<Compile Include="Handlers\InfosetFieldIndexingHandler.cs" />
|
||||
<Compile Include="Models\IndexingTask.cs" />
|
||||
<Compile Include="Models\IndexingTaskRecord.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
|
@ -72,12 +72,33 @@ namespace Orchard.Tags.Services {
|
||||
}
|
||||
|
||||
public void UpdateTag(int id, string tagName) {
|
||||
Tag tag = _tagRepository.Get(id);
|
||||
if (String.IsNullOrEmpty(tagName)) {
|
||||
if ( String.IsNullOrEmpty(tagName) ) {
|
||||
_notifier.Warning(T("Couldn't rename tag: name was empty"));
|
||||
return;
|
||||
}
|
||||
tag.TagName = tagName;
|
||||
|
||||
Tag tag = GetTagByName(tagName);
|
||||
if(tag != null) {
|
||||
// new tag name already existing => merge
|
||||
IEnumerable<TagsContentItems> tagsContentItems = _tagsContentItemsRepository.Fetch(x => x.TagId == id);
|
||||
|
||||
// get contentItems already tagged with the existing one
|
||||
var taggedContentItems = GetTaggedContentItems(tag.Id);
|
||||
|
||||
foreach ( var tagContentItem in tagsContentItems ) {
|
||||
var tagContentItemId = tagContentItem.ContentItemId;
|
||||
if ( !taggedContentItems.Any(c => c.ContentItem.Id == tagContentItemId) ) {
|
||||
TagContentItem(tagContentItem.ContentItemId, tagName);
|
||||
}
|
||||
_tagsContentItemsRepository.Delete(tagContentItem);
|
||||
}
|
||||
|
||||
_tagRepository.Delete(GetTag(id));
|
||||
}
|
||||
else {
|
||||
tag = _tagRepository.Get(id);
|
||||
tag.TagName = tagName;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IContent> GetTaggedContentItems(int id) {
|
||||
|
6
src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js
Normal file
6
src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js
Normal file
@ -0,0 +1,6 @@
|
||||
$(document).ready(function(){
|
||||
$("#navigation li span").click(function() {
|
||||
$(this).next().next().slideToggle(400);
|
||||
return false;
|
||||
});
|
||||
});
|
BIN
src/Orchard.Web/Themes/TheAdmin/Styles/images/menuClosed.gif
Normal file
BIN
src/Orchard.Web/Themes/TheAdmin/Styles/images/menuClosed.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpen.gif
Normal file
BIN
src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpen.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpenHover.gif
Normal file
BIN
src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpenHover.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -239,7 +239,7 @@ form.link button:hover {
|
||||
width:0;
|
||||
}
|
||||
#navigation li {
|
||||
margin:7px 0 20px 0;
|
||||
margin:7px 0 20px 4px;
|
||||
}
|
||||
#navigation ul li {
|
||||
border:0;
|
||||
@ -270,6 +270,19 @@ form.link button:hover {
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
/* todo: make generic so all toggles can use this and clean up jQuery */
|
||||
.menuGlyph {
|
||||
display:block;
|
||||
height:11px;
|
||||
width:11px;
|
||||
margin:0 0 -22px -8px;
|
||||
background:url("images/menuOpen.gif") no-repeat center top;
|
||||
}
|
||||
.menuGlyph:hover {
|
||||
background:url("images/menuOpenHover.gif") no-repeat center top;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
/* Content
|
||||
----------------------------------------------------------*/
|
||||
#main h1 {
|
||||
|
@ -8,6 +8,7 @@ Model.Zones.AddRenderPartial("header", "Header", Model);
|
||||
Model.Zones.AddRenderPartial("header:after", "User", Model); // todo: (heskew) should be a user display or widget
|
||||
Model.Zones.AddRenderPartial("menu", "Menu", Model);
|
||||
%>
|
||||
<script src="<%: Url.Content("~/Themes/TheAdmin/Scripts/admin.js") %>" type="text/javascript"></script>
|
||||
<div id="header" role="banner"><% Html.Zone("header"); %></div>
|
||||
<div id="content">
|
||||
<div id="navshortcut"><a href="#menu"><%: T("Skip to navigation") %></a></div>
|
||||
|
@ -15,7 +15,7 @@
|
||||
classification += "last ";
|
||||
|
||||
%>
|
||||
<li<%=!string.IsNullOrEmpty(classification) ? string.Format(" class=\"{0}\"", classification.TrimEnd()) : "" %>><h3><%=sectionHeaderMarkup %></h3><ul><%foreach (var menuItem in menuSection.Items) { %>
|
||||
<li<%=!string.IsNullOrEmpty(classification) ? string.Format(" class=\"{0}\"", classification.TrimEnd()) : "" %>><span class="menuGlyph"></span><h3><%=sectionHeaderMarkup %></h3><ul class="menuItems"><%foreach (var menuItem in menuSection.Items) { %>
|
||||
<li><%: Html.ActionLink(menuItem.Text, (string)menuItem.RouteValues["action"], menuItem.RouteValues)%></li>
|
||||
<%} %></ul></li>
|
||||
<%
|
||||
|
@ -9,6 +9,6 @@ namespace Orchard.ContentManagement {
|
||||
public ContentPartDefinition.Field PartFieldDefinition { get; set; }
|
||||
public ContentFieldDefinition FieldDefinition { get { return PartFieldDefinition.FieldDefinition; } }
|
||||
|
||||
public IFieldStorage Storage { protected get; set; }
|
||||
public IFieldStorage Storage { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user