mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Work Items: 18061, 18106 --HG-- branch : 1.x
This commit is contained in:
@@ -18,6 +18,7 @@ using Orchard.Logging;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Security;
|
||||
using Orchard.Blogs.Extensions;
|
||||
using Orchard.Mvc.Html;
|
||||
|
||||
namespace Orchard.Blogs.Services {
|
||||
[UsedImplicitly]
|
||||
@@ -321,7 +322,12 @@ namespace Orchard.Blogs.Services {
|
||||
BlogPostPart blogPostPart,
|
||||
UrlHelper urlHelper) {
|
||||
|
||||
var url = urlHelper.AbsoluteAction(() => urlHelper.BlogPost(blogPostPart));
|
||||
var url = urlHelper.AbsoluteAction(() => urlHelper.ItemDisplayUrl(blogPostPart));
|
||||
|
||||
if (blogPostPart.HasDraft()) {
|
||||
url = urlHelper.AbsoluteAction("Preview", "Item", new { area = "Contents", id = blogPostPart.ContentItem.Id });
|
||||
}
|
||||
|
||||
var blogStruct = new XRpcStruct()
|
||||
.Set("postid", blogPostPart.Id)
|
||||
.Set("title", blogPostPart.Title)
|
||||
|
@@ -1,9 +1,13 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Xml.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Core.XmlRpc;
|
||||
using Orchard.Core.XmlRpc.Models;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Media.Services {
|
||||
@@ -12,14 +16,17 @@ namespace Orchard.Media.Services {
|
||||
private readonly IMembershipService _membershipService;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IMediaService _mediaService;
|
||||
private readonly RouteCollection _routeCollection;
|
||||
|
||||
public XmlRpcHandler(
|
||||
IMembershipService membershipService,
|
||||
IAuthorizationService authorizationService,
|
||||
IMediaService mediaService) {
|
||||
IMediaService mediaService,
|
||||
RouteCollection routeCollection) {
|
||||
_membershipService = membershipService;
|
||||
_authorizationService = authorizationService;
|
||||
_mediaService = mediaService;
|
||||
_routeCollection = routeCollection;
|
||||
}
|
||||
|
||||
public void SetCapabilities(XElement options) {
|
||||
@@ -28,11 +35,14 @@ namespace Orchard.Media.Services {
|
||||
}
|
||||
|
||||
public void Process(XmlRpcContext context) {
|
||||
var urlHelper = new UrlHelper(context.ControllerContext.RequestContext, _routeCollection);
|
||||
|
||||
if (context.Request.MethodName == "metaWeblog.newMediaObject") {
|
||||
var result = MetaWeblogNewMediaObject(
|
||||
Convert.ToString(context.Request.Params[1].Value),
|
||||
Convert.ToString(context.Request.Params[2].Value),
|
||||
(XRpcStruct)context.Request.Params[3].Value);
|
||||
(XRpcStruct)context.Request.Params[3].Value,
|
||||
urlHelper);
|
||||
context.Response = new XRpcMethodResponse().Add(result);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +50,8 @@ namespace Orchard.Media.Services {
|
||||
private XRpcStruct MetaWeblogNewMediaObject(
|
||||
string userName,
|
||||
string password,
|
||||
XRpcStruct file) {
|
||||
XRpcStruct file,
|
||||
UrlHelper url) {
|
||||
|
||||
var user = _membershipService.ValidateUser(userName, password);
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMedia, user, null)) {
|
||||
@@ -52,7 +63,7 @@ namespace Orchard.Media.Services {
|
||||
var bits = file.Optional<byte[]>("bits");
|
||||
|
||||
string publicUrl = _mediaService.UploadMediaFile(Path.GetDirectoryName(name), Path.GetFileName(name), bits, true);
|
||||
return new XRpcStruct().Set("url", publicUrl);
|
||||
return new XRpcStruct().Set("url", url.MakeAbsolute(publicUrl));
|
||||
}
|
||||
}
|
||||
}
|
@@ -24,7 +24,7 @@ namespace Orchard.Mvc.Extensions {
|
||||
return urlHelper.MakeAbsolute(urlHelper.Action(actionName, controller, routeValues));
|
||||
}
|
||||
|
||||
private static string MakeAbsolute(this UrlHelper urlHelper, string url) {
|
||||
public static string MakeAbsolute(this UrlHelper urlHelper, string url) {
|
||||
var siteUrl = urlHelper.RequestContext.HttpContext.Request.ToRootUrlString();
|
||||
return siteUrl + url;
|
||||
}
|
||||
|
Reference in New Issue
Block a user