- Add tracklist support,

- Add tracklist page (unused),
- Add tracklist tab in discography page.
This commit is contained in:
agibert 2013-12-30 16:47:19 +00:00
parent e883a64bd7
commit 15da8b45a3

View File

@ -1,8 +1,8 @@
<? <?
// $RCSfile: lmbrowse.php,v $ // $RCSfile: lmbrowse.php,v $
// $Revision: 1.8 $ // $Revision: 1.9 $
// $Name: $ // $Name: $
// $Date: 2013/08/27 16:36:46 $ // $Date: 2013/12/30 16:47:19 $
// $Author: agibert $ // $Author: agibert $
/* /*
@ -49,6 +49,77 @@ $lmb_myver=strtr( "$lmb_tag_tab[1]-$lmb_tag_tab[2]", "_", ".");
/*--------------------------------------------------------------------------------------------------------------------*/
/* Sort Multy Array */
/*--------------------------------------------------------------------------------------------------------------------*/
/* Thanks http://stackoverflow.com/users/50079/jon ! */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_make_comparer() {
// Normalize criteria up front so that the comparer finds everything tidy
$criteria = func_get_args();
foreach ($criteria as $index => $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<func_num_args();$i++) {
$keys[$i-1] = func_get_arg($i);
}
// create a custom search function to pass to usort
$func = function ($a, $b) use ($keys) {
for ($i=0;$i<count($keys);$i++) {
if ($a[$keys[$i]] != $b[$keys[$i]]) {
return ($a[$keys[$i]] < $b[$keys[$i]]) ? -1 : 1;
}
}
return 0;
};
usort($array, $func);
return $array;
}
/*--------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------------*/
/* Cookies Set */ /* Cookies Set */
/*--------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------------*/
@ -1166,7 +1237,7 @@ function lmb_sitemap_play( $play_type, $play_id, $play_priority)
$nb = $cover_info_tab[1]; $nb = $cover_info_tab[1];
$size = str_replace( ".png", "", $cover_info_tab[2]); $size = str_replace( ".png", "", $cover_info_tab[2]);
$img_tab[$img_idx ]["url"] = "{$cover_path}/{$play_id}-cover-{$cover_tab[$i]}"; $img_tab[$img_idx ]["url"] = "{$cover_path}/{$play_id}-{$cover_tab[$i]}";
$img_tab[$img_idx++]["title"] = "Langueur Monotone - {$play_title} - Cover {$nb} ({$size})"; $img_tab[$img_idx++]["title"] = "Langueur Monotone - {$play_title} - Cover {$nb} ({$size})";
} }
@ -1536,6 +1607,10 @@ function lmb_playlist_cur( $play_type, $path, $row)
echo " <tr class=\"play{$css_row}\"><td class=\"play1\"><a href=\"{$url}\"><img src=\"/{$path}/{$play_tab[0]}-{$play_tab[1]}/covers/{$play_tab[1]}-cover-1-icon.png\" alt=\"\"/></a></td><td class=\"play2\"><a href=\"{$url}\">{$play_info["name"]}</a></td><td class=\"play3\">&nbsp;{$play_info["month"]}</td><td class=\"play3\">&nbsp;{$play_info["year"]}&nbsp;</td><td class=\"play4\">{$play_info["comment"]}</td><td>&nbsp;</td></tr> echo " <tr class=\"play{$css_row}\"><td class=\"play1\"><a href=\"{$url}\"><img src=\"/{$path}/{$play_tab[0]}-{$play_tab[1]}/covers/{$play_tab[1]}-cover-1-icon.png\" alt=\"\"/></a></td><td class=\"play2\"><a href=\"{$url}\">{$play_info["name"]}</a></td><td class=\"play3\">&nbsp;{$play_info["month"]}</td><td class=\"play3\">&nbsp;{$play_info["year"]}&nbsp;</td><td class=\"play4\">{$play_info["comment"]}</td><td>&nbsp;</td></tr>
"; ";
} }
else
{
$row--;
}
} }
return( $row); return( $row);
@ -1625,6 +1700,11 @@ function lmb_discography_body()
/* --- Oldies --- */ /* --- Oldies --- */
lmb_playlist( "oldies", "l"); 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(); $line = array();
$track_info = 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) if( count($track_array) == 0)
{ {
$track_info["status"] = 0; $track_info["status"] = 0;
} }
else 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/$/\"/') $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 */ /* 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++) for( $i = 0; $i < count($track_list); $i++)
{ {
$track_id = preg_replace( "/-.*/", "", basename( "{$track_list[$i]}", ".flac")); $track_loc = lmb_track_loc_get( "{$track_list[$i]}");
$track_list_info[$i] = lmb_track_info_get( $play_type, $play_id, $play_priority, $track_id); $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&amp;type={$play_type}&amp;id={$play_id}&amp;priority={$play_priority}";
$track_url = "{$lmb_url}?page=track&amp;type={$play_type}&amp;id={$play_id}&amp;priority={$play_priority}&amp;tid={$track_id}";
echo " <tr class=\"tracks{$css_row}\" style=\"height: {$height}px;\">";
echo "<td class=\"tracks1\">&nbsp;{$row}&nbsp;</td><td class=\"tracks2\">&nbsp;<a href=\"{$track_url}\">{$track_title}</a>&nbsp;</td><td class=\"tracks3\">&nbsp;<a href=\"{$track_url}\">{$track_mix}</a>&nbsp;</td><td class=\"tracks3\">&nbsp;{$track_length}&nbsp;</td><td class=\"tracks3\">&nbsp;{$play_type_name}&nbsp;</td><td class=\"tracks3\">&nbsp;<a href=\"{$play_url}\">{$track_album}</a>&nbsp;</td></tr>
";
}
$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 */ /* Track Info */
/*--------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------------*/
@ -3720,6 +3901,12 @@ function lmb_get_proceed( $get_array)
break; break;
} }
case "tracklist":
{
lmb_tracklist_page();
break;
}
case "track": case "track":
{ {
$play_type=$get_array["type"]; $play_type=$get_array["type"];