Index: og_files.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/og_files/Attic/og_files.module,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 og_files.module --- og_files.module 17 May 2008 13:42:16 -0000 1.1.2.2 +++ og_files.module 5 Dec 2008 02:00:12 -0000 @@ -132,9 +132,11 @@ function og_file_list_form($gid, $path){ - + $dir_tree_raw = array(); + while($file = db_fetch_object($files)) { - $array = explode('/',og_files_relative_path($gid,$file->filepath)); + $filename = og_files_relative_path($gid,$file->filepath); + $array = explode('/', $filename); array_pop($array); if((count($array) - $virtualpath_count) > 0) { //in a subdir @@ -143,39 +145,71 @@ function og_file_list_form($gid, $path){ if (count($array) - $virtualpath_count < 2) { $dir_list[$array[count($array)-1]] = l($array[count($array)-1], og_files_virtual_base_path($gid).implode('/',$array)); $dir_count++; + $dir_tree_raw[] = $array; } } else { - $file_list[$file->fid] = l($file->filename,og_files_virtual_base_path($gid).og_files_relative_path($gid,$file->filepath)); + $dir_tree_raw[] = explode('/', dirname($filename)); + $file_list[$file->fid] = l($file->filename,og_files_virtual_base_path($gid). $filename); $file_count++; } } + // Traverse $dir_tree_raw to $dir_tree + $dir_tree = array(); + if (count($dir_tree_raw)) { + foreach ($dir_tree_raw as $tree) { + $current_dir =& $dir_tree; + foreach ($tree as $dir) { + if($dir !== '.') { + if (!isset($current_dir[$dir])) + $current_dir[$dir] = array(); + $current_dir =& $current_dir[$dir]; + } + } + } + } $form['filelist'] = array( '#type' => 'fieldset', - '#title' => '/'.og_files_relative_path($gid,$path), + '#title' => '/'. og_files_relative_path($gid, $path), '#collapsible' => true, '#collapsed' => false ); - + + $form['filelist']['tree'] = array( + '#type' => 'item', + '#value' => theme('og_files_tree', $gid, array('/' => $dir_tree), $virtualpath), + '#prefix' => '