X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=web%2Fsongbook.php;h=113af43141efebd04ec4933a45d2db762178d18d;hb=674da66f3a92ece352779909a33494d30cf9c869;hp=cbfe933cab1f50b0056912ed457cebe4b5c7e78e;hpb=9ff77867804f8c00a2f83dec3442493a1a427006;p=songbook.git diff --git a/web/songbook.php b/web/songbook.php index cbfe933..113af43 100644 --- a/web/songbook.php +++ b/web/songbook.php @@ -3,6 +3,11 @@ $baseDir = getcwd(); $songDir = "/opt/songbook/Songs"; $debug = $_REQUEST["debug"]; +// Initialize music objects +$songs = getSongs($songDir); +$sets = getSets($songDir); +$artists = getArtists($songs); + function debug ($msg) { global $debug; @@ -11,20 +16,16 @@ function debug ($msg) { } // if } // debug -function getSongs () { - global $songDir; - +function getSongs ($songDir) { return glob("$songDir/*.pro"); } // getSongs -function getSets () { - global $songDir; - +function getSets ($songDir) { return glob("$songDir/*.lst"); } // getSets function songsDropdown () { - $songs = getSongs(); + global $songs; print "
"; print "Songs:  "; @@ -48,8 +49,7 @@ function songsDropdown () { } // songsDropdown function artistsDropdown () { - $songs = getSongs(); - $artists = getArtists ($songs); + global $artists; print ""; print "Artists:  "; @@ -66,7 +66,7 @@ function artistsDropdown () { } // artistsDropdown function setsDropdown () { - $sets = getSets(); + global $sets; print ""; print "Sets:     "; @@ -96,8 +96,6 @@ function getArtist ($song) { } // getArtist function getArtists ($songs) { - $artists = array(); - foreach ($songs as $song) { $artist = getArtist ($song); @@ -109,20 +107,3 @@ function getArtists ($songs) { return array_keys ($artists); } // getArtists -function formatTable ($songs) { - echo "
    "; - - foreach ($songs as $song) { - $artist = getArtist ($song); - - $title = basename ($song, ".pro"); - - echo "
  1. $title"; - - if ($artist != "") { - echo " ($artist)"; - } // if - } // foreach - - echo "
"; -} // formatTable