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