dolibarr 20.0.0
frmfolders.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 the list of folders available in the parent folder
52 * of the current folder.
53-->
54<?php
55//$arrayofjs=array('js/common.js');
56//top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
57?>
58<html>
59 <head>
60 <title>Folders</title>
61 <link href="browser.css" type="text/css" rel="stylesheet">
62 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
63<?php
64print '<!-- Includes CSS for Dolibarr theme -->'."\n";
65// Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
66$themepath = dol_buildpath($conf->css, 1);
67$themesubdir = '';
68if (!empty($conf->modules_parts['theme'])) { // This slow down
69 foreach ($conf->modules_parts['theme'] as $reldir) {
70 if (file_exists(dol_buildpath($reldir.$conf->css, 0))) {
71 $themepath = dol_buildpath($reldir.$conf->css, 1);
72 $themesubdir = $reldir;
73 break;
74 }
75 }
76}
77
78//print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
79print '<link rel="stylesheet" type="text/css" href="'.$themepath.'">'."\n";
80?>
81 <script type="text/javascript" src="js/common.js"></script>
82 <script type="text/javascript">
83
84var sActiveFolder ;
85
86var bIsLoaded = false ;
87var iIntervalId ;
88
89var oListManager = new Object();
90
91oListManager.Init = function()
92{
93 this.Table = document.getElementById('tableFiles');
94 this.UpRow = document.getElementById('trUp');
95
96 this.TableRows = new Object();
97}
98
99oListManager.Clear = function()
100{
101 // Remove all other rows available.
102 while ( this.Table.rows.length > 1 )
103 this.Table.deleteRow(1);
104
105 // Reset the TableRows collection.
106 this.TableRows = new Object();
107}
108
109oListManager.AddItem = function( folderName, folderPath )
110{
111 // Create the new row.
112 var oRow = this.Table.insertRow(-1);
113 oRow.className = 'FolderListFolder' ;
114
115 // Build the link to view the folder.
116 var sLink = '<a href="#" onclick="OpenFolder(\'' + folderPath + '\');return false;">' ;
117
118 // Add the folder icon cell.
119 var oCell = oRow.insertCell(-1);
120 oCell.width = 16 ;
121 oCell.innerHTML = sLink + ' <\/a>' ;
122
123 // Add the folder name cell.
124 oCell = oRow.insertCell(-1);
125 oCell.noWrap = true ;
126 oCell.innerHTML = '&nbsp;' + sLink + folderName + '<\/a>' ;
127
128 this.TableRows[ folderPath ] = oRow ;
129}
130
131oListManager.ShowUpFolder = function( upFolderPath )
132{
133 this.UpRow.style.display = ( upFolderPath != null ? '' : 'none' );
134
135 if ( upFolderPath != null )
136 {
137 document.getElementById('linkUpIcon').onclick = document.getElementById('linkUp').onclick = function()
138 {
139 LoadFolders( upFolderPath );
140 return false ;
141 }
142 }
143}
144
145function CheckLoaded()
146{
147 if ( window.top.IsLoadedActualFolder
148 && window.top.IsLoadedCreateFolder
149 && window.top.IsLoadedUpload
150 && window.top.IsLoadedResourcesList )
151 {
152 window.clearInterval( iIntervalId );
153 bIsLoaded = true ;
154 OpenFolder( sActiveFolder );
155 }
156}
157
158function OpenFolder( folderPath )
159{
160 sActiveFolder = folderPath ;
161
162 if ( ! bIsLoaded )
163 {
164 if ( ! iIntervalId )
165 iIntervalId = window.setInterval( CheckLoaded, 100 );
166 return ;
167 }
168
169 // Change the style for the select row (to show the opened folder).
170 for ( var sFolderPath in oListManager.TableRows )
171 {
172 oListManager.TableRows[ sFolderPath ].className =
173 ( sFolderPath == folderPath ? 'FolderListCurrentFolder' : 'FolderListFolder' );
174 }
175
176 // Set the current folder in all frames.
177 window.parent.frames['frmActualFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath );
178 window.parent.frames['frmCreateFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath );
179 window.parent.frames['frmUpload'].SetCurrentFolder( oConnector.ResourceType, folderPath );
180
181 // Load the resources list for this folder.
182 window.parent.frames['frmResourcesList'].LoadResources( oConnector.ResourceType, folderPath );
183}
184
185function LoadFolders( folderPath )
186{
187 console.log("LoadFolders folderPath="+folderPath);
188
189 // Clear the folders list.
190 oListManager.Clear();
191
192 // Get the parent folder path.
193 var sParentFolderPath ;
194 if ( folderPath != '/' )
195 sParentFolderPath = folderPath.substring( 0, folderPath.lastIndexOf( '/', folderPath.length - 2 ) + 1 );
196
197 // Show/Hide the Up Folder.
198 oListManager.ShowUpFolder( sParentFolderPath );
199
200 if ( folderPath != '/' )
201 {
202 sActiveFolder = folderPath ;
203 oConnector.CurrentFolder = sParentFolderPath ;
204 oConnector.SendCommand( 'GetFolders', null, GetFoldersCallBack );
205 }
206 else
207 OpenFolder( '/' );
208}
209
210function GetFoldersCallBack( fckXml )
211{
212 if ( oConnector.CheckError( fckXml ) != 0 )
213 return ;
214
215 // Get the current folder path.
216 var oNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' );
217 var sCurrentFolderPath = oNode.attributes.getNamedItem('path').value ;
218
219 var oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' );
220
221 for ( var i = 0 ; i < oNodes.length ; i++ )
222 {
223 var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
224 oListManager.AddItem( sFolderName, sCurrentFolderPath + sFolderName + '/' );
225 }
226
227 OpenFolder( sActiveFolder );
228}
229
230function SetResourceType( type )
231{
232 oConnector.ResourceType = type ;
233 LoadFolders( '/' );
234}
235
236window.onload = function()
237{
238 oListManager.Init();
239 LoadFolders( '/' );
240}
241 </script>
242 </head>
243 <body class="FileArea">
244 <table id="tableFiles" cellSpacing="0" cellPadding="0" width="100%" border="0">
245 <tr id="trUp" style="DISPLAY: none">
246 <td width="16"><a id="linkUpIcon" href="#"><img alt="" src="images/FolderUp.gif" width="16" height="16" border="0"></a></td>
247 <td class="nowrap" width="100%">&nbsp;<a id="linkUp" href="#">..</a></td>
248 </tr>
249 </table>
250 </body>
251</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:139