Skip to content

Commit

Permalink
merged dev branch for 2.7.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
psolom committed Dec 20, 2017
2 parents 9216222 + 6bc4787 commit cae9840
Show file tree
Hide file tree
Showing 252 changed files with 213,857 additions and 1,105 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"vendor-dir": "connectors/php/vendor"
},
"require": {
"servocoder/richfilemanager-php": "1.1.*"
"servocoder/richfilemanager-php": "dev-dev"
}
}
19 changes: 15 additions & 4 deletions config/filemanager.config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"showTitleAttr": false,
"showConfirmation": true,
"browseOnly": false,
"searchBox": true,
"fileSorting": "NAME_ASC",
"folderPosition": "bottom",
"quickSelect": false,
Expand All @@ -20,12 +19,18 @@
"copy",
"move",
"delete",
"extract"
"extract",
"createFolder"
]
},
"language": {
"default": "en",
"available": ["ar", "bs", "ca", "cs", "da", "de", "el", "en", "es", "fa", "fi", "fr", "he", "hu", "it", "ja", "nl", "pl", "pt", "ru", "sv", "th", "tr", "vn", "zh-cn", "zh-tw"]
"available": ["ar", "bs", "ca", "cs", "da", "de", "el", "en", "es", "fa", "fi", "fr", "he", "hu", "it", "ja", "nl", "pl", "pt", "ru", "sv", "th", "tr", "vi", "zh-CN", "zh-TW"]
},
"formatter": {
"datetime": {
"skeleton": "yMMMdHm"
}
},
"filetree": {
"enabled": true,
Expand Down Expand Up @@ -74,6 +79,12 @@
"audio": ["ogg", "mp3", "wav"],
"video": ["ogv", "avi", "mkv", "mp4", "webm", "m4v"]
},
"search": {
"enabled": true,
"recursive": false,
"caseSensitive": false,
"typingDelay": 500
},
"viewer": {
"absolutePath": true,
"previewUrl": false,
Expand Down Expand Up @@ -181,5 +192,5 @@
"extra_js_async": true
},
"url": "https://github.com/servocoder/RichFilemanager",
"version": "2.6.5"
"version": "2.7.0"
}
2 changes: 1 addition & 1 deletion connectors/ashx/filemanager.ashx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public class filemanager : IHttpHandler
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.Write(Initiate());
break;
case "getfolder":
case "readfolder":
context.Response.ContentType = "plain/text";
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.Write(getInfo(context.Request["path"]));
Expand Down
183 changes: 75 additions & 108 deletions connectors/asp/FileManagerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public IActionResult Index(string mode, string path, string name, List<IFormFile
{
case "initiate":
return Json(Initiate());
case "getfolder":
return Json(GetFolder(path));
case "readfolder":
return Json(ReadFolder(path));
case "addfolder":
return Json(AddFolder(path, name));
case "upload":
Expand All @@ -51,26 +51,16 @@ public IActionResult Index(string mode, string path, string name, List<IFormFile
return Json(Move(old, @new));
case "copy":
return Json(Copy(source, target));
case "editfile":
return Json(EditFile(path));
case "savefile":
return Json(SaveFile(path, content));
case "delete":
return Json(Delete(path));
case "download":
if (Request.Headers["accept"].ToString().Contains("json"))
{
return Json(Download(path));
}
else
{
var file = DownloadFile(path);
return File(file.FileBytes, "application/x-msdownload", file.FileName);
}
return Download(path);
case "getimage":
return GetImage(path, thumbnail);
case "readfile":
break;
return ReadFile(path);
case "summarize":
return Json(Summarize());
}
Expand Down Expand Up @@ -108,10 +98,8 @@ private dynamic Initiate()

}

private dynamic GetFolder(string path)
private dynamic ReadFolder(string path)
{


if (path == null) path = string.Empty;

var rootpath = Path.Combine(_webRootPath, path);
Expand Down Expand Up @@ -187,10 +175,13 @@ private dynamic AddFolder(string path, string name)
errorResult.Errors.Add(new
{
Code = "500",
Message = "DIRECTORY_ALREADY_EXISTS",
Arguments = new List<string>
Title = "DIRECTORY_ALREADY_EXISTS",
Meta = new
{
name
Arguments = new List<string>
{
name
}
}
});

Expand Down Expand Up @@ -239,10 +230,13 @@ private async Task<dynamic> Upload(string path, IEnumerable<IFormFile> files)
errorResult.Errors.Add(new
{
Code = "500",
Message = "FILE_ALREADY_EXISTS",
Arguments = new List<string>
Title = "FILE_ALREADY_EXISTS",
Meta = new
{
file.FileName
Arguments = new List<string>
{
file.FileName
}
}
});

Expand Down Expand Up @@ -297,10 +291,13 @@ private dynamic Rename(string old, string @new)
errorResult.Errors.Add(new
{
Code = "500",
Message = "DIRECTORY_ALREADY_EXISTS",
Arguments = new List<string>
Title = "DIRECTORY_ALREADY_EXISTS",
Meta = new
{
@new
Arguments = new List<string>
{
@new
}
}
});

Expand Down Expand Up @@ -345,10 +342,13 @@ private dynamic Rename(string old, string @new)
errorResult.Errors.Add(new
{
Code = "500",
Message = "FILE_ALREADY_EXISTS",
Arguments = new List<string>
Title = "FILE_ALREADY_EXISTS",
Meta = new
{
@new
Arguments = new List<string>
{
@new
}
}
});

Expand Down Expand Up @@ -400,10 +400,13 @@ private dynamic Move(string old, string @new)
errorResult.Errors.Add(new
{
Code = "500",
Message = "DIRECTORY_ALREADY_EXISTS",
Arguments = new List<string>
Title = "DIRECTORY_ALREADY_EXISTS",
Meta = new
{
directoryName
Arguments = new List<string>
{
directoryName
}
}
});

Expand Down Expand Up @@ -451,10 +454,13 @@ private dynamic Move(string old, string @new)
errorResult.Errors.Add(new
{
Code = "500",
Message = "FILE_ALREADY_EXISTS",
Arguments = new List<string>
Title = "FILE_ALREADY_EXISTS",
Meta = new
{
fileName
Arguments = new List<string>
{
fileName
}
}
});

Expand Down Expand Up @@ -506,10 +512,13 @@ private dynamic Copy(string source, string target)
errorResult.Errors.Add(new
{
Code = "500",
Message = "DIRECTORY_ALREADY_EXISTS",
Arguments = new List<string>
Title = "DIRECTORY_ALREADY_EXISTS",
Meta = new
{
directoryName
Arguments = new List<string>
{
directoryName
}
}
});

Expand Down Expand Up @@ -553,10 +562,13 @@ private dynamic Copy(string source, string target)
errorResult.Errors.Add(new
{
Code = "500",
Message = "FILE_ALREADY_EXISTS",
Arguments = new List<string>
Title = "FILE_ALREADY_EXISTS",
Meta = new
{
fileName
Arguments = new List<string>
{
fileName
}
}
});

Expand Down Expand Up @@ -588,36 +600,6 @@ private dynamic Copy(string source, string target)
}
}

