--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-06-24 14:35:34 -07:00
27 changed files with 649 additions and 97 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
@@ -102,44 +103,12 @@ namespace Orchard.Core.Contents.Controllers {
var viewModel = new EditTypeViewModel();
TryUpdateModel(viewModel);
if (!ModelState.IsValid) {
if (!ModelState.IsValid)
return EditType(id);
}
var contentTypeDefinitionParts = viewModel.Parts.Select(
p => new ContentTypeDefinition.Part(
new ContentPartDefinition(
p.PartDefinition.Name,
p.PartDefinition.Fields.Select(
f => new ContentPartDefinition.Field(
new ContentFieldDefinition(f.FieldDefinition.Name),
f.Name,
f.Settings
)
),
p.PartDefinition.Settings
),
p.Settings
)
).ToList();
if (viewModel.Fields.Any()) {
var implicitContentTypeDefinitionPart = new ContentTypeDefinition.Part(
new ContentPartDefinition(
viewModel.Name,
viewModel.Fields.Select(
f => new ContentPartDefinition.Field(
new ContentFieldDefinition(f.FieldDefinition.Name),
f.Name,
f.Settings
)
),
null
),
null
);
contentTypeDefinitionParts.Add(implicitContentTypeDefinitionPart);
}
var contentTypeDefinitionParts = viewModel.Parts.Select(GenerateTypePart).ToList();
if (viewModel.Fields.Any())
contentTypeDefinitionParts.Add(GenerateTypePart(viewModel));
//todo: apply the changes along the lines of but definately not resembling
// for now this _might_ just get a little messy ->
@@ -151,11 +120,48 @@ namespace Orchard.Core.Contents.Controllers {
viewModel.Settings
)
);
// little == lot
return RedirectToAction("Index");
}
private static ContentTypeDefinition.Part GenerateTypePart(EditTypePartViewModel viewModel) {
return new ContentTypeDefinition.Part(
new ContentPartDefinition(
viewModel.PartDefinition.Name,
viewModel.PartDefinition.Fields.Select(
f => new ContentPartDefinition.Field(
new ContentFieldDefinition(f.FieldDefinition.Name),
f.Name,
f.Settings
)
),
viewModel.PartDefinition.Settings
),
viewModel.Settings
);
}
private static ContentTypeDefinition.Part GenerateTypePart(EditTypeViewModel viewModel) {
return new ContentTypeDefinition.Part(
new ContentPartDefinition(
viewModel.Name,
viewModel.Fields.Select(
f => new ContentPartDefinition.Field(
new ContentFieldDefinition(f.FieldDefinition.Name),
f.Name,
f.Settings
)
),
null
),
null
);
}
#endregion
#region Parts
public ActionResult EditPart(string id) {
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
return new HttpUnauthorizedResult();
@@ -181,36 +187,101 @@ namespace Orchard.Core.Contents.Controllers {
var viewModel = new EditPartViewModel();
TryUpdateModel(viewModel);
if (!ModelState.IsValid) {
if (!ModelState.IsValid)
return EditPart(id);
}
//todo: apply the changes along the lines of but definately not resembling
// for now this _might_ just get a little messy ->
_contentDefinitionService.AlterPartDefinition(
new ContentPartDefinition(
viewModel.Name,
viewModel.Fields.Select(
f => new ContentPartDefinition.Field(
new ContentFieldDefinition(f.FieldDefinition.Name),
f.Name,
f.Settings
)
),
viewModel.Settings
)
);
// little == lot
_contentDefinitionService.AlterPartDefinition(GeneratePart(viewModel));
return RedirectToAction("Index");
}
public ActionResult AddFieldTo(string id) {
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
return new HttpUnauthorizedResult();
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
if (contentPartDefinition == null) {
//id passed in might be that of a type w/ no implicit field
var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id);
if (contentTypeDefinition != null)
contentPartDefinition = new ContentPartDefinition(id);
else
return new NotFoundResult();
}
var viewModel = new AddFieldViewModel {
Part = new EditPartViewModel(contentPartDefinition),
Fields = _contentDefinitionService.GetFieldDefinitions()
};
return View(viewModel);
}
[HttpPost, ActionName("AddFieldTo")]
public ActionResult AddFieldToPOST(string id) {
if (!Services.Authorizer.Authorize(Permissions.CreateContentTypes, T("Not allowed to edit a part.")))
return new HttpUnauthorizedResult();
var viewModel = new AddFieldViewModel();
TryUpdateModel(viewModel);
var contentPartDefinition = _contentDefinitionService.GetPartDefinition(id);
var contentTypeDefinition = _contentDefinitionService.GetTypeDefinition(id);
if (!ModelState.IsValid)
return AddFieldTo(id);
if (contentPartDefinition == null) {
//id passed in might be that of a type w/ no implicit field
if (contentTypeDefinition != null) {
contentPartDefinition = new ContentPartDefinition(id);
var contentTypeDefinitionParts = contentTypeDefinition.Parts.ToList();
contentTypeDefinitionParts.Add(new ContentTypeDefinition.Part(contentPartDefinition, null));
_contentDefinitionService.AlterTypeDefinition(
new ContentTypeDefinition(
contentTypeDefinition.Name,
contentTypeDefinition.DisplayName,
contentTypeDefinitionParts,
contentTypeDefinition.Settings
)
);
}
else {
return new NotFoundResult();
}
}
var contentPartFields = contentPartDefinition.Fields.ToList();
contentPartFields.Add(new ContentPartDefinition.Field(new ContentFieldDefinition(viewModel.FieldTypeName), viewModel.DisplayName, null));
_contentDefinitionService.AlterPartDefinition(new ContentPartDefinition(contentPartDefinition.Name, contentPartFields, contentPartDefinition.Settings));
if (contentTypeDefinition != null)
return RedirectToAction("EditType", new { id });
return RedirectToAction("EditPart", new {id});
}
private static ContentPartDefinition GeneratePart(EditPartViewModel viewModel) {
return new ContentPartDefinition(
viewModel.Name,
viewModel.Fields.Select(
f => new ContentPartDefinition.Field(
new ContentFieldDefinition(f.FieldDefinition.Name),
f.Name,
f.Settings
)
),
viewModel.Settings
);
}
#endregion
#region Content
#endregion
public ActionResult List(ListContentsViewModel model) {
const int pageSize = 20;
var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize;
@@ -328,5 +399,7 @@ namespace Orchard.Core.Contents.Controllers {
void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) {
ModelState.AddModelError(key, errorMessage.ToString());
}
#endregion
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.Localization;
@@ -10,10 +11,12 @@ using Orchard.UI.Notify;
namespace Orchard.Core.Contents.Services {
public class ContentDefinitionService : IContentDefinitionService {
private readonly IContentDefinitionManager _contentDefinitionManager;
private readonly IEnumerable<IContentFieldDriver> _contentFieldDrivers;
public ContentDefinitionService(IOrchardServices services, IContentDefinitionManager contentDefinitionManager) {
public ContentDefinitionService(IOrchardServices services, IContentDefinitionManager contentDefinitionManager, IEnumerable<IContentFieldDriver> contentFieldDrivers) {
Services = services;
_contentDefinitionManager = contentDefinitionManager;
_contentFieldDrivers = contentFieldDrivers;
T = NullLocalizer.Instance;
}
@@ -76,6 +79,10 @@ namespace Orchard.Core.Contents.Services {
throw new NotImplementedException();
}
public IEnumerable<ContentFieldInfo> GetFieldDefinitions() {
return _contentFieldDrivers.SelectMany(d => d.GetFieldInfo());
}
//gratuitously stolen from the RoutableService
private static string GenerateTypeName(string displayName) {
if (string.IsNullOrWhiteSpace(displayName))

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
namespace Orchard.Core.Contents.Services {
@@ -13,5 +14,7 @@ namespace Orchard.Core.Contents.Services {
void AddPartDefinition(ContentPartDefinition contentPartDefinition);
void AlterPartDefinition(ContentPartDefinition contentPartDefinition);
void RemovePartDefinition(string name);
IEnumerable<ContentFieldInfo> GetFieldDefinitions();
}
}

View File

@@ -5,13 +5,42 @@
margin-top:-4em;
}
.manage-part h3 {
.manage-part h3,
.manage-field h3 {
border-bottom:1px solid #EAEAEA;
}
.manage-part .manage {
.manage-part .manage,
.manage-field .manage {
font-size:1.4em;
margin-top:-2.4em;
}
.manage-part .manage.minor {
margin-top:-1.7em;
}
.manage-part label,
.manage-field label {
font-weight:normal;
}
/* should pull this back into the base admin theme css, w/out the .manage-part of course */
.manage-part dl {
margin:0 0 1em;
overflow:auto;
padding:6px 0 0;
}
.manage-part dt {
font-weight:bold;
}
.manage-part dl dl {
font-size:1em;
margin:0;
padding:0;
}
.manage-part dd dt {
clear:left;
float:left;
}
.manage-part dd dd {
float:left;
padding-left:.5em;
}

View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
using Orchard.ContentManagement.MetaData;
using Orchard.Mvc.ViewModels;
namespace Orchard.Core.Contents.ViewModels {
public class AddFieldViewModel : BaseViewModel {
public AddFieldViewModel() {
Fields = new List<ContentFieldInfo>();
}
public string DisplayName { get; set; }
public string FieldTypeName { get; set; }
public EditPartViewModel Part { get; set; }
public IEnumerable<ContentFieldInfo> Fields { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<AddFieldViewModel>" %>
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><%
Html.RegisterStyle("admin.css"); %>
<h1><%:Html.TitleForPage(T("Add a new field to {0}", Model.Part.Name).ToString())%></h1><%
using (Html.BeginFormAntiForgeryPost()) { %>
<%:Html.ValidationSummary() %>
<fieldset>
<label for="DisplayName"><%:T("Display Name") %></label>
<%:Html.TextBoxFor(m => m.DisplayName, new {@class = "textMedium", autofocus = "autofocus"}) %>
</fieldset>
<fieldset>
<label for="FieldTypeName"><%:T("Field Type") %></label>
<%:Html.DropDownListFor(m => m.FieldTypeName, new SelectList(Model.Fields, "FieldTypeName", "FieldTypeName"))%>
</fieldset>
<fieldset>
<button class="primaryAction" type="submit"><%:T("Save") %></button>
</fieldset><%
} %>

View File

@@ -1,7 +1,7 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<EditPartViewModel>" %>
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><%
Html.RegisterStyle("admin.css"); %>
<h1><%:Html.TitleForPage(T("Edit Part").ToString())%></h1><%
<h1><%:Html.TitleForPage(T("Edit Part").ToString()) %></h1><%
using (Html.BeginFormAntiForgeryPost()) { %>
<%:Html.ValidationSummary() %>
<fieldset>
@@ -9,9 +9,9 @@ using (Html.BeginFormAntiForgeryPost()) { %>
<%--// has unintended consequences (renamging the part) - changing the name creates a new part of that name--%>
<%:Html.TextBoxFor(m => m.Name, new {@class = "textMedium"}) %>
</fieldset>
<%:Html.EditorFor(m => m.Settings, "Settings", "")%>
<%:Html.EditorFor(m => m.Settings, "Settings", "") %>
<h2><%:T("Fields") %></h2>
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddField", new { }, new { @class = "button" })%></div>
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Contents", id = Model.Name }, new { @class = "button" }) %></div>
<%:Html.EditorFor(m => m.Fields, "Fields", "") %>
<fieldset>
<button class="primaryAction" type="submit"><%:T("Save") %></button>

View File

@@ -1,7 +1,8 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<EditTypeViewModel>" %>
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><%
Html.RegisterStyle("admin.css"); %>
<h1><%:Html.TitleForPage(T("Edit Content Type").ToString())%></h1><%
<h1><%:Html.TitleForPage(T("Edit Content Type").ToString())%></h1>
<p class="breadcrumb"><%:Html.ActionLink(T("Content Types").Text, "index") %><%:T(" &#62; ") %><%:T("Edit Content Type") %></p><%
using (Html.BeginFormAntiForgeryPost()) { %>
<%:Html.ValidationSummary() %>
<fieldset>
@@ -14,11 +15,11 @@ using (Html.BeginFormAntiForgeryPost()) { %>
</fieldset>
<%:Html.EditorFor(m => m.Settings) %>
<h2><%:T("Parts") %></h2>
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddPart", new { }, new { @class = "button" })%></div>
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddPart", new { }, new { @class = "button" }) %></div>
<%:Html.EditorFor(m => m.Parts, "Parts", "") %>
<h2><%:T("Fields") %></h2>
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddField", new { }, new { @class = "button" })%></div>
<%:Html.EditorFor(m => m.Fields, "Fields", "")%>
<div class="manage add-to-type"><%: Html.ActionLink(T("Add").Text, "AddFieldTo", new { area = "Contents", id = Model.Name }, new { @class = "button" }) %></div>
<%:Html.EditorFor(m => m.Fields, "Fields", "") %>
<fieldset>
<button class="primaryAction" type="submit"><%:T("Save") %></button>
</fieldset><%

View File

@@ -0,0 +1,6 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<EditPartFieldViewModel>" %>
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
<dt><%:Model.Name %> <span>(<%:Model.FieldDefinition.Name %>)</span></dt>
<dd>
<%:Html.DisplayFor(m => m.Settings, "Settings", "") %>
</dd>

View File

@@ -1,10 +1,10 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<EditPartFieldViewModel>>" %>
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %><%
if (Model.Any()) { %>
<fieldset><%
<dl><%
foreach (var field in Model) {
var f = field; %>
<%:Html.EditorFor(m => f, "Part.Fields") %><%
<%:Html.DisplayFor(m => f, "Field") %><%
} %>
</fieldset><%
</dl><%
} %>

View File

@@ -1,9 +1,8 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<EditPartFieldViewModel>" %>
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
<fieldset>
<h3><%:Model.Name %></h3>
<h4><%:Model.FieldDefinition.Name %></h4>
<div class="manage add-to-type">
<fieldset class="manage-field">
<h3><%:Model.Name %> <span>(<%:Model.FieldDefinition.Name %>)</span></h3>
<div class="manage">
<%--// these inline forms can't be here. should probably have some JavaScript in here to build up the forms and add the "remove" link.
// get the antiforgery token from the edit type form and mark up the part in a semantic way so I can get some info from the DOM --%>
<%:Html.Link("[remove]", "#forshowonlyandnotintendedtowork!") %>

View File

@@ -1,14 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentPartDefinition.Field>" %>
<%@ Import Namespace="Orchard.ContentManagement.MetaData.Models" %>
<fieldset>
<h3><%:Model.FieldDefinition.Name %></h3>
<div class="manage add-to-type">
<%--// these inline forms can't be here. should probably have some JavaScript in here to build up the forms and add the "remove" link.
// get the antiforgery token from the edit type form and mark up the part in a semantic way so I can get some info from the DOM --%>
<%:Html.Link("[remove]", "#forshowonlyandnotintendedtowork!") %>
<%-- <% using (Html.BeginFormAntiForgeryPost(Url.Action("RemovePart", new { area = "Contents" }), FormMethod.Post, new {@class = "inline link"})) { %>
<%=Html.Hidden("name", Model.PartDefinition.Name, new { id = "" }) %>
<button type="submit" title="<%:T("Remove") %>"><%:T("Remove") %></button>
<% } %> --%>
</div>
</fieldset>

View File

@@ -11,12 +11,10 @@
<button type="submit" title="<%:T("Remove") %>"><%:T("Remove") %></button>
<% } %> --%>
</div>
<%:Html.EditorFor(m => m.Settings, "Settings", "") %><%
if (Model.PartDefinition.Settings.Any() || Model.PartDefinition.Fields.Any()) { %>
<%:Html.EditorFor(m => m.Settings, "Settings", "") %>
<h4><%:T("Global configuration") %></h4>
<div class="manage minor"><%:Html.ActionLink(T("Edit").Text, "EditPart", new { area = "Contents", id = Model.PartDefinition.Name }) %></div>
<%:Html.DisplayFor(m => m.PartDefinition.Settings, "Settings", "PartDefinition") %>
<%:Html.EditorFor(m => m.PartDefinition.Fields, "Part.Fields") %><%
} %>
<%:Html.DisplayFor(m => m.PartDefinition.Fields, "Fields") %>
<%:Html.Hidden("PartDefinition.Name", Model.PartDefinition.Name) %>
</fieldset>

View File

@@ -1,8 +1,7 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SettingsDictionary>" %>
<%@ import Namespace="Orchard.ContentManagement.MetaData.Models" %><%
if (Model.Any()) { %>
<fieldset>
<legend><%:T("[Settings]") %></legend><%
<fieldset><%
var si = 0;
foreach (var setting in Model) {
var s = setting;

View File

@@ -76,6 +76,7 @@
<Compile Include="Contents\Permissions.cs" />
<Compile Include="Contents\Services\ContentDefinitionService.cs" />
<Compile Include="Contents\Services\IContentDefinitionService.cs" />
<Compile Include="Contents\ViewModels\AddFieldViewModel.cs" />
<Compile Include="Contents\ViewModels\EditTypeViewModel.cs" />
<Compile Include="Contents\ViewModels\CreateTypeViewModel.cs" />
<Compile Include="Contents\ViewModels\ListContentsViewModel.cs" />
@@ -207,6 +208,7 @@
<Content Include="Common\Views\EditorTemplates\Parts\Common.Container.ascx" />
<Content Include="Contents\Module.txt" />
<Content Include="Contents\Styles\admin.css" />
<Content Include="Contents\Views\Admin\AddFieldTo.ascx" />
<Content Include="Contents\Views\Admin\EditPart.ascx" />
<Content Include="Contents\Views\Admin\EditType.ascx" />
<Content Include="Contents\Views\Admin\CreateType.ascx" />
@@ -221,8 +223,8 @@
<Content Include="Contents\Views\EditorTemplates\Field.ascx" />
<Content Include="Contents\Views\EditorTemplates\Fields.ascx" />
<Content Include="Contents\Views\EditorTemplates\Settings.ascx" />
<Content Include="Contents\Views\EditorTemplates\Part.Fields.ascx" />
<Content Include="Contents\Views\EditorTemplates\Part.Field.ascx" />
<Content Include="Contents\Views\DisplayTemplates\Fields.ascx" />
<Content Include="Contents\Views\DisplayTemplates\Field.ascx" />
<Content Include="Contents\Views\EditorTemplates\Parts.ascx" />
<Content Include="Contents\Views\EditorTemplates\Part.ascx" />
<Content Include="Contents\Views\EditorTemplates\Items\Contents.Item.ascx" />

View File

@@ -46,6 +46,10 @@ namespace Orchard.Core.Settings.Metadata {
return _partDefinitionRepository.Fetch(x => !x.Hidden).Select(Build).ToReadOnlyCollection();
}
public IEnumerable<ContentFieldDefinition> ListFieldDefinitions() {
return _fieldDefinitionRepository.Fetch(x => true, cfdr => cfdr.Asc(fdr => fdr.Name)).Select(Build).ToReadOnlyCollection();
}
public void StoreTypeDefinition(ContentTypeDefinition contentTypeDefinition) {
Apply(contentTypeDefinition, Acquire(contentTypeDefinition));
}

View File

@@ -3,9 +3,11 @@ using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Common.Models;
using Orchard.Core.Navigation.Models;
using Orchard.Environment.Extensions;
using Orchard.Security;
namespace Orchard.DevTools.Commands {
[OrchardFeature("Profiling")]
public class ProfilingCommands : DefaultOrchardCommandHandler {
private readonly IContentManager _contentManager;
private readonly IMembershipService _membershipService;

View File

@@ -0,0 +1,136 @@
using System;
using System.IO;
using System.Linq;
using System.Web.Hosting;
using Orchard.Commands;
using Orchard.Environment.Extensions;
namespace Orchard.DevTools.Commands {
[OrchardFeature("Scaffolding")]
public class ScaffoldingCommands : DefaultOrchardCommandHandler {
private readonly IExtensionManager _extensionManager;
public ScaffoldingCommands(IExtensionManager extensionManager) {
_extensionManager = extensionManager;
}
[OrchardSwitch]
public bool IncludeInSolution { get; set; }
[CommandHelp("scaffolding create module <module-name> [/IncludeInSolution:true|false]\r\n\t" + "Create a new Orchard module")]
[CommandName("scaffolding create module")]
[OrchardSwitches("IncludeInSolution")]
public void CreateModule(string moduleName) {
Context.Output.WriteLine(T("Creating Module {0}", moduleName));
if (_extensionManager.AvailableExtensions().Any(extension => extension.ExtensionType == "Module" && String.Equals(moduleName, extension.DisplayName, StringComparison.OrdinalIgnoreCase))) {
Context.Output.WriteLine(T("Creating Module {0} failed: a module of the same name already exists", moduleName));
return;
}
IntegrateModule(moduleName);
Context.Output.WriteLine(T("Module {0} created successfully", moduleName));
}
[CommandHelp("scaffolding create controller <module-name> <controller-name>\r\n\t" + "Create a new Orchard controller in a module")]
[CommandName("scaffolding create controller")]
public void CreateController(string moduleName, string controllerName) {
Context.Output.WriteLine(T("Creating Controller {0} in Module {1}", controllerName, moduleName));
foreach (var extension in _extensionManager.AvailableExtensions()) {
if (extension.ExtensionType == "Module" && String.Equals(moduleName, extension.DisplayName, StringComparison.OrdinalIgnoreCase)) {
string moduleControllersPath = HostingEnvironment.MapPath("~/Modules/" + extension.Name + "/Controllers/");
string controllerPath = moduleControllersPath + controllerName + ".cs";
string moduleCsProjPath = HostingEnvironment.MapPath(string.Format("~/Modules/{0}/{0}.csproj", extension.Name));
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard.DevTools/ScaffoldingTemplates/");
if (!Directory.Exists(moduleControllersPath)) {
Directory.CreateDirectory(moduleControllersPath);
}
if (File.Exists(controllerPath)) {
Context.Output.WriteLine(T("Controller {0} already exists in target Module {1}.", controllerName, moduleName));
return;
}
string controllerText = File.ReadAllText(templatesPath + "Controller.txt");
controllerText = controllerText.Replace("$$ModuleName$$", moduleName);
controllerText = controllerText.Replace("$$ControllerName$$", controllerName);
File.WriteAllText(controllerPath, controllerText);
string projectFileText = File.ReadAllText(moduleCsProjPath);
// The string searches in solution/project files can be made aware of comment lines.
if (projectFileText.Contains("<Compile Include")) {
string compileReference = string.Format("<Compile Include=\"{0}\" />\r\n ", "Controllers\\" + controllerName + ".cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("<Compile Include"), compileReference);
}
else {
string itemGroupReference = string.Format("</ItemGroup>\r\n <ItemGroup>\r\n <Compile Include=\"{0}\" />\r\n ", "Controllers\\" + controllerName + ".cs");
projectFileText = projectFileText.Insert(projectFileText.LastIndexOf("</ItemGroup>"), itemGroupReference);
}
File.WriteAllText(moduleCsProjPath, projectFileText);
Context.Output.WriteLine(T("Controller {0} created successfully in Module {1}", controllerName, moduleName));
return;
}
}
Context.Output.WriteLine(T("Creating Controller {0} failed: target Module {1} could not be found.", controllerName, moduleName));
}
private void IntegrateModule(string moduleName) {
string rootWebProjectPath = HostingEnvironment.MapPath("~/Orchard.Web.csproj");
string projectGuid = Guid.NewGuid().ToString().ToUpper();
CreateFilesFromTemplates(moduleName, projectGuid);
// The string searches in solution/project files can be made aware of comment lines.
if (IncludeInSolution) {
// Add project reference to Orchard.Web.csproj
string webProjectReference = string.Format(
"</ProjectReference>\r\n <ProjectReference Include=\"Modules\\Orchard.{0}\\Orchard.{0}.csproj\">\r\n <Project>{{{1}}}</Project>\r\n <Name>Orchard.{0}</Name>\r\n ",
moduleName, projectGuid);
string webProjectText = File.ReadAllText(rootWebProjectPath);
webProjectText = webProjectText.Insert(webProjectText.LastIndexOf("</ProjectReference>\r\n"), webProjectReference);
File.WriteAllText(rootWebProjectPath, webProjectText);
// Add project to Orchard.sln
string solutionPath = Directory.GetParent(rootWebProjectPath).Parent.FullName + "\\Orchard.sln";
if (File.Exists(solutionPath)) {
string projectReference = string.Format(
"EndProject\r\nProject(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"Orchard.{0}\", \"Orchard.Web\\Modules\\Orchard.{0}\\Orchard.{0}.csproj\", \"{{{1}}}\"\r\n",
moduleName, projectGuid);
string projectConfiguationPlatforms = string.Format(
"GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{{{0}}}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r\n\t\t{{{0}}}.Debug|Any CPU.Build.0 = Debug|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.ActiveCfg = Release|Any CPU\r\n\t\t{{{0}}}.Release|Any CPU.Build.0 = Release|Any CPU\r\n",
projectGuid);
string solutionText = File.ReadAllText(solutionPath);
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndProject\r\n"), projectReference);
solutionText = solutionText.Replace("GlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n", projectConfiguationPlatforms);
solutionText = solutionText.Insert(solutionText.LastIndexOf("EndGlobalSection"), "\t{" + projectGuid + "} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}\r\n\t");
File.WriteAllText(solutionPath, solutionText);
}
else {
Context.Output.WriteLine(T("Warning: Solution file could not be found at {0}", solutionPath));
}
}
}
private static void CreateFilesFromTemplates(string moduleName, string projectGuid) {
string modulePath = HostingEnvironment.MapPath("~/Modules/Orchard." + moduleName + "/");
string propertiesPath = modulePath + "Properties";
string templatesPath = HostingEnvironment.MapPath("~/Modules/Orchard.DevTools/ScaffoldingTemplates/");
Directory.CreateDirectory(modulePath);
Directory.CreateDirectory(propertiesPath);
string templateText = File.ReadAllText(templatesPath + "ModuleAssemblyInfo.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
templateText = templateText.Replace("$$ModuleTypeLibGuid$$", Guid.NewGuid().ToString());
File.WriteAllText(propertiesPath + "\\AssemblyInfo.cs", templateText);
File.WriteAllText(modulePath + "\\Web.config", File.ReadAllText(templatesPath + "ModuleWebConfig.txt"));
templateText = File.ReadAllText(templatesPath + "ModuleManifest.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
File.WriteAllText(modulePath + "\\Module.txt", templateText);
templateText = File.ReadAllText(templatesPath + "\\ModuleCsProj.txt");
templateText = templateText.Replace("$$ModuleName$$", moduleName);
templateText = templateText.Replace("$$ModuleProjectGuid$$", projectGuid);
File.WriteAllText(modulePath + "\\Orchard." + moduleName + ".csproj", templateText);
}
}
}

View File

@@ -7,5 +7,13 @@ orchardversion: 0.1.2010.0312
description: This module is not activated by default and should only be used in a development environment. It contains various debugging and tracing tools that can display information about your content types.
features:
Orchard.DevTools:
Description: An assortment of debuging tools.
Category: Developer
Description: An assortment of debugging tools.
Category: Developer
Scaffolding:
Description: Tools to create Orchard components.
Category: Developer
Dependencies: Orchard.DevTools
Profiling:
Description: Tools to help profile Orchard.
Category: Developer
Dependencies: Orchard.DevTools

View File

@@ -71,6 +71,7 @@
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Commands\ProfilingCommands.cs" />
<Compile Include="Commands\ScaffoldingCommands.cs" />
<Compile Include="Controllers\ContentController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\MetadataController.cs" />
@@ -85,6 +86,11 @@
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="ScaffoldingTemplates\Controller.txt" />
<Content Include="ScaffoldingTemplates\ModuleAssemblyInfo.txt" />
<Content Include="ScaffoldingTemplates\ModuleCsProj.txt" />
<Content Include="ScaffoldingTemplates\ModuleManifest.txt" />
<Content Include="ScaffoldingTemplates\ModuleWebConfig.txt" />
<Content Include="Views\Home\_RenderableAction.ascx" />
<Content Include="Views\Home\Simple.aspx" />
<Content Include="Views\Content\Details.aspx" />
@@ -106,6 +112,7 @@
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -0,0 +1,15 @@
using System.Web.Mvc;
using Orchard.Localization;
namespace Orchard.$$ModuleName$$.Controllers {
public class $$ControllerName$$ : Controller {
public IOrchardServices Services { get; set; }
public $$ControllerName$$(IOrchardServices services) {
Services = services;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
}
}

View File

@@ -0,0 +1,34 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Orchard.$$ModuleName$$")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Orchard")]
[assembly: AssemblyCopyright("Copyright © CodePlex Foundation 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("$$ModuleTypeLibGuid$$")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{$$ModuleProjectGuid$$}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Orchard.$$ModuleName$$</RootNamespace>
<AssemblyName>Orchard.$$ModuleName$$</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Web.Mobile" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target> -->
<!-- To enable MVC area subproject support, uncomment the following two lines:
<UsingTask TaskName="Microsoft.Web.Mvc.Build.CreateAreaManifest" AssemblyName="Microsoft.Web.Mvc.Build, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<UsingTask TaskName="Microsoft.Web.Mvc.Build.CopyAreaManifests" AssemblyName="Microsoft.Web.Mvc.Build, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
-->
<Target Name="AfterBuild" DependsOnTargets="AfterBuildCompiler">
<PropertyGroup>
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
</PropertyGroup>
<!-- If this is an area child project, uncomment the following line:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
-->
<!-- If this is an area parent project, uncomment the following lines:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
-->
</Target>
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>45979</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@@ -0,0 +1,5 @@
name: $$ModuleName$$
antiforgery: enabled
features:
Orchard.$$ModuleName$$:
Description: Description for feature $$ModuleName$$.

View File

@@ -0,0 +1,75 @@
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
</compilation>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Linq"/>
<add namespace="System.Collections.Generic"/>
<add namespace="Orchard.Mvc.Html"/>
</namespaces>
</pages>
<httpHandlers>
<add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
</system.web>
<system.web.extensions/>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
</modules>
<handlers>
<remove name="MvcHttpHandler"/>
<remove name="UrlRoutingHandler"/>
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -147,10 +147,11 @@ h1 { font-size:2.6em; } /* 26px */
h2 { font-size:2.1em; } /* 21px */
h2 span { font-size:.57em; } /* 12px */
h3 { font-size:1.8em; } /* 18px */
h3 span { font-size:.667em; } /* 12px */
h4 { font-size:1.6em; } /* 16px */
h5 { font-size:1.4em; } /* 14px */
h6, p, label, /*input, select,*/ .button,
h6, p, dl, label, /*input, select,*/ .button,
.message, .validation-summary-errors,
table.items th, table.items td, table.items caption { font-size:1.4em; line-height:1.4em; } /* 14px */
table.items p, table.items label, table.items input, table.items .button { font-size:1em; line-height:1em; }

View File

@@ -7,6 +7,7 @@ namespace Orchard.ContentManagement.MetaData {
public interface IContentDefinitionManager : IDependency {
IEnumerable<ContentTypeDefinition> ListTypeDefinitions();
IEnumerable<ContentPartDefinition> ListPartDefinitions();
IEnumerable<ContentFieldDefinition> ListFieldDefinitions();
ContentTypeDefinition GetTypeDefinition(string name);
ContentPartDefinition GetPartDefinition(string name);