@@ -185,8 +185,8 @@ static function displayAjaxValue($datas) {
185
185
echo "<input type='text' name='filename' id='server_filename $ rand' " .
186
186
" style='width:120px;float:left' /> " ;
187
187
echo "<input type='button' class='submit' value=' " .__ ("Choose " , 'fusioninventory ' ).
188
- "' onclick='fileModal.show();' style='width:50px' /> " ;
189
- Ajax::createModalWindow (' fileModal ' ,
188
+ "' onclick='fileModal $ rand .show();' style='width:50px' /> " ;
189
+ Ajax::createModalWindow (" fileModal $ rand " ,
190
190
$ CFG_GLPI ['root_doc ' ]."/plugins/fusioninventory/ajax/deployfilemodal.php " ,
191
191
array ('title ' => __ ('Select the file on server ' , 'fusioninventory ' ),
192
192
'extraparams ' => array (
@@ -216,6 +216,121 @@ static function displayAjaxValue($datas) {
216
216
echo "</tr></table> " ;
217
217
}
218
218
219
+ static function showServerFileTree ($ params ) {
220
+ global $ CFG_GLPI ;
221
+
222
+ $ rand = $ params ['rand ' ];
223
+
224
+ echo "<script type='javascript'> " ;
225
+ echo "var Tree_Category_Loader $ rand = new Ext.tree.TreeLoader({
226
+ dataUrl:' " .$ CFG_GLPI ["root_doc " ]."/plugins/fusioninventory/ajax/serverfilestreesons.php'
227
+ }); " ;
228
+
229
+ echo "var Tree_Category $ rand = new Ext.tree.TreePanel({
230
+ collapsible : false,
231
+ animCollapse : false,
232
+ border : false,
233
+ id : 'tree_projectcategory $ rand',
234
+ el : 'tree_projectcategory $ rand',
235
+ autoScroll : true,
236
+ animate : false,
237
+ enableDD : true,
238
+ containerScroll : true,
239
+ height : 320,
240
+ width : 770,
241
+ loader : Tree_Category_Loader $ rand,
242
+ rootVisible : false,
243
+ listeners: {
244
+ click: function(node, event){
245
+ if (node.leaf == true) {
246
+ console.log('server_filename $ rand');
247
+ Ext.get('server_filename $ rand').dom.value = node.id;
248
+ fileModal $ rand.hide();
249
+ }
250
+ }
251
+ }
252
+ }); " ;
253
+
254
+ // SET the root node.
255
+ echo "var Tree_Category_Root $ rand = new Ext.tree.AsyncTreeNode({
256
+ text : '',
257
+ draggable : false,
258
+ id : '-1' // this IS the id of the startnode
259
+ });
260
+ Tree_Category $ rand.setRootNode(Tree_Category_Root $ rand); " ;
261
+
262
+ // Render the tree.
263
+ echo "Tree_Category $ rand.render();
264
+ Tree_Category_Root $ rand.expand(); " ;
265
+
266
+ echo "</script> " ;
267
+
268
+ echo "<div id='tree_projectcategory $ rand' ></div> " ;
269
+ echo "</div> " ;
270
+ }
271
+
272
+ static function getServerFileTree ($ params ) {
273
+
274
+ $ nodes = array ();
275
+
276
+ if (isset ($ params ['node ' ])) {
277
+
278
+ //root node
279
+ $ dir = "/var/www/glpi " ; // TODO : add config option as 0.83 version
280
+
281
+ // leaf node
282
+ if ($ params ['node ' ] != -1 ) {
283
+ $ dir = $ params ['node ' ];
284
+ }
285
+
286
+ if ($ handle = opendir ($ dir )) {
287
+ $ folders = $ files = array ();
288
+
289
+ //list files in dir selected
290
+ //we store folders and files separately to sort them alphabeticaly separatly
291
+ while (false !== ($ entry = readdir ($ handle ))) {
292
+ if ($ entry != ". " && $ entry != ".. " ) {
293
+ $ filepath = $ dir ."/ " .$ entry ;
294
+ if (is_dir ($ filepath )) {
295
+ $ folders [$ filepath ] = $ entry ;
296
+ } else {
297
+ $ files [$ filepath ] = $ entry ;
298
+ }
299
+ }
300
+ }
301
+
302
+ //sort folders and files (and maintain index association)
303
+ asort ($ folders );
304
+ asort ($ files );
305
+
306
+ //add folders in json
307
+ foreach ($ folders as $ filepath => $ entry ) {
308
+ $ path ['text ' ] = $ entry ;
309
+ $ path ['id ' ] = $ filepath ;
310
+ $ path ['draggable ' ] = false ;
311
+ $ path ['leaf ' ] = false ;
312
+ $ path ['cls ' ] = 'folder ' ;
313
+
314
+ $ nodes [] = $ path ;
315
+ }
316
+
317
+ //add files in json
318
+ foreach ($ files as $ filepath => $ entry ) {
319
+ $ path ['text ' ] = $ entry ;
320
+ $ path ['id ' ] = $ filepath ;
321
+ $ path ['draggable ' ] = false ;
322
+ $ path ['leaf ' ] = true ;
323
+ $ path ['cls ' ] = 'file ' ;
324
+
325
+ $ nodes [] = $ path ;
326
+ }
327
+
328
+ closedir ($ handle );
329
+ }
330
+ }
331
+
332
+ print json_encode ($ nodes );
333
+ }
219
334
220
335
221
336
static function getExtensionsWithAutoAction () {
0 commit comments