1
|
<!DOCTYPE HTML>
|
2
|
<!--
|
3
|
* CKeditor - The text editor for Internet - http://www.ckeditor.net
|
4
|
* Copyright (C) 2003-2010 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>
|
25
|
<head>
|
26
|
<title>Resources</title>
|
27
|
<link href="browser.css" type="text/css" rel="stylesheet">
|
28
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
29
|
<script type="text/javascript" src="js/common.js"></script>
|
30
|
|
31
|
<script type="text/javascript">
|
32
|
|
33
|
var oListManager = new Object() ;
|
34
|
|
35
|
oListManager.Clear = function()
|
36
|
{
|
37
|
document.body.innerHTML = '' ;
|
38
|
}
|
39
|
|
40
|
function ProtectPath(path)
|
41
|
{
|
42
|
path = path.replace( /\\/g, '\\\\') ;
|
43
|
path = path.replace( /'/g, '\\\'') ;
|
44
|
return path ;
|
45
|
}
|
46
|
|
47
|
oListManager.GetFolderRowHtml = function( folderName, folderPath )
|
48
|
{
|
49
|
// Build the link to view the folder.
|
50
|
var sLink = '<a href="#" onclick="OpenFolder(\'' + ProtectPath( folderPath ) + '\');return false;">' ;
|
51
|
|
52
|
return '<div class="file" title="'+ folderName +'">' +
|
53
|
'<div>' + sLink +
|
54
|
'<img class="icon" alt="" src="images/folder_big.gif" border="0" width="48" height="48" ><\/a>' +
|
55
|
'<\/div>' +
|
56
|
'<br /><div class="filename">'+ sLink + folderName +'<\/a>' + '<\/div>' +
|
57
|
'<\/div>';
|
58
|
}
|
59
|
|
60
|
oListManager.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
|
var relLink = '<a href="'+ fileUrl +'" rel="lightbox">' ;
|
65
|
|
66
|
// Get the file icon.
|
67
|
var sIcon = oIcons.GetIcon( fileName ) ;
|
68
|
|
69
|
/**
|
70
|
* Get file extension and decide if thumb or icon should be displayed
|
71
|
*/
|
72
|
|
73
|
if( sIcon == 'gif' || sIcon == 'jpg' || sIcon == 'jpeg' || sIcon == 'png' ){
|
74
|
var imgTag = '<img class="thumb" alt="" src="' + fileUrl + '" />' ;
|
75
|
}
|
76
|
else {
|
77
|
var imgTag = '<img class="icon" alt="" src="images/icons/' + sIcon + '.gif" />';
|
78
|
}
|
79
|
|
80
|
return '<div class="file" title="'+ fileName +'">' +
|
81
|
'<span class="fSize">' +
|
82
|
'<nobr><img alt="' + sIcon + '" title="' + sIcon + '" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"> '
|
83
|
+ fileSize +
|
84
|
' kB</nobr><\/span>' +
|
85
|
'<div class="thumbnail">' + sLink + imgTag +'<\/a>' +
|
86
|
'<\/div>' +
|
87
|
'<br /><div class="filename"><nobr>' + sLink + fileName + '<\/a>' + '</nobr><\/div>' +
|
88
|
'<\/div>' ;
|
89
|
}
|
90
|
|
91
|
function OpenFolder( folderPath )
|
92
|
{
|
93
|
// Load the resources list for this folder.
|
94
|
window.parent.frames['frmFolders'].LoadFolders( folderPath ) ;
|
95
|
}
|
96
|
|
97
|
function OpenFile( fileUrl )
|
98
|
{
|
99
|
//PATCH: Using CKEditors API we set the file in preview window.
|
100
|
|
101
|
funcNum = GetUrlParam('CKEditorFuncNum') ;
|
102
|
window.top.opener.CKEDITOR.tools.callFunction( funcNum, fileUrl.replace( '#', '%23' ));
|
103
|
window.top.close() ;
|
104
|
// window.top.opener.focus() ;
|
105
|
}
|
106
|
|
107
|
function LoadResources( resourceType, folderPath )
|
108
|
{
|
109
|
oListManager.Clear() ;
|
110
|
oConnector.ResourceType = resourceType ;
|
111
|
oConnector.CurrentFolder = folderPath ;
|
112
|
oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack ) ;
|
113
|
}
|
114
|
|
115
|
function Refresh()
|
116
|
{
|
117
|
LoadResources( oConnector.ResourceType, oConnector.CurrentFolder ) ;
|
118
|
}
|
119
|
|
120
|
function GetFoldersAndFilesCallBack( fckXml )
|
121
|
{
|
122
|
if ( oConnector.CheckError( fckXml ) != 0 ){return ;}
|
123
|
// Get the current folder path.
|
124
|
var oFolderNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' ) ;
|
125
|
if ( oFolderNode == null )
|
126
|
{
|
127
|
alert( 'The server didn\'t reply with a proper XML data. Please check your configuration.' ) ;
|
128
|
return ;
|
129
|
}
|
130
|
var sCurrentFolderPath = oFolderNode.attributes.getNamedItem('path').value ;
|
131
|
var sCurrentFolderUrl = oFolderNode.attributes.getNamedItem('url').value ;
|
132
|
// var dTimer = new Date() ;
|
133
|
var oHtml = new StringBuilder( '<div id="tableFiles"><div>' ) ;
|
134
|
|
135
|
// Add the Folders.
|
136
|
var oNodes ;
|
137
|
oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' ) ;
|
138
|
for ( var i = 0 ; i < oNodes.length ; i++ )
|
139
|
{
|
140
|
var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
|
141
|
oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/" ) ) ;
|
142
|
}
|
143
|
|
144
|
// Add the Files.
|
145
|
oNodes = fckXml.SelectNodes( 'Connector/Files/File' ) ;
|
146
|
for ( var j = 0 ; j < oNodes.length ; j++ )
|
147
|
{
|
148
|
var oNode = oNodes[j] ;
|
149
|
var sFileName = oNode.attributes.getNamedItem('name').value ;
|
150
|
var sFileSize = oNode.attributes.getNamedItem('size').value ;
|
151
|
|
152
|
// Get the optional "url" attribute. If not available, build the url.
|
153
|
var oFileUrlAtt = oNodes[j].attributes.getNamedItem('url') ;
|
154
|
var sFileUrl = oFileUrlAtt != null ? oFileUrlAtt.value : encodeURI( sCurrentFolderUrl + sFileName ).replace( /#/g, '%23' ) ;
|
155
|
|
156
|
// hide index.php in browse media - added for WebsiteBaker
|
157
|
if (sFileName != "index.php")
|
158
|
{
|
159
|
oHtml.Append( oListManager.GetFileRowHtml( sFileName, sFileUrl, sFileSize ) ) ;
|
160
|
}
|
161
|
}
|
162
|
|
163
|
oHtml.Append( '<\/div><\/div>' ) ;
|
164
|
document.body.innerHTML = oHtml.ToString() ;
|
165
|
window.top.document.title = 'Finished processing in ' + ( ( ( new Date() ) - dTimer ) / 1000 ) + ' seconds' ;
|
166
|
|
167
|
}
|
168
|
|
169
|
// Helper function to get parameters from the query string.
|
170
|
function _GetUrlParam( paramName ) {
|
171
|
var reParam = new RegExp( '(?:[\?&]|&)' + paramName + '=([^&]+)', 'i' );
|
172
|
var match = window.location.search.match( reParam );
|
173
|
return ( match && match.length > 1 ) ? match[1] : null;
|
174
|
}
|
175
|
|
176
|
function GetUrlParam( paramName )
|
177
|
{
|
178
|
var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
|
179
|
var oMatch = oRegex.exec( window.top.location.search ) ;
|
180
|
|
181
|
if ( oMatch && oMatch.length > 1 )
|
182
|
return decodeURIComponent( oMatch[1] ) ;
|
183
|
else
|
184
|
return '' ;
|
185
|
}
|
186
|
|
187
|
window.onload = function()
|
188
|
{
|
189
|
window.top.IsLoadedResourcesList = true ;
|
190
|
}
|
191
|
</script>
|
192
|
</head>
|
193
|
<body class="FileArea">
|
194
|
</body>
|
195
|
</html>
|