mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Starting to give more attention to generic content management
--HG-- branch : dev
This commit is contained in:
@@ -18,18 +18,18 @@ namespace Orchard.Core.Contents {
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
//var contentTypeDefinitions = _contentDefinitionManager.ListTypeDefinitions().OrderBy(d => d.Name);
|
||||
var contentTypeDefinitions = _contentDefinitionManager.ListTypeDefinitions().OrderBy(d => d.Name);
|
||||
|
||||
//builder.Add(T("Content"), "1", menu => {
|
||||
// menu.Add(T("Manage Content"), "1.2", item => item.Action("List", "Admin", new {area = "Orchard.ContentTypes"}));
|
||||
//foreach (var contentTypeDefinition in contentTypeDefinitions) {
|
||||
// var ci = _contentManager.New(contentTypeDefinition.Name);
|
||||
// var cim = _contentManager.GetItemMetadata(ci);
|
||||
// var createRouteValues = cim.CreateRouteValues;
|
||||
// if (createRouteValues.Any())
|
||||
// menu.Add(T("Create New {0}", contentTypeDefinition.DisplayName), "1.3", item => item.Action(cim.CreateRouteValues["Action"] as string, cim.CreateRouteValues["Controller"] as string, cim.CreateRouteValues));
|
||||
//}
|
||||
//});
|
||||
builder.Add(T("Content"), "1", menu => {
|
||||
menu.Add(T("Manage Content"), "1.2", item => item.Action("List", "Admin", new { area = "Contents" }));
|
||||
foreach (var contentTypeDefinition in contentTypeDefinitions) {
|
||||
var ci = _contentManager.New(contentTypeDefinition.Name);
|
||||
var cim = _contentManager.GetItemMetadata(ci);
|
||||
var createRouteValues = cim.CreateRouteValues;
|
||||
if (createRouteValues.Any())
|
||||
menu.Add(T("Create New {0}", contentTypeDefinition.DisplayName), "1.3", item => item.Action(cim.CreateRouteValues["Action"] as string, cim.CreateRouteValues["Controller"] as string, cim.CreateRouteValues));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -48,10 +48,17 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
const int pageSize = 20;
|
||||
var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize;
|
||||
|
||||
var query = _contentManager.Query(VersionOptions.Latest);
|
||||
var query = _contentManager.Query(VersionOptions.Latest, _contentDefinitionManager.ListTypeDefinitions().Select(ctd => ctd.Name).ToArray());
|
||||
|
||||
if (!string.IsNullOrEmpty(model.Id)) {
|
||||
query = query.ForType(model.Id);
|
||||
if (!string.IsNullOrEmpty(model.TypeName)) {
|
||||
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.TypeName);
|
||||
if (contentTypeDefinition == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
model.TypeDisplayName = !string.IsNullOrWhiteSpace(contentTypeDefinition.DisplayName)
|
||||
? contentTypeDefinition.DisplayName
|
||||
: contentTypeDefinition.Name;
|
||||
query = query.ForType(model.TypeName);
|
||||
}
|
||||
|
||||
var contentItems = query.Slice(skip, pageSize);
|
||||
@@ -148,6 +155,18 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return RedirectToAction("Edit", new RouteValueDictionary { { "Id", contentItem.Id } });
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Remove")]
|
||||
public ActionResult RemovePOST(int id, string returnUrl) {
|
||||
var contentItem = _contentManager.Get(id);
|
||||
if (contentItem != null)
|
||||
_contentManager.Remove(contentItem);
|
||||
|
||||
if (!String.IsNullOrEmpty(returnUrl))
|
||||
return Redirect(returnUrl);
|
||||
|
||||
return RedirectToAction("List");
|
||||
}
|
||||
|
||||
private void PrepareEditorViewModel(ContentItemViewModel itemViewModel) {
|
||||
if (string.IsNullOrEmpty(itemViewModel.TemplateName)) {
|
||||
itemViewModel.TemplateName = "Items/Contents.Item";
|
||||
|
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Core.Contents.ViewModels {
|
||||
public class ListContentsViewModel : BaseViewModel {
|
||||
public string Id { get; set; }
|
||||
public string TypeName { get { return Id; } }
|
||||
public string TypeDisplayName { get; set; }
|
||||
public int? Page { get; set; }
|
||||
public IList<Entry> Entries { get; set; }
|
||||
|
||||
|
@@ -0,0 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ListContentTypesViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
||||
<h1><%:Html.TitleForPage(T("Create New Content").ToString())%></h1>
|
||||
<%:Html.UnorderedList(
|
||||
Model.Types,
|
||||
(ctd, i) => MvcHtmlString.Create(string.Format("<p>{0}</p>", Html.ActionLink(ctd.Name, "Create", new { Area = "Contents", Id = ctd.Name }))),
|
||||
"contentTypes")%>
|
@@ -1,11 +0,0 @@
|
||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<ListContentTypesViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
||||
<% Html.AddTitleParts(T("Create Content").ToString()); %>
|
||||
<p>
|
||||
Create content</p>
|
||||
<ul>
|
||||
<% foreach (var t in Model.Types) {%>
|
||||
<li>
|
||||
<%:Html.ActionLink(t.Name, "Create", new RouteValueDictionary{{"Area","Contents"},{"Id",t.Name}}) %></li>
|
||||
<%} %>
|
||||
</ul>
|
37
src/Orchard.Web/Core/Contents/Views/Admin/List.ascx
Normal file
37
src/Orchard.Web/Core/Contents/Views/Admin/List.ascx
Normal file
@@ -0,0 +1,37 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Contents.ViewModels.ListContentsViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.ContentManagement.Aspects"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement"%>
|
||||
<%@ Import Namespace="Orchard.Utility.Extensions" %>
|
||||
<h1><%:Html.TitleForPage(T("Manage {0} Content", !string.IsNullOrEmpty(Model.TypeDisplayName) ? Model.TypeDisplayName : T("all").Text).ToString())%></h1>
|
||||
<div class="manage">
|
||||
<%:Html.ActionLink(!string.IsNullOrEmpty(Model.TypeDisplayName) ? T("Add new {0} content", Model.TypeDisplayName).Text : T("Add new content").Text, "Create", new { }, new { @class = "button primaryAction" })%>
|
||||
</div>
|
||||
<ul class="contentItems"><%
|
||||
foreach (var entry in Model.Entries) { %>
|
||||
<li>
|
||||
<div class="summary">
|
||||
<div class="properties">
|
||||
<h3><%:entry.ContentItem.Is<IRoutableAspect>()
|
||||
? Html.ActionLink(entry.ContentItem.As<IRoutableAspect>().Title, "Edit", new { id = entry.ContentItem.Id })
|
||||
: MvcHtmlString.Create(string.Format("[title display template needed] (content type == \"{0}\")", entry.ContentItem.TypeDefinition.Name)) %></h3>
|
||||
<ul class="pageStatus">
|
||||
<li>
|
||||
<%:T("Last modified: {0}",
|
||||
entry.ContentItem.Is<ICommonAspect>() && entry.ContentItem.As<ICommonAspect>().ModifiedUtc.HasValue
|
||||
? Html.DateTimeRelative(entry.ContentItem.As<ICommonAspect>().ModifiedUtc.Value, T)
|
||||
: T("unknown"))%>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="related">
|
||||
<%:Html.ActionLink(T("Edit").ToString(), "Edit", new { id = entry.ContentItem.Id }, new { title = T("Edit").ToString() })%><%: T(" | ")%>
|
||||
<% using (Html.BeginFormAntiForgeryPost(Url.Action("Remove", new { id = entry.ContentItem.Id }), FormMethod.Post, new { @class = "inline link" })) { %>
|
||||
<button type="submit" class="linkButton" title="<%: T("Remove") %>"><%: T("Remove") %></button>
|
||||
<%:Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString())%><%
|
||||
} %>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
</li><%
|
||||
} %>
|
||||
</ul>
|
@@ -1,32 +0,0 @@
|
||||
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<ListContentsViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Core.Contents.ViewModels" %>
|
||||
<% Html.AddTitleParts(T("Browse Contents").ToString()); %>
|
||||
<p>
|
||||
Browse Contents</p>
|
||||
<table>
|
||||
<% foreach (var t in Model.Entries) {%>
|
||||
<tr>
|
||||
<td>
|
||||
<%:t.ContentItem.Id %>.
|
||||
</td>
|
||||
<td>
|
||||
<%:t.ContentItem.ContentType %>
|
||||
</td>
|
||||
<td>
|
||||
ver #<%:t.ContentItem.Version %>
|
||||
</td>
|
||||
<td>
|
||||
<%if (t.ContentItemMetadata.DisplayRouteValues != null) {%>
|
||||
<%:Html.ActionLink(t.ContentItemMetadata.DisplayText, t.ContentItemMetadata.DisplayRouteValues["Action"].ToString(), t.ContentItemMetadata.DisplayRouteValues)%>
|
||||
<%}%>
|
||||
</td>
|
||||
<td>
|
||||
<%if (t.ContentItemMetadata.EditorRouteValues != null) {%>
|
||||
<%:Html.ActionLink("edit", t.ContentItemMetadata.EditorRouteValues["Action"].ToString(), t.ContentItemMetadata.EditorRouteValues)%>
|
||||
<%}%>
|
||||
</td>
|
||||
</tr>
|
||||
<%} %>
|
||||
</table>
|
||||
<p>
|
||||
<%:Html.ActionLink("Create new item", "Create", "Admin", new RouteValueDictionary{{"Area","Contents"},{"Id",Model.Id}}, new Dictionary<string, object>()) %></p>
|
@@ -210,10 +210,10 @@
|
||||
<Content Include="Common\Views\EditorTemplates\Parts\Common.Container.ascx" />
|
||||
<Content Include="Common\Views\EditorTemplates\PlainTextEditor.ascx" />
|
||||
<Content Include="Contents\Module.txt" />
|
||||
<Content Include="Contents\Views\Admin\List.aspx" />
|
||||
<Content Include="Contents\Views\Admin\Edit.aspx" />
|
||||
<Content Include="Contents\Views\Admin\CreatableTypeList.aspx" />
|
||||
<Content Include="Contents\Views\Admin\CreatableTypeList.ascx" />
|
||||
<Content Include="Contents\Views\Admin\Create.aspx" />
|
||||
<Content Include="Contents\Views\Admin\List.ascx" />
|
||||
<Content Include="Contents\Views\DisplayTemplates\Items\Contents.Item.ascx" />
|
||||
<Content Include="Contents\Views\EditorTemplates\Items\Contents.Item.ascx" />
|
||||
<Content Include="Contents\Views\Item\Preview.aspx" />
|
||||
|
Reference in New Issue
Block a user