Where To Look When You |
||
Need ForgivenessNeed Assurance of SalvationFeel Abandoned By GodNeed HealingNeed Guidance |
Wrestle With Grief
Struggle With Alcoholism And Drugs
Wrestle With Temptation |
Need To RepentFeel LonelyNeed to Control Your ThoughtsNeed EncouragementFeel Anxious |
Does a single ' really botch things up? I have been told it does, but this test doesn't validate that...
I read once about Genesis 1:1 (already a link) (a reference in an ALT tag).
All this should be untouched due to preformatting: John 3:16, Mal 2.
And this is in a code block: Matthew 1:1-18, ESV
[bible]John 3:16[/bible]This is text that should be enclosed by the ESV wordpress plugin and thus not affected.
The 3 of us went downtown, and the 3 of us had a great time.
I also read about Genesis 3:13-15 (CEV)
,as well as Genesis 40:3, NET
(Gen 3:4
) also see Gen. 15:1
and 1st Tim 2
and 2 Kings 4:3, NET
. I should also investigate John 1:1 (NRSV)
.
, NOTRANS
(GNT)
'
.
.
)
<?php
/*
Plugin Name: Scripturizer
Version: 1.55
Plugin URI: http://dev.wp-plugins.org/wiki/Scripturizer
Description: Changes Bible references to hyperlinks for Wordpress 1.5 and above. If you have a higher version of Wordpress you might want to upgrade the plugin.
Author: Dean Peters, ported by Glen Davis, updates by LaurenceO.com
Author URI: http://www.healyourchurchwebsite.com/
*/
// you can pick any translation supported by the Bible Gateway, as well as the NRSV, the NET, and the ESV
// should we add Blue Letter Bible and http://www.zhubert.com/greek as original language options somehow? ....
// http://www.blueletterbible.org/cgi-bin/tools/printer-friendly.pl?book=Gen&chapter=1&version=heb
// http://www.blueletterbible.org/cgi-bin/tools/printer-friendly.pl?book=Mat&chapter=1&version=grk
// the interface on zhubert.com is weird - the NT books are numbered instead of named
// we should also take a look at the New American Bible - http://www.nccbuscc.com/nab/bible/index.htm
$scripturizer_translations=array(
'NIV'=>'New International Version',
'KJV'=>'King James Version',
'ESV'=>'English Standard Version',
'NASB'=>'New American Standard Bible',
'HCSB'=>'Holman Christian Standard Bible',
'AMP'=>'Amplified Bible',
'NLV'=>'New Life Version',
'NLT'=>'New Living Translation',
'CEV'=>'Contemporary English Version',
'NKJV'=>'New King James Version',
'KJ21'=>'21st Century King James Version',
'ASV'=>'Authorized Standard Version',
'YLT'=>"Young's Literal Translation",
'Darby'=>'Darby Translation',
'WYC'=>'Wycliffe New Testament',
'NIV-UK'=>'New International Version (British Edition)',
'MSG'=>'The Message',
'NIRV'=>"New International Readers' Version",
'NET'=>'New English Translation',
'NRSV'=>'New Revised Standard Version',
'NA26'=>'Nestle-Aland Greek Text 26th edition',
'LXX'=>'Septaugint'
);
##### ADMIN CONSOLE #
if (! function_exists('scripturizer_add_options')) {
function scripturizer_add_options() {
if (function_exists('add_options_page')) {
add_options_page('Options', 'Scripturizer', 9, basename(__FILE__), 'scripturizer_options_subpanel');
}
}
}
// Show the admin page content
function scripturizer_options_subpanel() {
global $scripturizer_translations;
// to do -- add libronix link
// see http://www.logos.com/support/lbs/weblinking
if (isset($_POST['info_update'])) {
update_option('scripturizer_default_translation', $_POST['scripturizer_default_translation']);
update_option('scripturizer_dynamic_substitution', $_POST['scripturizer_dynamic_substitution']);
update_option('scripturizer_xml_show_hide', $_POST['scripturizer_xml_show_hide']);
update_option('scripturizer_esv_key', $_POST['scripturizer_esv_key']);
update_option('scripturizer_xml_css', $_POST['scripturizer_xml_css']);
update_option('scripturizer_esv_query_options', $_POST['scripturizer_esv_query_options']);
?>
<div class="updated"><p><strong>
<?php _e('Updates saved!', 'Scripturizer');?>
</strong></p></div>
<?php
} ?>
<div class="wrap">
<h2><?php _e('Scripturizer 1.55', 'Scripturizer'); ?></h2>
<form method="post">
<fieldset class="options">
<legend><b><?php _e('General Options', 'Scripturizer'); ?></b></legend>
<p><b><?php _e('IMPORTANT NOTES', 'Scripturizer'); ?></b></p>
<ol>
<li><?php _e('You must press the UPDATE OPTIONS button at least once to install the default settings.', 'Scripturizer'); ?></li>
<li><?php _e('If you mess up one of the following inputs, then clear the field (make it blank), hit "update options," and then the default values will reappear. Then, you <b>must hit "update options" again</b> in order to save the new value.', 'Scripturizer'); ?></li>
</ol>
<p>
<label for="scripturizer_default_translation">
<b><?php _e('Default Bible Translation', 'Scripturizer'); ?></b>
<br /><?php _e('The Scripturizer supports any version from the <a href="http://www.biblegateway.com" title="Go to Bible Gateway">Bible Gateway</a> plus ESV, NET, NRSV, and LXX. However, this option must be ESV if you want to use the ESV show/hide verse text option.', 'Scripturizer'); ?>
<br /><select name="scripturizer_default_translation">
<?php
if (get_option('scripturizer_default_translation') == ''){
$scripturizer_default_translation='ESV';
}else {
$scripturizer_default_translation=get_option('scripturizer_default_translation');// this is now defunct -- mess with it
}
ksort($scripturizer_translations);
$translations=array_keys($scripturizer_translations);
foreach ($translations as $translation) {
if (strcmp($translation,$scripturizer_default_translation)) {
echo "<option value='$translation'>".$translation.' ('.$scripturizer_translations[$translation].')</option>';
} else {
echo "<option value='$translation' selected>".$translation.' ('.$scripturizer_translations[$translation].')</option>';
}
}
?>
</select>
</label>
</p>
<p>
<label for="scripturizer_dynamic_substitution">
<b><?php _e('Scripturizer Mode. Set to 1 for dynamic substitutions. Set to 0 for permament changes.', 'Scripturizer'); ?></b>
<br /><input type="text" name="scripturizer_dynamic_substitution" value="<?php
if (get_option('scripturizer_dynamic_substitution') == ''){
echo '1';
}else {
echo get_option('scripturizer_dynamic_substitution');
} ?>" size="3" />
</label>
<br /><?php _e('You can use this plugin two ways; it can either scripturize your posts every time someone views them (dynamic), or it can permanently scripturize the posts whenever you create or edit them (static). If (1) you have a medium to high traffic site and (2) you use lots of verse references in your posts, then you probably want to use static mode. Otherwise, most low traffic blog sites should be OK in dynamic mode.', 'Scripturizer'); ?>
</p>
<p>
<?php _e('Considerations for Static Mode', 'Scripturizer'); ?>
</p>
<ol>
<li><?php _e('If Bible Gateway or any of the other Bible sites change their interface, then your old posts won\'t work right even if you update this plugin (whereas if you use dynamic substitution updating the plugin fixes all old and future posts transparently). This is not a theoretical consideration--the Bible sites have changed their interfaces since this plugin was first developed and they are likely to do so again.', 'Scripturizer'); ?></li>
<li><?php _e('If you change your default Bible translation then old posts will not be updated to reflect your new preference.', 'Scripturizer'); ?></li>
<li><?php _e('Since it only changes posts when you edit them, you need to go back through all your old posts with Bible', 'Scripturizer'); ?></li>
<li><?php _e('References and edit them to cause the plugin to take effect', 'Scripturizer'); ?></li>
</ol>
</fieldset>
<p> </p>
<fieldset class="options">
<legend><b><?php _e('ESV Show/Hide Verse Text Options', 'Scripturizer'); ?></b></legend>
<p>
<label for="scripturizer_xml_show_hide">
<b><?php _e('Show/hide the text (in addition to the reference) of the ESV in your page? If yes, set to 1. If no, set to 0.', 'Scripturizer'); ?></b>
<br /><?php _e('Do not set to 1 unless you have an ESV Web Services Key.', 'Scripturizer'); ?>
<br /><input type="text" name="scripturizer_xml_show_hide" value="<?php
if (get_option('scripturizer_xml_show_hide') == ''){
echo '0';
}else {
echo get_option('scripturizer_xml_show_hide');
} ?>" size="3" />
</label>
</p>
<p>
<label for="scripturizer_esv_key">
<b><?php _e('ESV Web Service Key', 'Scripturizer'); ?></b><br />
<?php _e('The ESV Web Service now has a <a href="http://www.esv.org/blog/2005/10/web.service.keyless">keyless option</a>. Therefore, you no longer need your key to use the show/hide ESV text option. Instead, use <b><code>IP</code></b> as your key. However, if you are using shared-IP hosting (i.e. more than one site is hosted on your IP address) you will likely need your own key. To get your free key, follow the simple instructions at <a href="http://www.gnpcb.org/esv/share/services/">http://www.gnpcb.org/esv/share/services/</a>', 'Scripturizer' ); ?><br />
<input type="text" name="scripturizer_esv_key" value="<?php
if (!get_option('scripturizer_esv_key')){
echo 'IP';
}else {
echo get_option('scripturizer_esv_key');
} ?>" size="30" />
</label>
</p>
<p>
<label for="scripturizer_xml_css">
<b><?php _e('CSS for ESV inline verse display', 'Scripturizer'); ?></b><br />
<?php _e('This CSS modifies the SPAN tag in which the ESV verse text will be displayed on your page. Do not use any line breaks--that means don\'t push your ENTER key in this box--since the styles are added straight to the span tag.', 'Scripturizer'); ?>
<br />
<?php
if (get_option('scripturizer_xml_css') == ''){
$LO_esv_form_css = 'white-space: pre; display: none; padding: 10px; border: dotted blue 1px; border-left: solid blue 5px; color: black;';
} else {
$LO_esv_form_css = get_option('scripturizer_xml_css');
} ?>
<textarea name="scripturizer_xml_css" cols="50" rows="10" wrap="VIRTUAL"><?php echo $LO_esv_form_css; ?></textarea>
</label>
</p>
<p>
<label for="scripturizer_esv_query_options">
<b><?php _e('ESV Web Service <a href="http://www.gnpcb.org/esv/share/services/api/">Query Options</a>', 'Scripturizer'); ?></b><br />
<?php
if (get_option('scripturizer_esv_query_options') == ''){
$LO_esv_form_qo = 'action=doPassageQuery&include-passage-references=true&include-short-copyright=true&include-audio-link=false&output-format=plain-text&include-passage-horizontal-lines=false&include-heading-horizontal-lines=false&line-length=60&include-headings=false&include-subheadings=false&include-footnotes=false';
} else {
$LO_esv_form_qo = get_option('scripturizer_esv_query_options');
} ?>
<textarea name="scripturizer_esv_query_options" cols="50" rows="6" wrap="VIRTUAL"><?php echo $LO_esv_form_qo; ?></textarea>
</label>
</p>
</fieldset>
<p class="submit">
<input type="submit" name="info_update" value="<?php _e('Update Options', 'Scripturizer') ?>" />
</p>
</form>
<fieldset class="options">
<legend><b><?php _e('Credits: "Give honor to whom honor is due"', 'Scripturizer'); ?></b></legend>
<p><?php _e('The story is too complicated to tell here. The main props go to <a href="http://www.healyourchurchwebsite.com/">Dean Peters</a> and you can learn more at the <a href="http://dev.wp-plugins.org/wiki/Scripturizer">Scripturizer central page</a>.', 'Scripturizer'); ?></p>
</fieldset>
<fieldset class="options">
<legend><b><?php _e('Updates and Bug Tracking', 'Scripturizer'); ?></b></legend>
<p><?php _e('Report bugs, request new features, download the latest updates, and contact the authors at <a href="http://dev.wp-plugins.org/wiki/Scripturizer">the Scripturizer Page</a>.', 'Scripturizer'); ?></p>
</fieldset>
</div>
<?php
} // close scripturizer_options_subpanel()
# END ADMIN CONSOLE #####
function scripturize($text = '',$bible = NULL) {
if (!isset($bible)) {
$bible = get_option('scripturizer_default_translation');
}
// skip everything within a hyperlink, a <pre> block, a <code> block, or a tag
// we skip inside tags because something like <img src="nicodemus.jpg" alt="John 3:16"> should not be messed with
$anchor_regex = '<a\s+href.*?<\/a>';
$pre_regex = '<pre>.*<\/pre>';
$code_regex = '<code>.*<\/code>';
$other_plugin_regex= '\[bible\].*\[\/bible\]'; // for the ESV Wordpress plugin (out of courtesy)
$other_plugin_block_regex='\[bibleblock\].*\[\/bibleblock\]'; // ditto
$tag_regex = '<(?:[^<>\s]*)(?:\s[^<>]*){0,1}>'; // $tag_regex='<[^>]+>';
$split_regex = "/((?:$anchor_regex)|(?:$pre_regex)|(?:$code_regex)|(?:$other_plugin_regex)|(?:$other_plugin_block_regex)|(?:$tag_regex))/i";
// $split_regex = "/((?:$anchor_regex)|(?:$pre_regex)|(?:$code_regex)|(?:$tag_regex))/i";
$parsed_text = preg_split($split_regex,$text,-1,PREG_SPLIT_DELIM_CAPTURE);
$linked_text = '';
while (list($key,$value) = each($parsed_text)) {
if (preg_match($split_regex,$value)) {
$linked_text .= $value; // if it is an HTML element or within a link, just leave it as is
} else {
$linked_text .= scripturizeAddLinks($value,$bible); // if it's text, parse it for Bible references
}
}
return $linked_text;
}
function getEsvText($volume, $book, $verse) {
//Get passage text from ESV web site
$esvPassage = htmlentities(urlencode(trim("$volume $book $verse")));
$esvUrl = "http://www.gnpcb.org/esv/share/get/?key=". get_option('scripturizer_esv_key') ."&passage=$esvPassage&". get_option('scripturizer_esv_query_options');
$esvCh = curl_init($esvUrl);
curl_setopt($esvCh, CURLOPT_RETURNTRANSFER, 1);
$esvResponse = curl_exec($esvCh);
curl_close($esvCh);
// Get rid of triple and double line breaks since WP turns them into <p>'s and thereby kills our <span>
// $esvResponse = str_replace("\n\n\n", "\n", $esvResponse);
$esvResponse = str_replace("\n\n", "\n", $esvResponse);
// Build the show/hide link
$esvSpanId = 'scripturizer' .mt_rand(); //prefix the rand number with "id" to pass XHTML validation
$output_dynamic = " <a href=\"javascript://\" onclick=\"showhide('"
. $esvSpanId
. "');\">[+/-]</a><span id=\""
. $esvSpanId
. "\" style=\""
. get_option('scripturizer_xml_css')
. "\">"
. $esvResponse
. "<br /><a href=\"http://www.esv.org/\"><img src=\"http://www.esv.org/assets/buttons/small.7.png\" alt=\"This text is from the ESV Bible. Visit www.esv.org to learn about the ESV.\" title=\"Visit www.esv.org to learn about the ESV Bible\" width=\"80\" height=\"21\" /></a>"
. "</span>";
// I don't know why, but I ran into bugs when switching between dynamic and static modes based on how WP parsed the '' in the onclick action.
// So, for now, I decided to have two different outputs. The static mode escapes the ' by using a double ''.
// The dynamic output does not need to escape the ' -- (go figure!)
$output_static = " <a href=\"javascript://\" onclick=\"showhide(''"
. $esvSpanId
. "'');\">[+/-]</a><span id=\""
. $esvSpanId
. "\" style=\""
. get_option('scripturizer_xml_css')
. "\">"
. $esvResponse
. "<br /><a href=\"http://www.esv.org/\"><img src=\"http://www.esv.org/assets/buttons/small.7.png\" alt=\"This text is from the ESV Bible. Visit www.esv.org to learn about the ESV.\" title=\"Visit www.esv.org to learn about the ESV Bible\" width=\"80\" height=\"21\" /></a>"
. "</span>";
if (get_option('scripturizer_dynamic_substitution')) {
return $output_dynamic;
} else {
return $output_static;
}
}
function scripturizeAddLinks($text = '',$bible = NULL) {
global $scripturizer_translations;
if (!isset($bible)) {
$bible=get_option('scripturizer_default_translation');
}
$volume_regex = '1|2|3|I|II|III|1st|2nd|3rd|First|Second|Third';
$book_regex = 'Genesis|Exodus|Leviticus|Numbers|Deuteronomy|Joshua|Judges|Ruth|Samuel|Kings|Chronicles|Ezra|Nehemiah|Esther';
$book_regex .= '|Job|Psalms?|Proverbs?|Ecclesiastes|Songs? of Solomon|Song of Songs|Isaiah|Jeremiah|Lamentations|Ezekiel|Daniel|Hosea|Joel|Amos|Obadiah|Jonah|Micah|Nahum|Habakkuk|Zephaniah|Haggai|Zechariah|Malachi';
$book_regex .= '|Mat+hew|Mark|Luke|John|Acts?|Acts of the Apostles|Romans|Corinthians|Galatians|Ephesians|Phil+ippians|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|Jude|Revelations?';
// I split these into two different variables from Dean's original Perl code because I want to be able to have an optional period at the end of just the abbreviations
$abbrev_regex = 'Gen|Ex|Exo|Lev|Num|Nmb|Deut?|Josh?|Judg?|Jdg|Rut|Sam|Ki?n|Chr(?:on?)?|Ezr|Neh|Est';
$abbrev_regex .= '|Jb|Psa?|Pr(?:ov?)?|Eccl?|Song?|Isa|Jer|Lam|Eze|Dan|Hos|Joe|Amo|Oba|Jon|Mic|Nah|Hab|Zeph?|Hag|Zech?|Mal';
$abbrev_regex .= '|Mat+|Mr?k|Lu?k|Jh?n|Jo|Act|Rom|Cor|Gal|Eph|Col|Phil?|The?|Thess?|Tim|Tit|Phile|Heb|Ja?m|Pe?t|Ju?d|Rev';
$book_regex='(?:'.$book_regex.')|(?:'.$abbrev_regex.')\.?';
$verse_regex="\d{1,3}(?::\d{1,3})?(?:\s?(?:[-&,]\s?\d+))*";
// non Bible Gateway translations are all together at the end to make it easier to maintain the list
$translation_regex = implode('|',array_keys($scripturizer_translations)); // makes it look like 'NIV|KJV|ESV' etc
// note that this will be executed as PHP code after substitution thanks to the /e at the end!
$passage_regex = '/(?:('.$volume_regex.')\s)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:'.$translation_regex.')|\s?\((?:'.$translation_regex.')\)))?/e';
$replacement_regex = "scripturizeLinkReference('\\0','\\1','\\2','\\3','\\4','$bible')";
$text=preg_replace($passage_regex,$replacement_regex,$text);
return $text;
}
function scripturizeLinkReference($reference='',$volume='',$book='',$verse='',$translation='',$user_translation='') {
if ($volume) {
$volume = str_replace('III','3',$volume);
$volume = str_replace('Third','3',$volume);
$volume = str_replace('II','2',$volume);
$volume = str_replace('Second','2',$volume);
$volume = str_replace('I','1',$volume);
$volume = str_replace('First','1',$volume);
$volume = $volume{0}; // will remove st,nd,and rd (presupposes regex is correct)
}
//catch an obscure bug where a sentence like "The 3 of us went downtown" triggers a link to 1 Thess 3
if (!strcmp(strtolower($book),"the") && $volume=='' ) {
return $reference;
}
if(!$translation) {
if (!$user_translation) {
$translation = get_option('scripturizer_default_translation');
} else {
$translation = $user_translation;
}
} else {
$translation = trim($translation,' ()'); // strip out any parentheses that might have made it this far
}
// if necessary, just choose part of the verse reference to pass to the web interfaces
// they wouldn't know what to do with John 5:1-2, 5, 10-13 so I just give them John 5:1-2
// this doesn't work quite right with something like 1:5,6 - it gets chopped to 1:5 instead of converted to 1:5-6
if ($verse) {
$verse = strtok($verse,',& ');
}
if (get_option('scripturizer_libronix')) {
$libronix=sprintf('<a title="View %s in Logos Bible Software Series X" href="libronixdls:keylink|ref=[en]bible:%s"><img border="0" src="%s/wp-content/LibronixLink.gif"></a>',trim("$volume $book $verse"),htmlentities(trim("$volume $book $verse")),get_settings('siteurl'));
}
switch ($translation) {
case 'ESV':
// note: the ESV could actually support a mouseover reference
// we could pull it directly from their site and include it in the $title text
// http://www.gnpcb.org/esv/share/services/api/ for more info
$link = 'http://www.gnpcb.org/esv/search/?go=Go&q=';
$title = 'English Standard Version Bible';
$link = sprintf('<a href="%s%s" title="%s">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$title,trim($reference));
# Insert Show/Hide link and include ESV verse text
if (get_option('scripturizer_xml_show_hide')) {
$link .= getEsvText($volume, $book, $verse);
}
break;
case 'NET':
// example URL http://www.bible.org/netbible2/index.php?book=gen&chapter=1&verse=1&submit=Lookup+Verse
$link = 'http://www.bible.org/netbible2/index.php';
$title = 'New English Translation';
$chapter = trim(strtok($verse,':'));
$verses = trim(strtok('-,'));
$book = scripturizeNETBook($volume.' '.$book);
$link = sprintf('<a href="%s?book=%s&chapter=%s&verse=%s&submit=Lookup+Verse" title="%s">%s</a>',$link,htmlentities(urlencode($book)),$chapter,$verses,$title,trim($reference));
break;
case 'NRSV':
// example URL http://bible.oremus.org/?passage=John+1%3A1&vnum=yes&version=nrsv
// there is a new interface being developed at http://bible.oremus.org/bible.cgi
$link = 'http://bible.oremus.org/';
$title = 'New Revised Standard Version';
$options ='&vnum=yes&version=nrsv';
$link = sprintf('<a href="%s?passage=%s%s" title="%s">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$options,$title,trim($reference));
break;
case 'NA26':
case 'LXX':
// example URL http://www.zhubert.com/bible?book=Matthew&chapter=2&verse=3
// there's also an XML interface to this content - could do a trick like I propose with the ESV
$link = 'http://www.zhubert.com/bible';
$title = 'original language at zhubert.com';
$chapter=zhubertize_chapter($verse);
$verse=zhubertize_verse($verse);
$book=zhubertize_book($volume.' '.$book);
$link = sprintf('<a href="%s?book=%s&chapter=%d&verse=%d" title="%s">%s</a>',$link,htmlentities(urlencode(trim($book))),$chapter,$verse,$title,trim($reference));
break;
default:
// Bible Gateway has a ton of translations, so just make it the default instead of checking for each one
// $translation_regex takes care of ensuring that only valid translations make it this far, anyway
// api at http://biblegateway.com/usage/linking/
$link = "http://biblegateway.com/bible?version=$translation&passage=";
$title = 'Bible Gateway';
$link = sprintf('<a href="%s%s" title="%s">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$title,trim($reference));
break;
}
if (get_option('scripturizer_libronix')) {
$link.=$libronix;
}
return $link;
}
function scripturizeNETBook($book='') {
// need this function because NET Bible needs rigid input
// it's not perfect, so someone who intends to link to the NET Bible must be cautious with their syntax
// Jn 5:1 won't work, for example (must be 'joh' or 'john').
$book = strtolower(trim($book));
if (!$book) return '';
$book = preg_replace('/\s+/', '', $book); //strip whitespace
switch ($book) {
case 'judges':
$book = 'jdg';
break;
case 'songofsongs':
case 'songofsolomon':
case 'song':
$book = 'sos';
break;
case 'philemon':
$book = 'phm';
break;
default:
$book = substr($book,0,3);
}
return $book;
}
function zhubertize_chapter($reference="") {
$chapter=strtok($reference,':');
return $chapter;
}
function zhubertize_verse($reference="") {
$chapter=strtok($reference,':');
$verse=strtok(' ,-;');
if (!$verse) {
$verse=1;
}
return $verse;
}
function zhubertize_book($rawbook) {
// ultimately I need to restore all abbreviations to the full book.
// perhaps take the first three letters and expand?
$book = strtolower(trim($rawbook));
$book = preg_replace('/\s+/', '', $book); //strip whitespace
$book= substr($book,0,3);
switch ($book) {
case 'gen':
$book='Genesis';
&n