From 15da8b45a3f1b31dc793f12d8812f1e6e2ed17bb Mon Sep 17 00:00:00 2001 From: agibert Date: Mon, 30 Dec 2013 16:47:19 +0000 Subject: [PATCH] - Add tracklist support, - Add tracklist page (unused), - Add tracklist tab in discography page. --- html/lmbrowse.php | 203 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 195 insertions(+), 8 deletions(-) diff --git a/html/lmbrowse.php b/html/lmbrowse.php index 43303ef..12d0973 100644 --- a/html/lmbrowse.php +++ b/html/lmbrowse.php @@ -1,8 +1,8 @@ $criterion) { + $criteria[$index] = is_array($criterion) + ? array_pad($criterion, 3, null) + : array($criterion, SORT_ASC, null); + } + + return function($first, $second) use (&$criteria) { + foreach ($criteria as $criterion) { + // How will we compare this round? + list($column, $sortOrder, $projection) = $criterion; + $sortOrder = $sortOrder === SORT_DESC ? -1 : 1; + + // If a projection was defined project the values now + if ($projection) { + $lhs = call_user_func($projection, $first[$column]); + $rhs = call_user_func($projection, $second[$column]); + } + else { + $lhs = $first[$column]; + $rhs = $second[$column]; + } + + // Do the actual comparison; do not return if equal + if ($lhs < $rhs) { + return -1 * $sortOrder; + } + else if ($lhs > $rhs) { + return 1 * $sortOrder; + } + } + + return 0; // tiebreakers exhausted, so $first == $second + }; +} + + + +function lmb_sort_multi_array( $array, $key) +{ + $keys = array(); + + for ($i=1;$i\"\"/{$play_info["name"]} {$play_info["month"]} {$play_info["year"]} {$play_info["comment"]}  "; } + else + { + $row--; + } } return( $row); @@ -1625,6 +1700,11 @@ function lmb_discography_body() /* --- Oldies --- */ lmb_playlist( "oldies", "l"); + + lmb_spacer( 5); + + /* --- TrackList --- */ + lmb_tracklist_body(); } @@ -1762,13 +1842,17 @@ function lmb_track_info_get( $play_type, $play_id, $play_priority, $track_id) $line = array(); $track_info = array(); + $track_info["play_type"] = $play_type; + $track_info["play_priority"] = $play_priority; + $track_info["play_id"] = $play_id; + if( count($track_array) == 0) { - $track_info["status"] = 0; + $track_info["status"] = 0; } else { - $track_info["status"] = 1; + $track_info["status"] = 1; $cmd="eval \$( metaflac --export-tags-to=- \"${track_file}\" | grep -v -e \".* .*=\" -e \".*-.*=\" | sed -e 's/=/=\\\"/' -e 's/$/\"/') @@ -1894,6 +1978,29 @@ function lmb_track_file_tag_get( $play_type, $play_id, $play_priority, $track_id +/*--------------------------------------------------------------------------------------------------------------------*/ +/* Track Loc Get */ +/*--------------------------------------------------------------------------------------------------------------------*/ + +function lmb_track_loc_get( $track_url) +{ + + $path_tab = explode( "/", $track_url); + $play_tab = explode( "-", $path_tab[2]); + $track_tab = explode( "-", basename( "{$path_tab[5]}", ".flac")); + + $track_loc["play_type"] = $path_tab[1]; + $track_loc["play_priority"] = $play_tab[0]; + $track_loc["play_id"] = $play_tab[1]; + $track_loc["track_id"] = $track_tab[0]; + $track_loc["track_title"] = $track_tab[1]; + $track_loc["track_mix"] = $track_tab[2]; + + return( $track_loc); +} + + + /*--------------------------------------------------------------------------------------------------------------------*/ /* Track List Info Get */ /*--------------------------------------------------------------------------------------------------------------------*/ @@ -1910,11 +2017,11 @@ function lmb_tracklist_info_get( $play_type, $play_id, $play_priority) for( $i = 0; $i < count($track_list); $i++) { - $track_id = preg_replace( "/-.*/", "", basename( "{$track_list[$i]}", ".flac")); - $track_list_info[$i] = lmb_track_info_get( $play_type, $play_id, $play_priority, $track_id); + $track_loc = lmb_track_loc_get( "{$track_list[$i]}"); + $track_info_list[$i] = lmb_track_info_get( "{$track_loc["play_type"]}", $track_loc["play_id"], $track_loc["play_priority"], $track_loc["track_id"]); } - return( $track_list_info); + return( $track_info_list); } @@ -2701,6 +2808,80 @@ function lmb_play_page( $play_type, $play_id, $play_priority) +/*--------------------------------------------------------------------------------------------------------------------*/ +/* Track List Page */ +/*--------------------------------------------------------------------------------------------------------------------*/ + +function lmb_tracklist_body() +{ + global $lmb_url; + + $play_path = "discography/{$play_type}/{$play_priority}-{$play_id}"; + $cover_path = "{$play_path}/covers/{$play_id}-cover"; + $logo_path = "{$play_path}/logos/{$play_id}-logo"; + $track_path = "{$play_path}/tracks"; + + $play_type = "*"; + $play_id = "*"; + $play_priority = "*"; + + + $track_info_list = lmb_tracklist_info_get( $play_type, $play_id, $play_priority); + + usort( $track_info_list, lmb_make_comparer( 'title', 'mix')); + + $track_nb = count($track_info_list); + + ob_start(); + + $size = $track_nb + 1; + $height = 220/$size; + + for( $i = 0, $row = 1; $i < $track_nb; $i++, $row++) + { + $css_row = ($row+1)%2+1; + + $play_type = "{$track_info_list[$i]["play_type"]}"; + $play_type_name = lmb_play_type_name_get( $play_type); + $play_id = "{$track_info_list[$i]["play_id"]}"; + $play_priority = "{$track_info_list[$i]["play_priority"]}"; + $track_id = str_pad( "{$track_info_list[$i]["id"]}", 2, '0', STR_PAD_LEFT); + $track_title = "{$track_info_list[$i]["title"]}"; + $track_mix = "{$track_info_list[$i]["mix"]}"; + $track_length = "{$track_info_list[$i]["length"]}"; + $track_album = "{$track_info_list[$i]["album"]}"; + + $play_url = "{$lmb_url}?page=play&type={$play_type}&id={$play_id}&priority={$play_priority}"; + $track_url = "{$lmb_url}?page=track&type={$play_type}&id={$play_id}&priority={$play_priority}&tid={$track_id}"; + + + echo " "; + + echo " {$row}  {$track_title}  {$track_mix}  {$track_length}  {$play_type_name}  {$track_album}  +"; + } + + $data = ob_get_contents(); + ob_end_clean(); + + lmb_make_tab( "tracks", "tracks", "r", "/images/lm-logo4-n-96.png", $data); +} + + + +/*--------------------------------------------------------------------------------------------------------------------*/ +/* Track List Page */ +/*--------------------------------------------------------------------------------------------------------------------*/ + +function lmb_tracklist_page() +{ + lmb_header( 3, "Langueur Monotone - Track List Page", "", "Track List", "Langueur Monotone track list page, listing all the released tracks", "track list", 0); + lmb_tracklist_body(); + lmb_footer(); +} + + + /*--------------------------------------------------------------------------------------------------------------------*/ /* Track Info */ /*--------------------------------------------------------------------------------------------------------------------*/ @@ -3720,6 +3901,12 @@ function lmb_get_proceed( $get_array) break; } + case "tracklist": + { + lmb_tracklist_page(); + break; + } + case "track": { $play_type=$get_array["type"];