private dynamic EditFile(string path)
{
var fileName = Path.GetFileName(path);
var fileExtension = Path.GetExtension(path).Replace(".", "");
var filePath = Path.Combine(_webRootPath, path);

var content = System.IO.File.ReadAllText(filePath, Encoding.UTF8);

var result = new
{
Data = new
{
Id = path,
Type = "file",
Attributes = new
{
Name = fileName,
Extension = fileExtension,
Writable = 1,
Readable = 1,
// created vb.
Content = content,
Path = $"/{Path.Combine(path)}"
}
}
};

return result;
}

private dynamic SaveFile(string path, string content)
{
var filePath = Path.Combine(_webRootPath, path);
Expand Down Expand Up @@ -707,56 +689,43 @@ private dynamic Delete(string path)
}
}

private dynamic Download(string path)
private dynamic ReadFile(string path)
{
var fileName = Path.GetFileName(Path.Combine(_webRootPath, path));
var fileExtension = Path.GetExtension(fileName).Replace(".", "");

// undone dosya var mý kontrolü...
var filePath = Path.Combine(_webRootPath, path);
var fileName = Path.GetFileName(filePath);
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);

var result = new
var cd = new ContentDisposition
{
Data = new
{
Id = path,
Type = "file",
Attributes = new
{
Name = fileName,
Extension = fileExtension,
Readable = 1,
Writable = 1,
// created date, size vb.
Modified = DateTime.Now.ToString(CultureInfo.InvariantCulture),
//Path = $"{path}"
}
}
Inline = true,
FileName = fileName
};
Response.AddHeader("Content-Disposition", cd.ToString());

return result;

return File(fileBytes, "application/octet-stream");
}

private dynamic DownloadFile(string path)
private IActionResult GetImage(string path, bool thumbnail)
{
var filepath = Path.Combine(_webRootPath, path);
var fileName = Path.GetFileName(filepath);
byte[] fileBytes = System.IO.File.ReadAllBytes(filepath);
var filePath = Path.Combine(_webRootPath, path);
var fileName = Path.GetFileName(filePath);
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);

var file = new
var cd = new ContentDisposition
{
FileName = fileName,
FileBytes = fileBytes
Inline = true,
FileName = fileName
};
Response.AddHeader("Content-Disposition", cd.ToString());

return file;
return File(fileBytes, "image/*");
}

private IActionResult GetImage(string path, bool thumbnail)
private dynamic Download(string path)
{
var filepath = Path.Combine(_webRootPath, path);
var fileName = Path.GetFileName(filepath);
byte[] fileBytes = System.IO.File.ReadAllBytes(filepath);
var filePath = Path.Combine(_webRootPath, path);
var fileName = Path.GetFileName(filePath);
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);

return File(fileBytes, "application/x-msdownload", fileName);
}
Expand All @@ -769,8 +738,6 @@ private dynamic Summarize()
var files = directoryInfo.GetFiles("*", SearchOption.AllDirectories);
var allSize = files.Select(f => f.Length).Sum();



var result = new
{
Data = new
Expand Down
Loading

0 comments on commit cae9840

Please sign in to comment.