Fixes: #U4-2027, changes DirectoryBrowser over to use correct webforms file structure, cleans up (a teeny bit)
how this page is structured, at least its not all inline c# code with inline styles.
This commit is contained in:
@@ -406,6 +406,13 @@
|
||||
<Compile Include="Umbraco\Developer\Macros\EditMacro.aspx.designer.cs">
|
||||
<DependentUpon>editMacro.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Developer\Packages\DirectoryBrowser.aspx.cs">
|
||||
<DependentUpon>directoryBrowser.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Developer\Packages\DirectoryBrowser.aspx.designer.cs">
|
||||
<DependentUpon>directoryBrowser.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Umbraco\Developer\Packages\StarterKits.aspx.cs">
|
||||
<DependentUpon>StarterKits.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -785,6 +792,7 @@
|
||||
<Content Include="Umbraco_Client\Dialogs\PublishDialog.css" />
|
||||
<Content Include="Umbraco_Client\Dialogs\PublishDialog.js" />
|
||||
<Content Include="Umbraco_Client\Dialogs\UmbracoField.js" />
|
||||
<Content Include="Umbraco_Client\Editors\DirectoryBrowser.css" />
|
||||
<Content Include="Umbraco_Client\Editors\EditMacro.css" />
|
||||
<Content Include="Umbraco_Client\Editors\EditView.js" />
|
||||
<Content Include="Umbraco_Client\FileUploader\Js\jquery.fileUploader.js" />
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco.Developer.Packages
|
||||
{
|
||||
public partial class DirectoryBrowser : UmbracoEnsuredPage
|
||||
{
|
||||
|
||||
string _lsTitle;
|
||||
string _lsLink;
|
||||
string _lsScriptName;
|
||||
string _lsWebPath;
|
||||
protected string Target = "";
|
||||
private readonly Regex _xssElementIdClean = new Regex(@"^([a-zA-Z0-9-_:\.]+)");
|
||||
|
||||
private readonly StringBuilder _sb = new StringBuilder();
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
Response.Cache.SetExpires(DateTime.Now.AddSeconds(5));
|
||||
Response.Cache.SetCacheability(HttpCacheability.Public);
|
||||
_lsTitle = Request.QueryString.Get("title");
|
||||
|
||||
//we need to clean this string:
|
||||
//http://issues.umbraco.org/issue/U4-2027
|
||||
var target = Request.QueryString.Get("target");
|
||||
if (target.IsNullOrWhiteSpace())
|
||||
throw new InvalidOperationException("The target query string must be set to a valid html element id");
|
||||
var matched = _xssElementIdClean.Matches(target);
|
||||
if (matched.Count == 0)
|
||||
throw new InvalidOperationException("The target query string must be set to a valid html element id");
|
||||
|
||||
Target = matched[0].Value;
|
||||
|
||||
if (string.IsNullOrEmpty(_lsTitle)) { _lsTitle = "Web Browse"; }
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
//Variables used in script
|
||||
var sebChar = IOHelper.DirSepChar.ToString();
|
||||
|
||||
//Write header, get link param
|
||||
_lsLink = Request.QueryString.Get("link");
|
||||
if (!string.IsNullOrEmpty(_lsLink))
|
||||
{
|
||||
_sb.Append("<A href=\"" + _lsLink + "\">[ Return ]</A><BR>");
|
||||
}
|
||||
|
||||
//Work on path and ensure no back tracking
|
||||
string sSubDir = Request.QueryString.Get("path");
|
||||
if (string.IsNullOrEmpty(sSubDir)) { sSubDir = "/"; }
|
||||
|
||||
sSubDir = sSubDir.Replace(IOHelper.DirSepChar.ToString(), "");
|
||||
sSubDir = sSubDir.Replace("//", "/");
|
||||
sSubDir = sSubDir.Replace("..", "./");
|
||||
sSubDir = sSubDir.Replace('/', IOHelper.DirSepChar);
|
||||
|
||||
//Clean path for processing and collect path varitations
|
||||
if (sSubDir.Substring(0, 1) != sebChar) { sSubDir = sebChar + sSubDir; }
|
||||
if (sSubDir.Substring(sSubDir.Length - 1, 1) != "\\") { sSubDir = sSubDir + sebChar; }
|
||||
|
||||
//Get name of the browser script file
|
||||
_lsScriptName = Request.ServerVariables.Get("SCRIPT_NAME");
|
||||
var j = _lsScriptName.LastIndexOf("/");
|
||||
if (j > 0) { _lsScriptName = _lsScriptName.Substring(j + 1, _lsScriptName.Length - (j + 1)).ToLower(); }
|
||||
|
||||
//Create navigation string and other path strings
|
||||
GetNavLink("", "root");
|
||||
if (sSubDir != sebChar)
|
||||
{
|
||||
j = 0; int i = 0;
|
||||
do
|
||||
{
|
||||
i = sSubDir.IndexOf(sebChar, j + 1);
|
||||
_lsWebPath += sSubDir.Substring(j + 1, i - (j + 1)) + "/";
|
||||
GetNavLink(_lsWebPath, sSubDir.Substring(j + 1, i - (j + 1)));
|
||||
j = i;
|
||||
} while (i != sSubDir.Length - 1);
|
||||
}
|
||||
|
||||
//Output header
|
||||
_sb.Append("<table cellpadding=3 cellspacing=1><tbody>");
|
||||
|
||||
//Output directorys
|
||||
var oDirInfo = new DirectoryInfo(IOHelper.MapPath("~/" + sSubDir));
|
||||
var oDirs = oDirInfo.GetDirectories();
|
||||
foreach (var oDir in oDirs)
|
||||
{
|
||||
try
|
||||
{
|
||||
_sb.Append("<tr><td class=\"tdDir\"><a href=\"" + _lsScriptName + "?path=" + _lsWebPath + oDir.Name + "&title=" + _lsTitle + "&link=" + _lsLink + "&target=" + Target + "\">" + oDir.Name + "</a> <small><a href=\"javascript:postPath('/" + _lsWebPath + oDir.Name + "')\"> (Include entire folder)</small></td></tr>");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_sb.Append("<tr><td class=\"tdDir\">" + oDir.Name + " (Access Denied)</td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//Ouput files
|
||||
var oFiles = oDirInfo.GetFiles();
|
||||
foreach (var oFile in oFiles.Where(oFile => oFile.Name.ToLower() != _lsScriptName))
|
||||
{
|
||||
decimal iLen = oFile.Length;
|
||||
string sLen;
|
||||
if (iLen >= 1048960) { iLen = iLen / 1048960; sLen = "mb"; } else { iLen = iLen / 1024; sLen = "kb"; }
|
||||
sLen = Decimal.Round(iLen, 2).ToString() + sLen;
|
||||
_sb.Append("<tr><td class=\"tdFile\"><a href=\"javascript:postPath('/" + _lsWebPath + oFile.Name + "')\">" + oFile.Name + "</a></td></tr>");
|
||||
}
|
||||
|
||||
//Output footer
|
||||
_sb.Append("</tbody></table></center>");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RptErr(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPreRender(EventArgs e)
|
||||
{
|
||||
base.OnPreRender(e);
|
||||
Output.Controls.Add(new LiteralControl(_sb.ToString()));
|
||||
}
|
||||
|
||||
private void RptErr(string psMessage)
|
||||
{
|
||||
_sb.Append("<DIV align=\"left\" width=\"100%\"><B>Script Reported Error: </B> " + psMessage + "</DIV><BR>");
|
||||
}
|
||||
|
||||
private string GetNavLink(string psHref, string psText)
|
||||
{
|
||||
return ("/<a class=\"tdheadA\" href=\"" + _lsScriptName + "?path=" + psHref + "&title=" + _lsTitle + "&link=" + _lsLink + "\">" + psText + "</a>");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
42
src/Umbraco.Web.UI/umbraco/developer/Packages/DirectoryBrowser.aspx.designer.cs
generated
Normal file
42
src/Umbraco.Web.UI/umbraco/developer/Packages/DirectoryBrowser.aspx.designer.cs
generated
Normal file
@@ -0,0 +1,42 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco.Developer.Packages {
|
||||
|
||||
|
||||
public partial class DirectoryBrowser {
|
||||
|
||||
/// <summary>
|
||||
/// CssInclude1 control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::ClientDependency.Core.Controls.CssInclude CssInclude1;
|
||||
|
||||
/// <summary>
|
||||
/// pane control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.Pane pane;
|
||||
|
||||
/// <summary>
|
||||
/// Output control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.PlaceHolder Output;
|
||||
}
|
||||
}
|
||||
@@ -1,142 +1,24 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="../../masterpages/umbracoPage.Master"Inherits="umbraco.presentation.developer.packages.directoryBrowser" %>
|
||||
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
|
||||
<%@ Import Namespace="System.IO" %>
|
||||
<%@ Page Language="C#" AutoEventWireup="True" MasterPageFile="../../masterpages/umbracoPage.Master" CodeBehind="DirectoryBrowser.aspx.cs" Inherits="Umbraco.Web.UI.Umbraco.Developer.Packages.DirectoryBrowser" %>
|
||||
|
||||
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
|
||||
<%@ Register TagPrefix="cdf" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server">
|
||||
<script language="C#" runat="server">
|
||||
//Import Namespace="System.Math"
|
||||
string lsTitle;
|
||||
string lsLink;
|
||||
string lsScriptName;
|
||||
string lsWebPath;
|
||||
string target = "";
|
||||
|
||||
public void Page_Load()
|
||||
{
|
||||
Response.Cache.SetExpires(DateTime.Now.AddSeconds(5));
|
||||
Response.Cache.SetCacheability(HttpCacheability.Public);
|
||||
lsTitle = Request.QueryString.Get("title");
|
||||
target = Request.QueryString.Get("target");
|
||||
if (lsTitle == null || lsTitle == "") { lsTitle = "Web Browse"; }
|
||||
}
|
||||
|
||||
private void RptErr(string psMessage)
|
||||
{
|
||||
Response.Write("<DIV align=\"left\" width=\"100%\"><B>Script Reported Error: </B> " + psMessage + "</DIV><BR>");
|
||||
}
|
||||
|
||||
private string GetNavLink(string psHref, string psText)
|
||||
{
|
||||
return ("/<a class=\"tdheadA\" href=\"" + lsScriptName + "?path=" + psHref + "&title=" + lsTitle + "&link=" + lsLink + "\">" + psText + "</a>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
a{color:#3C6B96;}
|
||||
|
||||
.tdDir a{padding: 3px; padding-left: 25px; background: url(../../images/foldericon.png) no-repeat 2px 2px;}
|
||||
.tdFile a{padding: 3px; padding-left: 25px; background: url(../../images/file.png) no-repeat 2px 2px;}
|
||||
small a{color: #999; padding-left: 3px !Important; background-image: none !Important; text-decoration: none;}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
function postPath(path) {
|
||||
top.right.document.getElementById('<%=target%>').value = path;
|
||||
UmbClientMgr.closeModalWindow();
|
||||
}
|
||||
</script>
|
||||
|
||||
<cdf:CssInclude ID="CssInclude1" runat="server" FilePath="Editors/DirectoryBrowser.css" PathNameAlias="UmbracoClient"></cdf:CssInclude>
|
||||
|
||||
<script type="text/javascript">
|
||||
function postPath(path) {
|
||||
var elementId = '<%=Target%>';
|
||||
top.right.document.getElementById(elementId).value = path;
|
||||
UmbClientMgr.closeModalWindow();
|
||||
}
|
||||
</script>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
<cc1:Pane runat="server" Width="100px" ID="pane">
|
||||
<%
|
||||
try
|
||||
{
|
||||
|
||||
//Variables used in script
|
||||
string sSubDir; int i; int j;
|
||||
string sPrevLink = "";
|
||||
string sebChar = umbraco.IO.IOHelper.DirSepChar.ToString();
|
||||
decimal iLen; string sLen;
|
||||
|
||||
//Write header, get link param
|
||||
lsLink = Request.QueryString.Get("link");
|
||||
if (lsLink != null && lsLink != "") { Response.Write("<A href=\"" + lsLink + "\">[ Return ]</A><BR>"); }
|
||||
|
||||
//Work on path and ensure no back tracking
|
||||
sSubDir = Request.QueryString.Get("path");
|
||||
if (sSubDir == null || sSubDir == "") { sSubDir = "/"; }
|
||||
|
||||
sSubDir = sSubDir.Replace(umbraco.IO.IOHelper.DirSepChar.ToString(), "");
|
||||
sSubDir = sSubDir.Replace("//", "/");
|
||||
sSubDir = sSubDir.Replace("..", "./");
|
||||
sSubDir = sSubDir.Replace('/', umbraco.IO.IOHelper.DirSepChar);
|
||||
|
||||
//Clean path for processing and collect path varitations
|
||||
if (sSubDir.Substring(0, 1) != sebChar) { sSubDir = sebChar + sSubDir; }
|
||||
if (sSubDir.Substring(sSubDir.Length - 1, 1) != "\\") { sSubDir = sSubDir + sebChar; }
|
||||
|
||||
//Get name of the browser script file
|
||||
lsScriptName = Request.ServerVariables.Get("SCRIPT_NAME");
|
||||
j = lsScriptName.LastIndexOf("/");
|
||||
if (j > 0) { lsScriptName = lsScriptName.Substring(j + 1, lsScriptName.Length - (j + 1)).ToLower(); }
|
||||
|
||||
//Create navigation string and other path strings
|
||||
sPrevLink += GetNavLink("", "root");
|
||||
if (sSubDir != sebChar)
|
||||
{
|
||||
j = 0; i = 0;
|
||||
do
|
||||
{
|
||||
i = sSubDir.IndexOf(sebChar, j + 1);
|
||||
lsWebPath += sSubDir.Substring(j + 1, i - (j + 1)) + "/";
|
||||
sPrevLink += GetNavLink(lsWebPath, sSubDir.Substring(j + 1, i - (j + 1)));
|
||||
j = i;
|
||||
} while (i != sSubDir.Length - 1);
|
||||
}
|
||||
|
||||
//Output header
|
||||
Response.Write("<table cellpadding=3 cellspacing=1><tbody>");
|
||||
|
||||
//Output directorys
|
||||
DirectoryInfo oDirInfo = new DirectoryInfo(umbraco.IO.IOHelper.MapPath("~/" + sSubDir));
|
||||
DirectoryInfo[] oDirs = oDirInfo.GetDirectories();
|
||||
foreach (DirectoryInfo oDir in oDirs)
|
||||
{
|
||||
try
|
||||
{
|
||||
Response.Write("<tr><td class=\"tdDir\"><a href=\"" + lsScriptName + "?path=" + lsWebPath + oDir.Name + "&title=" + lsTitle + "&link=" + lsLink + "&target=" + target + "\">" + oDir.Name + "</a> <small><a href=\"javascript:postPath('/" + lsWebPath + oDir.Name + "')\"> (Include entire folder)</small></td></tr>");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write("<tr><td class=\"tdDir\">" + oDir.Name + " (Access Denied)</td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//Ouput files
|
||||
FileInfo[] oFiles = oDirInfo.GetFiles();
|
||||
foreach (FileInfo oFile in oFiles)
|
||||
{
|
||||
if (oFile.Name.ToLower() != lsScriptName)
|
||||
{
|
||||
iLen = oFile.Length;
|
||||
if (iLen >= 1048960) { iLen = iLen / 1048960; sLen = "mb"; } else { iLen = iLen / 1024; sLen = "kb"; }
|
||||
sLen = Decimal.Round(iLen, 2).ToString() + sLen;
|
||||
Response.Write("<tr><td class=\"tdFile\"><a href=\"javascript:postPath('/" + lsWebPath + oFile.Name + "')\">" + oFile.Name + "</a></td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//Output footer
|
||||
Response.Write("</tbody></table></center>");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RptErr(ex.Message);
|
||||
}
|
||||
%>
|
||||
<cc1:Pane runat="server" Width="100px" ID="pane">
|
||||
<asp:PlaceHolder runat="server" ID="Output"></asp:PlaceHolder>
|
||||
</cc1:Pane>
|
||||
</asp:Content>
|
||||
</asp:Content>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
a
|
||||
{
|
||||
color: #3C6B96;
|
||||
}
|
||||
|
||||
.tdDir a
|
||||
{
|
||||
color: #3C6B96;
|
||||
padding: 3px;
|
||||
padding-left: 25px;
|
||||
background: url(../../umbraco/images/foldericon.png) no-repeat 2px 2px;
|
||||
}
|
||||
|
||||
.tdFile a
|
||||
{
|
||||
color: #3C6B96;
|
||||
padding: 3px;
|
||||
padding-left: 25px;
|
||||
background: url(../../umbraco/images/file.png) no-repeat 2px 2px;
|
||||
}
|
||||
|
||||
small a
|
||||
{
|
||||
color: #999;
|
||||
padding-left: 3px !Important;
|
||||
background-image: none !Important;
|
||||
text-decoration: none;
|
||||
}
|
||||
@@ -345,6 +345,9 @@
|
||||
<Compile Include="Security\ValidateUserAttempt.cs" />
|
||||
<Compile Include="Security\WebSecurity.cs" />
|
||||
<Compile Include="umbraco.presentation\LegacyClasses.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Packages\directoryBrowser.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\AssignDomain2.aspx.cs">
|
||||
<DependentUpon>AssignDomain2.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1140,13 +1143,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Packages\BrowseRepository.aspx.designer.cs">
|
||||
<DependentUpon>BrowseRepository.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Packages\directoryBrowser.aspx.cs">
|
||||
<DependentUpon>directoryBrowser.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Packages\directoryBrowser.aspx.designer.cs">
|
||||
<DependentUpon>directoryBrowser.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Packages\editPackage.aspx.cs">
|
||||
<DependentUpon>editPackage.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1868,9 +1864,6 @@
|
||||
<Content Include="umbraco.presentation\umbraco\members\search.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\translation\details.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Packages\BrowseRepository.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Packages\directoryBrowser.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Packages\editPackage.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Packages\installedPackage.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Packages\LoadNitros.ascx" />
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="../../masterpages/umbracoPage.Master"Inherits="umbraco.presentation.developer.packages.directoryBrowser" %>
|
||||
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
|
||||
<%@ Import Namespace="System.IO" %>
|
||||
|
||||
|
||||
<asp:Content ContentPlaceHolderID="head" runat="server">
|
||||
<script language="C#" runat="server">
|
||||
//Import Namespace="System.Math"
|
||||
string lsTitle;
|
||||
string lsLink;
|
||||
string lsScriptName;
|
||||
string lsWebPath;
|
||||
string target = "";
|
||||
|
||||
public void Page_Load()
|
||||
{
|
||||
Response.Cache.SetExpires(DateTime.Now.AddSeconds(5));
|
||||
Response.Cache.SetCacheability(HttpCacheability.Public);
|
||||
lsTitle = Request.QueryString.Get("title");
|
||||
target = Request.QueryString.Get("target");
|
||||
if (lsTitle == null || lsTitle == "") { lsTitle = "Web Browse"; }
|
||||
}
|
||||
|
||||
private void RptErr(string psMessage)
|
||||
{
|
||||
Response.Write("<DIV align=\"left\" width=\"100%\"><B>Script Reported Error: </B> " + psMessage + "</DIV><BR>");
|
||||
}
|
||||
|
||||
private string GetNavLink(string psHref, string psText)
|
||||
{
|
||||
return ("/<a class=\"tdheadA\" href=\"" + lsScriptName + "?path=" + psHref + "&title=" + lsTitle + "&link=" + lsLink + "\">" + psText + "</a>");
|
||||
}
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
a{color:#3C6B96;}
|
||||
|
||||
.tdDir a{padding: 3px; padding-left: 25px; background: url(../../images/foldericon.png) no-repeat 2px 2px;}
|
||||
.tdFile a{padding: 3px; padding-left: 25px; background: url(../../images/file.png) no-repeat 2px 2px;}
|
||||
small a{color: #999; padding-left: 3px !Important; background-image: none !Important; text-decoration: none;}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
function postPath(path) {
|
||||
top.right.document.getElementById('<%=target%>').value = path;
|
||||
UmbClientMgr.closeModalWindow();
|
||||
}
|
||||
</script>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ContentPlaceHolderID="body" runat="server">
|
||||
<cc1:Pane runat="server" Width="100px" ID="pane">
|
||||
<%
|
||||
try
|
||||
{
|
||||
|
||||
//Variables used in script
|
||||
string sSubDir; int i; int j;
|
||||
string sPrevLink = "";
|
||||
string sebChar = umbraco.IO.IOHelper.DirSepChar.ToString();
|
||||
decimal iLen; string sLen;
|
||||
|
||||
//Write header, get link param
|
||||
lsLink = Request.QueryString.Get("link");
|
||||
if (lsLink != null && lsLink != "") { Response.Write("<A href=\"" + lsLink + "\">[ Return ]</A><BR>"); }
|
||||
|
||||
//Work on path and ensure no back tracking
|
||||
sSubDir = Request.QueryString.Get("path");
|
||||
if (sSubDir == null || sSubDir == "") { sSubDir = "/"; }
|
||||
|
||||
sSubDir = sSubDir.Replace(umbraco.IO.IOHelper.DirSepChar.ToString(), "");
|
||||
sSubDir = sSubDir.Replace("//", "/");
|
||||
sSubDir = sSubDir.Replace("..", "./");
|
||||
sSubDir = sSubDir.Replace('/', umbraco.IO.IOHelper.DirSepChar);
|
||||
|
||||
//Clean path for processing and collect path varitations
|
||||
if (sSubDir.Substring(0, 1) != sebChar) { sSubDir = sebChar + sSubDir; }
|
||||
if (sSubDir.Substring(sSubDir.Length - 1, 1) != "\\") { sSubDir = sSubDir + sebChar; }
|
||||
|
||||
//Get name of the browser script file
|
||||
lsScriptName = Request.ServerVariables.Get("SCRIPT_NAME");
|
||||
j = lsScriptName.LastIndexOf("/");
|
||||
if (j > 0) { lsScriptName = lsScriptName.Substring(j + 1, lsScriptName.Length - (j + 1)).ToLower(); }
|
||||
|
||||
//Create navigation string and other path strings
|
||||
sPrevLink += GetNavLink("", "root");
|
||||
if (sSubDir != sebChar)
|
||||
{
|
||||
j = 0; i = 0;
|
||||
do
|
||||
{
|
||||
i = sSubDir.IndexOf(sebChar, j + 1);
|
||||
lsWebPath += sSubDir.Substring(j + 1, i - (j + 1)) + "/";
|
||||
sPrevLink += GetNavLink(lsWebPath, sSubDir.Substring(j + 1, i - (j + 1)));
|
||||
j = i;
|
||||
} while (i != sSubDir.Length - 1);
|
||||
}
|
||||
|
||||
//Output header
|
||||
Response.Write("<table cellpadding=3 cellspacing=1><tbody>");
|
||||
|
||||
//Output directorys
|
||||
DirectoryInfo oDirInfo = new DirectoryInfo(umbraco.IO.IOHelper.MapPath("~/" + sSubDir));
|
||||
DirectoryInfo[] oDirs = oDirInfo.GetDirectories();
|
||||
foreach (DirectoryInfo oDir in oDirs)
|
||||
{
|
||||
try
|
||||
{
|
||||
Response.Write("<tr><td class=\"tdDir\"><a href=\"" + lsScriptName + "?path=" + lsWebPath + oDir.Name + "&title=" + lsTitle + "&link=" + lsLink + "&target=" + target + "\">" + oDir.Name + "</a> <small><a href=\"javascript:postPath('/" + lsWebPath + oDir.Name + "')\"> (Include entire folder)</small></td></tr>");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write("<tr><td class=\"tdDir\">" + oDir.Name + " (Access Denied)</td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//Ouput files
|
||||
FileInfo[] oFiles = oDirInfo.GetFiles();
|
||||
foreach (FileInfo oFile in oFiles)
|
||||
{
|
||||
if (oFile.Name.ToLower() != lsScriptName)
|
||||
{
|
||||
iLen = oFile.Length;
|
||||
if (iLen >= 1048960) { iLen = iLen / 1048960; sLen = "mb"; } else { iLen = iLen / 1024; sLen = "kb"; }
|
||||
sLen = Decimal.Round(iLen, 2).ToString() + sLen;
|
||||
Response.Write("<tr><td class=\"tdFile\"><a href=\"javascript:postPath('/" + lsWebPath + oFile.Name + "')\">" + oFile.Name + "</a></td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
//Output footer
|
||||
Response.Write("</tbody></table></center>");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RptErr(ex.Message);
|
||||
}
|
||||
%>
|
||||
</cc1:Pane>
|
||||
</asp:Content>
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
@@ -11,8 +11,16 @@ using System.Web.UI.HtmlControls;
|
||||
|
||||
namespace umbraco.presentation.developer.packages
|
||||
{
|
||||
[Obsolete("This class is no longer used and will be removed from the codebase in the future")]
|
||||
public partial class directoryBrowser : BasePages.UmbracoEnsuredPage
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// pane control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.Pane pane;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.4200
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace umbraco.presentation.developer.packages {
|
||||
|
||||
|
||||
public partial class directoryBrowser {
|
||||
|
||||
/// <summary>
|
||||
/// pane control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::umbraco.uicontrols.Pane pane;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user