Ok everyone, I am sort of at your mercy here... I have spent several hours debugging trying to figure out why the manager aren't working and it seems to all point to that the new dialogs are expecting return strings in different formats. Here is the background on the application environment.
The admin application that contains the editor is in a different directory / application than the public website where the content is rendered. The images and flash folders are sub folders of the public site and there is a third securedocuments folder that sits outside of the publicwwwroot. These files are streamed using a httphandler.
Directory Structure:
- Drive:\SolutionFolder
-\adminwwwroot
-\publicwwwroot
-\publicwwwroot\Images
-\publicwwwroot\Flash
-\publicwwwroot\Documents
-\publicwwwroot
-\securedocuments
URL Structure:
- http://www.publicdomain.com/
/Images
/Flash
/Documents
/SecureDocuments.ashx?path=file.ext
- http://adminsubdomain.publicdomain.com/
/RadEditor.aspx?updatepage=1
I have worked with the code and got the files to list and new directories to create and delete. But upload / rename files are still not working... I haven't tried saving an image using the image editor yet.
I will provide you the customcontentprovider code and the filesystem code that supplies the directory and url structure as seen above. Here are my exact issues and what solutions I would like to see:
1.) Rename File - Call Stack Shows RenameFile function being called in the RadFileExplorer class in the Telerik.web.ui.dll
What changed? Why? Fixes?
2.) Upload File - This is the highest priority for me to get fixed. The StoreFile function doesn't even fire anymore. I can't get the break point to work anymore after the upgrade.....
With all of the bugs in this new RadFileExplorer I would prefer to use the old managers if possible... Not sure how to do that... any help would be appreciated. Thanks in advance!
New FileHandler Code (Partially Working):
Original FileHandlerCode (Only the changed functions) (Works with Q3 2008)
Here is the IO.FileSystem Class
The admin application that contains the editor is in a different directory / application than the public website where the content is rendered. The images and flash folders are sub folders of the public site and there is a third securedocuments folder that sits outside of the publicwwwroot. These files are streamed using a httphandler.
Directory Structure:
- Drive:\SolutionFolder
-\adminwwwroot
-\publicwwwroot
-\publicwwwroot\Images
-\publicwwwroot\Flash
-\publicwwwroot\Documents
-\publicwwwroot
-\securedocuments
URL Structure:
- http://www.publicdomain.com/
/Images
/Flash
/Documents
/SecureDocuments.ashx?path=file.ext
- http://adminsubdomain.publicdomain.com/
/RadEditor.aspx?updatepage=1
I have worked with the code and got the files to list and new directories to create and delete. But upload / rename files are still not working... I haven't tried saving an image using the image editor yet.
I will provide you the customcontentprovider code and the filesystem code that supplies the directory and url structure as seen above. Here are my exact issues and what solutions I would like to see:
1.) Rename File - Call Stack Shows RenameFile function being called in the RadFileExplorer class in the Telerik.web.ui.dll
What changed? Why? Fixes?
2.) Upload File - This is the highest priority for me to get fixed. The StoreFile function doesn't even fire anymore. I can't get the break point to work anymore after the upgrade.....
With all of the bugs in this new RadFileExplorer I would prefer to use the old managers if possible... Not sure how to do that... any help would be appreciated. Thanks in advance!
New FileHandler Code (Partially Working):
Public Class ContentEditorProvider |
Inherits FileBrowserContentProvider |
Private _LoadDirectory As String |
Private _ImgDirectory As String |
Private _DocumentsDirectory As String |
Private _SecureDocumentsDirectory As String |
Private _FullPermissions As PathPermissions = PathPermissions.Read Or PathPermissions.Delete Or PathPermissions.Upload |
Public Sub New(ByVal context As HttpContext, ByVal searchPatterns As String(), ByVal viewPaths As String(), ByVal uploadPaths As String(), ByVal deletePaths As String(), ByVal selectedUrl As String, ByVal selectedItemTag As String) |
MyBase.New(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag) |
End Sub |
Public Overloads Overrides ReadOnly Property CanCreateDirectory() As Boolean |
Get |
Return True |
End Get |
End Property |
Public Overrides Function CreateDirectory(ByVal path As String, ByVal name As String) As String |
Dim RealPath As String = IO.FileSystem.ResolveDirectory(path) |
Directory.CreateDirectory(RealPath & "\" & name) |
Return path & name |
End Function |
Public Overrides Function DeleteDirectory(ByVal path As String) As String |
DeleteDirectory = IO.FileSystem.ResolveDirectory(path) |
If Directory.Exists(DeleteDirectory) Then Directory.Delete(DeleteDirectory, True) |
DeleteDirectory = String.Empty |
Return DeleteDirectory |
End Function |
Public Overrides Function DeleteFile(ByVal path As String) As String |
DeleteFile = IO.FileSystem.ResolveDirectory(path) |
If File.Exists(DeleteFile) Then File.Delete(DeleteFile) |
DeleteFile = String.Empty |
Return DeleteFile |
End Function |
Public Overrides Function GetFile(ByVal url As String) As System.IO.Stream |
Dim RealPath As String = IO.FileSystem.ResolveURL(url) |
If System.IO.File.Exists(RealPath) = True Then |
Dim File As Byte() = System.IO.File.ReadAllBytes(RealPath) |
GetFile = New MemoryStream(File) |
Else |
GetFile = Nothing |
End If |
Return GetFile |
End Function |
Private Function GetName(ByVal path As String) As String |
GetName = IIf(path = Nothing, String.Empty, path.Substring(path.LastIndexOf("\"c) + 1)) |
Return GetName |
End Function |
Public Overrides Function GetFileName(ByVal url As String) As String |
GetFileName = IIf(url = Nothing, String.Empty, url.Substring(url.LastIndexOf("/"c) + 1)) |
Return GetFileName |
End Function |
Public Overrides Function GetPath(ByVal url As String) As String |
GetPath = IO.FileSystem.ResolveURL(url) |
Return GetPath |
End Function |
Public Function LoadFiles(ByVal Dir As System.IO.DirectoryInfo) As FileItem() |
Dim xFiles As New List(Of FileItem) |
For Each Fil As FileInfo In Dir.GetFiles() |
Dim RealPath As String = Fil.FullName |
Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
Dim VirtualURL As String = IO.FileSystem.TranslateURL(RealPath) |
xFiles.Add(New FileItem(Fil.Name, Fil.Extension, Fil.Length, VirtualPath, VirtualURL, VirtualPath, _FullPermissions)) |
Next |
Return xFiles.ToArray |
End Function |
Public Function LoadDirectories(ByVal Dir As System.IO.DirectoryInfo) As DirectoryItem() |
Dim xDir As New List(Of DirectoryItem) |
For Each SubDir As DirectoryInfo In Dir.GetDirectories() |
Dim RealPath As String = SubDir.FullName |
Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
xDir.Add(New DirectoryItem(SubDir.Name, VirtualPath, VirtualPath, VirtualPath, _FullPermissions, LoadFiles(SubDir), LoadDirectories(SubDir))) |
Next |
Return xDir.ToArray |
End Function |
Public Overrides Function ResolveDirectory(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem |
Dim RealPath As String = IO.FileSystem.ResolveDirectory(path) |
Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
Dim DirInfo As New DirectoryInfo(RealPath) |
ResolveDirectory = New DirectoryItem(DirInfo.Name, VirtualPath, VirtualPath, IO.FileSystem.TranslateURL(VirtualPath), _FullPermissions, LoadFiles(DirInfo), LoadDirectories(DirInfo)) |
Return ResolveDirectory |
End Function |
Public Overrides Function ResolveRootDirectoryAsList(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem() |
If path.StartsWith("/") = True Then path = IO.FileSystem.ResolveDirectory(path) |
Dim RealPath As String = IO.FileSystem.ProcessDirectory(path) |
Dim DirInfo As New DirectoryInfo(RealPath) |
ResolveRootDirectoryAsList = LoadDirectories(DirInfo) |
Return ResolveRootDirectoryAsList |
End Function |
Public Overrides Function ResolveRootDirectoryAsTree(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem |
If path.StartsWith("/") = True Then path = IO.FileSystem.ResolveDirectory(path) |
Dim RealPath As String = IO.FileSystem.ProcessDirectory(path) |
Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
Dim DirInfo As New DirectoryInfo(RealPath) |
'HttpContext.Current.Response.Write(path & " - " & RealPath & " - " & VirtualPath) |
'HttpContext.Current.Response.End() |
ResolveRootDirectoryAsTree = New DirectoryItem(DirInfo.Name, VirtualPath, VirtualPath, VirtualPath, _FullPermissions, LoadFiles(DirInfo), LoadDirectories(DirInfo)) |
Return ResolveRootDirectoryAsTree |
End Function |
Public Overrides Function StoreBitmap(ByVal bitmap As System.Drawing.Bitmap, ByVal url As String, ByVal format As System.Drawing.Imaging.ImageFormat) As String |
Dim RealPath As String = IO.FileSystem.ResolveURL(url) |
Dim newItemPath As String = IO.FileSystem.ResolveURL(url) |
Dim name As String = GetName(newItemPath) |
Dim _path As String = GetPath(newItemPath) |
Dim tempFilePath As String = Path.GetTempFileName() |
bitmap.Save(tempFilePath) |
Dim content As Byte() |
Using inputStream As FileStream = File.OpenRead(tempFilePath) |
Dim size As Long = inputStream.Length |
content = New Byte(size) {} |
inputStream.Read(content, 0, CType(size, Integer)) |
End Using |
If File.Exists(tempFilePath) Then |
File.Delete(tempFilePath) |
End If |
File.WriteAllBytes(RealPath, content) |
Return url |
End Function |
Public Overloads Overrides Function StoreFile(ByVal file As Telerik.Web.UI.UploadedFile, ByVal path As String, ByVal name As String, ByVal ParamArray arguments() As String) As String |
Dim FullName As String = IO.FileSystem.ResolveDirectory(path) & "\" & name |
file.SaveAs(FullName) |
Return path & name |
End Function |
End Class |
Original FileHandlerCode (Only the changed functions) (Works with Q3 2008)
Public Overrides Function CreateDirectory(ByVal path As String, ByVal name As String) As String |
Dim RealPath As String = IO.FileSystem.ResolveDirectory(path) |
Directory.CreateDirectory(RealPath & "\" & name) |
Return path & "/" & name |
End Function |
Public Overrides Function ResolveRootDirectoryAsList(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem() |
Dim RealPath As String = IO.FileSystem.ProcessDirectory(path) |
Dim DirInfo As New DirectoryInfo(RealPath) |
ResolveRootDirectoryAsList = LoadDirectories(DirInfo) |
Return ResolveRootDirectoryAsList |
End Function |
Public Overrides Function ResolveRootDirectoryAsTree(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem |
Dim RealPath As String = IO.FileSystem.ProcessDirectory(path) |
Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
Dim DirInfo As New DirectoryInfo(RealPath) |
'HttpContext.Current.Response.Write(path & " - " & RealPath & " - " & VirtualPath) |
'HttpContext.Current.Response.End() |
ResolveRootDirectoryAsTree = New DirectoryItem(DirInfo.Name, VirtualPath, VirtualPath, VirtualPath, _FullPermissions, LoadFiles(DirInfo), LoadDirectories(DirInfo)) |
Return ResolveRootDirectoryAsTree |
End Function |
Here is the IO.FileSystem Class
Public Class FileSystem |
Public Shared siteDomain As String = Configuration.Environment.SiteDomain |
Public Shared siteRoot As String = Configuration.Environment.SiteRoot |
Public Shared siteSecureDocuments As String = Configuration.Environment.SiteSecureDocuments |
Public Shared dirRoot As String = Configuration.FileSystem.RootDirectory |
Public Shared rgxDirRoot As String = Replace(dirRoot, "\", "\\") |
Public Shared dirDomain As String = Configuration.FileSystem.PublicSiteDirectory |
Public Shared rgxDirDomain As String = Replace(dirDomain, "\", "\\") |
Public Shared dirSecureDocuments As String = Configuration.FileSystem.SecureDocumentsDirectory |
Public Shared rgxDirSecureDocuments As String = Replace(dirSecureDocuments, "\", "\\") |
Public Shared vfsSecureDocuments As String = Replace(siteSecureDocuments, "\", "/") |
Public Shared Function QueryDirectory(ByVal path As String, Optional ByVal search As String = "*.*", Optional ByVal options As SearchOption = SearchOption.TopDirectoryOnly) As ListItemCollection |
QueryDirectory = New ListItemCollection |
Dim xDir As New DirectoryInfo(path) |
path = Replace(path, "\", "\\") |
For Each xFile As FileInfo In xDir.GetFiles(search, options) |
QueryDirectory.Add(New ListItem(Replace(Regex.Replace(xFile.FullName, path, "", RegexOptions.IgnoreCase), "\", "/"))) |
Next |
Return QueryDirectory |
End Function |
Public Shared Function ProcessDirectory(ByVal path As String) As String |
ProcessDirectory = path |
Dim _TokenPattern As String = "\[\[(?<ConfigVar>(.)*?)\]\]" |
Dim _RM As Match = Regex.Match(path, _TokenPattern) |
Dim HasMatch As Boolean = False |
HasMatch = _RM.Success |
While HasMatch = True |
Dim _Token As String = _RM.Groups("ConfigVar").Value |
'System.Web.HttpContext.Current.Response.Write(_Token & "<br />") |
_Token = Configuration.AppSettings.GetSetting(_Token) |
'System.Web.HttpContext.Current.Response.Write(_Token) |
'System.Web.HttpContext.Current.Response.End() |
ProcessDirectory = Replace(ProcessDirectory, _RM.Value, _Token) |
_RM = _RM.NextMatch() |
HasMatch = _RM.Success |
End While |
ProcessDirectory = Replace(ProcessDirectory, "/", "\") |
Return ProcessDirectory |
End Function |
Public Shared Function ResolveDirectory(ByVal path As String) As String |
ResolveDirectory = path |
If InStrRev(ResolveDirectory, ".") > InStrRev(ResolveDirectory, "/") Then |
ResolveDirectory = Left(ResolveDirectory, InStrRev(ResolveDirectory, "/")) |
End If |
If ResolveDirectory.StartsWith(dirRoot) = False Then |
If ResolveDirectory.StartsWith(vfsSecureDocuments) = True Then |
ResolveDirectory = Regex.Replace(ResolveDirectory, vfsSecureDocuments, dirRoot & dirSecureDocuments, RegexOptions.IgnoreCase) |
ResolveDirectory = Replace(ResolveDirectory, "/", "\") |
Else |
ResolveDirectory = dirRoot & dirDomain & ResolveDirectory |
ResolveDirectory = Replace(ResolveDirectory, "/", "\") |
End If |
End If |
Return ResolveDirectory |
End Function |
Public Shared Function ResolveURL(ByVal Url As String) As String |
If siteRoot.Length > 0 Then siteRoot = Left(siteRoot, siteRoot.Length - 1) |
ResolveURL = Url |
ResolveURL = Regex.Replace(ResolveURL, siteDomain & siteRoot, String.Empty, RegexOptions.IgnoreCase) |
ResolveURL = ResolveDirectory(ResolveURL) |
Return ResolveURL |
End Function |
Public Shared Function TranslateURL(ByVal path As String) As String |
Dim strSiteRoot As String = siteRoot |
If strSiteRoot.Length > 0 Then siteRoot = Left(strSiteRoot, siteRoot.Length - 1) |
path = Regex.Replace(path, rgxDirRoot, "", RegexOptions.IgnoreCase) |
path = Regex.Replace(path, rgxDirSecureDocuments, siteDomain & siteSecureDocuments, RegexOptions.IgnoreCase) |
path = Regex.Replace(path, rgxDirDomain, siteDomain & strSiteRoot, RegexOptions.IgnoreCase) |
path = Replace(path, "\", "/") |
TranslateURL = path |
Return TranslateURL |
End Function |
Public Shared Function TranslateDirectory(ByVal path As String) As String |
path = Regex.Replace(path, rgxDirRoot, "", RegexOptions.IgnoreCase) |
path = Regex.Replace(path, rgxDirDomain, "", RegexOptions.IgnoreCase) |
path = Regex.Replace(path, rgxDirSecureDocuments, vfsSecureDocuments, RegexOptions.IgnoreCase) |
path = Replace(path, "\", "/") |
TranslateDirectory = path |
Return TranslateDirectory |
End Function |
End Class |