Index: /gli/trunk/client-gli.bat
===================================================================
--- /gli/trunk/client-gli.bat	(revision 19387)
+++ /gli/trunk/client-gli.bat	(revision 19388)
@@ -3,8 +3,9 @@
 CD /D "%~dp0"
 set GLILANG=en
+set GLIMODE=client
 
-if "%PROGNAME" == "" set PROGNAME=Greenstone
+if "%PROGNAME%" == "" set PROGNAME=Greenstone
 
-if not "%PROGFULLNAME" == "" goto setvars
+if not "%PROGFULLNAME%" == "" goto setvars
 if "%GLILANG%" == "es" set PROGFULLNAME="Biblioteca Digital Greenstone"  
 if "%GLILANG%" == "fr" set PROGFULLNAME="Bibliothécaire Greenstone"
@@ -37,32 +38,12 @@
 
 :findGSDL
-echo.
-if "%GLILANG%" == "en" echo %PROGNAME_EN% (%PROGABBR%)
-if "%GLILANG%" == "en" echo Copyright (C) 2008, New Zealand Digital Library Project, University Of Waikato
-if "%GLILANG%" == "en" echo %PROGABBR% comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
-if "%GLILANG%" == "en" echo This is free software, and you are welcome to redistribute it
-
-if "%GLILANG%" == "es" echo Interfaz de la %PROGFULLNAME% (%PROGNAME_EN% - %PROGABBR%)
-if "%GLILANG%" == "es" echo Copyright (C) 2008, New Zealand Digital Library Project, University Of Waikato
-if "%GLILANG%" == "es" echo La Interfaz de la %PROGFULLNAME% NO INCLUYE ABSOLUTAMENTE NINGUNA GARANTÖA.
-if "%GLILANG%" == "es" echo Para mayor informaci¢n vea los trminos de la licencia en LICENSE.txt
-if "%GLILANG%" == "es" echo Este es un software abierto, por lo que lo invitamos a que lo distribuya de forma gratuita
-
-if "%GLILANG%" == "fr" echo Interface du %PROGFULLNAME% (%PROGNAME_EN% - %PROGABBR%)
-if "%GLILANG%" == "fr" echo Copyright (C) 2008, New Zealand Digital Library Project, University Of Waikato
-if "%GLILANG%" == "fr" echo %PROGABBR% est fourni sans AUCUNE GARANTIE; pour des dtails, voir LICENSE.txt
-if "%GLILANG%" == "fr" echo Ceci est un logiciel libre, et vous tes invit 
- le redistribuer
-
-if "%GLILANG%" == "ru" echo š¡«š®â¥ç­ë© š­â¥àä¥©á %PROGNAME% (%PROGNAME_EN% - %PROGABBR%)
-if "%GLILANG%" == "ru" echo Copyright (C) 2008, New Zealand Digital Library Project, University Of Waikato
-if "%GLILANG%" == "ru" echo  ­¥ € ¥â   ; €¥â «š á¬. ¢ â¥ªáâ¥ LICENSE.TXT
-if "%GLILANG%" == "ru" echo â® - á¢®¡®€­® à á¯à®áâà ­ï¥¬®¥ ¯à®£à ¬¬­®¥ ®¡¥á¯¥ç¥­š¥ š ë ¬®Š¥â¥ à á¯à®áâà ­ïâì ¥£®
-
-
-:: If there's a gs2build directory nested inside client-gli, then we can
-:: download and build locally, but ONLY if we have perl. Else building
-:: will have to be done remotely. If Perl is found, PERLPATH will be set.
-if not exist gs2build\nul goto findJava
+:: Try to detect a local GSDLHOME installation (gs2build). If none can be
+:: found, then client-gli won't have a download panel. We're calling 
+:: findgsdl.bat purely for knowing if there's a GSDLHOME around and to set and
+:: use that for downloading. If there IS a local GSDLHOME, then we can download
+:: (and build) locally, but ONLY if we have perl. Else downloading and building
+:: will have to be done remotely anyway. If Perl is found, PERLPATH will be set.
+call findgsdl.bat
+if "%GSDLHOME%" == "" goto findJava
 	call findperl.bat
 
