mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
MetaData Review Changes
--HG-- branch : dev
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
using System.Linq;
|
||||
|
||||
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
namespace Orchard.MetaData {
|
||||
public class AdminMenu : INavigationProvider {
|
||||
//private readonly IBlogService _blogService;
|
||||
|
||||
public AdminMenu() {
|
||||
//_blogService = blogService;
|
||||
}
|
||||
|
||||
public string MenuName { get { return "admin"; } }
|
||||
|
||||
|
@@ -1,41 +1,46 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement.MetaData.Services;
|
||||
using Orchard.Themes;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.ContentManagement.MetaData.Records;
|
||||
using Orchard.Localization;
|
||||
using Orchard.MetaData.ViewModels;
|
||||
using Orchard.UI.Admin;
|
||||
|
||||
namespace Orchard.MetaData.Controllers
|
||||
{
|
||||
[Themed]
|
||||
[Admin]
|
||||
public class MetaDataController : Controller
|
||||
{
|
||||
private readonly IRepository<ContentTypeRecord> _ctps;
|
||||
private readonly IContentTypeService _contentTypeService;
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public MetaDataController(IRepository<ContentTypeRecord> ctps, IContentTypeService contentTypeService){
|
||||
_ctps = ctps;
|
||||
public MetaDataController(IOrchardServices services, IContentTypeService contentTypeService)
|
||||
{
|
||||
_contentTypeService = contentTypeService;
|
||||
Services = services;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
private Localizer T { get; set; }
|
||||
//
|
||||
// GET: /ContentTypeList/
|
||||
|
||||
public ActionResult ContentTypeList(string id) {
|
||||
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMetaData, T("Not allowed to manage MetaData")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentTypes = _contentTypeService.GetContentTypes();
|
||||
var contentTypePartNames = _contentTypeService.GetContentTypePartNames();
|
||||
|
||||
var model = new ContentTypesIndexViewModel();
|
||||
|
||||
foreach(ContentTypeRecord contentType in contentTypes) {
|
||||
var contentTypeEntry = new ContentTypeEntry() {Name = contentType.Name,DisplayName = contentType.Name};
|
||||
foreach(var contentType in contentTypes) {
|
||||
var contentTypeEntry = new ContentTypeEntry {Name = contentType.Name,DisplayName = contentType.Name};
|
||||
|
||||
if (contentType.Name==id) {
|
||||
foreach(ContentTypePartNameRecord contentTypePartNameRecord in contentTypePartNames) {
|
||||
var contentTypePartEntry = new ContentTypePartEntry() { Name = contentTypePartNameRecord.PartName };
|
||||
foreach(var contentTypePartNameRecord in contentTypePartNames) {
|
||||
var contentTypePartEntry = new ContentTypePartEntry { Name = contentTypePartNameRecord.PartName };
|
||||
foreach(var contentTypePartEntryTest in contentType.ContentParts) {
|
||||
if (contentTypePartEntryTest.PartName==contentTypePartEntry.Name) {
|
||||
if (contentTypePartEntryTest.PartName.PartName==contentTypePartEntry.Name) {
|
||||
contentTypePartEntry.Selected = true;
|
||||
}
|
||||
}
|
||||
@@ -44,8 +49,7 @@ namespace Orchard.MetaData.Controllers
|
||||
model.SelectedContentType = contentTypeEntry;
|
||||
}
|
||||
model.ContentTypes.Add(contentTypeEntry);
|
||||
};
|
||||
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -55,13 +59,14 @@ namespace Orchard.MetaData.Controllers
|
||||
[HttpPost]
|
||||
public ActionResult Save(string id, FormCollection collection)
|
||||
{
|
||||
ContentTypeRecord contentTypeRecord = _contentTypeService.GetContentTypeRecord(id);
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMetaData, T("Not allowed to manage MetaData")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentTypeRecord = _contentTypeService.GetContentTypeRecord(id);
|
||||
//using a while loop because we are removing items from the collection
|
||||
while (contentTypeRecord.ContentParts.Count>0) {
|
||||
_contentTypeService.UnMapContentTypeToContentPart(contentTypeRecord.Name, contentTypeRecord.ContentParts[0].PartName);
|
||||
_contentTypeService.UnMapContentTypeToContentPart(contentTypeRecord.Name, contentTypeRecord.ContentParts[0].PartName.PartName);
|
||||
}
|
||||
//foreach(var contentTypePartNameRecord in contentTypeRecord.ContentParts) {
|
||||
// _contentTypeService.UnMapContentTypeToContentPart(contentTypeRecord.Name,contentTypePartNameRecord.PartName);
|
||||
//}
|
||||
foreach(var formKey in collection.AllKeys) {
|
||||
if (formKey.Contains("part_")) {
|
||||
var partName = formKey.Replace("part_", "");
|
||||
@@ -69,7 +74,7 @@ namespace Orchard.MetaData.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToAction("ContentTypeList", new { id = id });
|
||||
return RedirectToAction("ContentTypeList", new { id });
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.MetaData {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageMetaData = new Permission { Description = "Manage MetaData", Name = "ManageMetaData" };//q: Should edit_MetaData be ManageMetaData?
|
||||
|
||||
public static readonly Permission PublishOthersMetaDataPost = new Permission { Description = "Publish or unpublish MetaData post for others", Name = "PublishOthersMetaDataPost", ImpliedBy = new[] { ManageMetaData } };
|
||||
public static readonly Permission PublishMetaDataPost = new Permission { Description = "Publish or unpublish MetaData post", Name = "PublishMetaDataPost", ImpliedBy = new[] { PublishOthersMetaDataPost } };
|
||||
public static readonly Permission EditOthersMetaDataPost = new Permission { Description = "Edit any MetaData posts", Name = "EditOthersMetaDataPost", ImpliedBy = new[] { PublishOthersMetaDataPost } };
|
||||
public static readonly Permission EditMetaDataPost = new Permission { Description = "Edit own MetaData posts", Name = "EditMetaDataPost", ImpliedBy = new[] { EditOthersMetaDataPost, PublishMetaDataPost } };
|
||||
public static readonly Permission DeleteOthersMetaDataPost = new Permission { Description = "Delete MetaData post for others", Name = "DeleteOthersMetaDataPost", ImpliedBy = new[] { ManageMetaData } };
|
||||
public static readonly Permission DeleteMetaDataPost = new Permission { Description = "Delete MetaData post", Name = "DeleteMetaDataPost", ImpliedBy = new[] { DeleteOthersMetaDataPost } };
|
||||
|
||||
public static readonly Permission MetaListOthersMetaData = new Permission { ImpliedBy = new[] { EditOthersMetaDataPost, PublishOthersMetaDataPost, DeleteOthersMetaDataPost } };
|
||||
public static readonly Permission MetaListMetaData = new Permission { ImpliedBy = new[] { EditMetaDataPost, PublishMetaDataPost, DeleteMetaDataPost } };
|
||||
|
||||
public string ModuleName {
|
||||
get {
|
||||
@@ -25,12 +15,6 @@ namespace Orchard.MetaData {
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new Permission[] {
|
||||
ManageMetaData,
|
||||
EditMetaDataPost,
|
||||
EditOthersMetaDataPost,
|
||||
PublishMetaDataPost,
|
||||
PublishOthersMetaDataPost,
|
||||
DeleteMetaDataPost,
|
||||
DeleteOthersMetaDataPost,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,22 +24,6 @@ namespace Orchard.MetaData {
|
||||
Name = "Administrator",
|
||||
Permissions = new[] {ManageMetaData}
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Editor",
|
||||
Permissions = new[] {PublishOthersMetaDataPost,EditOthersMetaDataPost,DeleteOthersMetaDataPost}
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Moderator",
|
||||
//Permissions = new[] {}
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Author",
|
||||
Permissions = new[] {PublishMetaDataPost,EditMetaDataPost,DeleteMetaDataPost}
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Contributor",
|
||||
Permissions = new[] {EditMetaDataPost}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
|
@@ -15,13 +15,13 @@
|
||||
<% foreach (var item in Model.ContentTypes) { %>
|
||||
|
||||
<%
|
||||
string contentTypeClass = "";
|
||||
var contentTypeClass = "";
|
||||
if (Model.SelectedContentType!=null && Model.SelectedContentType.Name == item.Name)
|
||||
{
|
||||
contentTypeClass = "SelectedContentPart";
|
||||
}else{
|
||||
contentTypeClass = "UnSelectedContentPart";
|
||||
}
|
||||
contentTypeClass = "SelectedContentPart";
|
||||
}else{
|
||||
contentTypeClass = "UnSelectedContentPart";
|
||||
}
|
||||
%>
|
||||
<tr class="<%=contentTypeClass %>">
|
||||
<td>
|
||||
|
@@ -3,9 +3,6 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.MetaData.Records;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Core.Settings.Models;
|
||||
|
Reference in New Issue
Block a user