Okay, here's the fix.
Make the following modification to the searchnew.php file.
Old code:
$dir = opendir($dir_path);
while ($file = readdir($dir)) {
//if (is_dir($CONFIG['fullpath'] . $folder . $file) && $file != "." && $file != "..") { // removed by following line for 'do not show folders with dots': gaugau 03-11-02
if (is_dir($CONFIG['fullpath'] . $folder . $file) && substr($file,0,1) != "." && strpos($file,"'") == FALSE && $file != "userpics" && $file != "edit" ) {
$start_target = $folder . $file;
$dir_path = $CONFIG['fullpath'] . $folder . $file;
$warnings = '';
if (!is_writable($dir_path)) $warnings .= $lang_search_new_php['dir_ro'];
if (!is_readable($dir_path)) $warnings .= $lang_search_new_php['dir_cant_read'];
if ($warnings) $warnings = ' <b>' . $warnings . '<b>';
echo <<<EOT
<tr>
<td class="tableb">
$ident<img src="images/folder.gif" alt="" /> <a href= "$PHP_SELF?startdir=$start_target">$file</a>$warnings
</td>
</tr>
EOT;
display_dir_tree($folder . $file . '/', $ident . ' ');
}
}
closedir($dir);
New code:
$dir = opendir($dir_path);
while (($file = readdir($dir)) !== false) { $filelist[] = $file; }
closedir($dir);
asort($filelist);
while (list ($key, $file) = each ($filelist)) {
//if (is_dir($CONFIG['fullpath'] . $folder . $file) && $file != "." && $file != "..") { // removed by following line for 'do not show folders with dots': gaugau 03-11-02
if (is_dir($CONFIG['fullpath'] . $folder . $file) && substr($file,0,1) != "." && strpos($file,"'") == FALSE && $file != "userpics" && $file != "edit" ) {
$start_target = $folder . $file;
$dir_path = $CONFIG['fullpath'] . $folder . $file;
$warnings = '';
if (!is_writable($dir_path)) $warnings .= $lang_search_new_php['dir_ro'];
if (!is_readable($dir_path)) $warnings .= $lang_search_new_php['dir_cant_read'];
if ($warnings) $warnings = ' <b>' . $warnings . '<b>';
echo <<<EOT
<tr>
<td class="tableb">
$ident<img src="images/folder.gif" alt="" /> <a href= "$PHP_SELF?startdir=$start_target">$file</a>$warnings
</td>
</tr>
EOT;
display_dir_tree($folder . $file . '/', $ident . ' ');
}
}
This preserves the original logic of the existing code (I didn't want to tinker with that) but does so by having it run against an alphabetically sorted array. No doubt this could be streamlined - so that checks are done within the reading of the array itself rather than just having it capture everything - but for now I was just concerned with the simplest fix.
With this in place, all of your "Select Directory" listings (from "Batch add files") will be in alphabetical order.
I didn't bother doing anything to sort the dropdown Folders list, since I realised that I've been creating them in alphabetical order anyway.