@@ -109,12 +90,15 @@
 
 
-:: If there was a gs2build directory inside the client-gli folder, we'd have looked for Perl.
-:: If we had found Perl, PERLPATH would have been set. If no perl, can't download or build locally
-:: on the client side. If we have Perl, pass the gs2build dir with the -gsdl flag and the PERLPATH.
-if "%PERLPATH%" == "" goto :nogsdl
-	"%JAVA_EXECUTABLE%" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar org.greenstone.gatherer.GathererProg -use_remote_greenstone -gsdl %~dp0gs2build -perl %PERLPATH% %1 %2 %3 %4 %5 %6 %7 %8 %9
+:: If there a local GS2 installation (GSDLHOME set), we'd have looked for Perl. If we had
+:: found Perl, PERLPATH would have been set. If no perl, can't download or build locally on
+:: the client side. If we have Perl, pass the gs2build dir with the -gsdl flag and the PERLPATH.
+if "%PERLPATH%" == "" goto nogsdl
+	echo Perl and GSDLHOME (%GSDLHOME%) detected. Downloading is enabled.
+	echo.
+	"%JAVA_EXECUTABLE%" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar org.greenstone.gatherer.GathererProg -use_remote_greenstone -gsdl "%GSDLHOME%" -perl "%PERLPATH%" %1 %2 %3 %4 %5 %6 %7 %8 %9
 	goto finish
 
 :nogsdl
+echo Since there's no GSDLHOME, client-GLI's download panel will be deactivated.
 "%JAVA_EXECUTABLE%" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar org.greenstone.gatherer.GathererProg -use_remote_greenstone %1 %2 %3 %4 %5 %6 %7 %8 %9
 
@@ -133,5 +117,9 @@
 :: ---- Clean up ----
 set PERLPATH=
-set JAVAPATH=
 set JAVA_EXECUTABLE=
+set GLIMODE=
+set PROGNAME=
+set PROGNAME_EN=
+set PROGFULLNAME=
+set PROGABBR=
 popd
