Project

General

Profile

1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<!--
3
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
5
 *
6
 * == BEGIN LICENSE ==
7
 *
8
 * Licensed under the terms of any of the following licenses at your
9
 * choice:
10
 *
11
 *  - GNU General Public License Version 2 or later (the "GPL")
12
 *    http://www.gnu.org/licenses/gpl.html
13
 *
14
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15
 *    http://www.gnu.org/licenses/lgpl.html
16
 *
17
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
18
 *    http://www.mozilla.org/MPL/MPL-1.1.html
19
 *
20
 * == END LICENSE ==
21
 *
22
 * This page shows all resources available in a folder in the File Browser.
23
-->
24
<html xmlns="http://www.w3.org/1999/xhtml">
25
<head>
26
	<link href="browser.css" type="text/css" rel="stylesheet" />
27
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
28
	<script type="text/javascript" src="js/common.js"></script>
29
	<script type="text/javascript">
30

    
31
var oListManager = new Object() ;
32

    
33
oListManager.Clear = function()
34
{
35
	document.body.innerHTML = '' ;
36
}
37

    
38
function ProtectPath(path)
39
{
40
	path = path.replace( /\\/g, '\\\\') ;
41
	path = path.replace( /'/g, '\\\'') ;
42
	return path ;
43
}
44

    
45
oListManager.GetFolderRowHtml = function( folderName, folderPath )
46
{
47
	// Build the link to view the folder.
48
	var sLink = '<a href="#" onclick="OpenFolder(\'' + ProtectPath( folderPath ) + '\');return false;">' ;
49

    
50
	return '<tr>' +
51
			'<td width="16">' +
52
				sLink +
53
				'<img alt="" src="images/Folder.gif" width="16" height="16" border="0"><\/a>' +
54
			'<\/td><td nowrap colspan="2">&nbsp;' +
55
				sLink +
56
				folderName +
57
				'<\/a>' +
58
		'<\/td><\/tr>' ;
59
}
60

    
61
oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
62
{
63
	// Build the link to view the folder.
64
	var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( fileUrl ) + '\');return false;">' ;
65

    
66
	// Get the file icon.
67
	var sIcon = oIcons.GetIcon( fileName ) ;
68

    
69
	return '<tr>' +
70
			'<td width="16">' +
71
				sLink +
72
				'<img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"><\/a>' +
73
			'<\/td><td>&nbsp;' +
74
				sLink +
75
				fileName +
76
				'<\/a>' +
77
			'<\/td><td align="right" nowrap>&nbsp;' +
78
				fileSize +
79
				' KB' +
80
		'<\/td><\/tr>' ;
81
}
82

    
83
function OpenFolder( folderPath )
84
{
85
	// Load the resources list for this folder.
86
	window.parent.frames['frmFolders'].LoadFolders( folderPath ) ;
87
}
88

    
89
function OpenFile( fileUrl )
90
{
91
	window.top.opener.SetUrl( encodeURI( fileUrl ).replace( '#', '%23' ) ) ;
92
	window.top.close() ;
93
	window.top.opener.focus() ;
94
}
95

    
96
function LoadResources( resourceType, folderPath )
97
{
98
	oListManager.Clear() ;
99
	oConnector.ResourceType = resourceType ;
100
	oConnector.CurrentFolder = folderPath ;
101
	oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack ) ;
102
}
103

    
104
function Refresh()
105
{
106
	LoadResources( oConnector.ResourceType, oConnector.CurrentFolder ) ;
107
}
108

    
109
function GetFoldersAndFilesCallBack( fckXml )
110
{
111
	if ( oConnector.CheckError( fckXml ) != 0 )
112
		return ;
113

    
114
	// Get the current folder path.
115
	var oFolderNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' ) ;
116
	if ( oFolderNode == null )
117
	{
118
		alert( 'The server didn\'t reply with a proper XML data. Please check your configuration.' ) ;
119
		return ;
120
	}
121
	var sCurrentFolderPath	= oFolderNode.attributes.getNamedItem('path').value ;
122
	var sCurrentFolderUrl	= oFolderNode.attributes.getNamedItem('url').value ;
123

    
124
//	var dTimer = new Date() ;
125

    
126
	var oHtml = new StringBuilder( '<table id="tableFiles" cellspacing="1" cellpadding="0" width="100%" border="0">' ) ;
127

    
128
	// Add the Folders.
129
	var oNodes ;
130
	oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' ) ;
131
	for ( var i = 0 ; i < oNodes.length ; i++ )
132
	{
133
		var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
134
		oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/" ) ) ;
135
	}
136

    
137
	// Add the Files.
138
	oNodes = fckXml.SelectNodes( 'Connector/Files/File' ) ;
139
	for ( var j = 0 ; j < oNodes.length ; j++ )
140
	{
141
		var oNode = oNodes[j] ;
142
		var sFileName = oNode.attributes.getNamedItem('name').value ;
143
		var sFileSize = oNode.attributes.getNamedItem('size').value ;
144

    
145
		// Get the optional "url" attribute. If not available, build the url.
146
		var oFileUrlAtt = oNodes[j].attributes.getNamedItem('url') ;
147
		var sFileUrl = oFileUrlAtt != null ? oFileUrlAtt.value : sCurrentFolderUrl + sFileName ;
148

    
149
		oHtml.Append( oListManager.GetFileRowHtml( sFileName, sFileUrl, sFileSize ) ) ;
150
	}
151

    
152
	oHtml.Append( '<\/table>' ) ;
153

    
154
	document.body.innerHTML = oHtml.ToString() ;
155

    
156
//	window.top.document.title = 'Finished processing in ' + ( ( ( new Date() ) - dTimer ) / 1000 ) + ' seconds' ;
157

    
158
}
159

    
160
window.onload = function()
161
{
162
	window.top.IsLoadedResourcesList = true ;
163
}
164
	</script>
165
</head>
166
<body class="FileArea">
167
</body>
168
</html>
(6-6/10)