Skip to content

Commit f451b2a

Browse files
authored
Merge pull request siteserver#86 from siteserverekun/master
修复编辑器远程图片和附件无法管理bug
2 parents 8edf5eb + 85ec7fb commit f451b2a

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

source/SiteServer.CMS/UEditor/ListFileHandler.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
using System.Linq;
55
using System.Web;
66

7+
using BaiRong.Core;
8+
using BaiRong.Core.Model.Enumerations;
9+
using SiteServer.CMS.Core;
10+
using SiteServer.CMS.Model;
11+
712
namespace SiteServer.CMS.UEditor
813
{
914
/// <summary>
@@ -28,11 +33,16 @@ enum ResultState
2833
private string[] FileList;
2934
private string[] SearchExtensions;
3035

31-
public ListFileManager(HttpContext context, string pathToList, string[] searchExtensions)
36+
public int PublishmentSystemID { get; private set; }
37+
public EUploadType UploadType { get; private set; }
38+
39+
public ListFileManager(HttpContext context, string pathToList, string[] searchExtensions, int publishmentSystemID, EUploadType uploadType)
3240
: base(context)
3341
{
3442
SearchExtensions = searchExtensions.Select(x => x.ToLower()).ToArray();
3543
PathToList = pathToList;
44+
PublishmentSystemID = publishmentSystemID;
45+
UploadType = uploadType;
3646
}
3747

3848
public override void Process()
@@ -51,10 +61,24 @@ public override void Process()
5161
var buildingList = new List<String>();
5262
try
5363
{
54-
var localPath = Server.MapPath(PathToList);
64+
var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(PublishmentSystemID);
65+
var publishmentSystemPath = PathUtility.GetPublishmentSystemPath(publishmentSystemInfo); // 本站点物理路径
66+
var applicationPath = WebConfigUtils.PhysicalApplicationPath.ToLower().Trim(' ', '/', '\\'); // 系统物理路径
67+
if (UploadType == EUploadType.Image)
68+
{
69+
PathToList = publishmentSystemInfo.Additional.ImageUploadDirectoryName;
70+
}
71+
else if(UploadType == EUploadType.File)
72+
{
73+
PathToList = publishmentSystemInfo.Additional.FileUploadDirectoryName;
74+
}
75+
76+
//var localPath = Server.MapPath(PathToList);
77+
var localPath = PathUtils.Combine(publishmentSystemPath, PathToList);
78+
5579
buildingList.AddRange(Directory.GetFiles(localPath, "*", SearchOption.AllDirectories)
5680
.Where(x => SearchExtensions.Contains(Path.GetExtension(x).ToLower()))
57-
.Select(x => PathToList + x.Substring(localPath.Length).Replace("\\", "/")));
81+
.Select(x => x.Substring(applicationPath.Length).Replace("\\", "/")));
5882
Total = buildingList.Count;
5983
FileList = buildingList.OrderBy(x => x).Skip(Start).Take(Size).ToArray();
6084
}

source/SiteServer.Web/Controllers/Files/FilesUEditorController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ public void Main(int publishmentSystemId)
7070
}, publishmentSystemId, EUploadType.File);
7171
break;
7272
case "listimage":
73-
action = new ListFileManager(HttpContext.Current, Config.GetString("imageManagerListPath"), Config.GetStringList("imageManagerAllowFiles"));
73+
action = new ListFileManager(HttpContext.Current, Config.GetString("imageManagerListPath"), Config.GetStringList("imageManagerAllowFiles"), publishmentSystemId, EUploadType.Image);
7474
break;
7575
case "listfile":
76-
action = new ListFileManager(HttpContext.Current, Config.GetString("fileManagerListPath"), Config.GetStringList("fileManagerAllowFiles"));
76+
action = new ListFileManager(HttpContext.Current, Config.GetString("fileManagerListPath"), Config.GetStringList("fileManagerAllowFiles"), publishmentSystemId, EUploadType.File);
7777
break;
7878
case "catchimage":
7979
action = new CrawlerHandler(HttpContext.Current, publishmentSystemId);

0 commit comments

Comments
 (0)