#19262: Adding /Name switch to "widget create" command and removing unused contentManager.

Work Item: 19262

--HG--
branch : 1.x
This commit is contained in:
Sipke Schoorstra
2013-04-06 20:43:17 +02:00
parent 6850d9d3da
commit d6f86b3e2a

View File

@@ -6,7 +6,6 @@ using Orchard.ContentManagement.Aspects;
using Orchard.Core.Common.Models;
using Orchard.Core.Navigation.Models;
using Orchard.Core.Navigation.Services;
using Orchard.Core.Title.Models;
using Orchard.Security;
using Orchard.Settings;
using Orchard.Widgets.Models;
@@ -17,7 +16,6 @@ namespace Orchard.Widgets.Commands {
private readonly IWidgetsService _widgetsService;
private readonly ISiteService _siteService;
private readonly IMembershipService _membershipService;
private readonly IContentManager _contentManager;
private readonly IMenuService _menuService;
private const string LoremIpsum = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur a nibh ut tortor dapibus vestibulum. Aliquam vel sem nibh. Suspendisse vel condimentum tellus.</p>";
@@ -25,12 +23,10 @@ namespace Orchard.Widgets.Commands {
IWidgetsService widgetsService,
ISiteService siteService,
IMembershipService membershipService,
IContentManager contentManager,
IMenuService menuService) {
_widgetsService = widgetsService;
_siteService = siteService;
_membershipService = membershipService;
_contentManager = contentManager;
_menuService = menuService;
RenderTitle = true;
@@ -39,6 +35,9 @@ namespace Orchard.Widgets.Commands {
[OrchardSwitch]
public string Title { get; set; }
[OrchardSwitch]
public string Name { get; set; }
[OrchardSwitch]
public bool RenderTitle { get; set; }
@@ -70,8 +69,8 @@ namespace Orchard.Widgets.Commands {
public string MenuName { get; set; }
[CommandName("widget create")]
[CommandHelp("widget create <type> /Title:<title> /Zone:<zone> /Position:<position> /Layer:<layer> [/Identity:<identity>] [/RenderTitle:true|false] [/Owner:<owner>] [/Text:<text>] [/UseLoremIpsumText:true|false] [/MenuName:<name>]\r\n\t" + "Creates a new widget")]
[OrchardSwitches("Title,Zone,Position,Layer,Identity,Owner,Text,UseLoremIpsumText,MenuName,RenderTitle")]
[CommandHelp("widget create <type> /Title:<title> /Name:<name> /Zone:<zone> /Position:<position> /Layer:<layer> [/Identity:<identity>] [/RenderTitle:true|false] [/Owner:<owner>] [/Text:<text>] [/UseLoremIpsumText:true|false] [/MenuName:<name>]\r\n\t" + "Creates a new widget")]
[OrchardSwitches("Title,Name,Zone,Position,Layer,Identity,Owner,Text,UseLoremIpsumText,MenuName,RenderTitle")]
public void Create(string type) {
var widgetTypeNames = _widgetsService.GetWidgetTypeNames();
if (!widgetTypeNames.Contains(type)) {
@@ -88,6 +87,11 @@ namespace Orchard.Widgets.Commands {
}
var widget = _widgetsService.CreateWidget(layer.ContentItem.Id, type, T(Title).Text, Position, Zone);
if (!String.IsNullOrWhiteSpace(Name)) {
widget.Name = Name.Trim();
}
var text = String.Empty;
if (widget.Has<BodyPart>()) {
if (UseLoremIpsumText) {