User:Afaprof01/BibleRef.php
Appearance
<?php
- Bible References
- Version: 1.1
- Modified 7th May 2007 by Matt Dolan
- Links a Bible reference to the text at Biblegateway.com
- You can take advantage of BibleGateway's features such as displaying two references together:
- eg. Matt 28:18-20,2Cor 4
- Tag :
- <bible>ref</bible>
- Example :
- Col 1:15-20
- <bible>Col 1:15-20</bible>
- Soli Deo Gloria!
$wgExtensionFunctions[] = 'wfBibleRef';
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Bible References', 'version' => 1.2, 'description' => 'Links Bible References to BibleGateway.com', 'author' => 'Matt Dolan', 'url' => 'http://www.mediawiki.org/wiki/Extension:BibleRef'
);
function wfBibleRef() {
global $wgParser; $wgParser->setHook('bible', 'linkBibleRef');
}
- The callback function for converting the input text to HTML output
function linkBibleRef($input, $args) {
global $wgBibleRefDefaultVersion; // BibleGateway's Version numbers $versions = array( 'niv-us' => 31, // New International Version (American English) 'niv' => 64, // New International Version (British English) 'nasb' => 49, // North American Standard Bible 'esv' => 47, // English Standard Version 'tniv' => 72, // Today's New International Version 'msg' => 65, // The Message 'nlt' => 51, // New Living Translation 'kjv' => 9, // King James Version 'av' => 9, // Authorised Version (= KJV) 'cev' => 46, // Contemporary English Version 'nkjv' => 50, // New King James Version 'ls' => 2, // Louis Segond 'sem' => 32, // La Bible du Semeur ); // Added functionality for other online Bibles - array values are URLs to search path $nonBGVersions = array( 'net' => 'http://net.bible.org/passage.php?passage=', // Net Bible 'greek' => 'http://www.zhubert.com/bible?source=greek&verseref=', // Original Greek ); $versionText = strtolower($args['ver']); // get the desired version from the XML tag if ($versionText==) // if no version specified in XML tag { if (isset($wgBibleRefDefaultVersion)) { // use the default defined value, if that's set elsewhere if (is_int($wgBibleRefDefaultVersion)) $versionText = $wgBibleRefDefaultVersion; else $versionText = $versions[$wgBibleRefDefaultVersion]; } else // if none if given, default to ESV $versionText = 47; } if ($nonBGVersions[$versionText]!=) { // if the version requested match a non-Bible Gateway one above $output = "<a href='".$nonBGVersions[$versionText].urlencode($input)."' "; } else { if ($versions[$versionText]!=) // if the version requested match one defined above... $version = $versions[$versionText]; // get the BibleGateway version number elseif (is_int($versionText)) // if the given 'ver' tag is an integer, we'll assumed it's a version number $version = $versionText; $output = "<a href='http://www.biblegateway.com/passage/?search=".urlencode($input).";&version=".$version.";' "; } // if 'thisframe' is not specified in the XML tag, load it in a new window if (!isset($args['thiswindow'])) $output .= " target='_blank'"; $output .= ">".htmlspecialchars($input)."</a>"; return $output;
}