dolibarr  7.0.0-beta
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  * retreived 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 <http://www.gnu.org/licenses/>.
20  */
21 
22 define('NOTOKENRENEWAL',1); // Disables token renewal
23 
24 require '../../../../main.inc.php';
25 ?>
26 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
27 <!--
28  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
29  * Copyright (C) 2003-2010 Frederico Caldeira Knabben
30  *
31  * == BEGIN LICENSE ==
32  *
33  * Licensed under the terms of any of the following licenses at your
34  * choice:
35  *
36  * - GNU General Public License Version 2 or later (the "GPL")
37  * http://www.gnu.org/licenses/gpl.html
38  *
39  * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
40  * http://www.gnu.org/licenses/lgpl.html
41  *
42  * - Mozilla Public License Version 1.1 or later (the "MPL")
43  * http://www.mozilla.org/MPL/MPL-1.1.html
44  *
45  * == END LICENSE ==
46  *
47  * This page shows the list of folders available in the parent folder
48  * of the current folder.
49 -->
50 <?php
51 //$arrayofjs=array('js/common.js');
52 //echo top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
53 ?>
54 <html>
55  <head>
56  <title>Folders</title>
57  <link href="browser.css" type="text/css" rel="stylesheet">
58  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
59  <script type="text/javascript" src="js/common.js"></script>
60  <script type="text/javascript">
61 
62 var sActiveFolder ;
63 
64 var bIsLoaded = false ;
65 var iIntervalId ;
66 
67 var oListManager = new Object();
68 
69 oListManager.Init = function()
70 {
71  this.Table = document.getElementById('tableFiles');
72  this.UpRow = document.getElementById('trUp');
73 
74  this.TableRows = new Object();
75 }
76 
77 oListManager.Clear = function()
78 {
79  // Remove all other rows available.
80  while ( this.Table.rows.length > 1 )
81  this.Table.deleteRow(1);
82 
83  // Reset the TableRows collection.
84  this.TableRows = new Object();
85 }
86 
87 oListManager.AddItem = function( folderName, folderPath )
88 {
89  // Create the new row.
90  var oRow = this.Table.insertRow(-1);
91  oRow.className = 'FolderListFolder' ;
92 
93  // Build the link to view the folder.
94  var sLink = '<a href="#" onclick="OpenFolder(\'' + folderPath + '\');return false;">' ;
95 
96  // Add the folder icon cell.
97  var oCell = oRow.insertCell(-1);
98  oCell.width = 16 ;
99  oCell.innerHTML = sLink + '<img alt="" src="spacer.gif" width="16" height="16" border="0"><\/a>' ;
100 
101  // Add the folder name cell.
102  oCell = oRow.insertCell(-1);
103  oCell.noWrap = true ;
104  oCell.innerHTML = '&nbsp;' + sLink + folderName + '<\/a>' ;
105 
106  this.TableRows[ folderPath ] = oRow ;
107 }
108 
109 oListManager.ShowUpFolder = function( upFolderPath )
110 {
111  this.UpRow.style.display = ( upFolderPath != null ? '' : 'none' );
112 
113  if ( upFolderPath != null )
114  {
115  document.getElementById('linkUpIcon').onclick = document.getElementById('linkUp').onclick = function()
116  {
117  LoadFolders( upFolderPath );
118  return false ;
119  }
120  }
121 }
122 
123 function CheckLoaded()
124 {
125  if ( window.top.IsLoadedActualFolder
126  && window.top.IsLoadedCreateFolder
127  && window.top.IsLoadedUpload
128  && window.top.IsLoadedResourcesList )
129  {
130  window.clearInterval( iIntervalId );
131  bIsLoaded = true ;
132  OpenFolder( sActiveFolder );
133  }
134 }
135 
136 function OpenFolder( folderPath )
137 {
138  sActiveFolder = folderPath ;
139 
140  if ( ! bIsLoaded )
141  {
142  if ( ! iIntervalId )
143  iIntervalId = window.setInterval( CheckLoaded, 100 );
144  return ;
145  }
146 
147  // Change the style for the select row (to show the opened folder).
148  for ( var sFolderPath in oListManager.TableRows )
149  {
150  oListManager.TableRows[ sFolderPath ].className =
151  ( sFolderPath == folderPath ? 'FolderListCurrentFolder' : 'FolderListFolder' );
152  }
153 
154  // Set the current folder in all frames.
155  window.parent.frames['frmActualFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath );
156  window.parent.frames['frmCreateFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath );
157  window.parent.frames['frmUpload'].SetCurrentFolder( oConnector.ResourceType, folderPath );
158 
159  // Load the resources list for this folder.
160  window.parent.frames['frmResourcesList'].LoadResources( oConnector.ResourceType, folderPath );
161 }
162 
163 function LoadFolders( folderPath )
164 {
165  // Clear the folders list.
166  oListManager.Clear();
167 
168  // Get the parent folder path.
169  var sParentFolderPath ;
170  if ( folderPath != '/' )
171  sParentFolderPath = folderPath.substring( 0, folderPath.lastIndexOf( '/', folderPath.length - 2 ) + 1 );
172 
173  // Show/Hide the Up Folder.
174  oListManager.ShowUpFolder( sParentFolderPath );
175 
176  if ( folderPath != '/' )
177  {
178  sActiveFolder = folderPath ;
179  oConnector.CurrentFolder = sParentFolderPath ;
180  oConnector.SendCommand( 'GetFolders', null, GetFoldersCallBack );
181  }
182  else
183  OpenFolder( '/' );
184 }
185 
186 function GetFoldersCallBack( fckXml )
187 {
188  if ( oConnector.CheckError( fckXml ) != 0 )
189  return ;
190 
191  // Get the current folder path.
192  var oNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' );
193  var sCurrentFolderPath = oNode.attributes.getNamedItem('path').value ;
194 
195  var oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' );
196 
197  for ( var i = 0 ; i < oNodes.length ; i++ )
198  {
199  var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
200  oListManager.AddItem( sFolderName, sCurrentFolderPath + sFolderName + '/' );
201  }
202 
203  OpenFolder( sActiveFolder );
204 }
205 
206 function SetResourceType( type )
207 {
208  oConnector.ResourceType = type ;
209  LoadFolders( '/' );
210 }
211 
212 window.onload = function()
213 {
214  oListManager.Init();
215  LoadFolders( '/' );
216 }
217  </script>
218  </head>
219  <body class="FileArea">
220  <table id="tableFiles" cellSpacing="0" cellPadding="0" width="100%" border="0">
221  <tr id="trUp" style="DISPLAY: none">
222  <td width="16"><a id="linkUpIcon" href="#"><img alt="" src="images/FolderUp.gif" width="16" height="16" border="0"></a></td>
223  <td class="nowrap" width="100%">&nbsp;<a id="linkUp" href="#">..</a></td>
224  </tr>
225  </table>
226  </body>
227 </html>
type
Definition: viewcat.php:283