Here is the Hymnal class. It may run out to the right a bit.
<?
/*
##################################################
#
# Filename..........: $RCSfile: Hymnal.class,v $
# Original Author...: Anthony L. Awtrey
# Version...........: $Revision: 0.1 $
# Last Modified By..: $Author: aawtrey $
# Last Modified.....: $Date: 2006/09/21 09:34:00 $
#
# Copyright 2006 Anthony Awtrey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
*/
/*
* This class provides the methods to load and query hymnal of the
* Hymnal stored in XML.
*/
class Hymnal {
var $error;
var $file;
var $hymnal;
/*
* Class initialization
*/
function Hymnal($file='the_hymnbook-1955') {
global $_SERVER;
global $_SESSION;
global $_REQUEST;
global $_POST;
global $_GET;
return $this->setHymnal($file);
}
/*
* Loads a hymnal
*/
function setHymnal($file) {
$this->file = $file;
if ( is_file(constant("RELPATH").'include/'.$this->file.'.xml') ) {
$this->hymnal = @simplexml_load_file(constant("RELPATH").'include/'.$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() {
$result .= "<table width="100%" style="border-style:dotted; border-color:#C0C0C0; border-width:1px;">n";
$result .= " <tr bgcolor="#e0e0e0">n";
$result .= " <th>#</th>n";
$result .= " <th>Title</th>n";
$result .= " <th>Scripture</th>n";
$result .= " </tr>n";
$count = 1;
foreach ( $this->hymnal->xpath('//hymns/hymn') as $hymn) {
if ( ($count) % 2 == 0 ) {
$result .= " <tr bgcolor="#f0f0f0">n";
} else {
$result .= " <tr>n";
}
$result .= ' <td>' . $hymn->number . "</td>n";
$result .= ' <td>' . $hymn->title . "</td>n";
$result .= ' <td>';
foreach ( explode(', ',$hymn->scripture) as $s ) {
$result .= '<a href="../bible/?verse='.urlencode($s).'">'.$s.'</a><br />';
}
$result .= "</td>n";
$result .= " </tr>n";
$count++;
}
$result .= "</table>n";
return($result);
}
}
?>