From 2cf2931745986f694d9482914c64580717c795bf Mon Sep 17 00:00:00 2001 From: Jonathan Wall Date: Tue, 20 Jul 2010 11:22:53 -0700 Subject: [PATCH 01/10] Added toggle for admin menu. Some work needed to make generic. --HG-- branch : dev --- src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js | 6 ++++++ .../Themes/TheAdmin/Styles/images/menuClosed.gif | Bin 0 -> 1206 bytes .../TheAdmin/Styles/images/menuClosedHover.gif | Bin 0 -> 1191 bytes .../Themes/TheAdmin/Styles/images/menuOpen.gif | Bin 0 -> 1206 bytes .../TheAdmin/Styles/images/menuOpenHover.gif | Bin 0 -> 1191 bytes src/Orchard.Web/Themes/TheAdmin/Styles/site.css | 15 ++++++++++++++- .../Themes/TheAdmin/Views/Layout.ascx | 1 + src/Orchard.Web/Themes/TheAdmin/Views/Menu.ascx | 2 +- 8 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js create mode 100644 src/Orchard.Web/Themes/TheAdmin/Styles/images/menuClosed.gif create mode 100644 src/Orchard.Web/Themes/TheAdmin/Styles/images/menuClosedHover.gif create mode 100644 src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpen.gif create mode 100644 src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpenHover.gif diff --git a/src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js b/src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js new file mode 100644 index 000000000..31c9ae137 --- /dev/null +++ b/src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js @@ -0,0 +1,6 @@ +$(document).ready(function(){ +$("#navigation li span").click(function() { +$(this).next().next().slideToggle(600); +return false; + }); +}); diff --git a/src/Orchard.Web/Themes/TheAdmin/Styles/images/menuClosed.gif b/src/Orchard.Web/Themes/TheAdmin/Styles/images/menuClosed.gif new file mode 100644 index 0000000000000000000000000000000000000000..f4f5884ea1172f96d2763c7018abd1e69077b470 GIT binary patch literal 1206 zcmZ?wbhEHb3>5!!NB9OPxFnV&0%;rj zih{)C?9>v4q}24xJX@vryZ0+8WTx0Eg`4^s_!c;)W@LI)6{QAO`Gq7`WhYyvDB0U7 z*i=|m)9WTXpJp<7&;SCUwvn^&w1Gr=XbIJqdZ zpd>RtPXT0NVp4u-iLDaQr4TRV7Wn$Y4bCgp1A9m>IX_pwBC$Z$_ zi>(q+MlU5Z#mdOp#L~^o!pO+N(!|Bh(9puw&CSWp#M#No#lYOs+ze(0HoZW7PEKx) zMwTW<7KVl{Zk86t20(32MrH=i#xAY~Fuk66#U+V($*C}VGlBL(^%~;UYvo*&npl!w z6q28x14{t`8Tlpo#Toep3eLf%3gMY~Df#8apvZyv)g`qkvn(~mttdZN0UWwknOJN$ zav|hvh~5-(LQEg%7=2LEKuRhwAz=CgG2sax$bn~_)I4B*DFS8;#{d8R{`vju=a28- zzJB@q>Enm@@7}(7{p#h5=g*!#dHm?%gZuaH-no72=8fyuu3ou(>Eea+=gyuved^?i z(;JWy=vu(<;#{XS-fcBg8B32&Y3-H z=8WmnrcRkWY2t+bzTTehuFj73w$_&BrpAW)y4srRs>+J;veJ^`qQZjwyxg4Ztjvt` zwA7U3q{M{yxY(HJsK|)$u+Wg;puhlsKVKhjFHaA5H&+*DCr1Z+J6juTD@zM=GgA{| zBVeY~)78<|($r8_Q&mw`QdE$ala-N{l9Uh^6BQ8_5)|O)PzOq=?o0k00#D_ AE&u=k literal 0 HcmV?d00001 diff --git a/src/Orchard.Web/Themes/TheAdmin/Styles/images/menuClosedHover.gif b/src/Orchard.Web/Themes/TheAdmin/Styles/images/menuClosedHover.gif new file mode 100644 index 0000000000000000000000000000000000000000..f1fbdc6d8c347cf826cd27e6293d5195da4d7c23 GIT binary patch literal 1191 zcmZ?wbhEHbWS005B~rEU-3V8gl~X?OJYePkhZa}C`e4sPAySL zN=?tqvsHS(d%u!GW{Ry+xT&v!Z-H}aMy5wqQEG6NUr2IQcCuxPlD(aRO@&oOZb5Ep zNuokUZcbjYRfVlmVoH8esuhq864qBz04piUwpDTjNhpBqbj~kIRWQ{v&`mZlGf*%y z)H5_TF*i5YQ7|$vG|)FN(l<2HH8i&}HnK7>P=Ep@plwAdX;wilZcw{`JX@uVl9B=| zef{$Ca=mh6z5JqdeM3u2OOP2xM!G;1y2X`wC5aWfdBw^w6I@b@lZ!G7N;32F6hI~> zCgqow*eU^C3h_d2fv+#z;Jjizu!r=L^KSknJ0o7b;izIguZ>66Eg9zM8#@9v%3w{G6Je(ma&%a<-*IDhW!nbW6Eo;ZH&=#j&R z4j$OQZ||PnyLRr_zHRH4&6_rESif%Vn$@dTu2{Zo>5|2Z7A}}SZ|F(<6Xm4w6X>Mw4sIRN7sjjN5C@(85DK083$j{5o$mNlr>k zh>weniH?el2oDPl2@VPj@b~le@%HlcaCdWcadvWau(z|dv9_|bFgG(bF*X8bNqwaWPR5VIe^Qem-6vZZ1v^b~aWPW+p}k2F0H&K$4k3 qhXDvcr4Iv>)E%K^+7njKY8Lddda`&H+iuPKM;ju9jhMn17_0&QQKC@* literal 0 HcmV?d00001 diff --git a/src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpen.gif b/src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpen.gif new file mode 100644 index 0000000000000000000000000000000000000000..1a761a88bd1c3503aae3921e4be3393f2fc26b31 GIT binary patch literal 1206 zcmZ?wbhEHb3>5!!NB9OPxFnV&0%;rj zih{)C?9>v4q}24xJX@vryZ0+8WTx0Eg`4^s_!c;)W@LI)6{QAO`Gq7`WhYyvDB0U7 z*i=|m)9WTXpJp<7&;SCUwvn^&w1Gr=XbIJqdZ zpd>RtPXT0NVp4u-iLDaQr4TRV7Wn$Y4bCgp1A9m>IX_pwBC$Z$_ zi>(q+MlU5Z#mdOp#L~^o!pO+N(!|Bh(9puw&CSWp#M#No#lYOs+ze(0HoY#!PNqht z#;%qoMiz#KE^d|vmWIx*CdNi?uI6qgj)pM3o_WP3iFwJXFncqB_Coc#;MHs8T$Gwv zl3x^(pPvIu0Rb8LCHch}`2`Bj!KMn~nRzMs<;9@Lf%w%WwJ5VJHN~wcKUV=9x>lK3 zY&UWtyv|Nj2@{p;tC z@87({PcxqRv3h4bgmo;iK$ z#u35cm<%;FYmM&SmXyJnS^XAT( zJ!|HS>C>i8nLKIYg#NzXp6;&Bj`p_Jmgc6$hWfhNn(C^`it@73lH#Jmg8aPPob0U3 zjP$hBl;otug!s7FnCPg;i14t`kl>)e0DnJUA8#*D4|g|L7iT9&2YWkP8*3{|3v)A5 zU}^wnNqwaWPR5VIe^Qem-6vZZ1v^b~aWPW+p}k z2F0H&K$4X~2UOO8N+Jek*@#_t;uN=WGzla`#xOj*HbHZqK%cj!-GN^v`8w(h)&PhW BrOf~U literal 0 HcmV?d00001 diff --git a/src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpenHover.gif b/src/Orchard.Web/Themes/TheAdmin/Styles/images/menuOpenHover.gif new file mode 100644 index 0000000000000000000000000000000000000000..711dc85f52e6d21b781e1cda4fccbe63d4bca188 GIT binary patch literal 1191 zcmZ?wbhEHbWS005B~rEU-3V8gl~X?OJYePkhZa}C`e4sPAySL zN=?tqvsHS(d%u!GW{Ry+xT&v!Z-H}aMy5wqQEG6NUr2IQcCuxPlD(aRO@&oOZb5Ep zNuokUZcbjYRfVlmVoH8esuhq864qBz04piUwpDTjNhpBqbj~kIRWQ{v&`mZlGf*%y z)H5_TF*i5YQ7|$vG|)FN(l<2HH8i&}HnK7>P=Ep@plwAdX;wilZcw{`JX@uVl9B=| zef{$Ca=mh6z5JqdeM3u2OOP2xM!G;1y2X`wC5aWfdBw^w6I@b@lZ!G7N;32F6hI~> zCgqow*eU^C3h_d2fv+#z;Jjizu!r=L^KnJ0o7b;izIguZ>66Eg9zM8#@9v%3w{G6Je(ma&%a<-*IDhW!nbW6Eo;ZH&=#j&R z4j$OQZ||PnyLRr_zHRH4&6_rESif%Vn$@dTu2{Zo>5|2Z7A}}SZ|F(<6Xm4w6X>Mw4sIRN7sjjN5C@(85DK083$j{5o$mNlr>k zh>weniH?el2oDPl2@VPj@b~le@%HlcaCdWcadvWau(z|dv9_|bFgG(bF*X8bNqwaWPR5VIe^Qem-6vZZ1v^b~aWPW+p}k2F0H&K$4k3 rhXDvcr4Iv>)SUj6%5!B|7#@099a^(pinoNbLvz;l1*cDmF<1itU(KT5 literal 0 HcmV?d00001 diff --git a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css index 3aedae27f..8ac3c7b37 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Styles/site.css +++ b/src/Orchard.Web/Themes/TheAdmin/Styles/site.css @@ -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 { diff --git a/src/Orchard.Web/Themes/TheAdmin/Views/Layout.ascx b/src/Orchard.Web/Themes/TheAdmin/Views/Layout.ascx index 5788e69a2..032e2f475 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Views/Layout.ascx +++ b/src/Orchard.Web/Themes/TheAdmin/Views/Layout.ascx @@ -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); %> +
diff --git a/src/Orchard.Web/Themes/TheAdmin/Views/Menu.ascx b/src/Orchard.Web/Themes/TheAdmin/Views/Menu.ascx index 5cb2c2a2a..ae65161c3 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Views/Menu.ascx +++ b/src/Orchard.Web/Themes/TheAdmin/Views/Menu.ascx @@ -15,7 +15,7 @@ classification += "last "; %> - >

