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