[Mapbender-commits] r6929 - in trunk/mapbender/http: classes javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Sep 22 10:00:03 EDT 2010


Author: christoph
Date: 2010-09-22 14:00:03 +0000 (Wed, 22 Sep 2010)
New Revision: 6929

Modified:
   trunk/mapbender/http/classes/class_elementVar.php
   trunk/mapbender/http/classes/class_wmc.php
   trunk/mapbender/http/javascripts/initWmcObj.php
   trunk/mapbender/http/javascripts/mod_savewmc.js
Log:
http://trac.osgeo.org/mapbender/ticket/667

http://www.mapbender.org/index.php?title=GET-Parameter&oldid=16933

Modified: trunk/mapbender/http/classes/class_elementVar.php
===================================================================
--- trunk/mapbender/http/classes/class_elementVar.php	2010-09-22 11:06:38 UTC (rev 6928)
+++ trunk/mapbender/http/classes/class_elementVar.php	2010-09-22 14:00:03 UTC (rev 6929)
@@ -25,7 +25,8 @@
 	/**
 	 * Constructor
 	 * @param $application String 	name of the application
-	 * @param $element String 	name of the element
+	 * @param $element String		name of the element
+	 * @param $name String			name of the element var
 	 */
 	public function __construct () {
 		if (func_num_args() === 3) {

Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php	2010-09-22 11:06:38 UTC (rev 6928)
+++ trunk/mapbender/http/classes/class_wmc.php	2010-09-22 14:00:03 UTC (rev 6929)
@@ -1109,7 +1109,9 @@
 		$this->xml = $data;
 	
 		$values = administration::parseXml($data);
-
+		if (!$values) {
+			throw new Exception("WMC document could not be parsed.");
+		}
 		//
 		// Local variables that indicate which section of the WMC
 		// is currently parsed.

Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php	2010-09-22 11:06:38 UTC (rev 6928)
+++ trunk/mapbender/http/javascripts/initWmcObj.php	2010-09-22 14:00:03 UTC (rev 6929)
@@ -6,23 +6,10 @@
 require_once dirname(__FILE__)."/../classes/class_wmc.php";
 require_once dirname(__FILE__)."/../classes/class_administration.php";
 require_once dirname(__FILE__)."/../../lib/class_GetApi.php";
+require_once dirname(__FILE__)."/../classes/class_elementVar.php";
 
-$wmc = new wmc();
-
-//check if session contains a wmc, otherwise create a new wmc from application
-if (!Mapbender::session()->get("mb_wmc")) {
-	$e = new mb_notice("wmc not set, generating from app: " .
-			Mapbender::session()->get("mb_user_gui"));
-	$wmc->createFromApplication(Mapbender::session()->get("mb_user_gui"));
-}
-else {
-	if (!$wmc->createFromXml(Mapbender::session()->get("mb_wmc"))) {
-		$e = new mb_notice("error creating initial WMC from session.");
-	}
-}
-
 function getConfiguration ($key) {
-	//check if key param can be found in SESSION, 
+	//check if key param can be found in SESSION,
 	// otherwise take it from GET
 	if (Mapbender::session()->exists($key)) {
 		return Mapbender::session()->get($key);
@@ -30,6 +17,35 @@
 	return $_GET[$key];
 }
 
+$wmc = new wmc();
+
+$firephp->log($_SESSION);
+
+$app = Mapbender::session()->get("mb_user_gui");
+$wmcDocSession = Mapbender::session()->get("mb_wmc");
+
+try {
+	$loadFromSession = new ElementVar($app, "loadwmc", "loadFromSession");
+	if ($loadFromSession->value === "1") {
+		//check if session contains a wmc, otherwise create a new wmc from application
+		$e = new mb_notice("trying to load session WMC...");
+		if (!$wmc->createFromXml($wmcDocSession)) {
+			$e = new mb_notice("loading session WMC failed.");
+			$e = new mb_notice("creating wmc from app: " . $app);
+			$wmc->createFromApplication($app);
+		}
+	}
+	else {
+		$e = new mb_notice("loading from session WMC disabled in loadwmc.");
+		$e = new mb_notice("creating wmc from app: " . $app);
+		$wmc->createFromApplication($app);
+	}
+}
+catch (Exception $e) {
+	$e = new mb_notice("creating wmc from app: " . $app);
+	$wmc->createFromApplication($app);
+}
+
 $options = array();
 if (Mapbender::session()->exists("addwms_showWMS")) {
 	$options["show"] = intval(Mapbender::session()->get("addwms_showWMS"));

Modified: trunk/mapbender/http/javascripts/mod_savewmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.js	2010-09-22 11:06:38 UTC (rev 6928)
+++ trunk/mapbender/http/javascripts/mod_savewmc.js	2010-09-22 14:00:03 UTC (rev 6929)
@@ -55,7 +55,8 @@
 // init element_vars
 //
 var overwrite = options.overwrite || false;
-var saveInSession = typeof options.saveInSession === "undefined" ? 0 : options.saveInSession;
+var saveInSession = typeof options.saveInSession === "undefined" ?
+	0 : options.saveInSession;
 if (typeof originalI18nObj !== "object") {
 	var originalI18nObj = {};
 }



More information about the Mapbender_commits mailing list