mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Orchard.Media.Models;
|
||||
|
||||
namespace Orchard.Media.Helpers {
|
||||
@@ -9,12 +10,12 @@ namespace Orchard.Media.Helpers {
|
||||
if (String.IsNullOrEmpty(mediaPath)) {
|
||||
return navigations;
|
||||
}
|
||||
if (!mediaPath.Contains("\\")) {
|
||||
if ( !mediaPath.Contains(Path.DirectorySeparatorChar.ToString()) && !mediaPath.Contains(Path.AltDirectorySeparatorChar.ToString()) ) {
|
||||
navigations.Add(new FolderNavigation { FolderName = mediaPath, FolderPath = mediaPath });
|
||||
return navigations;
|
||||
}
|
||||
|
||||
string[] navigationParts = mediaPath.Split(new[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] navigationParts = mediaPath.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries);
|
||||
string currentPath = String.Empty;
|
||||
foreach (string navigationPart in navigationParts) {
|
||||
currentPath = (string.IsNullOrEmpty(currentPath) ? navigationPart : currentPath + "\\" + navigationPart);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Orchard.Media.Services {
|
||||
_storageProvider.CreateFolder(name);
|
||||
return;
|
||||
}
|
||||
_storageProvider.CreateFolder(mediaPath + "\\" + name);
|
||||
_storageProvider.CreateFolder(_storageProvider.Combine(mediaPath, name));
|
||||
}
|
||||
|
||||
public void DeleteFolder(string name) {
|
||||
@@ -79,12 +79,12 @@ namespace Orchard.Media.Services {
|
||||
}
|
||||
|
||||
public void DeleteFile(string name, string folderName) {
|
||||
_storageProvider.DeleteFile(folderName + "\\" + name);
|
||||
_storageProvider.DeleteFile(_storageProvider.Combine(folderName, name));
|
||||
}
|
||||
|
||||
public void RenameFile(string name, string newName, string folderName) {
|
||||
if (FileAllowed(newName, false)) {
|
||||
_storageProvider.RenameFile(folderName + "\\" + name, folderName + "\\" + newName);
|
||||
_storageProvider.RenameFile(_storageProvider.Combine(folderName, name), _storageProvider.Combine(folderName, newName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,14 +193,14 @@ namespace Orchard.Media.Services {
|
||||
}
|
||||
}
|
||||
|
||||
private static string RenameFolderPath(string path, string newName) {
|
||||
var lastIndex = path.LastIndexOf("\\");
|
||||
private string RenameFolderPath(string path, string newName) {
|
||||
var lastIndex = Math.Max(path.LastIndexOf(Path.DirectorySeparatorChar), path.LastIndexOf(Path.AltDirectorySeparatorChar));
|
||||
|
||||
if (lastIndex == -1) {
|
||||
return newName;
|
||||
}
|
||||
|
||||
return path.Substring(0, lastIndex) + "\\" + newName;
|
||||
return _storageProvider.Combine(path.Substring(0, lastIndex), newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<p>@Html.ActionLink(T("Media Folders").ToString(), "Index") >
|
||||
@foreach (FolderNavigation navigation in MediaHelpers.GetFolderNavigationHierarchy(Model.MediaPath)) {
|
||||
@Html.ActionLink(navigation.FolderName, "Edit",
|
||||
new {name = navigation.FolderName, mediaPath = navigation.FolderPath})
|
||||
new {name = navigation.FolderName, mediaPath = navigation.FolderPath}) <text>></text>
|
||||
|
||||
}
|
||||
@T("Folder Properties")</p>
|
||||
|
||||
Reference in New Issue
Block a user