r61330 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61329‎ | r61330 | r61331 >
Date:14:24, 21 January 2010
Author:demon
Status:deferred
Tags:
Comment:
Code formatting cleanup, Rm unneeded global delcaration, Drop pre-ParserFirstCallInit compat, Renamed file to SacredText.php like other extensions, Needs i18n love, some caching
Modified paths:
  • /trunk/extensions/SacredText/SacredText.php (added) (history)
  • /trunk/extensions/SacredText/SacredText.setup.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/SacredText/SacredText.setup.php
@@ -1,232 +0,0 @@
2 -<?php
3 -# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
4 -if (!defined('MEDIAWIKI')) {
5 - echo <<<EOT
6 -To install my extension, put the following line in LocalSettings.php:
7 -require_once( "\$IP/extensions/SacredText/SacredText.setup.php" );
8 -EOT;
9 - exit( 1 );
10 -}
11 -
12 -// the following are the parameters that can be set in LocalSettings.php
13 -global $wgSacredChapterAlias;
14 -global $wgSacredUseBibleTag;
15 -$wgSacredUseBibleTag = true;
16 -
17 -$wgSacredChapterAlias = array();
18 -$wgSacredChapterAlias["Christian Bible"] = array();
19 -$wgSacredChapterAlias["Christian Bible"]["1Chronicles"]="1 Chronicles";
20 -$wgSacredChapterAlias["Christian Bible"]["1Corinthians"]="1 Corinthians";
21 -$wgSacredChapterAlias["Christian Bible"]["1John"]="1 John";
22 -$wgSacredChapterAlias["Christian Bible"]["1Kings"]="1 Kings";
23 -$wgSacredChapterAlias["Christian Bible"]["1Peter"]="1 Peter";
24 -$wgSacredChapterAlias["Christian Bible"]["1Samuel"]="1 Samuel";
25 -$wgSacredChapterAlias["Christian Bible"]["1Thessalonians"]="1 Thessalonians";
26 -$wgSacredChapterAlias["Christian Bible"]["1Timothy"]="1 Timothy";
27 -$wgSacredChapterAlias["Christian Bible"]["2Chronicles"]="2 Chronicles";
28 -$wgSacredChapterAlias["Christian Bible"]["2Corinthians"]="2 Corinthians";
29 -$wgSacredChapterAlias["Christian Bible"]["2John"]="2 John";
30 -$wgSacredChapterAlias["Christian Bible"]["2Kings"]="2 Kings";
31 -$wgSacredChapterAlias["Christian Bible"]["2Peter"]="2 Peter";
32 -$wgSacredChapterAlias["Christian Bible"]["2Samuel"]="2 Samuel";
33 -$wgSacredChapterAlias["Christian Bible"]["2Thessalonians"]="2 Thessalonians";
34 -$wgSacredChapterAlias["Christian Bible"]["2Timothy"]="2 Timothy";
35 -$wgSacredChapterAlias["Christian Bible"]["3John"]="3 John";
36 -$wgSacredChapterAlias["Christian Bible"]["1Ch"]="1 Chronicles";
37 -$wgSacredChapterAlias["Christian Bible"]["1Co"]="1 Corinthians";
38 -$wgSacredChapterAlias["Christian Bible"]["1Jo"]="1 John";
39 -$wgSacredChapterAlias["Christian Bible"]["1Ki"]="1 Kings";
40 -$wgSacredChapterAlias["Christian Bible"]["1Pe"]="1 Peter";
41 -$wgSacredChapterAlias["Christian Bible"]["1Sa"]="1 Samuel";
42 -$wgSacredChapterAlias["Christian Bible"]["1Th"]="1 Thessalonians";
43 -$wgSacredChapterAlias["Christian Bible"]["1Ti"]="1 Timothy";
44 -$wgSacredChapterAlias["Christian Bible"]["2Ch"]="2 Chronicles";
45 -$wgSacredChapterAlias["Christian Bible"]["2Co"]="2 Corinthians";
46 -$wgSacredChapterAlias["Christian Bible"]["2Jo"]="2 John";
47 -$wgSacredChapterAlias["Christian Bible"]["2Ki"]="2 Kings";
48 -$wgSacredChapterAlias["Christian Bible"]["2Pe"]="2 Peter";
49 -$wgSacredChapterAlias["Christian Bible"]["2Sa"]="2 Samuel";
50 -$wgSacredChapterAlias["Christian Bible"]["2Th"]="2 Thessalonians";
51 -$wgSacredChapterAlias["Christian Bible"]["2Ti"]="2 Timothy";
52 -$wgSacredChapterAlias["Christian Bible"]["3Jo"]="3 John";
53 -$wgSacredChapterAlias["Christian Bible"]["Act"]="Acts";
54 -$wgSacredChapterAlias["Christian Bible"]["Amo"]="Amos";
55 -$wgSacredChapterAlias["Christian Bible"]["Col"]="Colossians";
56 -$wgSacredChapterAlias["Christian Bible"]["Dan"]="Daniel";
57 -$wgSacredChapterAlias["Christian Bible"]["Deu"]="Deuteronomy";
58 -$wgSacredChapterAlias["Christian Bible"]["Ecc"]="Ecclesiastes";
59 -$wgSacredChapterAlias["Christian Bible"]["Eph"]="Ephesians";
60 -$wgSacredChapterAlias["Christian Bible"]["Est"]="Esther";
61 -$wgSacredChapterAlias["Christian Bible"]["Exo"]="Exodus";
62 -$wgSacredChapterAlias["Christian Bible"]["Eze"]="Ezekial";
63 -$wgSacredChapterAlias["Christian Bible"]["Ezr"]="Ezra";
64 -$wgSacredChapterAlias["Christian Bible"]["Gal"]="Galatians";
65 -$wgSacredChapterAlias["Christian Bible"]["Gen"]="Genesis";
66 -$wgSacredChapterAlias["Christian Bible"]["Ge"]="Genesis";
67 -$wgSacredChapterAlias["Christian Bible"]["Hab"]="Habakkuk";
68 -$wgSacredChapterAlias["Christian Bible"]["Hag"]="Haggai";
69 -$wgSacredChapterAlias["Christian Bible"]["Heb"]="Hebrews";
70 -$wgSacredChapterAlias["Christian Bible"]["Hos"]="Hosea";
71 -$wgSacredChapterAlias["Christian Bible"]["Isa"]="Isaiah";
72 -$wgSacredChapterAlias["Christian Bible"]["Jam"]="James";
73 -$wgSacredChapterAlias["Christian Bible"]["Jer"]="Jeremiah";
74 -$wgSacredChapterAlias["Christian Bible"]["Job"]="Job";
75 -$wgSacredChapterAlias["Christian Bible"]["Joe"]="Joel";
76 -$wgSacredChapterAlias["Christian Bible"]["Joh"]="John";
77 -$wgSacredChapterAlias["Christian Bible"]["Jon"]="Jonah";
78 -$wgSacredChapterAlias["Christian Bible"]["Jos"]="Joshua";
79 -$wgSacredChapterAlias["Christian Bible"]["Jud"]="Jude";
80 -$wgSacredChapterAlias["Christian Bible"]["Jud"]="Judges";
81 -$wgSacredChapterAlias["Christian Bible"]["Lam"]="Lamentations";
82 -$wgSacredChapterAlias["Christian Bible"]["Lev"]="Leviticus";
83 -$wgSacredChapterAlias["Christian Bible"]["Luk"]="Luke";
84 -$wgSacredChapterAlias["Christian Bible"]["Mal"]="Malachi";
85 -$wgSacredChapterAlias["Christian Bible"]["Mar"]="Mark";
86 -$wgSacredChapterAlias["Christian Bible"]["Mat"]="Matthew";
87 -$wgSacredChapterAlias["Christian Bible"]["Mic"]="Micah";
88 -$wgSacredChapterAlias["Christian Bible"]["Nah"]="Nahum";
89 -$wgSacredChapterAlias["Christian Bible"]["Neh"]="Nehemiah";
90 -$wgSacredChapterAlias["Christian Bible"]["Num"]="Numbers";
91 -$wgSacredChapterAlias["Christian Bible"]["Oba"]="Obad";
92 -$wgSacredChapterAlias["Christian Bible"]["Phi"]="Philemon";
93 -$wgSacredChapterAlias["Christian Bible"]["Phi"]="Philippians";
94 -$wgSacredChapterAlias["Christian Bible"]["Pro"]="Proverbs";
95 -$wgSacredChapterAlias["Christian Bible"]["Psa"]="Psalms";
96 -$wgSacredChapterAlias["Christian Bible"]["Rev"]="Revelation";
97 -$wgSacredChapterAlias["Christian Bible"]["Rom"]="Romans";
98 -$wgSacredChapterAlias["Christian Bible"]["Rut"]="Ruth";
99 -$wgSacredChapterAlias["Christian Bible"]["Son"]="Song of Solomon";
100 -$wgSacredChapterAlias["Christian Bible"]["Song"]="Song of Solomon";
101 -$wgSacredChapterAlias["Christian Bible"]["SSol"]="Song of Solomon";
102 -$wgSacredChapterAlias["Christian Bible"]["Tit"]="Titus";
103 -$wgSacredChapterAlias["Christian Bible"]["Zec"]="Zechariah";
104 -$wgSacredChapterAlias["Christian Bible"]["Zep"]="Zephaniah";
105 -
106 -
107 -// based on http://www.mediawiki.org/wiki/Manual:Tag_extensions
108 -if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
109 - $wgHooks['ParserFirstCallInit'][] = 'efSacredTextParserInit';
110 -} else { // Otherwise do things the old fashioned way
111 - $wgExtensionFunctions[] = 'efSacredTextParserInit';
112 -}
113 -
114 -function efSacredTextParserInit() {
115 - global $wgParser;
116 - global $wgSacredUseBibleTag;
117 - $wgParser->setHook( 'sacredtext', 'efSacredTextRenderHook' );
118 - if( $wgSacredUseBibleTag ) {
119 - $wgParser->setHook( 'bible', 'efSacredTextRenderHook_Bible' );
120 - }
121 - return true;
122 -}
123 -
124 -function efSacredTextRender( $religtext, $book, $chapternum, $versenums, $lang, $ver )
125 -{
126 - global $wgSacredChapterAlias;
127 - $dbr = wfGetDB( DB_SLAVE );
128 -
129 - if( array_key_exists($religtext, $wgSacredChapterAlias) &&
130 - array_key_exists($book, $wgSacredChapterAlias[$religtext] ) )
131 - {
132 - $book = $wgSacredChapterAlias[$religtext][$book];
133 - }
134 -
135 - if( strcasecmp($religtext,"Christian Bible")==0 ) {
136 - if( strcasecmp($ver,"AV")==0 ) {
137 - $ver = "KJV";
138 - }
139 - }
140 -
141 - $obj = $dbr->selectRow( "sacredtext_verses", array("st_text"),
142 - array( "st_religious_text"=>$religtext,
143 - "st_book"=>$book,
144 - "st_chapter_num"=>$chapternum,
145 - "st_verse_num"=>$versenums[0],
146 - "st_translation"=>$ver,
147 - "st_language"=>$lang));
148 - if( $obj )
149 - {
150 - return htmlspecialchars( $obj->st_text );
151 - }
152 - else
153 - {
154 - return htmlspecialchars( "Could not find: ". $book ." ".$chapternum.":".$versenums[0]." in the ". $religtext );
155 - }
156 -}
157 -function efSacredTextParseInput( $input, &$book, &$chapternum, &$versenums )
158 -{
159 - if( preg_match( "/^\s*([\s\w]*\w+)\s*(\d+):(\d+)/", $input, $matches) )
160 - {
161 - $book = $matches[1];
162 - $chapternum = $matches[2];
163 -
164 - $versenums = array();
165 - $versenums[] = $matches[3];
166 - return true;
167 - }
168 - else
169 - {
170 - return false;
171 - }
172 -}
173 -function efSacredTextRenderHook_Bible( $input, $args, &$parser, $frame )
174 -{
175 - $parser->disableCache();
176 - if( efSacredTextParseInput( $input, $book, $chapternum, $versenums ) )
177 - {
178 - $lang = "en";
179 - $ver = "kjv";
180 - if( array_key_exists("lang", $args) ) $lang = $args["lang"];
181 - if( array_key_exists("ver", $args) ) $ver = $args["ver"];
182 -
183 - return htmlspecialchars( $input ) ." ". efSacredTextRender( "Christian Bible", $book, $chapternum, $versenums, $lang, $ver );
184 - }
185 - else
186 - {
187 - return htmlspecialchars( $input . " Could not parse reference. Please use the format 'Gen 1:10'." );
188 - }
189 -}
190 -
191 -function efSacredTextRenderHook( $input, $args, &$parser, $frame ) {
192 - $parser->disableCache();
193 - if( efSacredTextParseInput( $input, $book, $chapternum, $versenums ) )
194 - {
195 - $lang = "en";
196 - $ver = "kjv";
197 - $religtext = "Christian Bible";
198 - if( array_key_exists("lang", $args) ) $lang = $args["lang"];
199 - if( array_key_exists("ver", $args) ) $ver = $args["ver"];
200 - if( array_key_exists("text", $args) ) $religtext = $args["text"];
201 -
202 - return htmlspecialchars( $input ) ." ". efSacredTextRender( $religtext, $book, $chapternum, $versenums, $lang, $ver );
203 - }
204 - else
205 - {
206 - return htmlspecialchars( $input . " Could not parse reference. Please use the format 'Gen 1:10'." );
207 - }
208 -}
209 -
210 -
211 -# Schema updates for update.php
212 -$wgHooks['LoadExtensionSchemaUpdates'][] = 'updateSacredTextDB';
213 -
214 -function updateSacredTextDB() {
215 - global $wgExtNewTables;
216 - $wgExtNewTables[] = array(
217 - 'sacredtext_verses',
218 - dirname( __FILE__ ) . '/SacredText.verses.sql' );
219 - $wgExtNewTables[] = array(
220 - 'sacredtext_verses_kjv_entire',
221 - dirname( __FILE__ ) . '/data/bible_kjv_entire.sql' );
222 - return true;
223 -}
224 -
225 -$wgExtensionCredits['parserhook'][] = array(
226 - 'name' => 'SacredText',
227 - 'author' => 'Jonathan Williford',
228 - 'description' => 'Makes it easy to quote religious scriptures.',
229 - 'descriptionmsg' => 'This extension helps to quote religious scriptures.',
230 - 'version' => '0.0.1',
231 -);
232 -
233 -?>
Index: trunk/extensions/SacredText/SacredText.php
@@ -0,0 +1,205 @@
 2+<?php
 3+# Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
 4+if (!defined('MEDIAWIKI')) {
 5+ echo <<<EOT
 6+To install my extension, put the following line in LocalSettings.php:
 7+require_once( "\$IP/extensions/SacredText/SacredText.setup.php" );
 8+EOT;
 9+ exit( 1 );
 10+}
 11+
 12+$wgExtensionCredits['parserhook'][] = array(
 13+ 'path' => __FILE__,
 14+ 'name' => 'SacredText',
 15+ 'author' => 'Jonathan Williford',
 16+ 'description' => 'Makes it easy to quote religious scriptures.',
 17+ 'descriptionmsg' => 'This extension helps to quote religious scriptures.',
 18+ 'version' => '0.0.1',
 19+);
 20+
 21+// the following are the parameters that can be set in LocalSettings.php
 22+$wgSacredUseBibleTag = true;
 23+$wgSacredChapterAlias = array();
 24+$wgSacredChapterAlias["Christian Bible"] = array();
 25+$wgSacredChapterAlias["Christian Bible"]["1Chronicles"]="1 Chronicles";
 26+$wgSacredChapterAlias["Christian Bible"]["1Corinthians"]="1 Corinthians";
 27+$wgSacredChapterAlias["Christian Bible"]["1John"]="1 John";
 28+$wgSacredChapterAlias["Christian Bible"]["1Kings"]="1 Kings";
 29+$wgSacredChapterAlias["Christian Bible"]["1Peter"]="1 Peter";
 30+$wgSacredChapterAlias["Christian Bible"]["1Samuel"]="1 Samuel";
 31+$wgSacredChapterAlias["Christian Bible"]["1Thessalonians"]="1 Thessalonians";
 32+$wgSacredChapterAlias["Christian Bible"]["1Timothy"]="1 Timothy";
 33+$wgSacredChapterAlias["Christian Bible"]["2Chronicles"]="2 Chronicles";
 34+$wgSacredChapterAlias["Christian Bible"]["2Corinthians"]="2 Corinthians";
 35+$wgSacredChapterAlias["Christian Bible"]["2John"]="2 John";
 36+$wgSacredChapterAlias["Christian Bible"]["2Kings"]="2 Kings";
 37+$wgSacredChapterAlias["Christian Bible"]["2Peter"]="2 Peter";
 38+$wgSacredChapterAlias["Christian Bible"]["2Samuel"]="2 Samuel";
 39+$wgSacredChapterAlias["Christian Bible"]["2Thessalonians"]="2 Thessalonians";
 40+$wgSacredChapterAlias["Christian Bible"]["2Timothy"]="2 Timothy";
 41+$wgSacredChapterAlias["Christian Bible"]["3John"]="3 John";
 42+$wgSacredChapterAlias["Christian Bible"]["1Ch"]="1 Chronicles";
 43+$wgSacredChapterAlias["Christian Bible"]["1Co"]="1 Corinthians";
 44+$wgSacredChapterAlias["Christian Bible"]["1Jo"]="1 John";
 45+$wgSacredChapterAlias["Christian Bible"]["1Ki"]="1 Kings";
 46+$wgSacredChapterAlias["Christian Bible"]["1Pe"]="1 Peter";
 47+$wgSacredChapterAlias["Christian Bible"]["1Sa"]="1 Samuel";
 48+$wgSacredChapterAlias["Christian Bible"]["1Th"]="1 Thessalonians";
 49+$wgSacredChapterAlias["Christian Bible"]["1Ti"]="1 Timothy";
 50+$wgSacredChapterAlias["Christian Bible"]["2Ch"]="2 Chronicles";
 51+$wgSacredChapterAlias["Christian Bible"]["2Co"]="2 Corinthians";
 52+$wgSacredChapterAlias["Christian Bible"]["2Jo"]="2 John";
 53+$wgSacredChapterAlias["Christian Bible"]["2Ki"]="2 Kings";
 54+$wgSacredChapterAlias["Christian Bible"]["2Pe"]="2 Peter";
 55+$wgSacredChapterAlias["Christian Bible"]["2Sa"]="2 Samuel";
 56+$wgSacredChapterAlias["Christian Bible"]["2Th"]="2 Thessalonians";
 57+$wgSacredChapterAlias["Christian Bible"]["2Ti"]="2 Timothy";
 58+$wgSacredChapterAlias["Christian Bible"]["3Jo"]="3 John";
 59+$wgSacredChapterAlias["Christian Bible"]["Act"]="Acts";
 60+$wgSacredChapterAlias["Christian Bible"]["Amo"]="Amos";
 61+$wgSacredChapterAlias["Christian Bible"]["Col"]="Colossians";
 62+$wgSacredChapterAlias["Christian Bible"]["Dan"]="Daniel";
 63+$wgSacredChapterAlias["Christian Bible"]["Deu"]="Deuteronomy";
 64+$wgSacredChapterAlias["Christian Bible"]["Ecc"]="Ecclesiastes";
 65+$wgSacredChapterAlias["Christian Bible"]["Eph"]="Ephesians";
 66+$wgSacredChapterAlias["Christian Bible"]["Est"]="Esther";
 67+$wgSacredChapterAlias["Christian Bible"]["Exo"]="Exodus";
 68+$wgSacredChapterAlias["Christian Bible"]["Eze"]="Ezekial";
 69+$wgSacredChapterAlias["Christian Bible"]["Ezr"]="Ezra";
 70+$wgSacredChapterAlias["Christian Bible"]["Gal"]="Galatians";
 71+$wgSacredChapterAlias["Christian Bible"]["Gen"]="Genesis";
 72+$wgSacredChapterAlias["Christian Bible"]["Ge"]="Genesis";
 73+$wgSacredChapterAlias["Christian Bible"]["Hab"]="Habakkuk";
 74+$wgSacredChapterAlias["Christian Bible"]["Hag"]="Haggai";
 75+$wgSacredChapterAlias["Christian Bible"]["Heb"]="Hebrews";
 76+$wgSacredChapterAlias["Christian Bible"]["Hos"]="Hosea";
 77+$wgSacredChapterAlias["Christian Bible"]["Isa"]="Isaiah";
 78+$wgSacredChapterAlias["Christian Bible"]["Jam"]="James";
 79+$wgSacredChapterAlias["Christian Bible"]["Jer"]="Jeremiah";
 80+$wgSacredChapterAlias["Christian Bible"]["Job"]="Job";
 81+$wgSacredChapterAlias["Christian Bible"]["Joe"]="Joel";
 82+$wgSacredChapterAlias["Christian Bible"]["Joh"]="John";
 83+$wgSacredChapterAlias["Christian Bible"]["Jon"]="Jonah";
 84+$wgSacredChapterAlias["Christian Bible"]["Jos"]="Joshua";
 85+$wgSacredChapterAlias["Christian Bible"]["Jud"]="Jude";
 86+$wgSacredChapterAlias["Christian Bible"]["Jud"]="Judges";
 87+$wgSacredChapterAlias["Christian Bible"]["Lam"]="Lamentations";
 88+$wgSacredChapterAlias["Christian Bible"]["Lev"]="Leviticus";
 89+$wgSacredChapterAlias["Christian Bible"]["Luk"]="Luke";
 90+$wgSacredChapterAlias["Christian Bible"]["Mal"]="Malachi";
 91+$wgSacredChapterAlias["Christian Bible"]["Mar"]="Mark";
 92+$wgSacredChapterAlias["Christian Bible"]["Mat"]="Matthew";
 93+$wgSacredChapterAlias["Christian Bible"]["Mic"]="Micah";
 94+$wgSacredChapterAlias["Christian Bible"]["Nah"]="Nahum";
 95+$wgSacredChapterAlias["Christian Bible"]["Neh"]="Nehemiah";
 96+$wgSacredChapterAlias["Christian Bible"]["Num"]="Numbers";
 97+$wgSacredChapterAlias["Christian Bible"]["Oba"]="Obad";
 98+$wgSacredChapterAlias["Christian Bible"]["Phi"]="Philemon";
 99+$wgSacredChapterAlias["Christian Bible"]["Phi"]="Philippians";
 100+$wgSacredChapterAlias["Christian Bible"]["Pro"]="Proverbs";
 101+$wgSacredChapterAlias["Christian Bible"]["Psa"]="Psalms";
 102+$wgSacredChapterAlias["Christian Bible"]["Rev"]="Revelation";
 103+$wgSacredChapterAlias["Christian Bible"]["Rom"]="Romans";
 104+$wgSacredChapterAlias["Christian Bible"]["Rut"]="Ruth";
 105+$wgSacredChapterAlias["Christian Bible"]["Son"]="Song of Solomon";
 106+$wgSacredChapterAlias["Christian Bible"]["Song"]="Song of Solomon";
 107+$wgSacredChapterAlias["Christian Bible"]["SSol"]="Song of Solomon";
 108+$wgSacredChapterAlias["Christian Bible"]["Tit"]="Titus";
 109+$wgSacredChapterAlias["Christian Bible"]["Zec"]="Zechariah";
 110+$wgSacredChapterAlias["Christian Bible"]["Zep"]="Zephaniah";
 111+
 112+$wgHooks['ParserFirstCallInit'][] = 'efSacredTextParserInit';
 113+$wgHooks['LoadExtensionSchemaUpdates'][] = 'updateSacredTextDB';
 114+
 115+function efSacredTextParserInit( &$parser ) {
 116+ global $wgSacredUseBibleTag;
 117+ $parser->setHook( 'sacredtext', 'efSacredTextRenderHook' );
 118+ if( $wgSacredUseBibleTag ) {
 119+ $parser->setHook( 'bible', 'efSacredTextRenderHook_Bible' );
 120+ }
 121+ return true;
 122+}
 123+
 124+function efSacredTextRender( $religtext, $book, $chapternum, $versenums, $lang, $ver ) {
 125+ global $wgSacredChapterAlias;
 126+ $dbr = wfGetDB( DB_SLAVE );
 127+
 128+ if( array_key_exists($religtext, $wgSacredChapterAlias) &&
 129+ array_key_exists($book, $wgSacredChapterAlias[$religtext] ) )
 130+ {
 131+ $book = $wgSacredChapterAlias[$religtext][$book];
 132+ }
 133+
 134+ if( strcasecmp($religtext,"Christian Bible")==0 ) {
 135+ if( strcasecmp($ver,"AV")==0 ) {
 136+ $ver = "KJV";
 137+ }
 138+ }
 139+
 140+ $obj = $dbr->selectRow( "sacredtext_verses", array("st_text"),
 141+ array(
 142+ "st_religious_text" => $religtext,
 143+ "st_book" => $book,
 144+ "st_chapter_num" =>$chapternum,
 145+ "st_verse_num" =>$versenums[0],
 146+ "st_translation" =>$ver,
 147+ "st_language" =>$lang
 148+ ) );
 149+ if( $obj ) {
 150+ return htmlspecialchars( $obj->st_text );
 151+ } else {
 152+ return htmlspecialchars( "Could not find: ". $book ." ".$chapternum.":".$versenums[0]." in the ". $religtext );
 153+ }
 154+}
 155+
 156+function efSacredTextParseInput( $input, &$book, &$chapternum, &$versenums ) {
 157+ if( preg_match( "/^\s*([\s\w]*\w+)\s*(\d+):(\d+)/", $input, $matches) ) {
 158+ $book = $matches[1];
 159+ $chapternum = $matches[2];
 160+ $versenums = array();
 161+ $versenums[] = $matches[3];
 162+ return true;
 163+ } else {
 164+ return false;
 165+ }
 166+}
 167+
 168+function efSacredTextRenderHook_Bible( $input, $args, &$parser, $frame ) {
 169+ $parser->disableCache();
 170+ if( efSacredTextParseInput( $input, $book, $chapternum, $versenums ) ) {
 171+ $lang = "en";
 172+ $ver = "kjv";
 173+ if( array_key_exists("lang", $args) ) $lang = $args["lang"];
 174+ if( array_key_exists("ver", $args) ) $ver = $args["ver"];
 175+ return htmlspecialchars( $input ) ." ". efSacredTextRender( "Christian Bible", $book, $chapternum, $versenums, $lang, $ver );
 176+ } else {
 177+ return htmlspecialchars( $input . " Could not parse reference. Please use the format 'Gen 1:10'." );
 178+ }
 179+}
 180+
 181+function efSacredTextRenderHook( $input, $args, &$parser, $frame ) {
 182+ $parser->disableCache();
 183+ if( efSacredTextParseInput( $input, $book, $chapternum, $versenums ) ) {
 184+ $lang = "en";
 185+ $ver = "kjv";
 186+ $religtext = "Christian Bible";
 187+ if( array_key_exists("lang", $args) ) $lang = $args["lang"];
 188+ if( array_key_exists("ver", $args) ) $ver = $args["ver"];
 189+ if( array_key_exists("text", $args) ) $religtext = $args["text"];
 190+
 191+ return htmlspecialchars( $input ) ." ". efSacredTextRender( $religtext, $book, $chapternum, $versenums, $lang, $ver );
 192+ } else {
 193+ return htmlspecialchars( $input . " Could not parse reference. Please use the format 'Gen 1:10'." );
 194+ }
 195+}
 196+
 197+function updateSacredTextDB() {
 198+ global $wgExtNewTables;
 199+ $wgExtNewTables[] = array(
 200+ 'sacredtext_verses',
 201+ dirname( __FILE__ ) . '/SacredText.verses.sql' );
 202+ $wgExtNewTables[] = array(
 203+ 'sacredtext_verses_kjv_entire',
 204+ dirname( __FILE__ ) . '/data/bible_kjv_entire.sql' );
 205+ return true;
 206+}

Status & tagging log