setHymnal($file); } /* * Loads a hymnal */ function setHymnal($file) { $this->file = $file; if ( is_file(constant("RELPATH").'include/hymnals/'.$this->file.'.xml') ) { $this->hymnal = @simplexml_load_file(constant("RELPATH").'include/hymnals/'.$this->file.'.xml'); return(true); } else { $this->hymnal = false; return(false); } } function getHymnal() { return($this->file); } /* * Prints the hymns in the hymnal */ function print_hymnal() { require_once('Table.class'); $t = new Table(); $t->add_headers(array('#', 'Title', 'Scripture')); foreach ( $this->hymnal->xpath('//hymns/hymn') as $hymn) { $t->add_cell( $hymn->number ); $title_string = ''.$hymn->title.''; $t->add_cell( $title_string ); $scripture = ''; foreach ( explode('; ',$hymn->scripture) as $s ) { $scripture .= ''.$s.'
'; } $t->add_cell( $scripture ); $t->add_row(); } return( $t->render() ); } /* * Prints a hymn from the hymnal */ function print_hymn( $number ) { $hymn = $this->hymnal->xpath('//hymn[number='.$number.']'); $hymn = $hymn[0]; $result = "

\n"; if ( $hymn->number != '' ) { $result .= "Number: ". $hymn->number ."
\n"; } if ( $hymn->title != '' ) { $result .= "Title: ". $hymn->title ."
\n"; } if ( $hymn->tune != '' ) { $result .= "Tune: ". $hymn->tune ."
\n"; } if ( $hymn->composer != '' ) { $result .= "Composer: ". $hymn->composer ."
\n"; } if ( $hymn->author != '' ) { $result .= "Author: ". $hymn->author ."
\n"; } if ( $hymn->scripture != '' ) { $result .= "Scripture: "; foreach ( explode('; ',$hymn->scripture) as $s ) { $result .= ''.$s.' '; } $result .= "
"; } if ( $hymn->topic != '' ) { $result .= "Topic: ". $hymn->topic ."
\n"; } if ( $hymn->tags != '' ) { $result .= "Tags: ". $hymn->tags ."
\n"; } if ( $hymn->theme != '' ) { $result .= "Theme: ". $hymn->theme ."
\n"; } $result .= "

\n"; if ( $hymn->lyrics != '' ) { $result .= "Lyrics:
\n
". $hymn->lyrics ."
\n"; } return($result); } } ?>