- <?php
- /**
- * <b>Worship Music</b><br />
- * The worship music section shows all of the information and downloading of worship music.<br />
- * Views available are:
- * - Album Listing
- * - Non-Album Listing (all songs not on a specific CD)
- * - All Songs
- * Every song has a mp3, m3u, lyric, and chord (all but mp3 are optional).<br />
- * This section is searchable.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_business_logic
- * @since Build 0.1
- * @version Build 0.7
- * @filesource
- */
- /**
- * Include the constants file and all of the files in the include list
- */
- if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
- if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
- else { require_once("../constants.php"); }
- }
- else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
- foreach($INCLUDE_LIST as $includefile) { require_once $includefile; }
-
- $db = new Database();
- $db_music = $db->GetClass('music');
- $data =& $db_music->GetAllAlbums();
- $smarty = UtilSmarty::createSmarty();
-
- $id="";$all="";$search="";$searchflg=false;$lyric_search="";
- if(getenv("QUERY_STRING")) {
- if(isset($HTTP_GET_VARS['id'])) {$id = $HTTP_GET_VARS['id'];}
- if(isset($HTTP_GET_VARS['all'])) {$all = $HTTP_GET_VARS['all'];}
- if(isset($HTTP_GET_VARS['SearchTerm'])) {
- $search = $HTTP_GET_VARS['SearchTerm'];
- $searchflg = true;
- }
- }
-
- if($id != "") {
- $value =& $db_music->GetAlbumSongs($id);
- $pagesubtitle = $value[0]->ATitle;
- }
- else if($all != "") { $pagesubtitle = $S_ALL." ".$S_SONGS; }
- else if($search != "") { $pagesubtitle = $S_SEARCH." - ".ucwords(strtolower($search)); }
- else { $pagesubtitle = $S_MAIN; }
-
- require_once $HTTP_DOCUMENT_ROOT.$INCLUDE_PATH.$HEADER.
- "?pagetitle=".str_replace(" ","%20",htmlentities($S_WORSHIP_MUSIC)).
- "&pagesubtitle=".str_replace(" ","%20",htmlentities(stripslashes($pagesubtitle))).
- "&pagedesc=".str_replace(" ","%20",htmlentities($CHURCH_NAME." ".$S_DESC_MUSIC));
-
- $sidesection = array();
- $sidesection['Title'] = $S_WORSHIP_MUSIC;
- $sidesection['Links'] = array();
- foreach ($data as $value) {
- if($value->Title != $S_OTHERS) {
- $sidesection['Links'][] = array('LinkPath'=>$MUSIC_FILE."?id=".$value->ID,'LinkText'=>$value->Title);
- }
- else {
- $other = $value;
- }
- }
- $sidesection['Links'][] = array('LinkPath'=>"",'LinkText'=>"break");
- $sidesection['Links'][] = array('LinkPath'=>$MUSIC_FILE."?id=".$other->ID,'LinkText'=>$other->Title);
- $sidesection['Links'][] = array('LinkPath'=>$MUSIC_FILE."?all=yes",'LinkText'=>$S_ALL." ".$S_SONGS);
- $smarty->assign('sidesections',array($sidesection));
-
- $smarty->assign('searchformname','lyricsearch');
- $smarty->assign('searchformfile',$MUSIC_FILE);
- $smarty->assign('searchsubmittitle',$S_LYRICS." ".$S_SEARCH);
-
- $icondescriptions = array();
- $icondescriptions[] = array('src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$MP3_IMG,
- 'alt'=>"MP3 ".$S_DOWNLOAD,'desc'=>"MP3 (".$S_DOWNLOAD.")");
- $icondescriptions[] = array('src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$MP3_IMG_STREAM,
- 'alt'=>"MP3 ".$S_STREAMING,'desc'=>"MP3 (".$S_STREAMING.")");
- $icondescriptions[] = array('src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$LYRICS_IMG,
- 'alt'=>$S_LYRICS,'desc'=>$S_LYRICS);
- $icondescriptions[] = array('src'=>$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$CHORDS_IMG,
- 'alt'=>$S_CHORDS,'desc'=>$S_CHORDS);
- $smarty->assign('icondescriptions',$icondescriptions);
-
- if(getenv("QUERY_STRING")) {
- $tblarr = array();
- $tblclass = "tbl-listing";
- $tbltdclass = array("tbl-listing-track-number","tbl-listing-track-name",
- "tbl-listing-track-dl","tbl-listing-track-stream",
- "tbl-listing-track-lyric","tbl-listing-track-chord");
- $tblheader = "";
-
- if($searchflg) {
- if($search == "") { $lyric_search =& $db_music->GetAllSongs(); }
- else {
- $data =& $db_music->GetAllAlbums();
- foreach ($data as $value) {
- $data2 =& $db_music->GetAlbumSongs($value->ID);
- foreach ($data2 as $value2) {
- $file_name = $HTTP_DOCUMENT_ROOT.$MUSIC_PATH.$LYRICS_DIR.$value2->Lyrics;
- $file_content = trim(implode('',file($file_name,"r")));
- if(stristr($file_content,$search)) { $lyric_search[] = $value2; }
- else if(strcasecmp($value2->Title,$search)==0) { $lyric_search[] = $value2; }
- }
- }
- }
- if($lyric_search != null) {
- $tblheader = "<h2>".$S_SEARCH." ".$S_RESULTS." (".sizeof($lyric_search)." ".$S_TOTAL.")</h2>";
- $data = $lyric_search;
- }
- else {
- $tblheader = "<h2>".$N_SEARCH_NONE."</h2>";
- $data = null;
- }
- }
-
- else if($all == "yes") {
- $data =& $db_music->GetAllSongs();
- $tblheader = "<h2>".$S_ALL." ".$S_SONGS." (".sizeof($data)." ".$S_TOTAL.")</h2>";
- }
-
- else if($id != null && $all != "yes") {
- $data =& $db_music->GetAlbumSongs($id);
- $tblheader = "<h2>".$data[0]->ATitle."</h2>";
- }
-
- if($data != null) {
- foreach ($data as $value) {
- if($value->TNumber != 0 && $value->TNumber != "" && $lyric_search == null) {
- $tnumber = $value->TNumber;
- }
- else { $tnumber = " "; }
- $ttitle = $value->Title;
- if ($value->AULinkDownload && $value->AULinkDownload != "No Link") {
- $tdl = "<a href=\"".$value->AULinkDownload."\">".
- "<img src=\"".$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$MP3_IMG."\" ".
- "border=\"0\" alt=\"mp3\" id=\"mp3\" name=\"mp3\" align=\"middle\" /></a>".
- "<br /><span class=\"filesize\">".
- "(".UtilFiles::GetFilesize($value->AULinkDownload).")</span>";
- }
- else { $tdl = " "; }
- if ($value->AULinkStream) {
- $tstream = "<a href=\"".$value->AULinkStream."\">".
- "<img src=\"".$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$MP3_IMG_STREAM."\" ".
- "border=\"0\" alt=\"mp3 ".$S_STREAMING."\" id=\"mp3 Stream\" name=\"mp3 Stream\" align=\"middle\" /></a>";
- }
- else { $tstream = " "; }
- if ($value->Lyrics != null) {
- $tlyric = "<a href=\"".$HTTP_DOCUMENT_ROOT.$MUSIC_PATH.$LYRICS_DIR.$value->Lyrics."\">".
- "<img src=\"".$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$LYRICS_IMG."\" ".
- "border=\"0\" alt=\"".$S_LYRICS."\" id=\"lyrics\" name=\"lyrics\" align=\"middle\" /></a>";
- }
- else { $tlyric = " "; }
- if ($value->Chords != null) {
- $tchord = "<a href=\"".$HTTP_DOCUMENT_ROOT.$MUSIC_PATH.$CHORDS_DIR.$value->Chords."\">".
- "<img src=\"".$HTTP_DOCUMENT_ROOT.$IMAGE_PATH.$CHORDS_IMG."\" ".
- "border=\"0\" alt=\"".$S_CHORDS."\" id=\"chords\" name=\"chords\" align=\"middle\" /></a>";
- }
- else { $tchord = " "; }
- array_push($tblarr,array($tnumber,$ttitle,$tdl,$tstream,$tlyric,$tchord));
- }
- }
- $tblfooter = "";
- if($id != null) {
- if($data[0]->ADescription != null) {
- $tblfooter = $data[0]->ADescription;
- } }
- $smarty->assign('printtable',UtilHtml::createTable($tblarr,$tblheader,$tblclass,$tblfooter,"",$tbltdclass));
- }
- else {
- $smarty->assign('introstatements',array(array('Title'=>$S_WORSHIP_MUSIC,'Text'=>$MUSIC_INTRO)));
- }
- $smarty->assign('bottomnote',$S_NOTE_MUSIC);
- UtilSmarty::displaySectionPage($smarty);
- ?>
- <?php require_once $SERVER_DIRECTORY.$INCLUDE_PATH.$FOOTER; ?>