/* ################################################## # # Filename..........: $RCSfile: Anthem.class,v $ # Original Author...: Anthony L. Awtrey # Version...........: $Revision: 0.1 $ # Last Modified By..: $Author: aawtrey $ # Last Modified.....: $Date: 2006/09/21 18:15:56 $ # # 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 mechanisms to manage the data in the account * database. */ class Anthem { var $page; var $data; var $error_string; /* * Class initialization */ function Anthem() { global $_SERVER; global $_SESSION; global $_REQUEST; global $_POST; global $_GET; $this->page = new Page(); $this->page->title = "Anthem Library"; $this->page->description = "This is the anthem library."; $this->data = new Data("anthem"); } function generate_alpha_links($current_link) { $alpha = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); $result = '
['."\n"; foreach ( $alpha as $letter ) { if ( $letter == $current_link ) { $result .= strtoupper($letter)." \n"; } else { $result .= ''.strtoupper($letter)." \n"; } } $result .= ']
'."\n"; return($result); } function generate_anthem_table($anthems) { $result = "| Title | \n"; $result .= "Composer | \n"; $result .= "Author | \n"; $result .= "
|---|---|---|
| ' . $val['title'] . " | \n"; $result .= '' . $val['composer'] . " | \n"; $result .= '' . $val['author'] . " | \n"; $result .= "
\n"; $this->page->content .= '
\n"; $this->page->content .= "Add an anthem\n"; $this->page->content .= "
\n"; } $this->page->content .= $this->generate_alpha_links($alpha); $this->page->content .= $this->generate_anthem_table($anthems); $this->page->content .= $this->generate_alpha_links($alpha); $this->page->display(); } function print_anthem() { $anthem = $this->data->get_record_by_id($_GET['id']); $this->page->title = $anthem['title']; $this->page->description = $anthem['title']; $this->page->content .= "\n";
if ( !empty($anthem['composer']) ) { $this->page->content .= 'Composer: ' . $anthem['composer'] . "
\n"; }
if ( !empty($anthem['author']) ) { $this->page->content .= 'Author: ' . $anthem['author'] . "
\n"; }
if ( !empty($anthem['arranger']) ) { $this->page->content .= 'Arranger: ' . $anthem['arranger'] . "
\n"; }
if ( !empty($anthem['publisher']) ) { $this->page->content .= 'Publisher: ' . $anthem['publisher'] . "
\n"; }
if ( !empty($anthem['scripture']) ) { $this->page->content .= 'Scripture Allusion: ' . $anthem['scripture'] . "
\n"; }
if ( !empty($anthem['voicing']) ) { $this->page->content .= 'Voicing: ' . $anthem['voicing'] . "
\n"; }
if ( !empty($anthem['pages']) ) { $this->page->content .= 'Pages: ' . $anthem['pages'] . "
\n"; }
if ( !empty($anthem['length']) ) { $this->page->content .= 'Length: ' . $anthem['length'] . "
\n"; }
if ( !empty($anthem['copies']) ) { $this->page->content .= 'Copies: ' . $anthem['copies'] . "
\n"; }
if ( !empty($anthem['publish_date']) ) { $this->page->content .= 'Publish Date: ' . $anthem['publish_date'] . "
\n"; }
if ( !empty($anthem['purchase_date']) ) { $this->page->content .= 'Purchase Date: ' . $anthem['purchase_date'] . "
\n"; }
if ( !empty($anthem['lyrics']) ) {
$this->page->content .= "
\n";
$this->page->content .= nl2br($anthem['lyrics']) . "
\n";
$this->page->content .= "
\n";
$this->page->content .= nl2br($anthem['notes']) . "
\n";
$this->page->content .= "
\n"; $this->page->content .= "[Edit this anthem]\n"; $this->page->content .= "[Delete this anthem]\n"; $this->page->content .= "
\n"; } $this->page->display(); } /* * This method prints the add/edit confirmation form */ function print_anthem_form() { if ( $anthem['action'] == 'add' || $_GET['action'] == 'add' ) { $action = 'add'; } elseif ( $anthem['action'] == 'edit' || $_GET['action'] == 'edit' ) { list( $anthem['inId'], $anthem['inAccount'], $anthem['inTitle'], $anthem['inComposer'], $anthem['inAuthor'], $anthem['inArranger'], $anthem['inPublisher'], $anthem['inScripture'], $anthem['inVoicing'], $anthem['inPages'], $anthem['inLength'], $anthem['inCopies'], $anthem['inPublish_date'], $anthem['inPurchase_date'], $anthem['inLyrics'], $anthem['inNotes'] ) = array_values($this->data->get_record_by_id($_GET['id'])); $action = 'edit'; } else { redirect('./'.$_POST['backto']); } $this->page->title = ucwords($action) . " Anthem"; $this->page->description = ucwords($action) . "ing Anthem."; if (!$_SESSION['login'] ) { redirect($anthem['inId']); } if (!$anthem['inAccount']) { $anthem['inAccount'] = $_SESSION['login']; } if ($this->error_string) { $this->page->content .= "" . $this->error_string . "
\n"; } require_once('Form.class'); $form = new Form('index.php','post'); $form->hidden('action',$action); $form->hidden('inId',$anthem['inId']); $form->hidden('inAccount',$anthem['inAccount']); $form->text('Title','inTitle',$anthem['inTitle'],60,200); $form->text('Composer','inComposer',$anthem['inComposer'],60,200); $form->text('Author','inAuthor',$anthem['inAuthor'],60,200); $form->text('Arranger','inArranger',$anthem['inArranger'],60,200); $form->text('Publisher','inPublisher',$anthem['inPublisher'],60,200); $form->text('Scripture','inScripture',$anthem['inScripture'],60,200); $form->text('Voicing','inVoicing',$anthem['inVoicing'],60,200); $form->text('Length in Pages','inPages',$anthem['inPages'],60,6); $form->text('Length in Seconds','inLength',$anthem['inLength'],60,6); $form->text('Copies','inCopies',$anthem['inCopies'],60,6); $form->text('Published Date','inPublish_date',$anthem['inPublish_date'],60,32); $form->text('Purchase Date','inPurchase_date',$anthem['inPurchase_date'],60,32); $form->textarea('Lyrics','inLyrics',$anthem['inLyrics'],10,80); $form->textarea('Notes','inNotes',$anthem['inNotes'],10,80); $form->submit('submit',ucwords($action)); $form->submit('submit','Cancel'); $this->page->content .= $form->render(); $this->page->display(); } /* * This method prints a delete confirmation form */ function print_anthem_delete_confirmation($id) { $anthem = $this->data->get_record_by_id($id); $this->page->title = "Delete Anthem"; $this->page->description = "Anthem deletion confirmation"; $this->page->content .= "\n";
$this->page->content .= "Warning! You are about to delete the anthem entitled:
\n";
$this->page->content .= "\"" . $anthem['title'] . "\"
\n";
$this->page->content .= "Click 'Delete' again if you are sure.\n";
$this->page->content .= "