News:

Join the Facebook Fan Page.

Main Menu

Bible Tag

Started by Sheepy, November 12, 2005, 02:49:43 AM

Previous topic - Next topic

Sheepy

Link to Mod

This mod adds bible BBC Tag.  Please download and install ALL files.  Bible is too big for one package.

Display style of bible verse can be changed by editing style.css.

Bible verses are in King James Version.

Does NOT work with faster parsecode. (Not available by time of release)

Usage:
[bible] 1 Cor 13:4-8 [/bible]
[bible] Psalm 117 [/bible]
[bible] Mat 1:2-3:4 [/bible]

Technical notes: Verse table size 4.6MB in total, use one query per quote.

Elmacik

Nice mod.
What I think is this mod will display the relevant part of the Bible according to the numbers typed into the tags.. Right?
Home of Elmacik

houston

#2
This is what I get when I hit post.

Fatal error: Call to undefined function: str_ireplace() in /home/eaglebay/public_html/forum/Sources/Subs.php(1657) : runtime-created function on line 29


Running on smf1.1 rc1

SamoanOnion

ok, for some reason, it won't edit my subs.php through the package manager, so I know I'll have to do it manually.  what I didn't know is what I need to look for and whether to put it before or after.  here is the code if someone could just tell me what to look for and whether to put the added code before or after that.