<%=sectionHeaderMarkup %>

    <%foreach (var menuItem in menuSection.Items) { %> + >

    <%=sectionHeaderMarkup %>

    <% From 30fbf7f46920167725684481d64fe9de3a13c2ea Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Tue, 20 Jul 2010 11:45:44 -0700 Subject: [PATCH 02/10] Some work on the content localization UI --HG-- branch : dev --- .../Controllers/AdminController.cs | 7 ++- .../Drivers/LocalizationDriver.cs | 59 ++++++++++++++----- .../Handlers/LocalizationHandler.cs | 9 +-- .../Services/ILocalizationService.cs | 1 + .../Services/LocalizationService.cs | 14 ++++- .../Core/Localization/Styles/admin.css | 32 ++++++++-- .../ContentLocalizationsViewModel.cs | 9 +-- .../ViewModels/EditLocalizationViewModel.cs | 12 ++++ .../SelectLocalizationsViewModel.cs | 9 --- ...tion.ContentTranslations.SummaryAdmin.ascx | 4 +- .../Localization.ContentTranslations.ascx | 2 +- .../Parts/Localization.Translation.ascx | 24 ++++++++ src/Orchard.Web/Core/Orchard.Core.csproj | 3 +- 13 files changed, 135 insertions(+), 50 deletions(-) create mode 100644 src/Orchard.Web/Core/Localization/ViewModels/EditLocalizationViewModel.cs delete mode 100644 src/Orchard.Web/Core/Localization/ViewModels/SelectLocalizationsViewModel.cs create mode 100644 src/Orchard.Web/Core/Localization/Views/EditorTemplates/Parts/Localization.Translation.ascx diff --git a/src/Orchard.Web/Core/Localization/Controllers/AdminController.cs b/src/Orchard.Web/Core/Localization/Controllers/AdminController.cs index 0eafb5cf6..9411eda95 100644 --- a/src/Orchard.Web/Core/Localization/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Localization/Controllers/AdminController.cs @@ -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() || contentItem.As().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, diff --git a/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs b/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs index c22671eca..1b269b850 100644 --- a/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs +++ b/src/Orchard.Web/Core/Localization/Drivers/LocalizationDriver.cs @@ -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 { + 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(); - 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 GetDisplayLocalizations(Localized part) { + return _localizationService.GetLocalizations(part.ContentItem) + .Select(c => { + var localized = c.ContentItem.As(); + if (localized.Culture == null) { + localized.Culture = _cultureManager.GetCultureByName(_cultureManager.GetCurrentCulture(new HttpContextWrapper(HttpContext.Current))); + } + return c; + }).ToList(); + } + + private IEnumerable GetEditorLocalizations(Localized part) { + return _localizationService.GetLocalizations(part.ContentItem) + .Select(c => c.ContentItem.As()) + .Where(l => l.MasterContentItem != null).ToList(); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/Handlers/LocalizationHandler.cs b/src/Orchard.Web/Core/Localization/Handlers/LocalizationHandler.cs index 04596ba31..e731f92fa 100644 --- a/src/Orchard.Web/Core/Localization/Handlers/LocalizationHandler.cs +++ b/src/Orchard.Web/Core/Localization/Handlers/LocalizationHandler.cs @@ -22,8 +22,6 @@ namespace Orchard.Core.Localization.Handlers { OnInitializing(InitializePart); - OnLoaded(LazyLoadHandlers); - OnIndexed((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)); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/Services/ILocalizationService.cs b/src/Orchard.Web/Core/Localization/Services/ILocalizationService.cs index b53b6fc5c..c11ebcb32 100644 --- a/src/Orchard.Web/Core/Localization/Services/ILocalizationService.cs +++ b/src/Orchard.Web/Core/Localization/Services/ILocalizationService.cs @@ -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 GetLocalizations(IContent contentItem); } } diff --git a/src/Orchard.Web/Core/Localization/Services/LocalizationService.cs b/src/Orchard.Web/Core/Localization/Services/LocalizationService.cs index 82e7a257b..7bdc5e6d4 100644 --- a/src/Orchard.Web/Core/Localization/Services/LocalizationService.cs +++ b/src/Orchard.Web/Core/Localization/Services/LocalizationService.cs @@ -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() && content.As().Culture != null - ? content.As().Culture.Culture + var localized = content.As(); + return localized != null && localized.Culture != null + ? localized.Culture.Culture : _cultureManager.GetSiteCulture(); } + void ILocalizationService.SetContentCulture(IContent content, string culture) { + var localized = content.As(); + if (localized == null || localized.MasterContentItem == null) + return; + + localized.Culture = _cultureManager.GetCultureByName(culture); + } + IEnumerable ILocalizationService.GetLocalizations(IContent content) { var localized = content.As(); diff --git a/src/Orchard.Web/Core/Localization/Styles/admin.css b/src/Orchard.Web/Core/Localization/Styles/admin.css index 6895e51c0..7da94d32e 100644 --- a/src/Orchard.Web/Core/Localization/Styles/admin.css +++ b/src/Orchard.Web/Core/Localization/Styles/admin.css @@ -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; } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/ViewModels/ContentLocalizationsViewModel.cs b/src/Orchard.Web/Core/Localization/ViewModels/ContentLocalizationsViewModel.cs index eff2149dd..2ee7efeda 100644 --- a/src/Orchard.Web/Core/Localization/ViewModels/ContentLocalizationsViewModel.cs +++ b/src/Orchard.Web/Core/Localization/ViewModels/ContentLocalizationsViewModel.cs @@ -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 Localizations { get; set; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/ViewModels/EditLocalizationViewModel.cs b/src/Orchard.Web/Core/Localization/ViewModels/EditLocalizationViewModel.cs new file mode 100644 index 000000000..9dd435a8b --- /dev/null +++ b/src/Orchard.Web/Core/Localization/ViewModels/EditLocalizationViewModel.cs @@ -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 SiteCultures { get; set; } + public IContent MasterContentItem { get; set; } + public ContentLocalizationsViewModel ContentLocalizations { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/ViewModels/SelectLocalizationsViewModel.cs b/src/Orchard.Web/Core/Localization/ViewModels/SelectLocalizationsViewModel.cs deleted file mode 100644 index d581664a2..000000000 --- a/src/Orchard.Web/Core/Localization/ViewModels/SelectLocalizationsViewModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Orchard.Core.Localization.Models; - -namespace Orchard.Core.Localization.ViewModels { - public class SelectLocalizationsViewModel { - public SelectLocalizationsViewModel(Localized part) { - - } - } -} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.SummaryAdmin.ascx b/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.SummaryAdmin.ascx index 371bb6823..e9d3522e4 100644 --- a/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.SummaryAdmin.ascx +++ b/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.SummaryAdmin.ascx @@ -4,7 +4,7 @@
    <% if (Model.Localizations.Count() > 0) { %> <%--//todo: need this info in the view model--%> -

    <%:T("Translations:") %>

    <%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations") %>
    <% +

    <%:T("Translations:") %>

    <%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemEditLink(c.Culture.Culture, c), "localizations") %>
    <% } %> -
    <%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.Id }, null)%>
    +
    <%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.MasterId }, null)%>
    \ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.ascx b/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.ascx index 1389d7a38..7511aac14 100644 --- a/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.ascx +++ b/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.ascx @@ -6,5 +6,5 @@ <%--//todo: need this info in the view model--%>
    <%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations") %>
    <% } %> -
    <%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.Id }, null)%>
    +
    <%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.MasterId }, null)%>
