0) echo "Find $q\n"; elseif(strlen($p) > 0) echo "$p\n"; else echo "The Holy Bible\n"; ?>
Passage:
Search:
0) { /* something was typed in to the Passage field, so figure out what it is */ $startbook = ""; $startchapter = ""; $startverse = ""; $endbook = ""; $endchapter = ""; $endverse = ""; if($dash = strpos($p,"-")) { /* the passage contains a dash, so this must be a range e.g. Genesis 1:1-3 */ /* figure out the starting and ending points indicated by the range */ $firstpart = substr($p,0,$dash); $dash = $dash+1; $secondpart = substr($p,$dash); $ref1 = parse_reference($firstpart); $startbook = $ref1['book']; $startchapter = $ref1['chapter']; $startverse = $ref1['verse']; $ref2 = parse_reference($secondpart); $endbook = $ref2['book']; $endchapter = $ref2['chapter']; $endverse = $ref2['verse']; /* if there's something typed in to the Search field, then perform a search */ /* otherwise, simply display the entire passage. */ if(strlen($q) < 1) display_passage($version,$startbook,$startchapter,$startverse, $endbook,$endchapter,$endverse); else { $totalcount = display_search($version,$startbook,$startchapter,$startverse, $endbook,$endchapter,$endverse,$startat,$count,$q); } } /* end if found dash - this is a range */ else { /* this isn't a range - but it might be a list of passages separated by commas */ $parts = explode(",",$p); if(count($parts) > 1) { /* there are multiple passages separated by commas, handle each one */ for($i = 0;$i < count($parts);$i++) { $reflist[$i] = parse_reference($parts[$i]); if(strlen($reflist[$i]['book']) > 0) $startbook = $reflist[$i]['book']; if(strlen($reflist[$i]['chapter']) > 0) $startchapter = $reflist[$i]['chapter']; if(strlen($reflist[$i]['verse']) > 0) $startverse = $reflist[$i]['verse']; /* if there's something typed in to the Search field, then perform a search */ /* otherwise, simply display the entire passage. */ if(strlen($q) < 1) display_passage($version,$startbook,$startchapter,$startverse, $endbook,$endchapter,$endverse); else { $totalcount = display_search($version,$startbook,$startchapter, $startverse,$endbook,$endchapter,$endverse,$startat,$count,$q); } } } /* comma found - this is a list */ else /* neither a range nor a list */ { $ref = parse_reference($p); $startbook = $ref['book']; $startchapter = $ref['chapter']; $startverse = $ref['verse']; /* if there's something typed in to the Search field, then perform a search */ /* otherwise, simply display the entire passage. */ if(strlen($q) < 1) display_passage($version,$startbook,$startchapter,$startverse, $endbook,$endchapter,$endverse); else { $totalcount = display_search($version,$startbook,$startchapter,$startverse, $endbook,$endchapter,$endverse,$startat,$count,$q); } } /* no comma found - not a list nor a range */ } /* end no dash found - not a range */ /* provide some navigation */ /* if a query wasn't typed in, then we want to provide the user with a way to move around */ /* in the Bible, going to the previous chapter, the next chapter, and displaying the */ /* entire current chapter. */ if(strlen($q) < 1) { $numsections = 0; if(strlen($endbook) < 1) $endbook = $startbook; if(strlen($endchapter) < 1) $endchapter = $startchapter; if(strlen($endverse) < 1) $endverse = $startverse; /* figure out what chapter is just before this one - may be in the previous book */ /* note: numsections is used to decide how many columns to use in the navigation table */ $prevbook = $startbook; $prevchapter = $startchapter - 1; if($prevchapter < 1) { $prevbook = $prevbook - 1; if($prevbook > 0) $prevchapter = $chapters[$prevbook]; } if($prevbook > 0) $numsections = $numsections + 1; if(strlen($startverse) > 0) $numsections = $numsections + 1; if((strlen($endverse) > 0) AND (($startchapter != $endchapter) OR ($startbooknum != $endbooknum))) $numsections = $numsections + 1; /* figure out what chapter is just after this one - may be in the next book */ $nextbook = 67; if((strlen($endbook) > 0) AND (strlen($endchapter) > 0)) { $nextbook = $endbook; $nextchapter = $endchapter + 1; if($nextchapter > $chapters[$nextbook]) { $nextchapter = 1; $nextbook = $nextbook + 1; } if($nextbook < 67) $numsections = $numsections + 1; } /* if no startchapter was provided, then what we show doesn't need navigation */ if(strlen($startchapter) < 1) $numsections = 0; if($numsections > 0) { echo "\n"; $colwidth = 100/$numsections; echo "\n"; if($prevbook > 0) echo "\n"; if(strlen($startverse) > 0) echo "\n"; if((strlen($endverse) > 0) AND (($startchapter != $endchapter) OR ($startbook != $endbook))) echo "\n"; if($nextbook < 67) echo "\n"; echo "\n"; echo "
". "". $longbook[$prevbook]." $prevchapter". "". $longbook[$startbook]. " $startchapter". "". $longbook[$endbook]." $endchapter". "". $longbook[$nextbook]." $nextchapter
\n"; } /* end if numsections > 0 */ } /* end if no q - this is merely browsing the Bible */ } /* end if p */ else if(strlen($q) > 0) { /* a query was specified, but no passage, so search the entire Bible */ $totalcount = display_search($version,1,1,1,66,22,20,$startat,$count,$q); } /* end if q but not p */ if(strlen($q) > 0) { /* navigation for search results */ echo ""; for($i=$lowend;$i<$highend;$i=$i+$count) { $pagenum = (int)(1 + $i/$count); if($i == $startat) echo ""; else echo "\n"; } echo "
"; $prevstart = $startat-$count; $nextset = $startat+$count; $lowend = 0; $highend = $totalcount; /* We're going to show, at most, 10 pages of search matches in the navigation area */ /* The user will still be able to get to all of them, just by moving around */ if($startat > 5*$count) $lowend = $startat - 5*$count; if($startat < ($totalcount - 5*$count)) $highend = $startat + 5*$count; if(($totalcount > 10*$count) AND ($startat < 5*$count)) $highend = 10*$count; echo "
"; if($startat > 0) echo "Prev"; echo "$pagenum". "$pagenum"; if($startat < ($totalcount - $count)) echo "Next"; echo "
"; } /* end if q - providing navigation for search results */ ?>