Index: /gli/trunk/findgsdl.bat
===================================================================
--- /gli/trunk/findgsdl.bat	(revision 19388)
+++ /gli/trunk/findgsdl.bat	(revision 19388)
@@ -0,0 +1,169 @@
+:: By the time this script is called by gli.bat, PROGNAME, 
+:: PROGABBR and GLILANG would be set.
+
+:: At the end of this script, GSDLHOME (and possibly GSDL3SRCHOME, GSDL3HOME)
+:: will have been set if a local GS installation was found. If not found, then 
+:: GSDLHOME would not have been set.
+
+:findGSDL
+echo.
+if "%GLILANG%" == "en" (
+		echo %PROGNAME% ^(%PROGABBR%^)
+		echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
+		echo %PROGABBR% comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
+		echo This is free software, and you are welcome to redistribute it
+	)
+
+if "%GLILANG%" == "es" (
+		echo Interfaz de la %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
+		echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
+		echo La Interfaz de la %PROGNAME% NO INCLUYE ABSOLUTAMENTE NINGUNA GARANTÖA.
+		echo Para mayor informaci¢n vea los trminos de la licencia en LICENSE.txt
+		echo Este es un software abierto, por lo que lo invitamos a que lo distribuya de forma gratuita
+	)
+
+if "%GLILANG%" == "fr" (
+		echo Interface du %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
+		echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
+		echo %PROGABBR% est fourni sans AUCUNE GARANTIE; pour des dtails, voir LICENSE.txt
+		echo Ceci est un logiciel libre, et vous tes invit 
+ le redistribuer
+	)
+
+if "%GLILANG%" == "ru" (
+		echo š¡«š®â¥ç­ë© š­â¥àä¥©á %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
+		echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
+		echo  ­¥ € ¥â   ; €¥â «š á¬. ¢ â¥ªáâ¥ LICENSE.TXT
+		echo â® - á¢®¡®€­® à á¯à®áâà ­ï¥¬®¥ ¯à®£à ¬¬­®¥ ®¡¥á¯¥ç¥­š¥ š ë ¬®Š¥â¥ à á¯à®áâà ­ïâì ¥£®
+	)
+
+echo.
+::  ---- Determine path to Greenstone home for GS2 and GS3 ----
+set GSDLPATH=
+:: Some users may set the above line manually, or it may be set as an argument
+
+set _VERSION=
+if not "%GSDLPATH%" == "" goto getVer
+	:: Otherwise gsdlpath is not yet set
+	:: Check the env vars first 
+	if not "%GSDL3SRCHOME%" == "" goto ver3
+		if not "%GSDLHOME%" == "" goto ver2
+			:: If not set, the default location for the GLI is a subdirectory of Greenstone
+			set GSDLPATH=..
+			goto getVer				
+
+:getVer
+call gsdlver.bat %GSDLPATH% %_VERSION%
+:: Stand-alone GLI with no Greenstone installation to be detected
+:: otherwise
+if "%_VERSION%" == "1" goto noVer
+	::if we are running GS2, free up any pre-set GS3 environment variables since we won't need them
+	if "%_VERSION%" == "2" set GSDL3SRCHOME=
+	if "%_VERSION%" == "2" set GSDL3HOME=
+	goto testGSDL
+	:: else _VERSION is 3, we continue:
+
+:ver3
+set _VERSION=3
+set GSDLPATH=%GSDL3SRCHOME%
+:: if GS2 is now also set, then both GS3 and GS2 are set: 
+:: warn the user that we have defaulted to GS3
+if not "%GSDLHOME%" == "" (
+		echo Both Greenstone 2 and Greenstone 3 environments are set.
+		echo It is assumed you want to run Greenstone 3.
+		echo If you want to run Greenstone 2, please unset the
+		echo environment variable GSDL3SRCHOME before running GLI.
+		echo.
+	)
+goto testGSDL
+
+:ver2
+set _VERSION=2
+set GSDLPATH=%GSDLHOME%
+::free up the GS3 environment variables since we are running GS2 and don't need them
+set GSDL3SRCHOME=
+set GSDL3HOME=
+goto testGSDL
+
+:noVer
+if "%GLIMODE%" == "local" if "%GLILANG%" == "en" echo Error: can't determine which Greenstone version is being run.
+if "%GLIMODE%" == "client" if "%GLILANG%" == "en" echo Could not detect a Greenstone installation (no GSDLHOME).
+goto exit
+
+:testGSDL
+set CHECK=1
+call chkinst.bat "%GSDLPATH%" %_VERSION% %GLILANG% %CHECK% > nul
+if "%CHECK%" == "1" goto exit
+	:: otherwise installation worked well
+	goto prepGSDL
+
+
+:prepGSDL
+:: Greenstone 3 case
+if "%_VERSION%" == "3" goto prepGS3
+
+if not "%_VERSION%" == "2" echo "Greenstone version unknown"
+if not "%_VERSION%" == "2" goto exit
+
+:: Otherwise, we are dealing with Greenstone 2
+:: Setup Greenstone 2, unless it has already been done
+if not "%GSDLHOME%" == "" goto doneGSDL
+    call "%GSDLPATH%\setup.bat" SetEnv
+    goto doneGSDL
+
+
+:prepGS3
+set GSDL2PATH=
+:: Some users may set the above line manually
+
+if "%GSDL3SRCHOME%" == "" goto setup3
+	if "%GSDL3HOME%" == "" goto setup3
+		::otherwise
+		goto gs2build
+
+
+:setup3
+:: Setup Greenstone 3, unless it has already been done
+    cd | winutil\setvar.exe GLIDIR > %TMP%\setgli.bat
+    call %TMP%\setgli.bat
+    del %TMP%\setgli.bat
+    cd "%GSDLPATH%"
+    call gs3-setup.bat SetEnv
+    cd %GLIDIR%
+    goto gs2build
+
+
+:gs2build
+	:: If Greenstone version 3 is running, we want to set gsdl2path
+	:: Determine GSDLHOME for GS3 
+	if not "%GSDL2PATH%" == "" goto setupGS2
+		:: GSDL2PATH is not yet set. 
+		:: And if GSDLHOME is not set either, then assume 
+		:: that the gs2build subdir of GS3 exists
+		if "%GSDLHOME%" == "" set GSDL2PATH=%GSDL3SRCHOME%\gs2build
+		if "%GSDLHOME%" == "" goto setupGS2	
+			:: Otherwise GSDLHOME is set, so set GSDL2PATH to GSDLHOME
+			echo GSDLHOME environment variable is set to %GSDLHOME%.	
+			echo Will use this to find build scripts.
+			set GSDL2PATH=%GSDLHOME%
+
+:setupGS2
+set CHECK=1
+call chkinst.bat "%GSDL2PATH%" 2 %GLILANG% %CHECK% > nul
+if "%CHECK%" == "1" goto exit
+	:: otherwise installation worked well
+	:: Setup Greenstone, unless it has already been done
+	if "%GSDLHOME%" == "" call "%GSDL2PATH%\setup.bat" SetEnv
+	:: Either way, we can now dispose of GSDL2PATH
+	set GSDL2PATH=	
+	goto doneGSDL
+
+
+:exit
+:: if exit, then something went wrong. GSDLHOME would be empty already
+
+:doneGSDL
+:: GSDLPATH is no longer needed, since GSDLHOME should now be set
+set GSDLPATH=
+set CHECK=
+set GLIDIR=
Index: /gli/trunk/gli.bat
===================================================================
--- /gli/trunk/gli.bat	(revision 19387)
+++ /gli/trunk/gli.bat	(revision 19388)
@@ -4,5 +4,7 @@
 CD /D "%~dp0"
 set GLILANG=en