\ No newline at end of file diff --git a/src/Orchard.Web/Core/Localization/Views/EditorTemplates/Parts/Localization.Translation.ascx b/src/Orchard.Web/Core/Localization/Views/EditorTemplates/Parts/Localization.Translation.ascx new file mode 100644 index 000000000..5c388f609 --- /dev/null +++ b/src/Orchard.Web/Core/Localization/Views/EditorTemplates/Parts/Localization.Translation.ascx @@ -0,0 +1,24 @@ +<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> +<% +Html.RegisterStyle("admin.css"); +Html.RegisterStyle("base.css"); +if (Model.ContentLocalizations.MasterId > 0) { %> +
<% + if (Model.MasterContentItem != null) { %> +
+ +
<%:T("This is the {0} variation of {1}.", + Html.DropDownList("SelectedCulture", new SelectList(Model.SiteCultures, Model.SelectedCulture)), + Html.ItemEditLink(Model.MasterContentItem)) %>
+
<% + } + if (Model.ContentLocalizations.Localizations.Count() > 0) { //todo: find a good place for this info on the content edit page %> +
+
<%:Model.MasterContentItem != null ? T("Other translations:") : T("Translations:") %>
+
+ <%:Html.UnorderedList(Model.ContentLocalizations.Localizations, (c, i) => Html.ItemEditLink(c.Culture.Culture, c), "localizations") %> +
+
<% + } %> +
<% +} %> \ 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 5aa40ce5a..18367777d 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -80,6 +80,7 @@ + @@ -93,7 +94,6 @@ - @@ -233,6 +233,7 @@ + From e5d335792383d525a3ce653c9c494590f672c6ea Mon Sep 17 00:00:00 2001 From: Jonathan Wall Date: Tue, 20 Jul 2010 14:07:33 -0700 Subject: [PATCH 03/10] Sped up admin navigation toggle. --HG-- branch : dev --- src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js b/src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js index 31c9ae137..0306c639a 100644 --- a/src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js +++ b/src/Orchard.Web/Themes/TheAdmin/Scripts/admin.js @@ -1,6 +1,6 @@ $(document).ready(function(){ $("#navigation li span").click(function() { -$(this).next().next().slideToggle(600); +$(this).next().next().slideToggle(400); return false; }); }); From f97351ee5994451e7c897aa5d1d71df686121f5f Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 20 Jul 2010 14:34:01 -0700 Subject: [PATCH 04/10] Index dynamic content fields - Create a new index field named {part}-{field} - Had to remove "protected" qualifier on Storage accessor --HG-- branch : dev --- .../Handlers/InfosetFieldIndexingHandler.cs | 30 +++++++++++++++++++ .../Orchard.Indexing/Orchard.Indexing.csproj | 1 + src/Orchard/ContentManagement/ContentField.cs | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/Orchard.Web/Modules/Orchard.Indexing/Handlers/InfosetFieldIndexingHandler.cs diff --git a/src/Orchard.Web/Modules/Orchard.Indexing/Handlers/InfosetFieldIndexingHandler.cs b/src/Orchard.Web/Modules/Orchard.Indexing/Handlers/InfosetFieldIndexingHandler.cs new file mode 100644 index 000000000..cc82f3055 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Indexing/Handlers/InfosetFieldIndexingHandler.cs @@ -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( + (context, cp) => { + var infosetPart = context.ContentItem.As(); + if ( infosetPart != null ) { + foreach ( var part in infosetPart.ContentItem.Parts ) { + foreach ( var field in part.PartDefinition.Fields ) { + if ( field.Settings.GetModel().Included ) { + var fieldName = field.Name; + var value = part.Fields.Where(f => f.Name == fieldName).First().Storage.Get(null); + context.DocumentIndex.Add(String.Format("{0}-{1}", infosetPart.TypeDefinition.Name, fieldName.ToLower()), value).RemoveTags().Analyze(); + } + } + } + } + }); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Indexing/Orchard.Indexing.csproj b/src/Orchard.Web/Modules/Orchard.Indexing/Orchard.Indexing.csproj index 20add5d2e..27a1f975d 100644 --- a/src/Orchard.Web/Modules/Orchard.Indexing/Orchard.Indexing.csproj +++ b/src/Orchard.Web/Modules/Orchard.Indexing/Orchard.Indexing.csproj @@ -63,6 +63,7 @@ + diff --git a/src/Orchard/ContentManagement/ContentField.cs b/src/Orchard/ContentManagement/ContentField.cs index 3d3486ac5..1e2a5cd9d 100644 --- a/src/Orchard/ContentManagement/ContentField.cs +++ b/src/Orchard/ContentManagement/ContentField.cs @@ -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; } } } From b621af1a8a409ab93c16c6a4a56b5d2e6f88fe43 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 20 Jul 2010 14:44:47 -0700 Subject: [PATCH 05/10] Make "Container" and "Owner" the last parts to show on the editor screen --HG-- branch : dev --- src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs | 4 ++-- .../Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs b/src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs index 84c71fc20..89dbb5b5b 100644 --- a/src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/CommonDriver.cs @@ -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"); } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs index de1f5bcbd..ac4ceb686 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Drivers/HasCommentsDriver.cs @@ -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"); } } } \ No newline at end of file From 8c0ed525a1bc28ab00f591ec6b6230f4df08f175 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 20 Jul 2010 14:48:27 -0700 Subject: [PATCH 06/10] Scaffold module command creates Module.txt with all metadata properties set to a default value (author, version, description, etc). --HG-- branch : dev --- .../Orchard.DevTools/ScaffoldingTemplates/ModuleManifest.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/ScaffoldingTemplates/ModuleManifest.txt b/src/Orchard.Web/Modules/Orchard.DevTools/ScaffoldingTemplates/ModuleManifest.txt index 82a831e23..193964f30 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/ScaffoldingTemplates/ModuleManifest.txt +++ b/src/Orchard.Web/Modules/Orchard.DevTools/ScaffoldingTemplates/ModuleManifest.txt @@ -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$$. \ No newline at end of file From ee6ee571de0df902d983282d695eb189f307ed96 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 20 Jul 2010 14:58:36 -0700 Subject: [PATCH 07/10] Remove "+New Translation" link on the front-end (keep in "Manage Content" though). --HG-- branch : dev --- .../Parts/Localization.ContentTranslations.ascx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.ascx b/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.ascx index 7511aac14..9cf7d0d03 100644 --- a/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.ascx +++ b/src/Orchard.Web/Core/Localization/Views/DisplayTemplates/Parts/Localization.ContentTranslations.ascx @@ -1,10 +1 @@ <%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl" %> -<% - Html.RegisterStyle("base.css"); %> -
<% - if (Model.Localizations.Count() > 0) { %> - <%--//todo: need this info in the view model--%> -
<%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations") %>
<% - } %> -
<%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.MasterId }, null)%>
-
\ No newline at end of file From 2b72a69740112a82cfdfea62ecfae248265741a4 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 20 Jul 2010 15:08:45 -0700 Subject: [PATCH 08/10] Touch solution file at the end of each scaffolding command. --HG-- branch : dev --- .../Orchard.DevTools/Commands/ScaffoldingCommands.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Commands/ScaffoldingCommands.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Commands/ScaffoldingCommands.cs index dcaa4665a..b8f3f7ce7 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Commands/ScaffoldingCommands.cs +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Commands/ScaffoldingCommands.cs @@ -69,7 +69,7 @@ namespace Orchard.DevTools.Commands { projectFileText = projectFileText.Insert(projectFileText.LastIndexOf(""), 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); + } } } From efbae2c93b14a330a0ae0bb310bd90146199bf73 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 20 Jul 2010 17:30:28 -0700 Subject: [PATCH 09/10] =?UTF-8?q?Under=20DevTools,=20rename=20=E2=80=9CDat?= =?UTF-8?q?a=20Migration=E2=80=9D=20to=20=E2=80=9CDatabase=20Update?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : dev --- ...DataMigrationController.cs => DatabaseUpdateController.cs} | 4 ++-- .../Modules/Orchard.DevTools/Orchard.DevTools.csproj | 4 ++-- .../Views/{DataMigration => DatabaseUpdate}/Index.aspx | 2 +- .../Modules/Orchard.DevTools/Views/Home/Index.aspx | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename src/Orchard.Web/Modules/Orchard.DevTools/Controllers/{DataMigrationController.cs => DatabaseUpdateController.cs} (83%) rename src/Orchard.Web/Modules/Orchard.DevTools/Views/{DataMigration => DatabaseUpdate}/Index.aspx (86%) diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/DataMigrationController.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/DatabaseUpdateController.cs similarity index 83% rename from src/Orchard.Web/Modules/Orchard.DevTools/Controllers/DataMigrationController.cs rename to src/Orchard.Web/Modules/Orchard.DevTools/Controllers/DatabaseUpdateController.cs index ee0da1c75..ad89b140d 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/DataMigrationController.cs +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/DatabaseUpdateController.cs @@ -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; } diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Orchard.DevTools.csproj b/src/Orchard.Web/Modules/Orchard.DevTools/Orchard.DevTools.csproj index 089d9b74b..5eb447a86 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Orchard.DevTools.csproj +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Orchard.DevTools.csproj @@ -74,7 +74,7 @@ - + @@ -99,7 +99,7 @@ - + diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Views/DataMigration/Index.aspx b/src/Orchard.Web/Modules/Orchard.DevTools/Views/DatabaseUpdate/Index.aspx similarity index 86% rename from src/Orchard.Web/Modules/Orchard.DevTools/Views/DataMigration/Index.aspx rename to src/Orchard.Web/Modules/Orchard.DevTools/Views/DatabaseUpdate/Index.aspx index 7a5ba876d..6f49aa6be 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Views/DataMigration/Index.aspx +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Views/DatabaseUpdate/Index.aspx @@ -1,5 +1,5 @@ <%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage"%> <%@ Import Namespace="Orchard.Mvc.ViewModels"%>

