mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 03:58:13 +08:00
Merge with 1.x
--HG-- branch : autoroute
This commit is contained in:
@@ -212,7 +212,11 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
[HttpPost, ActionName("Create")]
|
||||
[FormValueRequired("submit.Publish")]
|
||||
public ActionResult CreateAndPublishPOST(string id, string returnUrl) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't create content")))
|
||||
|
||||
// pass a dummy content to the authorization check to check for "own" variations
|
||||
var dummyContent = _contentManager.New(id);
|
||||
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, dummyContent, T("Couldn't create content")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return CreatePOST(id, returnUrl, contentItem => _contentManager.Publish(contentItem));
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
</span>
|
||||
<span class="user-actions">
|
||||
@Html.ActionLink(T("Sign Out").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }, new { rel = "nofollow" })
|
||||
@Html.ActionLink(T("Dashboard").ToString(), "Index", new { Area = "Dashboard", Controller = "Admin" })
|
||||
@if (AuthorizedFor(Orchard.Security.StandardPermissions.AccessAdminPanel)) {
|
||||
@Html.ActionLink(T("Dashboard").ToString(), "Index", new {Area = "Dashboard", Controller = "Admin"})
|
||||
}
|
||||
</span>
|
||||
} else {
|
||||
<span class="user-actions">@Html.ActionLink(T("Sign In").ToString(), "LogOn", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = (Request.QueryString["ReturnUrl"] ?? Request.RawUrl) }, new { rel = "nofollow" })</span>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Core.XmlRpc.Models;
|
||||
@@ -29,8 +31,10 @@ namespace Orchard.Core.XmlRpc.Controllers {
|
||||
if (methodResponse == null)
|
||||
throw new HttpException(500, "TODO: xmlrpc fault");
|
||||
|
||||
var content = _writer.MapMethodResponse(methodResponse).ToString();
|
||||
return Content(content, "text/xml");
|
||||
var content = new StringBuilder();
|
||||
_writer.MapMethodResponse(methodResponse).Save(new StringWriter(content));
|
||||
|
||||
return Content(content.ToString(), "text/xml");
|
||||
}
|
||||
|
||||
private XRpcMethodResponse Dispatch(XRpcMethodCall request) {
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<Compile Include="Models\CommentsPartRecord.cs" />
|
||||
<Compile Include="Services\CreateCommentContext.cs" />
|
||||
<Compile Include="Services\ICommentService.cs" />
|
||||
<Compile Include="Tokens\CommentTokens.cs" />
|
||||
<Compile Include="ViewModels\CommentCountViewModel.cs" />
|
||||
<Compile Include="Models\CommentSettingsPart.cs" />
|
||||
<Compile Include="Handlers\CommentSettingsPartHandler.cs" />
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Events;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.Comments.Tokens {
|
||||
public interface ITokenProvider : IEventHandler {
|
||||
void Describe(dynamic context);
|
||||
void Evaluate(dynamic context);
|
||||
}
|
||||
|
||||
public class CommentTokens : ITokenProvider {
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public CommentTokens(IContentManager contentManager) {
|
||||
_contentManager = contentManager;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public void Describe(dynamic context) {
|
||||
context.For("Content", T("Content Items"), T("Content Items"))
|
||||
.Token("CommentedOn", T("Commented On"), T("The content item this comment was created on."))
|
||||
.Token("CommentMessage", T("Comment Message"), T("The text of the comment itself"))
|
||||
.Token("CommentAuthor", T("Comment Author"), T("The author of the comment."))
|
||||
;
|
||||
}
|
||||
|
||||
public void Evaluate(dynamic context) {
|
||||
context.For<IContent>("Content")
|
||||
.Token("CommentedOn", (Func<IContent, object>)(content => content.As<CommentPart>().Record.CommentedOn))
|
||||
.Chain("CommentedOn", "Content", (Func<IContent, object>)(content => _contentManager.Get(content.As<CommentPart>().Record.CommentedOn)))
|
||||
.Token("CommentMessage", (Func<IContent, object>)(content => content.As<CommentPart>().Record.CommentText))
|
||||
.Token("CommentAuthor", (Func<IContent, object>)CommentAuthor)
|
||||
;
|
||||
}
|
||||
|
||||
private static string CommentAuthor(IContent comment) {
|
||||
var commentPart = comment.As<CommentPart>();
|
||||
return String.IsNullOrWhiteSpace(commentPart.Record.UserName) ? commentPart.Record.Author : commentPart.Record.UserName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,8 +65,13 @@ namespace Orchard.Media.Services {
|
||||
var name = file.Optional<string>("name");
|
||||
var bits = file.Optional<byte[]>("bits");
|
||||
|
||||
string directoryName = Path.GetDirectoryName(name);
|
||||
if (string.IsNullOrWhiteSpace(directoryName)) { // Some clients only pass in a name path that does not contain a directory component.
|
||||
directoryName = "media";
|
||||
}
|
||||
|
||||
try {
|
||||
// delete the file if it already exists, e.g. and updated image in a blog post
|
||||
// delete the file if it already exists, e.g. an updated image in a blog post
|
||||
// it's safe to delete the file as each content item gets a specific folder
|
||||
_mediaService.DeleteFile(Path.GetDirectoryName(name), Path.GetFileName(name));
|
||||
}
|
||||
@@ -74,8 +79,11 @@ namespace Orchard.Media.Services {
|
||||
// current way to delete a file if it exists
|
||||
}
|
||||
|
||||
string publicUrl = _mediaService.UploadMediaFile(Path.GetDirectoryName(name), Path.GetFileName(name), bits, false);
|
||||
return new XRpcStruct().Set("url", url.MakeAbsolute(publicUrl));
|
||||
string publicUrl = _mediaService.UploadMediaFile(directoryName, Path.GetFileName(name), bits, true);
|
||||
return new XRpcStruct() // Some clients require all optional attributes to be declared Wordpress responds in this way as well.
|
||||
.Set("file", publicUrl)
|
||||
.Set("url", url.MakeAbsolute(publicUrl))
|
||||
.Set("type", file.Optional<string>("type"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
@@ -76,12 +77,24 @@ namespace Orchard.Widgets.Drivers {
|
||||
if (zone != null) {
|
||||
part.Zone = zone;
|
||||
}
|
||||
|
||||
var renderTitle = context.Attribute(part.PartDefinition.Name, "RenderTitle");
|
||||
if (!string.IsNullOrWhiteSpace(renderTitle)) {
|
||||
part.RenderTitle = Convert.ToBoolean(renderTitle);
|
||||
}
|
||||
|
||||
var name = context.Attribute(part.PartDefinition.Name, "Name");
|
||||
if (name != null) {
|
||||
part.Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Exporting(WidgetPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Title", part.Title);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Position", part.Position);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Zone", part.Zone);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("RenderTitle", part.RenderTitle);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Name", part.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user