changeset 255:d9e51ab58503 gmap2

Improve the bootstrap configuration process.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 19 Mar 2014 14:08:17 +0200
parents dc16903bf004
children 85f79c765ab1
files index.php tools/makegmaps.php
diffstat 2 files changed, 32 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/index.php	Wed Mar 19 13:54:47 2014 +0200
+++ b/index.php	Wed Mar 19 14:08:17 2014 +0200
@@ -1,6 +1,12 @@
 <?php
 require "config.inc.php";
 
+if (!isset($pageBaseURL) || !isset($gmapsKey) || !isset($gmapsVersion))
+{
+  echo "Some settings are missing. Please check your configuration."
+  exit;
+}
+
 //
 // Generic settings
 //
@@ -30,9 +36,6 @@
 }
 $pageCSS = "css/mapstyle".$pageCSSIndex.".css";
 
-if (!isset($pageBaseURL))
-  $pageBaseURL = "";
-
 echo
   "<!DOCTYPE html>\n".
   "<html>\n".
--- a/tools/makegmaps.php	Wed Mar 19 13:54:47 2014 +0200
+++ b/tools/makegmaps.php	Wed Mar 19 14:08:17 2014 +0200
@@ -186,13 +186,13 @@
   if (substr($sprefix, 0, 7) != "http://" &&
       substr($sprefix, 0, 8) != "https://")
   {
-    echo "Prefix must start with http:// or https://\n";
+    echo "URL must start with http:// or https://\n";
     return FALSE;
   }
   else
   if (substr($sprefix, -1) != "/")
   {
-    echo "Prefix must end with /\n";
+    echo "URL must end with /\n";
     return FALSE;
   }
   else
@@ -253,6 +253,30 @@
     "You will be asked some information this time, which will be\n".
     "and saved for later use in file '".$gmapsConfig."'\n";
 
+  $sdone = FALSE;
+  while (!$sdone)
+  {
+    $cfg["pageBaseURL"] = stInputPrompt(
+      "Enter base URL for the map page. For example: http://foobar.com/map/\n",
+      FALSE, "stValidateURLPrefix");
+    $sdone = stYesNoPrompt("The page base URL to be used is \"".$cfg["pageBaseURL"]."\", e.g.\n".
+      "index.php would be: \"".$cfg["pageBaseURL"]."index.php\"\n".
+      "Is this correct?");
+    echo "\n";
+  }
+
+  $sdone = FALSE;
+  while (!$sdone)
+  {
+    $cfg["urlTilePrefix"] = stInputPrompt(
+      "Enter URL prefix for tiles. For example: http://foobar.com/map/tiles/\n",
+      $cfg["pageBaseURL"]."tiles/", "stValidateURLPrefix");
+    $sdone = stYesNoPrompt("The URL prefix to be used is \"".$cfg["urlTilePrefix"]."\", e.g.\n".
+      "htaccess to be created would be: \"".$cfg["urlTilePrefix"]."sea.png\"\n".
+      "Is this correct?");
+    echo "\n";
+  }
+
   stQueryConfigItems(1);
   stQueryConfigItems(2);
 
@@ -262,17 +286,6 @@
 
   stQueryConfigItems(3);
 
-  $sdone = FALSE;
-  while (!$sdone)
-  {
-    $cfg["urlTilePrefix"] = stInputPrompt(
-      "Enter URL prefix for tiles. For example: http://foobar.com/map/tiles/\n",
-      FALSE, "stValidateURLPrefix");
-    $sdone = stYesNoPrompt("The URL prefix to be used is \"".$cfg["urlTilePrefix"]."\", e.g.\n".
-      "htaccess to be created would be: \"".$cfg["urlTilePrefix"]."sea.png\"\n".
-      "Is this correct?");
-    echo "\n";
-  }
 
   stOutputToFile($gmapsConfig, "<?\n\$cfg = ".var_export($cfg, TRUE)."\n?>");
 }