44using System . Linq ;
55using System . Web ;
66
7+ using BaiRong . Core ;
8+ using BaiRong . Core . Model . Enumerations ;
9+ using SiteServer . CMS . Core ;
10+ using SiteServer . CMS . Model ;
11+
712namespace 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 }
0 commit comments