dolibarr 21.0.0-alpha
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 console.log("OpenFolder folderPath="+folderPath);
135
136 // Load the resources list for this folder.
137 window.parent.frames['frmFolders'].LoadFolders( folderPath );
138}
139
140function GetUrlParam( paramName )
141{
142 var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' );
143 var oMatch = oRegex.exec( window.top.location.search );
144
145 if ( oMatch && oMatch.length > 1 )
146 return decodeURIComponent( oMatch[1] );
147 else
148 return '' ;
149}
150
151// Note fileUrl must be already "URL encoded"
152function OpenFile( fileUrl )
153{
154 funcNum = GetUrlParam('CKEditorFuncNum');
155 //window.top.opener.CKEDITOR.tools.callFunction(funcNum, encodeURI( fileUrl ).replace( '#', '%23' ));
156 window.top.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl.replace( '#', '%23' ));
157
159 window.top.close();
160 window.top.opener.focus();
161}
162
163function LoadResources( resourceType, folderPath )
164{
165 oListManager.Clear();
166 oConnector.ResourceType = resourceType ;
167 oConnector.CurrentFolder = folderPath ;
168 oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack );
169}
170
171function Refresh()
172{
173 LoadResources( oConnector.ResourceType, oConnector.CurrentFolder );
174}
175
176function GetFoldersAndFilesCallBack( fckXml )
177{
178 if ( oConnector.CheckError( fckXml ) != 0 )
179 return ;
180
181 // Get the current folder path.
182 var oFolderNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' );
183 if ( oFolderNode == null )
184 {
185 alert( 'The server didn\'t reply with a proper XML data. Please check your configuration.' );
186 return ;
187 }
188 var sCurrentFolderPath = oFolderNode.attributes.getNamedItem('path').value ;
189 var sCurrentFolderUrl = oFolderNode.attributes.getNamedItem('url').value ;
190
191// var dTimer = new Date();
192
193 var oHtml = new StringBuilder( '<table id="tableFiles" cellspacing="1" cellpadding="0" width="100%" border="0">' );
194
195 // Add the Folders.
196 var oNodes ;
197 oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' );
198 for ( var i = 0 ; i < oNodes.length ; i++ )
199 {
200 var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
201 oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/" ) );
202 }
203
204 // Add the Files.
205 oNodes = fckXml.SelectNodes( 'Connector/Files/File' );
206 for ( var j = 0 ; j < oNodes.length ; j++ )
207 {
208 var oNode = oNodes[j] ;
209 var sFileName = oNode.attributes.getNamedItem('name').value ;
210 var sFileSize = oNode.attributes.getNamedItem('size').value ;
211
212 // Get the optional "url" attribute. If not available, build the url.
213 var oFileUrlAtt = oNodes[j].attributes.getNamedItem('url');
214 var sFileUrl = oFileUrlAtt != null ? oFileUrlAtt.value : encodeURI( sCurrentFolderUrl + sFileName ).replace( /#/g, '%23' );
215
216 oHtml.Append( oListManager.GetFileRowHtml( sFileName, sFileUrl, sFileSize ) );
217 }
218
219 oHtml.Append( '<\/table>' );
220
221 document.body.innerHTML = oHtml.ToString();
222
223// window.top.document.title = 'Finished processing in ' + ( ( ( new Date() ) - dTimer ) / 1000 ) + ' seconds' ;
224
225}
226
227window.onload = function()
228{
229 window.top.IsLoadedResourcesList = true ;
230}
231 </script>
232</head>
233<body class="FileArea">
234</body>
235</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:137