dolibarr 18.0.6
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
22define('NOTOKENRENEWAL', 1); // Disables token renewal
23
24// Load Dolibarr environment
25require '../../../../main.inc.php';
26
28
29?>
30<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
31<!--
32 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
33 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
34 *
35 * == BEGIN LICENSE ==
36 *
37 * Licensed under the terms of any of the following licenses at your
38 * choice:
39 *
40 * - GNU General Public License Version 2 or later (the "GPL")
41 * https://www.gnu.org/licenses/gpl.html
42 *
43 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
44 * https://www.gnu.org/licenses/lgpl.html
45 *
46 * - Mozilla Public License Version 1.1 or later (the "MPL")
47 * http://www.mozilla.org/MPL/MPL-1.1.html
48 *
49 * == END LICENSE ==
50 *
51 * This page shows all resources available in a folder in the File Browser.
52-->
53<html>
54<head>
55 <title>Resources</title>
56 <link href="browser.css" type="text/css" rel="stylesheet">
57<?php
58print '<!-- Includes CSS for Dolibarr theme -->'."\n";
59// Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
60$themepath = dol_buildpath($conf->css, 1);
61$themesubdir = '';
62if (!empty($conf->modules_parts['theme'])) { // This slow down
63 foreach ($conf->modules_parts['theme'] as $reldir) {
64 if (file_exists(dol_buildpath($reldir.$conf->css, 0))) {
65 $themepath = dol_buildpath($reldir.$conf->css, 1);
66 $themesubdir = $reldir;
67 break;
68 }
69 }
70}
71
72//print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
73print '<link rel="stylesheet" type="text/css" href="'.$themepath.'">'."\n";
74?>
75 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
76 <script type="text/javascript" src="js/common.js"></script>
77 <script type="text/javascript">
78
79var oListManager = new Object();
80
81oListManager.Clear = function()
82{
83 document.body.innerHTML = '' ;
84}
85
86function ProtectPath(path)
87{
88 path = path.replace( /\\/g, '\\\\');
89 path = path.replace( /'/g, '\\\'');
90 return path ;
91}
92
93oListManager.GetFolderRowHtml = function( folderName, folderPath )
94{
95 // Build the link to view the folder.
96 var sLink = '<a href="#" onclick="OpenFolder(\'' + ProtectPath(folderPath) + '\');return false;">' ;
97
98 return '<tr>' +
99 '<td width="16">' +
100 sLink +
101 '<img alt="" src="images/Folder.gif" width="16" height="16" border="0"><\/a>' +
102 '<\/td><td class="nowrap" colspan="2">&nbsp;' +
103 sLink +
104 folderName +
105 '<\/a>' +
106 '<\/td><\/tr>' ;
107}
108
109// Note: fileUrl must be already "URL encoded"
110oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
111{
112 // Build the link to view the folder.
113 var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath(fileUrl) + '\');return false;">' ;
114
115 // Get the file icon.
116 var sIcon = oIcons.GetIcon( fileName );
117
118 return '<tr>' +
119 '<td width="16">' +
120 sLink +
121 '<img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"><\/a>' +
122 '<\/td><td>&nbsp;' +
123 sLink +
124 fileName +
125 '<\/a>' +
126 '<\/td><td class="nowrap right">&nbsp;' +
127 fileSize +
128 ' KB' +
129 '<\/td><\/tr>' ;
130}
131
132function OpenFolder( folderPath )
133{
134 // Load the resources list for this folder.
135 window.parent.frames['frmFolders'].LoadFolders( folderPath );
136}
137
138function GetUrlParam( paramName )
139{
140 var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' );
141 var oMatch = oRegex.exec( window.top.location.search );
142
143 if ( oMatch && oMatch.length > 1 )
144 return decodeURIComponent( oMatch[1] );
145 else
146 return '' ;
147}
148
149// Note fileUrl must be already "URL encoded"
150function OpenFile( fileUrl )
151{
152 funcNum = GetUrlParam('CKEditorFuncNum');
153 //window.top.opener.CKEDITOR.tools.callFunction(funcNum, encodeURI( fileUrl ).replace( '#', '%23' ));
154 window.top.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl.replace( '#', '%23' ));
155
157 window.top.close();
158 window.top.opener.focus();
159}
160
161function LoadResources( resourceType, folderPath )
162{
163 oListManager.Clear();
164 oConnector.ResourceType = resourceType ;
165 oConnector.CurrentFolder = folderPath ;
166 oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack );
167}
168
169function Refresh()
170{
171 LoadResources( oConnector.ResourceType, oConnector.CurrentFolder );
172}
173
174function GetFoldersAndFilesCallBack( fckXml )
175{
176 if ( oConnector.CheckError( fckXml ) != 0 )
177 return ;
178
179 // Get the current folder path.
180 var oFolderNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' );
181 if ( oFolderNode == null )
182 {
183 alert( 'The server didn\'t reply with a proper XML data. Please check your configuration.' );
184 return ;
185 }
186 var sCurrentFolderPath = oFolderNode.attributes.getNamedItem('path').value ;
187 var sCurrentFolderUrl = oFolderNode.attributes.getNamedItem('url').value ;
188
189// var dTimer = new Date();
190
191 var oHtml = new StringBuilder( '<table id="tableFiles" cellspacing="1" cellpadding="0" width="100%" border="0">' );
192
193 // Add the Folders.
194 var oNodes ;
195 oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' );
196 for ( var i = 0 ; i < oNodes.length ; i++ )
197 {
198 var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
199 oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/" ) );
200 }
201
202 // Add the Files.
203 oNodes = fckXml.SelectNodes( 'Connector/Files/File' );
204 for ( var j = 0 ; j < oNodes.length ; j++ )
205 {
206 var oNode = oNodes[j] ;
207 var sFileName = oNode.attributes.getNamedItem('name').value ;
208 var sFileSize = oNode.attributes.getNamedItem('size').value ;
209
210 // Get the optional "url" attribute. If not available, build the url.
211 var oFileUrlAtt = oNodes[j].attributes.getNamedItem('url');
212 var sFileUrl = oFileUrlAtt != null ? oFileUrlAtt.value : encodeURI( sCurrentFolderUrl + sFileName ).replace( /#/g, '%23' );
213
214 oHtml.Append( oListManager.GetFileRowHtml( sFileName, sFileUrl, sFileSize ) );
215 }
216
217 oHtml.Append( '<\/table>' );
218
219 document.body.innerHTML = oHtml.ToString();
220
221// window.top.document.title = 'Finished processing in ' + ( ( ( new Date() ) - dTimer ) / 1000 ) + ' seconds' ;
222
223}
224
225window.onload = function()
226{
227 window.top.IsLoadedResourcesList = true ;
228}
229 </script>
230</head>
231<body class="FileArea">
232</body>
233</html>
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:120