+echo "%~dp0"
 
+if "%GLIMODE%" == "" set GLIMODE=local
 
 ::  -------- Run the Greenstone Librarian Interface --------
@@ -38,155 +40,8 @@
 if "%PROGNAME_EN%" == "" set PROGNAME_EN=Greenstone Librarian Interface
 
+:: Now need to work out the _VERSION, GSDLHOME (and if GS3, then GSDL3SRCHOME and GSDL3HOME)
 :findGSDL
-echo.
-if "%GLILANG%" == "en" (
-		echo %PROGNAME% ^(%PROGABBR%^)
-		echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
-		echo %PROGABBR% comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
-		echo This is free software, and you are welcome to redistribute it
-	)
-
-if "%GLILANG%" == "es" (
-		echo Interfaz de la %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
-		echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
-		echo La Interfaz de la %PROGNAME% NO INCLUYE ABSOLUTAMENTE NINGUNA GARANTÖA.
-		echo Para mayor informaci¢n vea los trminos de la licencia en LICENSE.txt
-		echo Este es un software abierto, por lo que lo invitamos a que lo distribuya de forma gratuita
-	)
-
-if "%GLILANG%" == "fr" (
-		echo Interface du %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
-		echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
-		echo %PROGABBR% est fourni sans AUCUNE GARANTIE; pour des dtails, voir LICENSE.txt
-		echo Ceci est un logiciel libre, et vous tes invit 
- le redistribuer
-	)
-
-if "%GLILANG%" == "ru" (
-		echo š¡«š®â¥ç­ë© š­â¥àä¥©á %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
-		echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
-		echo  ­¥ € ¥â   ; €¥â «š á¬. ¢ â¥ªáâ¥ LICENSE.TXT
-		echo â® - á¢®¡®€­® à á¯à®áâà ­ï¥¬®¥ ¯à®£à ¬¬­®¥ ®¡¥á¯¥ç¥­š¥ š ë ¬®Š¥â¥ à á¯à®áâà ­ïâì ¥£®
-	)
-
-echo.
-::  ---- Determine path to Greenstone home for GS2 and GS3 ----
-set GSDLPATH=
-:: Some users may set the above line manually, or it may be set as an argument
-
-set _VERSION=
-if not "%GSDLPATH%" == "" goto getVer
-	:: Otherwise gsdlpath is not yet set
-	:: Check the env vars first 
-	if not "%GSDL3SRCHOME%" == "" goto ver3
-		if not "%GSDLHOME%" == "" goto ver2
-			:: If not set, the default location for the GLI is a subdirectory of Greenstone
-			set GSDLPATH=..
-			goto getVer
-
-:getVer
-call gsdlver.bat %GSDLPATH% %_VERSION% > nul
-if "%_VERSION%" == "1" goto exit
-::if we are running GS2, free up any pre-set GS3 environment variables since we won't need them
-if "%_VERSION%" == "2" set GSDL3SRCHOME=
-if "%_VERSION%" == "2" set GSDL3HOME=
-goto testGSDL
-
-
-:ver3
-set _VERSION=3
-set GSDLPATH=%GSDL3SRCHOME%
-:: if GS2 is now also set, then both GS3 and GS2 are set: 
-:: warn the user that we have defaulted to GS3
-if not "%GSDLHOME%" == "" echo Both Greenstone 2 and Greenstone 3 environments are set.
-if not "%GSDLHOME%" == "" echo It is assumed you want to run Greenstone 3.
-if not "%GSDLHOME%" == "" echo If you want to run Greenstone 2, please unset the
-if not "%GSDLHOME%" == "" echo environment variable GSDL3SRCHOME before running GLI.
-if not "%GSDLHOME%" == "" echo.
-goto testGSDL
-
-
-:ver2
-set _VERSION=2
-set GSDLPATH=%GSDLHOME%
-::free up the GS3 environment variables since we are running GS2 and don't need them
-set GSDL3SRCHOME=
-set GSDL3HOME=
-goto testGSDL
-
-
-:testGSDL
-set CHECK=1
-call chkinst.bat "%GSDLPATH%" %_VERSION% %GLILANG% %CHECK% > nul
-if "%CHECK%" == "1" goto exit
-	:: otherwise installation worked well
-	goto prepGSDL
-
-
-:prepGSDL
-:: Greenstone 3 case
-if "%_VERSION%" == "3" goto prepGS3
-
-if not "%_VERSION%" == "2" echo "Greenstone version unknown"
-if not "%_VERSION%" == "2" goto exit
-
-:: Otherwise, we are dealing with Greenstone 2
-:: Setup Greenstone 2, unless it has already been done
-if not "%GSDLHOME%" == "" goto doneGSDL
-    call "%GSDLPATH%\setup.bat" SetEnv
-    goto doneGSDL
-
-
-:prepGS3
-set GSDL2PATH=
-:: Some users may set the above line manually
-
-if "%GSDL3SRCHOME%" == "" goto setup3
-	if "%GSDL3HOME%" == "" goto setup3
-		::otherwise
-		goto gs2build
-
-
-:setup3
-:: Setup Greenstone 3, unless it has already been done
-    cd | winutil\setvar.exe GLIDIR > %TMP%\setgli.bat
-    call %TMP%\setgli.bat
-    del %TMP%\setgli.bat
-    cd "%GSDLPATH%"
-    call gs3-setup.bat SetEnv
-    cd %GLIDIR%
-    goto gs2build
-
-
-:gs2build
-	:: If Greenstone version 3 is running, we want to set gsdl2path
-	:: Determine GSDLHOME for GS3 
-	if not "%GSDL2PATH%" == "" goto setupGS2
-		:: GSDL2PATH is not yet set. 
-		:: And if GSDLHOME is not set either, then assume 
-		:: that the gs2build subdir of GS3 exists
-		if "%GSDLHOME%" == "" set GSDL2PATH=%GSDL3SRCHOME%\gs2build
-		if "%GSDLHOME%" == "" goto setupGS2	
-			:: Otherwise GSDLHOME is set, so set GSDL2PATH to GSDLHOME
-			echo GSDLHOME environment variable is set to %GSDLHOME%.	
-			echo Will use this to find build scripts.
-			set GSDL2PATH=%GSDLHOME%
-
-:setupGS2
-set CHECK=1
-call chkinst.bat "%GSDL2PATH%" 2 %GLILANG% %CHECK% > nul
-if "%CHECK%" == "1" goto exit
-	:: otherwise installation worked well
-	:: Setup Greenstone, unless it has already been done
-	if "%GSDLHOME%" == "" call "%GSDL2PATH%\setup.bat" SetEnv
-	:: Either way, we can now dispose of GSDL2PATH
-	set GSDL2PATH=	
-	goto doneGSDL
-
-
-:doneGSDL
-:: GSDLPATH is no longer needed, since GSDLHOME should now be set
-set GSDLPATH=
-
+call findgsdl.bat
+if "%GSDLHOME%" == "" goto exit
 
 :: Now need to find Perl. If found, PERLPATH will be set
@@ -311,4 +166,9 @@
 set PERLPATH=
 set JAVA_EXECUTABLE=
+set GLIMODE=
+set PROGNAME=
+set PROGNAME_EN=
+set PROGFULLNAME=
+set PROGABBR=
 color 07
 popd
