dolibarr  16.0.5
frmresourceslist.php
1 <?php
2 /* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2003-2010 Frederico Caldeira Knabben
4  *
5  * Source modified from part of fckeditor (http://www.fckeditor.net)
6  * retrieved as GPL v2 or later
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 define('NOTOKENRENEWAL', 1); // Disables token renewal
23 
24 require '../../../../main.inc.php';
25 
26 ?>
27 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
28 <!--
29  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
30  * Copyright (C) 2003-2010 Frederico Caldeira Knabben
31  *
32  * == BEGIN LICENSE ==
33  *
34  * Licensed under the terms of any of the following licenses at your
35  * choice:
36  *
37  * - GNU General Public License Version 2 or later (the "GPL")
38  * https://www.gnu.org/licenses/gpl.html
39  *
40  * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
41  * https://www.gnu.org/licenses/lgpl.html
42  *
43  * - Mozilla Public License Version 1.1 or later (the "MPL")
44  * http://www.mozilla.org/MPL/MPL-1.1.html
45  *
46  * == END LICENSE ==
47  *
48  * This page shows all resources available in a folder in the File Browser.
49 -->
50 <html>
51 <head>
52  <title>Resources</title>
53  <link href="browser.css" type="text/css" rel="stylesheet">
54 <?php
55 print '<!-- Includes CSS for Dolibarr theme -->'."\n";
56 // Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
57 $themepath = dol_buildpath($conf->css, 1);
58 $themesubdir = '';
59 if (!empty($conf->modules_parts['theme'])) { // This slow down
60  foreach ($conf->modules_parts['theme'] as $reldir) {
61  if (file_exists(dol_buildpath($reldir.$conf->css, 0))) {
62  $themepath = dol_buildpath($reldir.$conf->css, 1);
63  $themesubdir = $reldir;
64  break;
65  }
66  }
67 }
68 
69 //print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
70 print '<link rel="stylesheet" type="text/css" href="'.$themepath.'">'."\n";
71 ?>
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">
75 
76 var oListManager = new Object();
77 
78 oListManager.Clear = function()
79 {
80  document.body.innerHTML = '' ;
81 }
82 
83 function ProtectPath(path)
84 {
85  path = path.replace( /\\/g, '\\\\');
86  path = path.replace( /'/g, '\\\'');
87  return path ;
88 }
89 
90 oListManager.GetFolderRowHtml = function( folderName, folderPath )
91 {
92  // Build the link to view the folder.
93  var sLink = '<a href="#" onclick="OpenFolder(\'' + ProtectPath(folderPath) + '\');return false;">' ;
94 
95  return '<tr>' +
96  '<td width="16">' +
97  sLink +
98  '<img alt="" src="images/Folder.gif" width="16" height="16" border="0"><\/a>' +
99  '<\/td><td class="nowrap" colspan="2">&nbsp;' +
100  sLink +
101  folderName +
102  '<\/a>' +
103  '<\/td><\/tr>' ;
104 }
105 
106 // Note: fileUrl must be already "URL encoded"
107 oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
108 {
109  // Build the link to view the folder.
110  var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath(fileUrl) + '\');return false;">' ;
111 
112  // Get the file icon.
113  var sIcon = oIcons.GetIcon( fileName );
114 
115  return '<tr>' +
116  '<td width="16">' +
117  sLink +
118  '<img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"><\/a>' +
119  '<\/td><td>&nbsp;' +
120  sLink +
121  fileName +
122  '<\/a>' +
123  '<\/td><td class="nowrap right">&nbsp;' +
124  fileSize +
125  ' KB' +
126  '<\/td><\/tr>' ;
127 }
128 
129 function OpenFolder( folderPath )
130 {
131  // Load the resources list for this folder.
132  window.parent.frames['frmFolders'].LoadFolders( folderPath );
133 }
134 
135 function GetUrlParam( paramName )
136 {
137  var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' );
138  var oMatch = oRegex.exec( window.top.location.search );
139 
140  if ( oMatch && oMatch.length > 1 )
141  return decodeURIComponent( oMatch[1] );
142  else
143  return '' ;
144 }
145 
146 // Note fileUrl must be already "URL encoded"
147 function OpenFile( fileUrl )
148 {
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' ));
152 
154  window.top.close();
155  window.top.opener.focus();
156 }
157 
158 function LoadResources( resourceType, folderPath )
159 {
160  oListManager.Clear();
161  oConnector.ResourceType = resourceType ;
162  oConnector.CurrentFolder = folderPath ;
163  oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack );
164 }
165 
166 function Refresh()
167 {
168  LoadResources( oConnector.ResourceType, oConnector.CurrentFolder );
169 }
170 
171 function GetFoldersAndFilesCallBack( fckXml )
172 {
173  if ( oConnector.CheckError( fckXml ) != 0 )
174  return ;
175 
176  // Get the current folder path.
177  var oFolderNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' );
178  if ( oFolderNode == null )
179  {
180  alert( 'The server didn\'t reply with a proper XML data. Please check your configuration.' );
181  return ;
182  }
183  var sCurrentFolderPath = oFolderNode.attributes.getNamedItem('path').value ;
184  var sCurrentFolderUrl = oFolderNode.attributes.getNamedItem('url').value ;
185 
186 // var dTimer = new Date();
187 
188  var oHtml = new StringBuilder( '<table id="tableFiles" cellspacing="1" cellpadding="0" width="100%" border="0">' );
189 
190  // Add the Folders.
191  var oNodes ;
192  oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' );
193  for ( var i = 0 ; i < oNodes.length ; i++ )
194  {
195  var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
196  oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/" ) );
197  }
198 
199  // Add the Files.
200  oNodes = fckXml.SelectNodes( 'Connector/Files/File' );
201  for ( var j = 0 ; j < oNodes.length ; j++ )
202  {
203  var oNode = oNodes[j] ;
204  var sFileName = oNode.attributes.getNamedItem('name').value ;
205  var sFileSize = oNode.attributes.getNamedItem('size').value ;
206 
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' );
210 
211  oHtml.Append( oListManager.GetFileRowHtml( sFileName, sFileUrl, sFileSize ) );
212  }
213 
214  oHtml.Append( '<\/table>' );
215 
216  document.body.innerHTML = oHtml.ToString();
217 
218 // window.top.document.title = 'Finished processing in ' + ( ( ( new Date() ) - dTimer ) / 1000 ) + ' seconds' ;
219 
220 }
221 
222 window.onload = function()
223 {
224  window.top.IsLoadedResourcesList = true ;
225 }
226  </script>
227 </head>
228 <body class="FileArea">
229 </body>
230 </html>
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119