[sword-devel] Web Interface

Daniel Adams sword-devel@crosswire.org
Fri, 21 Feb 2003 16:06:40 -0700

This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable

	I don't know if you remember, but David Woods and I had discussed
somehow redoing the diatheke interface into the SWORD Library, but my
primary interest is in the concordance project that I am working on. If =
are possibly going to do this via PHP for websites, I am rather curious =
it is possible to get a function to return an array of the different =
names and a function to return a single verses text. I do already have =
of how I am desiring to do this, my goal of it is so that I can link =
into it
directly from my project and not have to use diatheke.exe. If these =
don't make sense, or if they do and you might want more elaboration of
exactly which functions I am thinking of, please let me know.

I did write a PHP file to be able to extract the module names and also =
texts from the diatheke.exe program, but I still desire to be able to
reference directly into the Libraries to get the stuff, thus it might be

I attached the PHP file that I have used, in it there is a large section
commented out because I have not taken the time to deal with the stuff =
regex and the idea of how it links to the Strong's text.

I also have interest in the ability to display GenBooks on a website/PHP
format specifically one verse at a time, such as with the BoM module. I
would be able to reference the module however needed, so format of the
search key for the BoM stuff isn't entirely necessary.

By the Grace of God,
Dan Adams - infoChi@infomagic.net

  1 Peter 4:10 (NIV)-  Each one should use whatever gift he has received =
serve others, faithfully administering God's grace in its various forms.

-----Original Message-----
From: sword-devel-admin@crosswire.org
[mailto:sword-devel-admin@crosswire.org] On Behalf Of Troy A. Griffitts
Sent: Friday, February 21, 2003 3:10 PM
To: sword-devel@crosswire.org
Subject: [sword-devel] Web Interface

Currently, I'm planning to spend next month working on a web interface=20
to the sword engine.

I'd love to get input on what features you like/use from other sites,=20
and what you would like a web interface to a Bible study tool to look =

Please consider GenBook support, as well.  What would a general book=20
reader look like for the web?

I'd love any time you have to help design and implement this.

	Thank you,

sword-devel mailing list

Content-Type: application/octet-stream;
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;

class Diatheke {
	var $Cmd_Str;
	function Diatheke($Cmd_Str) {
		$this->Cmd_Str =3D $Cmd_Str;
	function ModNames(&$Ret, $Type) {
		static $Abbrev, $Name, $Spot, $Spots; // Using Session Variables more =
HD used though rather than time
		$Go =3D false;

		if (!is_array($Spot)) {	// Make Arrays
			$Abbrev =3D array();
			$Name =3D array();
			$Spot =3D array();
			$Spots =3D array();

			$ML =3D "$Cmd_Str -b system -k modulelist";
			$MLN =3D $ML . "names";
			$A =3D 0; $B =3D 0; // Counters
			$Num_Types =3D 2;
			$Counter =3D 0;

			exec($ML, $ML_A);
			exec($MLN, $ML_B);

			while ($Counter <=3D $Num_Types) {
				array_push($Spots, $ML_A[$A]);

				while (!strncmp($ML_A[$A], $ML_B[$B], 2)) {
					array_push($Abbrev, $ML_B[$B]);
					$str =3D substr_replace($ML_A[$A], '', 0, strlen("$ML_B[$B] : "));
					array_push($Name, $str);

					$A++; $B++;
					if (!array_key_exists($B, $ML_B)) break;
				array_push($Spot, $B);

		if ($Type =3D=3D 0) $Ret =3D $Abbrev;
		if ($Type =3D=3D 1) $Ret =3D $Name;
		if ($Type =3D=3D 2) $Ret =3D $Spot;
		if ($Type =3D=3D 3) $Ret =3D $Spots;

	function Verse_2($str, &$Ret) {
		exec($str, $out);
		$Ret =3D $out[0];

		// Parse and link to Strong's references if present

	//	$line =3D~ s/<sync type=3D\"Strongs\" value=3D\"\w?H([0-9]+)\"\/>/<a =
	//	$line =3D~ s/<sync type=3D\"Strongs\" value=3D\"\w?G([0-9]+)\"\/>/<a =
	//	$line =3D~ s/<sync type=3D\"Morph\" value=3D\"\w?H([0-9]+)\" \/>/<a =
	//	$line =3D~ s/<sync type=3D\"Morph\" value=3D\"\w?G([0-9]+)\" \/>/<a =
	/*	$line =3D~ s/<sync type=3D\"Morph\" value=3D\"([^\"]+)\" \/>/<a =
		$line =3D~ s/<sync type=3D\"([^\"]+)\" value=3D\"([^\"]+)\" \/>/<a =
href=3D\"diatheke.pl?verse=3D$2&$1=3Don\">&lt;$1 $2&gt;\<\/a\>/g;

		$line =3D~ s/<note [^>]+>/<small>{/g;
		$line =3D~ s/<\/note[^>]*>/}<\/small>/g;

		$info =3D `$diatheke -b info -k $versions[$i]`;
		$info =3D~ /([^\;]+)\;([^\;]+)/;
		$format =3D $1;
		$type =3D $2;

		if ($versions[$i] eq "StrongsHebrew") {
		$line =3D~ s/(see HEBREW for )([0-9]+)/<a =
		elsif($versions[$i] eq "StrongsGreek") {
		$line =3D~ s/(see GREEK for )([0-9]+)/<a =
		#case for searches
		elsif($search ne "") {
		$line =3D~ s/ ([^;\-]+:[^;]+) ([;\-])/urlvers($1, $2, =
		#case for ThML format texts
		elsif($format eq "ThML") {
		$line =3D~ s/<scripRef version=3D\"([^\"]+)\" =
		$line =3D~ s/<\/scripRef>/<\/a>/g;
		#case for non-ThML, non-Bible texts
		elsif($type ne "Biblical Texts") {
		$book =3D $verse; //*/
	//	$book =3D~ s/^([A-Za-z0-9]+) [0-9]+:[0-9]+.*/$1/;
	//	$chapter =3D $verse;
	//	$chapter =3D~ s/[A-Za-z0-9]+ ([0-9]+):[0-9]+.*/$1/;

	//	$line =3D~ s/\#*([1-9]*[A-Z][a-z]+\.*) =
([0-9]+):([0-9]+-*,*[0-9]*)\|*/<a =
href=3D\"diatheke.pl?verse=3D$1+$2%3A$3&$defversion=3Don\">$1 =
	//	$line =3D~ s/\#([0-9]+):([0-9]+-*,*[0-9]*)\|*/<a =
href=3D\"diatheke.pl?verse=3D$book+$1%3A$2&$defversion=3Don\">$book =
	//	$line =3D~ s/\#([0-9]+-*,*[0-9]*)\|*/<a =
	/*    }

		if ($locale ne "abbr") {
		$line =3D~ =
	//	*/

	function Verse($Search, $Version, $Verse, $Of =3D '', $MaxVerses=3D50, =
$Locale=3D'en') {
		$Ret =3D '';

			// Search to perform in this book.
		if ($Search !=3D '') $Search =3D '-s ' . $Search;

		$str =3D "$this->Cmd_Str $Search $Of -m $MaxVerses -f thml -l $Locale =
-b $Version -k $Verse";

		$this->Verse_2($str, $Ret);

		$Ret =3D str_replace("$Verse: ", '', $Ret);
		$Ret =3D str_replace("($Version)", '', $Ret);

		return $Ret;