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