frmfolders.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. define('NOTOKENRENEWAL', 1); // Disables token renewal
  22. // Load Dolibarr environment
  23. require '../../../../main.inc.php';
  24. top_httphead();
  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. * https://www.gnu.org/licenses/gpl.html
  38. *
  39. * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  40. * https://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. //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. <?php
  60. print '<!-- Includes CSS for Dolibarr theme -->'."\n";
  61. // Output style sheets (optioncss='print' or ''). Note: $conf->css looks like '/theme/eldy/style.css.php'
  62. $themepath = dol_buildpath($conf->css, 1);
  63. $themesubdir = '';
  64. if (!empty($conf->modules_parts['theme'])) { // This slow down
  65. foreach ($conf->modules_parts['theme'] as $reldir) {
  66. if (file_exists(dol_buildpath($reldir.$conf->css, 0))) {
  67. $themepath = dol_buildpath($reldir.$conf->css, 1);
  68. $themesubdir = $reldir;
  69. break;
  70. }
  71. }
  72. }
  73. //print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
  74. print '<link rel="stylesheet" type="text/css" href="'.$themepath.'">'."\n";
  75. ?>
  76. <script type="text/javascript" src="js/common.js"></script>
  77. <script type="text/javascript">
  78. var sActiveFolder ;
  79. var bIsLoaded = false ;
  80. var iIntervalId ;
  81. var oListManager = new Object();
  82. oListManager.Init = function()
  83. {
  84. this.Table = document.getElementById('tableFiles');
  85. this.UpRow = document.getElementById('trUp');
  86. this.TableRows = new Object();
  87. }
  88. oListManager.Clear = function()
  89. {
  90. // Remove all other rows available.
  91. while ( this.Table.rows.length > 1 )
  92. this.Table.deleteRow(1);
  93. // Reset the TableRows collection.
  94. this.TableRows = new Object();
  95. }
  96. oListManager.AddItem = function( folderName, folderPath )
  97. {
  98. // Create the new row.
  99. var oRow = this.Table.insertRow(-1);
  100. oRow.className = 'FolderListFolder' ;
  101. // Build the link to view the folder.
  102. var sLink = '<a href="#" onclick="OpenFolder(\'' + folderPath + '\');return false;">' ;
  103. // Add the folder icon cell.
  104. var oCell = oRow.insertCell(-1);
  105. oCell.width = 16 ;
  106. oCell.innerHTML = sLink + ' <\/a>' ;
  107. // Add the folder name cell.
  108. oCell = oRow.insertCell(-1);
  109. oCell.noWrap = true ;
  110. oCell.innerHTML = '&nbsp;' + sLink + folderName + '<\/a>' ;
  111. this.TableRows[ folderPath ] = oRow ;
  112. }
  113. oListManager.ShowUpFolder = function( upFolderPath )
  114. {
  115. this.UpRow.style.display = ( upFolderPath != null ? '' : 'none' );
  116. if ( upFolderPath != null )
  117. {
  118. document.getElementById('linkUpIcon').onclick = document.getElementById('linkUp').onclick = function()
  119. {
  120. LoadFolders( upFolderPath );
  121. return false ;
  122. }
  123. }
  124. }
  125. function CheckLoaded()
  126. {
  127. if ( window.top.IsLoadedActualFolder
  128. && window.top.IsLoadedCreateFolder
  129. && window.top.IsLoadedUpload
  130. && window.top.IsLoadedResourcesList )
  131. {
  132. window.clearInterval( iIntervalId );
  133. bIsLoaded = true ;
  134. OpenFolder( sActiveFolder );
  135. }
  136. }
  137. function OpenFolder( folderPath )
  138. {
  139. sActiveFolder = folderPath ;
  140. if ( ! bIsLoaded )
  141. {
  142. if ( ! iIntervalId )
  143. iIntervalId = window.setInterval( CheckLoaded, 100 );
  144. return ;
  145. }
  146. // Change the style for the select row (to show the opened folder).
  147. for ( var sFolderPath in oListManager.TableRows )
  148. {
  149. oListManager.TableRows[ sFolderPath ].className =
  150. ( sFolderPath == folderPath ? 'FolderListCurrentFolder' : 'FolderListFolder' );
  151. }
  152. // Set the current folder in all frames.
  153. window.parent.frames['frmActualFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath );
  154. window.parent.frames['frmCreateFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath );
  155. window.parent.frames['frmUpload'].SetCurrentFolder( oConnector.ResourceType, folderPath );
  156. // Load the resources list for this folder.
  157. window.parent.frames['frmResourcesList'].LoadResources( oConnector.ResourceType, folderPath );
  158. }
  159. function LoadFolders( folderPath )
  160. {
  161. // Clear the folders list.
  162. oListManager.Clear();
  163. // Get the parent folder path.
  164. var sParentFolderPath ;
  165. if ( folderPath != '/' )
  166. sParentFolderPath = folderPath.substring( 0, folderPath.lastIndexOf( '/', folderPath.length - 2 ) + 1 );
  167. // Show/Hide the Up Folder.
  168. oListManager.ShowUpFolder( sParentFolderPath );
  169. if ( folderPath != '/' )
  170. {
  171. sActiveFolder = folderPath ;
  172. oConnector.CurrentFolder = sParentFolderPath ;
  173. oConnector.SendCommand( 'GetFolders', null, GetFoldersCallBack );
  174. }
  175. else
  176. OpenFolder( '/' );
  177. }
  178. function GetFoldersCallBack( fckXml )
  179. {
  180. if ( oConnector.CheckError( fckXml ) != 0 )
  181. return ;
  182. // Get the current folder path.
  183. var oNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' );
  184. var sCurrentFolderPath = oNode.attributes.getNamedItem('path').value ;
  185. var oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' );
  186. for ( var i = 0 ; i < oNodes.length ; i++ )
  187. {
  188. var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
  189. oListManager.AddItem( sFolderName, sCurrentFolderPath + sFolderName + '/' );
  190. }
  191. OpenFolder( sActiveFolder );
  192. }
  193. function SetResourceType( type )
  194. {
  195. oConnector.ResourceType = type ;
  196. LoadFolders( '/' );
  197. }
  198. window.onload = function()
  199. {
  200. oListManager.Init();
  201. LoadFolders( '/' );
  202. }
  203. </script>
  204. </head>
  205. <body class="FileArea">
  206. <table id="tableFiles" cellSpacing="0" cellPadding="0" width="100%" border="0">
  207. <tr id="trUp" style="DISPLAY: none">
  208. <td width="16"><a id="linkUpIcon" href="#"><img alt="" src="images/FolderUp.gif" width="16" height="16" border="0"></a></td>
  209. <td class="nowrap" width="100%">&nbsp;<a id="linkUp" href="#">..</a></td>
  210. </tr>
  211. </table>
  212. </body>
  213. </html>