Changeset 2626359
- Timestamp:
- 11/08/2021 10:29:27 PM (4 years ago)
- Location:
- igefilter/trunk
- Files:
-
- 3 edited
-
igefilter.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
-
readme_en.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
igefilter/trunk/igefilter.php
r2006579 r2626359 2 2 /* 3 3 * Plugin Name: Igefilter 4 * Version: 1. 04 * Version: 1.1 5 5 * Plugin URI: http://dev.wp-plugins.org/wiki/igefilter 6 6 * Description: Changes Bible references to hyperlinks. … … 35 35 36 36 define('IGEFILTER_DEFAULT_BIBLE_TRANSLATION', '4'); 37 38 // you can pick any translation supported by the Bible Gateway, as well as the NRSV, the NET, and the ESV39 // should we add Blue Letter Bible and http://www.zhubert.com/greek as original language options somehow? ....40 // http://www.blueletterbible.org/cgi-bin/tools/printer-friendly.pl?book=Gen&chapter=1&version=heb41 // http://www.blueletterbible.org/cgi-bin/tools/printer-friendly.pl?book=Mat&chapter=1&version=grk42 // the interface on zhubert.com is weird - the NT books are numbered instead of named43 // we should also take a look at the New American Bible - http://www.nccbuscc.com/nab/bible/index.htm44 37 45 38 /** … … 266 259 $verse_regex="\d{1,3}(?:[:,]\d{1,3})?(?:[-,]?\d+)*[-:\d]*"; // felismeri a kovetkezoket: Mt. 5:2, Jn 5,6, 1Kor. 1:12-2:11 267 260 268 $translation_regex = 'NIV|NASB|AMP|NLT|KJV|ESV|CEV|NET|NKJV|KJ21|ASV|WE|YLT|DARBY|WYC|NIV-UK|TNIV|MSG|NIRV'; 269 // non Bible Gateway translations are all together at the end to make it easier to maintain the list 270 //$translation_regex = implode('|',array_keys($igefilter_translations)); // makes it look like 'NIV|KJV|ESV' etc 271 272 // note that this will be executed as PHP code after substitution thanks to the /e at the end! 273 // $passage_regex = '/(?:('.$volume_regex.')\s?)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:'.$translation_regex.')|\s?\((?:'.$translation_regex.')\)))?/e'; 274 $passage_regex = '/(?:('.$volume_regex.')\s?)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:'.$translation_regex.')|\s?\((?:'.$translation_regex.')\)))?/e'; 275 276 $replacement_regex = "igefilter_scripturizeLinkReference('\\0','\\1','\\2','\\3','\\4','$bible')"; 277 278 $text = preg_replace( $passage_regex, $replacement_regex, $text ); 261 // $translation_regex = 'NIV|NASB|AMP|NLT|KJV|ESV|CEV|NET|NKJV|KJ21|ASV|WE|YLT|DARBY|WYC|NIV-UK|TNIV|MSG|NIRV'; 262 // $passage_regex = '/(?:('.$volume_regex.')\s?)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:'.$translation_regex.')|\s?\((?:'.$translation_regex.')\)))?/'; 263 $passage_regex = '/(?:('.$volume_regex.')\s?)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:NIV|KJV)|\s?\((?:NIV|KJV)\)))?/'; 264 265 // $replacement_regex = "igefilter_scripturizeLinkReference('\\0','\\1','\\2','\\3','\\4','$bible')"; 266 267 // $text = preg_replace_callback( $passage_regex, $replacement_regex, $text ); 268 $wrapper = new IgeFilterCallbackWrapper(); 269 $wrapper->bible = $bible; 270 $text = preg_replace_callback($passage_regex, 271 array( 272 &$wrapper, 273 "igefilterCallback", 274 ), 275 $text); 279 276 280 277 return $text; // TODO: make this an array, to return text, plus OT/NT (for original languages) 281 278 } 282 279 283 function igefilter_scripturizeLinkReference( $reference='', $volume='', $book='', $verse='', $translation='', $user_translation='' ) { 284 global $igefilter_options; 285 //echo $reference .'|'. $book .'|' . $volume .'|'. $verse .'|'. $translation .'|'; 280 281 /** 282 * A simple class to wrap our callback function. 283 * 284 * We need this because we need to pass the Bible parameter in. 285 * The preg_replace callback is only passed the matched groups. 286 */ 287 class IgeFilterCallbackWrapper { 288 289 /** 290 * A function just to work on a Bible reference, and turn into a link. 291 * 292 * It is passed the details of the incoming Bible reference to, and also the 293 * original reference, so that the reference can be surrounded by an anchor 294 * linking to the relevant site which has the text for that verse. It then 295 * passes the transformed reference back out so that it can be replaced in the 296 * wider body of text from which it came. 297 * Two arguments for book; the first will be populated if no volume is given. 298 * The second will be populated if there's a volume number. 299 */ 300 //function scripturizeLinkReference($reference='',$volume='',$book='',$verse='',$translation='',$user_translation='') { 301 302 public function igefilterCallback($matches) { 303 $reference = $matches[0]; 304 $book1 = $matches[2]; 305 $volume = $matches[1]; 306 // $book2 = $matches[3]; 307 $verse = $matches[3]; 308 $translation = isset($matches[5]) ? $matches[5] : NULL; 309 $user_translation = $this->bible; 310 311 global $igefilter_options; 312 //echo $reference .'|'. $book .'|' . $volume .'|'. $verse .'|'. $translation .'|'; 286 313 287 314 $link_target = ( $igefilter_options['link_target_blank'] ? ' target="_blank"' : '' ); 288 315 316 $book = ($book1 == '') ? $book2 : $book1; 289 317 if ($volume) { 290 318 $volume = str_replace('IV','4',$volume); … … 305 333 } 306 334 } 307 308 335 //if necessary, just choose part of the verse reference to pass to the web interfaces 309 336 //they wouldn't know what to do with John 5:1-2, 5, 10-13 so I just give them John 5:1-2 … … 337 364 // $link = sprintf('<a href="%s/%s/%s/%s#v%s" class="reform" title="%s">%s</a>',$link,htmlentities(urlencode($book)),$chapter,$verses,$verses,$title,trim($reference)); 338 365 $link = sprintf('<a class="%s"%s href="%s/%s/%s#v%s" class="reform" title="%s">%s</a>',$igefilter_options['link_css_class'], $link_target,$link,htmlentities(urlencode($book)),$chapter,$verses,$title,trim($reference)); 339 340 return $link; 366 367 return $link; 368 } 341 369 } 342 370 -
igefilter/trunk/readme.txt
r2039180 r2626359 4 4 Tags: bible, biblia, scripture, szentiras, ige 5 5 Requires at least: 3.1 6 Tested up to: 5. 17 Stable tag: 1. 06 Tested up to: 5.8 7 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 68 68 == Changelog == 69 69 70 = 1.1 = 71 * Added compatibility with PHP 7. 72 70 73 = 1.0 = 71 74 * Original release. -
igefilter/trunk/readme_en.txt
r2039180 r2626359 4 4 Tags: bible, biblia, scripture, szentiras 5 5 Requires at least: 3.1 6 Tested up to: 5. 17 Stable tag: 1. 06 Tested up to: 5.8 7 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 74 74 == Changelog == 75 75 76 = 1.1 = 77 * Added compatibility with PHP 7. 78 76 79 = 1.0 = 77 80 * Original release.
Note: See TracChangeset
for help on using the changeset viewer.