<file name="$sourcedir/Subs.php">
<operation>
<search position="before"><![CDATA[
array(
'tag' => 'white',
'before' => '<span style="color: white;">',
'after' => '</span>',
),
]]></search>
<add><![CDATA[      array(
        'tag' => 'bible',
        'type' => 'unparsed_content',
        'content' => '$1',
        'validate' => create_function('&$tag, &$data, $disabled', '
          global $db_prefix;
          $parse_result = array();

          // Check syntax
          if (!preg_match(\'/^([1-3]?[a-zA-Z ]{3,})(\\d{1,3}(?:\\s*:\\s*\\d{1,3})?)(\\s*-\\s*\\d{1,3}(?:\\s*:\\s*\\d{1,3})?)?$/\', trim($data), &$parse_result)) return;
         
          // Parse book, starting verse, and ending verse
          // Verse index = Book * 1000000 + Chapter * 1000 + Verse
          // e.g. 46013001 = Book 46 Chapter 13 Verse 1 = 1 Cor 13:1
          $book = $parse_result[1];
          $verses = $parse_result[2];
          $start_index = $parse_result[2];
          $end_index = (count($parse_result) > 3) ? trim($parse_result[3], \' -\') : null;
          if (preg_match(\'/^(\\d{1,3})\\s*:\\s*(\\d{1,3})$/\', $start_index, &$parse_result)) // has verse part?
            $start_index = ((int)$parse_result[1]) * 1000 + (int) $parse_result[2];
          else
            $start_index = $start_index * 1000 + 1; // Chapter only
          if ($end_index) {
            $verses .= \'-\' . $end_index;  // Remember verse for header
            if (preg_match(\'/^(\\d{1,3})\\s*:\\s*(\\d{1,3})$/\', $end_index, &$parse_result))  // has verse part?
              $end_index = ((int)$parse_result[1]) * 1000 + (int) $parse_result[2];
            else
              $end_index = floor($start_index / 1000) * 1000 + $end_index; // Verse only
          } else
            $end_index = $start_index;

          // Turns book name into bible index
          $book = str_ireplace(\'Songs\', \'Song\', $book);
          $book = trim(preg_replace(\'/^([1-3])\\s*([a-zA-Z ]+)\\s*$/\', \'$1 $2\', $book)); // Normalise
          $bible_index= array(
            \'Genesis\' => 1, \'Exodus\' => 2, \'Leviticus\' => 3, \'Numbers\' => 4,
            \'Deuteronomy\' => 5, \'Joshua\' => 6, \'Judges\' => 7, \'Ruth\' => 8,
            \'1 Samuel\' => 9, \'2 Samuel\' => 10, \'1 Kings\' => 11, \'2 Kings\' => 12,
            \'1 Chronicles\' => 13, \'2 Chronicles\' => 14, \'Ezra\' => 15,
            \'Nehemiah\' => 16, \'Esther\' => 17, \'Job\' => 18, \'Psalms\' => 19,
            \'Proverbs\' => 20, \'Ecclesiastes\' => 21, \'Song of Solomon\' => 22,
            \'Isaiah\' => 23, \'Jeremiah\' => 24, \'Lamentations\' => 25,
            \'Ezekiel\' => 26, \'Daniel\' => 27, \'Hosea\' => 28, \'Joel\' => 29,
            \'Amos\' => 30, \'Obadiah\' => 31, \'Jonah\' => 32, \'Micah\' => 33,
            \'Nahum\' => 34, \'Habakkuk\' => 35, \'Zephaniah\' => 36, \'Haggai\' => 37,
            \'Zechariah\' => 38, \'Malachi\' => 39, \'Matthew\' => 40, \'Mark\' => 41,
            \'Luke\' => 42, \'John\' => 43, \'Acts\' => 44, \'Romans\' => 45,
            \'1 Corinthians\' => 46, \'2 Corinthians\' => 47, \'Galatians\' => 48,
            \'Ephesians\' => 49, \'Philippians\' => 50, \'Colossians\' => 51,
            \'1 Thessalonians\' => 52, \'2 Thessalonians\' => 53, \'1 Timothy\' => 54,
            \'2 Timothy\' => 55, \'Titus\' => 56, \'Philemon\' => 57, \'Hebrews\' => 58,
            \'James\' => 59, \'1 Peter\' => 60, \'2 Peter\' => 61, \'1 John\' => 62,
            \'2 John\' => 63, \'3 John\' => 64, \'Jude\' => 65, \'Revelation\' => 66,
          );
          foreach ($bible_index as $book_name => $book_index)
            if (stripos($book_name, $book) === 0) {
              $book = $book_name; // Remember name of book for header
              $start_index += $book_index * 1000000;
              $end_index += $book_index * 1000000;
              break;
            }

          // Range check
          if ($start_index < 1000000) return;
          if ($start_index > $end_index) {
            $temp = $start_index;
            $start_index = $end_index;
            $end_index = $temp;
          }

          // Find the verses
          $result = db_query("SELECT text FROM {$db_prefix}bible WHERE id >= $start_index AND id <= $end_index ORDER BY id ASC", __FILE__, __LINE__);
          if (mysql_num_rows($result)) {
            $data = "<div class=\\"bibleheader\\">$book $verses</div><div class=\\"biblequote\\">";
            while ($row = mysql_fetch_row($result))
              $data .= $row[0] . " ";
            $data .= \'</div>\';
          }
          mysql_free_result($result);
        '),
        'block_level' => true,
      ),
]]></add>
</operation>
</file>

Sheepy

#4
Quote from: houston on November 13, 2005, 09:20:24 PM
Fatal error: Call to undefined function: str_ireplace() in /home/eaglebay/public_html/forum/Sources/Subs.php(1657) : runtime-created function on line 29
Oh my, that's a php function that does case insensitive string replace.  Change it to str_replace or remove it entirely should be fine.  It just remove the 's' from "Songs of Solomon", in case someone misnamed it.  Will fix in next release.  Let me find a copy of PHP 4...

Sheepy

Quote from: SamoanOnion on November 13, 2005, 09:37:22 PM
ok, for some reason, it won't edit my subs.php through the package manager, so I know I'll have to do it manually.  what I didn't know is what I need to look for and whether to put it before or after.
You want to look for the shorter code i.e. array('tag'=>'white'...),

I put it after, so it's at the end of BB code tag list.  However its position doesn't matter much if you see no errors after manual modification.

Have you tried to check the file's permission?

SamoanOnion

yea, it was wierd, I did change the permissions to 777 and it still didn't want to edit it for me, but, I can do it manually and see how it goes.

thanx a bunch sheepy.

SamoanOnion

hey Sheepy,

would it be possible to make it display the verse numbers as well, like in a superscript format?

so instead of this:
QuoteFor God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. For God sent not his Son into the world to condemn the world; but that the world through him might be saved.

it would look like this:
Quote16For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. 17For God sent not his Son into the world to condemn the world; but that the world through him might be saved.

Sheepy

#8
Quote from: Sheepy on November 14, 2005, 04:40:17 PM
Quote from: houston on November 13, 2005, 09:20:24 PM
Fatal error: Call to undefined function: str_ireplace() in /home/eaglebay/public_html/forum/Sources/Subs.php(1657) : runtime-created function on line 29
Will fix in next release.  Let me find a copy of PHP 4...
Interesting.  It runs fine on PHP 4.4.0.  Anyway I replace it and str_ipos.  If it still doesn't work, please keep telling me. ^_^'

Uninstall old version first if you can, or restore backup first, or manually update the file.  Only two lines has been changed.
There is no need to update bible database, but I did changed their uninstallation so that they uninstall section by section now.


Quote from: SamoanOnion on November 15, 2005, 05:08:12 AMwould it be possible to make it display the verse numbers as well, like in a superscript format?
Yes that's possible.  Because of time I didn't do that.  Let me put it on my task list.  Meanwhile if you know php (even a bit) you can try to modify it yourself.  It is easy.  It's just that I can't do it the easy way in a mod...

houston

QuoteInteresting.  It runs fine on PHP 4.4.0.  Anyway I replace it and str_ipos.  If it still doesn't work, please keep telling me. ^_^'

Uninstall old version first if you can, or restore backup first, or manually update the file.  Only two lines has been changed.
There is no need to update bible database, but I did changed their uninstallation so that they uninstall section by section now.



That did it. I may try to put one together using the NIV Bible

Thanks.

Sheepy

Apart from verse superscript, also look for possibility of including other bible version.  ESV and WEB are two of those that is free to use for non-commercial purpose. The formar can be accessed from web (thanks myjc), and the later I can convert into MySQL.

Dannii

Maybe you could make underneath the main verse, a list of links to other versions of those same verses. Maybe those could even be included in the BBcode.
for example:
[bible version="KJV,NIV,ESV,NL,WEB"] 1 Cor 13:4-8 [/bible]
Would then display that verse, with specific links to that verse in online copies of those 5 versions.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

SamoanOnion

ok, got it work'n and it works like a champ, much prop's sheepy.

Quote from: Sheepy on November 14, 2005, 04:40:17 PM
Quote from: houston on November 13, 2005, 09:20:24 PM
Fatal error: Call to undefined function: str_ireplace() in /home/eaglebay/public_html/forum/Sources/Subs.php(1657) : runtime-created function on line 29
Oh my, that's a php function that does case insensitive string replace.  Change it to str_replace or remove it entirely should be fine.  It just remove the 's' from "Songs of Solomon", in case someone misnamed it.  Will fix in next release.  Let me find a copy of PHP 4...
I got this error as well, but I just renamed it to str_replace is that still a good fix or should I use something else?

@houston
that would be sweeet

@eldacar
thats a good idea, would be cool if it could be done

houston

Quote
I got this error as well, but I just renamed it to str_replace is that still a good fix or should I use something else?

The script Bible Tag has been updated to remove this error. It works well.

Elmacik

Can you please make this mod work with 1.0.5 ? It shouldnt be much difficult as its only Subs.php..
Home of Elmacik

Thantos

Quote from: Elmacik on December 06, 2005, 06:38:30 AM
Can you please make this mod work with 1.0.5 ? It shouldnt be much difficult as its only Subs.php..
The change in BBC handling from 1.0 to 1.1 is huge and 1.0's handling was a lot more difficult if you didn't know regular expressions

Sheepy

Ok. I'll try.  New version is almost done, by the way.

SaltedWeb

Hi, what do you think the ETA is on the Mod?
Sounds cool. I am just not 100% sure what it does ?

Cozmo
Knowing your limitations makes you human, exceeding these limitations makes you worthy of being human.

Sheepy

Quote from: MikeMill on December 06, 2005, 08:20:48 AM
The change in BBC handling from 1.0 to 1.1 is huge and 1.0's handling was a lot more difficult if you didn't know regular expressions
Fortunately I do.  IT remains true however that the environment of 1.0 is more diverse...

Sorry there's a slight delay in my schedule, but I haven't forgotten this. ^^'

Lisah

I installed the Bibles first no problem. Then I installed the bible tag mod and have run into the following error. I am running smf 1.1 rc1. Can someone please tell me what I need to do to fix this problem. Thanks.

Warning: Unexpected character in input: ' in /home/caf****/public_html/Sources/Subs.php(2114) : eval()'d code on line 1

Parse error: parse error, unexpected $ in /home/caf****/public_html/Sources/Subs.php(2114) : eval()'d code on line 1

Advertisement: