SHARE
TWEET

SB translation fix: sb_tidy_reference

bhengh Jan 25th, 2013 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sb_tidy_reference ($start, $end, $add_link = FALSE, $translate_book = FALSE) {
  2.         if (!trim($start['book'])) {
  3.                 return "";
  4.         }
  5.         $start_book = trim($start['book']);
  6.         $end_book = trim($end['book']);
  7.        
  8.         if ($translate_book) {
  9.                 $translated_books = array_combine(sb_get_default('eng_bible_books'), sb_get_default('bible_books'));
  10.                 $t_start_book = $translated_books[$start_book];
  11.                 $t_end_book = $translated_books[$end_book];
  12.         }
  13.         else {
  14.                 $t_start_book = $start_book;
  15.                 $t_end_book = $end_book;
  16.         }
  17.        
  18.         $start_chapter = trim($start['chapter']);
  19.         $end_chapter = trim($end['chapter']);
  20.         $start_verse = trim($start['verse']);
  21.         $end_verse = trim($end['verse']);
  22.         if ($add_link) {
  23.                 $t_start_book = "<a href=\"".sb_get_book_link($start_book)."\">{$t_start_book}</a>";
  24.                 $t_end_book = "<a href=\"".sb_get_book_link($end_book)."\">{$t_end_book}</a>";
  25.         }
  26.         if ($start_book == $end_book) {
  27.                 if ($start_chapter == $end_chapter) {
  28.                         if ($start_verse == $end_verse) {
  29.                                 $reference = "$t_start_book $start_chapter:$start_verse";
  30.                         } else {
  31.                                 $reference = "$t_start_book $start_chapter:$start_verse-$end_verse";
  32.                         }
  33.                 } else {
  34.                          $reference = "$t_start_book $start_chapter:$start_verse-$end_chapter:$end_verse";
  35.                 }
  36.         } else {
  37.                 $reference =  "$t_start_book $start_chapter:$start_verse - $t_end_book $end_chapter:$end_verse";
  38.         }
  39.         return $reference;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top