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-2009 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 <script type="text/javascript" src="js/language.js"></script> 31 <script type="text/javascript" src="js/safeFN_class.js"></script> 32 <script type="text/javascript"> 33 34var oListManager = new Object() ; 35var currentFolderUploadStatus; 36var DwikiFNencode = parent.DwikiFNencode; 37var isInternalLink = parent.isLocalDwikiBrowser; 38var ImagesAllowed = new RegExp(parent.FCKConfig.ImageUploadAllowedExtensions); 39var FCKImageSaveDir = false; 40 41function getFCKSaveDir() { 42 //alert(dwikiUTF8_decodeFN(document.cookie,DwikiFNencode)); 43 var allcookies = document.cookie; 44 var pos = allcookies.indexOf("FCK_media="); 45 if(pos != -1) { 46 var start = pos+10; 47 var end = allcookies.indexOf(";",start); 48 if(end == -1) end = allcookies.length; 49 var value = allcookies.substring(start,end); 50 value = decodeURIComponent(value); 51 return dwikiUTF8_decodeFN(value,DwikiFNencode); 52 } 53 return false; 54} 55 56oListManager.Clear = function() 57{ 58 document.body.innerHTML = '' ; 59} 60 61function ProtectPath(path) 62{ 63 path = path.replace( /\\/g, '\\\\') ; 64 path = path.replace( /'/g, '\\\'') ; 65 return path ; 66} 67 68oListManager.GetFolderRowHtml = function( folderName, folderPath, folder_class, isImage ) 69{ 70 // Build the link to view the folder. 71 // folderPath = decodeURI(folderPath); 72 folderPath = dwikiUTF8_decodeFN(folderPath,DwikiFNencode); 73 var sLink = '<a href="#" onclick="OpenFolder(\'' + ProtectPath( folderPath ) + '\');return false;">' ; 74 icon = 'images/Folder.gif'; 75 76 if(folder_class == 'r') icon = 'images/FolderRO.gif'; 77 var ColSpan = isImage ? 4 : 3; 78 return '<tr>' + 79 '<td width="16">' + 80 sLink + 81 '<img alt="" src="' + icon +'" width="16" height="16" border="0"><\/a>' + 82 '<\/td><td nowrap colspan="' + ColSpan +'"> ' + 83 sLink + 84 folderName + 85 '<\/a>' + 86 '<\/td><\/tr>' ; 87} 88 89 90var imageDirectoryRegex = new RegExp ('^(.*?fckg\\/fckeditor\\/userfiles\\/image\\/)(.*)'); 91function reviseImgSrc(url) { 92 var imgUrl = decodeURI(decodeURI(url)); 93 var matches = imgUrl.match(imageDirectoryRegex); 94 if(matches && matches.length > 1) { 95 return matches[1]+ encodeURI(dwikiUTF8_encodeFN(matches[2],DwikiFNencode)); 96 } 97 else { 98 var matches = imgUrl.match(/^http:\/\/(.*)/); 99 if(matches) { 100 return 'http://' + encodeURI(dwikiUTF8_encodeFN(matches[1],DwikiFNencode)); 101 } 102 } 103 return url; 104} 105 106function oListImage(fileUrl,width,height) { 107 108 src = ProtectPath( fileUrl ); 109 this.src = reviseImgSrc(src); 110 this.fileUrl = fileUrl; 111 this.width = width; 112 this.height = height; 113} 114 115var imgCount = 0; 116var imageArray = new Array(); 117var KBArray = new Array(); 118var imgProcessingStack = new Array(); 119 120function big_image(id) { 121 var elems = id.split('_'); 122 var oImg = imageArray[elems[1]]; 123 124 125 var height = oImg.height; 126 var width = oImg.width; 127 128 if(elems.length > 1) { 129 if(oImg.width > 500) { 130 height = Math.round( oImg.height * ( 500 / oImg.width ) ) ; 131 width = 500; 132 } 133 if(height > 400) { 134 width = Math.round( width * ( 400 / height ) ) ; 135 height = 400; 136 } 137 } 138 139 var element = '<img border = "0" src = "' + oImg.src + '" width = "' + width + '" height="' + height + '">'; 140 element += '<center><br /><button class="bigwin_close_but" onclick="OpenFile(\''+ ProtectPath(oImg.fileUrl) +'\');void 0;">' 141 + translateItem('DlgImgInsert', 'insert into document') + '<\/button><\/center>'; 142 var big_win = document.getElementById('bigwin_display'); 143 big_win.innerHTML = element; 144 big_win = document.getElementById('big_imagewin'); 145 big_win.style.display = 'block'; 146 big_win.scrollIntoView(); 147 148} 149 150function getImageSize(oImgWidth,oImgHeight) { 151 152 var width = oImgWidth; var height = oImgHeight; 153 154 if(oImgWidth > 120) { 155 height = Math.round( oImgHeight * ( 120 / oImgWidth ) ) ; 156 width = 120; 157 } 158 if(height > 120) { 159 width = Math.round( width * ( 120 / height ) ) ; 160 height = 120; 161 } 162 163 return width + 'x' + height +' '; 164} 165 166function showImage(id) { 167 var elems = id.split('_'); 168 var oImg = imageArray[elems[1]]; 169 if(!oImg) return id; 170 171 var height = oImg.height; 172 var width = oImg.width; 173 174 175 if(oImg.width > 120) { 176 height = Math.round( oImg.height * ( 120 / oImg.width ) ) ; 177 width = 120; 178 } 179 if(height > 120) { 180 width = Math.round( width * ( 120 / height ) ) ; 181 height = 120; 182 } 183 184 var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( oImg.fileUrl ) + '\');return false;">' ; 185 var element = sLink + '<img border = "0" src = "' + oImg.src + '" width = "' + width + '" height="' + height + '"></a>'; 186 return element; 187 // document.getElementById(id).innerHTML = element; 188 189 190} 191 192var foldersDone = { }; 193oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize, isImage ) 194{ 195 var c_type = "file"; 196 if(isImage) { 197 198 if(imgCount % 2 == 0) { 199 c_type = 'silver'; 200 } 201 else c_type = 'img'; 202 } 203 204 // Build the link to view the folder. 205 var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( fileUrl ) + '\');return false;">' ; 206 207 var trash = 'images/trash.png'; 208 var sUnlink = '<td width="20" class="' + c_type +'"><a href="#" onclick="UnlinkFile(event,\'' + fileName + '\');return false;">' ; 209 sUnlink += '<img src="' + trash + '" border="0"></a><\/td>'; 210 211 var imgTD = ""; 212 var fileSizeSpan=""; 213 if(isImage) { 214 elems = fileSize.split(';;'); 215 fileSize = elems[0]; 216 217 var oImage = new oListImage(fileUrl, elems[1],elems[2]); 218 oImage.inserted = false; 219 imageArray[imgCount] = oImage; 220 var imgId = 'img_' + imgCount; 221 var imgTD = '<td width="152" align="center" class="' +c_type +'"><div id="' + imgId + '">' 222 + showImage(imgId) + '<\/div>' + 223 '<div class="img_buttons"><a href="#" onclick="big_image(\'' + imgId + '\');return false;">' 224 + translateItem('DlgFileBrowserMagnify', 'magnify') + 225 '<\/a><\/div><\/td>'; 226 fileSizeSpan='<span id="size_'+ imgCount + '">' + elems[1] + 'x' + elems[2] + ' </span>'; 227 imgCount++; 228 229 230 } 231 if(currentFolderUploadStatus == 'r') sUnlink = ' '; 232 // Get the file icon. 233 var sIcon = oIcons.GetIcon( fileName ) ; 234 235 236 return '<tr>' + sUnlink + 237 '<td width="16" class="' + c_type + '">' + 238 sLink + 239 '<img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"><\/a>' + 240 '<\/td><td class="' + c_type + '"> ' + 241 sLink + 242 fileName + 243 '<\/a>' + 244 '<\/td>' + imgTD + 245 '<\/td>' + '<td align="right" class="' + c_type + '"nowrap> ' + fileSizeSpan + 246 fileSize + 247 ' KB' + 248 '<\/td><\/tr>' ; 249} 250 251function OpenFolder( folderPath ) 252{ 253 254 // Load the resources list for this folder. 255 window.parent.frames['frmFolders'].LoadFolders( dwikiUTF8_encodeFN(folderPath,DwikiFNencode) ) ; 256} 257 258function UnlinkFile(evt,f) { 259var evt = (evt) ? evt : ((window.event) ? event : null); 260 261 if(evt && (evt.ctrlKey||evt.metaKey)) { 262 move_to = window.prompt(translateItem('FolderMovePrompt','Subdirectory of Current Directory to which you want to move ') + f, "secure"); 263 if(move_to) { 264 move_to = move_to.replace(/^[\/\s]+/,""); 265 move_to = move_to.replace(/[\/\s]+$/,""); 266 if(move_to.match(/[\/\\]/)) { 267 alert(translateItem('FolderMoveWarning','You can only move files to a folder one level below the current directory')); 268 return false; 269 } 270 move_to = move_to.toLowerCase(move_to); 271 move_to = move_to.replace(/\s/g, '_'); 272 move_to = encodeURI(dwikiUTF8_encodeFN(move_to,DwikiFNencode)); 273 f = move_to + '/' +f; 274 } 275 else return false; 276 } 277 else { 278 if(!confirm("Delete " + f + "?")) return false; 279 } 280 oConnector.SendCommand( 'UnlinkFile', 'file=' + f, UnlinkFileCallBack ) ; 281} 282 283function OpenFile( fileUrl ) 284{ 285 fileUrl = dwikiUTF8_decodeFN(fileUrl,DwikiFNencode); 286 fileUrl = decodeURI( fileUrl ); 287 288 window.top.opener.SetUrl( decodeURI( fileUrl ).replace( '#', '%23' ) ) ; 289 window.top.close() ; 290 window.top.opener.focus() ; 291} 292 293function LoadResources( resourceType, folderPath ) 294{ 295 oListManager.Clear() ; 296 oConnector.ResourceType = resourceType ; 297 oConnector.CurrentFolder = folderPath ; 298 oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack ) ; 299} 300 301function Refresh() 302{ 303 LoadResources( oConnector.ResourceType, oConnector.CurrentFolder ) ; 304} 305 306function GetFoldersAndFilesCallBack( fckXml ) 307{ 308 imgCount = 0; 309 imageArray = new Array(); 310 KBArray = new Array(); 311 imgProcessingStack = new Array(); 312 313 if ( oConnector.CheckError( fckXml ) != 0 ) 314 return ; 315 316 // Get the current folder path. 317 var oFolderNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' ) ; 318 if ( oFolderNode == null ) 319 { 320 321 alert(translateItem('FileBrowserError_XML', 'The server didn\'t reply with a proper XML data. Please check your configuration.')); 322 return ; 323 } 324 var sCurrentFolderPath = oFolderNode.attributes.getNamedItem('path').value ; 325 326 var sCurrentFolderUrl = oFolderNode.attributes.getNamedItem('url').value ; 327 328 var oHtml = new StringBuilder( '<table id="tableFiles" cellspacing="0" cellpadding="1" width="100%" border="0">' ) ; 329 330 // Add the Folders. 331 var isImage = oConnector.ResourceType == 'Image' ? true : false; 332 var oNodes ; 333 oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' ) ; 334 for ( var i = 0 ; i < oNodes.length ; i++ ) 335 { 336 337 var sFolderName = dwikiUTF8_decodeFN(oNodes[i].attributes.getNamedItem('name').value,DwikiFNencode); 338 var folder_class = oNodes[i].attributes.getNamedItem('class').value ; 339 if(sFolderName.match(/__AAAAAAAA__.AAA/)) { 340 currentFolderUploadStatus = folder_class; 341 continue; 342 } 343 oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/", folder_class, isImage ) ) ; 344 } 345 346 // Add the Files. 347 oNodes = fckXml.SelectNodes( 'Connector/Files/File' ) ; 348 for ( var j = 0 ; j < oNodes.length ; j++ ) 349 { 350 var oNode = oNodes[j] ; 351 var sFileName = dwikiUTF8_decodeFN(oNode.attributes.getNamedItem('name').value,DwikiFNencode); 352 var sFileSize = oNode.attributes.getNamedItem('size').value ; 353 if(isInternalLink) { 354 if(!sFileName.match(/\.txt$/)) continue; 355 sFileName = sFileName.replace(/\.txt$/,""); 356 } 357 else if(isImage) { 358 if(!sFileName.match(ImagesAllowed)) { 359 continue; 360 } 361 } 362 363 364 // Get the optional "url" attribute. If not available, build the url. 365 var oFileUrlAtt = oNodes[j].attributes.getNamedItem('url') ; 366 var sFileUrl = oFileUrlAtt != null ? oFileUrlAtt.value : sCurrentFolderUrl + sFileName ; 367 368 if(isImage && FCKImageSaveDir) { 369 sFileUrl=sFileUrl.replace(/^.*?\/image\//,""); 370 sFileUrl = FCKImageSaveDir + sFileUrl; 371 } 372 373 sFileUrl = dwikiUTF8_decodeFN(sFileUrl,DwikiFNencode); 374 sFileUrl = decodeURI(sFileUrl); 375 sFileUrl = decodeURI(sFileUrl); 376 if(isImage) { 377 sFileUrl = encodeURI(sFileUrl); 378 sFileUrl = encodeURI(sFileUrl); 379 } 380 381 oHtml.Append( oListManager.GetFileRowHtml( sFileName, sFileUrl, sFileSize, isImage) ) ; 382 } 383 384 oHtml.Append( '<\/table>' ) ; 385 var big = '<center><div id="big_imagewin"><div id="bigwin_display"></div>' + 386 '<div id="big_iwin_close"><button onclick="close_bigImgwin();" class="bigwin_close_but">' 387 + translateItem('DlgBtnClose', 'close') + 388 '</button> </div></div></center>'; 389 document.body.innerHTML = big + oHtml.ToString() ; 390 391 392} 393 394 395function insertImages() { 396 397 for(var i = 0; i<imageArray.length; i++) { 398 var imgId = 'img_' + i; 399 showImage(imgId); 400 } 401 402} 403 404 405 406function UnlinkFileCallBack( fckXml ) 407{ 408 GetFoldersAndFilesCallBack( fckXml ) 409} 410 411function close_bigImgwin() { 412 413 document.getElementById('big_imagewin').style.display='none'; 414} 415 416window.onload = function() 417{ 418 window.top.IsLoadedResourcesList = true ; 419 setupLanguage(); 420 FCKImageSaveDir=getFCKSaveDir() ; 421// alert(FCKImageSaveDir); 422} 423 </script> 424</head> 425<body class="FileArea"> 426</body> 427</html> 428