22 define(
'NOTOKENRENEWAL', 1);
24 require
'../../../../main.inc.php';
27 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
29 * FCKeditor - The text editor
for Internet - http:
30 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
34 * Licensed under the terms of any of the following licenses at your
37 * - GNU General Public License Version 2 or later (the
"GPL")
40 * - GNU Lesser General Public License Version 2.1 or later (the
"LGPL")
43 * - Mozilla Public License Version 1.1 or later (the
"MPL")
48 * This page shows all resources available in a folder in the File Browser.
52 <title>Resources</title>
53 <link href=
"browser.css" type=
"text/css" rel=
"stylesheet">
55 print
'<!-- Includes CSS for Dolibarr theme -->'.
"\n";
59 if (!empty($conf->modules_parts[
'theme'])) {
60 foreach ($conf->modules_parts[
'theme'] as $reldir) {
63 $themesubdir = $reldir;
70 print
'<link rel="stylesheet" type="text/css" href="'.$themepath.
'">'.
"\n";
72 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8">
73 <script
type=
"text/javascript" src=
"js/common.js"></script>
74 <script
type=
"text/javascript">
76 var oListManager =
new Object();
78 oListManager.Clear =
function()
80 document.body.innerHTML =
'' ;
83 function ProtectPath(path)
85 path = path.replace( /\\/g,
'\\\\');
86 path = path.replace( /
'/g, '\\\
'');
90 oListManager.GetFolderRowHtml =
function( folderName, folderPath )
93 var sLink =
'<a href="#" onclick="OpenFolder(\'' + ProtectPath(folderPath) +
'\');
return false;
">' ;
98 '<img alt="" src="images/Folder.gif
" width="16
" height="16
" border="0
"><\/a>' +
99 '<\/td><td class="nowrap
" colspan="2
"> ' +
106 // Note: fileUrl must be already "URL encoded
"
107 oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
109 // Build the link to view the folder.
110 var sLink = '<a href="#
" onclick="OpenFile(\
'' + ProtectPath(fileUrl) +
'\');
return false;
">' ;
112 // Get the file icon.
113 var sIcon = oIcons.GetIcon( fileName );
118 '<img alt="" src="images/icons/
' + sIcon + '.gif
" width="16
" height="16
" border="0
"><\/a>' +
123 '<\/td><td class="nowrap right
"> ' +
129 function OpenFolder( folderPath )
131 // Load the resources list for this folder.
132 window.parent.frames['frmFolders'].LoadFolders( folderPath );
135 function GetUrlParam( paramName )
137 var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' );
138 var oMatch = oRegex.exec( window.top.location.search );
140 if ( oMatch && oMatch.length > 1 )
141 return decodeURIComponent( oMatch[1] );
146 // Note fileUrl must be already "URL encoded
"
147 function OpenFile( fileUrl )
149 funcNum = GetUrlParam('CKEditorFuncNum');
150 //window.top.opener.CKEDITOR.tools.callFunction(funcNum, encodeURI( fileUrl ).replace( '#', '%23' ));
151 window.top.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl.replace( '#', '%23' ));
155 window.top.opener.focus();
158 function LoadResources( resourceType, folderPath )
160 oListManager.Clear();
161 oConnector.ResourceType = resourceType ;
162 oConnector.CurrentFolder = folderPath ;
163 oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack );
168 LoadResources( oConnector.ResourceType, oConnector.CurrentFolder );
171 function GetFoldersAndFilesCallBack( fckXml )
173 if ( oConnector.CheckError( fckXml ) != 0 )
176 // Get the current folder path.
177 var oFolderNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' );
178 if ( oFolderNode == null )
180 alert( 'The server didn\'t reply with a proper XML data. Please check your configuration.' );
183 var sCurrentFolderPath = oFolderNode.attributes.getNamedItem('path').value ;
184 var sCurrentFolderUrl = oFolderNode.attributes.getNamedItem('url').value ;
186 // var dTimer = new Date();
188 var oHtml = new StringBuilder( '<table id="tableFiles
" cellspacing="1
" cellpadding="0
" width="100%
" border="0
">' );
192 oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' );
193 for ( var i = 0 ; i < oNodes.length ; i++ )
195 var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
196 oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/
" ) );
200 oNodes = fckXml.SelectNodes( 'Connector/Files/File' );
201 for ( var j = 0 ; j < oNodes.length ; j++ )
203 var oNode = oNodes[j] ;
204 var sFileName = oNode.attributes.getNamedItem('name').value ;
205 var sFileSize = oNode.attributes.getNamedItem('size').value ;
207 // Get the optional "url
" attribute. If not available, build the url.
208 var oFileUrlAtt = oNodes[j].attributes.getNamedItem('url');
209 var sFileUrl = oFileUrlAtt != null ? oFileUrlAtt.value : encodeURI( sCurrentFolderUrl + sFileName ).replace( /#/g, '%23' );
211 oHtml.Append( oListManager.GetFileRowHtml( sFileName, sFileUrl, sFileSize ) );
214 oHtml.Append( '<\/table>' );
216 document.body.innerHTML = oHtml.ToString();
218 // window.top.document.title = 'Finished processing in ' + ( ( ( new Date() ) - dTimer ) / 1000 ) + ' seconds' ;
222 window.onload = function()
224 window.top.IsLoadedResourcesList = true ;
228 <body class="FileArea
">