<%: Html.TitleForPage(T("Data Migration").ToString()) %>

-

<%: Html.ActionLink(T("Update Database").ToString(), "UpdateDatabase", "DataMigration") %>

+

<%: Html.ActionLink(T("Update Database").ToString(), "UpdateDatabase", "DatabaseUpdate") %>

diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Views/Home/Index.aspx b/src/Orchard.Web/Modules/Orchard.DevTools/Views/Home/Index.aspx index 3e7859f27..7b95f214e 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Views/Home/Index.aspx +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Views/Home/Index.aspx @@ -4,4 +4,4 @@

<%: Html.ActionLink(T("Contents").ToString(), "Index", "Content") %>

<%: Html.ActionLink(T("Metadata").ToString(), "Index", "Metadata") %>

<%: Html.ActionLink(T("Test Unauthorized Request").ToString(), "NotAuthorized", "Home")%>

-

<%: Html.ActionLink(T("Data migration").ToString(), "Index", "DataMigration")%>

+

<%: Html.ActionLink(T("Database Update").ToString(), "Index", "DatabaseUpdate")%>

From c7ad9c06c9d12805ea65ee8a6f9bac20fe0c8a17 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 20 Jul 2010 17:48:51 -0700 Subject: [PATCH 10/10] =?UTF-8?q?Renaming=20a=20tag=20to=20the=20same=20na?= =?UTF-8?q?me=20as=20another=20tag=20didn=E2=80=99t=20collapse=20these=20i?= =?UTF-8?q?nto=20a=20single=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : dev --- .../Orchard.Tags/Services/TagService.cs | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Services/TagService.cs b/src/Orchard.Web/Modules/Orchard.Tags/Services/TagService.cs index e9e540f52..edae1aa46 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Services/TagService.cs +++ b/src/Orchard.Web/Modules/Orchard.Tags/Services/TagService.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 = _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 GetTaggedContentItems(int id) {