From: Harvie Date: Sat, 10 Jul 2010 06:18:47 +0000 (+0200) Subject: Support for sorting directories X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;ds=sidebyside;h=aa3a0f3272105445bd4f6de949c0ccf70a16fad3;p=mirrors%2FJukeBox.git Support for sorting directories --- diff --git a/index.php b/index.php index 9d2a21d..91b2afb 100755 --- a/index.php +++ b/index.php @@ -204,6 +204,17 @@ function render_file_line($dir, $item, $dir_url, $index, $filesize, $parent = fa echo(' '.unxss(str_replace('_', ' ', $item)).''.$filesize." MiB \n"); } +function render_dir_line($item, $i) { + $parclass=($i%2?'even':'odd'); $parcolor=($index%2?'lightblue':'white'); + $temp=str_replace('%2F', '/', rawurlencode($current_dir)).rawurlencode($item); + echo("". + ''.$i.'P/'. + 'R'); + if($GLOBALS['useflash']) echo('/F'); + echo('[DIR] '.unxss(str_replace('_', ' ', $item)). + "\n"); +} + function render_tr_playframe_show() { if($GLOBALS['flash_player_frame'] == 'playframe-show' && $GLOBALS['useflash']) { ?> @@ -450,28 +461,34 @@ for($s=2;$s;$s--) { while(($item = readdir($dd)) != false) { if($item == '.' || $item == '..') continue; if(($s==2 && is_file($dir.$item)) || ($s!=2 && is_dir($dir.$item))) continue; $i++; - $parclass=($i%2?'even':'odd'); $parcolor=($i%2?'lightblue':'white'); + //$parclass=($i%2?'even':'odd'); $parcolor=($i%2?'lightblue':'white'); + if($sort > 1) { if(is_file($dir.$item)) { - if($sort > 1) { - $i--; - $items[] = $item; - } else { - render_file_line($dir, $item, $music_dir_url, $i, filesize($dir.$item)); - } + $i--; + $itemsf[] = $item; } if(is_dir($dir.$item)) { - $temp=str_replace('%2F', '/', rawurlencode($current_dir)).rawurlencode($item); - echo("". - ''.$i.'P/'. - 'R'); - if($GLOBALS['useflash']) echo('/F'); - echo('[DIR] '.unxss(str_replace('_', ' ', -$item))."\n"); + $i--; + $itemsd[] = $item; + } + } else { + if(is_file($dir.$item)) { + render_file_line($dir, $item, $music_dir_url, $i, filesize($dir.$item)); } + if(is_dir($dir.$item)) { + render_dir_line($item, $i); + } + } } rewinddir($dd); } + if($sort > 1) { - @sort($items); - foreach($items as $item) { + @sort($itemsf); + @sort($itemsd); + foreach($itemsd as $item) { + $i++; + render_dir_line($item, $i); + } + foreach($itemsf as $item) { $i++; render_file_line($dir, $item, $music_dir_url, $i, filesize($dir.$item)); }