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-2007 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	<script type="text/javascript" src="js/common.js"></script>
28	<script type="text/javascript">
29
30var oListManager = new Object() ;
31
32oListManager.Clear = function()
33{
34	document.body.innerHTML = '' ;
35}
36
37function ProtectPath(path)
38{
39	path = path.replace( /\\/g, '\\\\') ;
40	path = path.replace( /'/g, '\\\'') ;
41	return path ;
42}
43
44oListManager.GetFolderRowHtml = function( folderName, folderPath )
45{
46	// Build the link to view the folder.
47	var sLink = '<a href="#" onclick="OpenFolder(\'' + ProtectPath( folderPath ) + '\');return false;">' ;
48
49	return '<tr>' +
50			'<td width="16">' +
51				sLink +
52				'<img alt="" src="images/Folder.gif" width="16" height="16" border="0"><\/a>' +
53			'<\/td><td nowrap colspan="2">&nbsp;' +
54				sLink +
55				folderName +
56				'<\/a>' +
57		'<\/td><\/tr>' ;
58}
59
60oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
61{
62	// Build the link to view the folder.
63	var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( fileUrl ) + '\');return false;">' ;
64
65	// Get the file icon.
66	var sIcon = oIcons.GetIcon( fileName ) ;
67
68	return '<tr>' +
69			'<td width="16">' +
70				sLink +
71				'<img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"><\/a>' +
72			'<\/td><td>&nbsp;' +
73				sLink +
74				fileName +
75				'<\/a>' +
76			'<\/td><td align="right" nowrap>&nbsp;' +
77				fileSize +
78				' KB' +
79		'<\/td><\/tr>' ;
80}
81
82function OpenFolder( folderPath )
83{
84	// Load the resources list for this folder.
85	window.parent.frames['frmFolders'].LoadFolders( folderPath ) ;
86}
87
88function OpenFile( fileUrl )
89{
90	window.top.opener.SetUrl( encodeURI( fileUrl ) ) ;
91	window.top.close() ;
92	window.top.opener.focus() ;
93}
94
95function LoadResources( resourceType, folderPath )
96{
97	oListManager.Clear() ;
98	oConnector.ResourceType = resourceType ;
99	oConnector.CurrentFolder = folderPath ;
100	oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack ) ;
101}
102
103function Refresh()
104{
105	LoadResources( oConnector.ResourceType, oConnector.CurrentFolder ) ;
106}
107
108function GetFoldersAndFilesCallBack( fckXml )
109{
110	if ( oConnector.CheckError( fckXml ) != 0 )
111		return ;
112
113	// Get the current folder path.
114	var oFolderNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' ) ;
115	if ( oFolderNode == null )
116	{
117		alert( 'The server didn\'t reply with a proper XML data. Please check your configuration.' ) ;
118		return ;
119	}
120	var sCurrentFolderPath	= oFolderNode.attributes.getNamedItem('path').value ;
121	var sCurrentFolderUrl	= oFolderNode.attributes.getNamedItem('url').value ;
122
123//	var dTimer = new Date() ;
124
125	var oHtml = new StringBuilder( '<table id="tableFiles" cellspacing="1" cellpadding="0" width="100%" border="0">' ) ;
126
127	// Add the Folders.
128	var oNodes ;
129	oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' ) ;
130	for ( var i = 0 ; i < oNodes.length ; i++ )
131	{
132		var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
133		oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/" ) ) ;
134	}
135
136	// Add the Files.
137	oNodes = fckXml.SelectNodes( 'Connector/Files/File' ) ;
138	for ( var j = 0 ; j < oNodes.length ; j++ )
139	{
140		var oNode = oNodes[j] ;
141		var sFileName = oNode.attributes.getNamedItem('name').value ;
142		var sFileSize = oNode.attributes.getNamedItem('size').value ;
143
144		// Get the optional "url" attribute. If not available, build the url.
145		var oFileUrlAtt = oNodes[j].attributes.getNamedItem('url') ;
146		var sFileUrl = oFileUrlAtt != null ? oFileUrlAtt.value : sCurrentFolderUrl + sFileName ;
147
148		oHtml.Append( oListManager.GetFileRowHtml( sFileName, sFileUrl, sFileSize ) ) ;
149	}
150
151	oHtml.Append( '<\/table>' ) ;
152
153	document.body.innerHTML = oHtml.ToString() ;
154
155//	window.top.document.title = 'Finished processing in ' + ( ( ( new Date() ) - dTimer ) / 1000 ) + ' seconds' ;
156
157}
158
159window.onload = function()
160{
161	window.top.IsLoadedResourcesList = true ;
162}
163	</script>
164</head>
165<body class="FileArea">
166</body>
167</html>
168