[Mapbender-commits] r1669 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Sep 17 10:51:13 EDT 2007


Author: christoph
Date: 2007-09-17 10:51:13 -0400 (Mon, 17 Sep 2007)
New Revision: 1669

Modified:
   trunk/mapbender/http/php/mb_listWMCs.php
Log:
load wmc from a file

Modified: trunk/mapbender/http/php/mb_listWMCs.php
===================================================================
--- trunk/mapbender/http/php/mb_listWMCs.php	2007-09-11 19:10:28 UTC (rev 1668)
+++ trunk/mapbender/http/php/mb_listWMCs.php	2007-09-17 14:51:13 UTC (rev 1669)
@@ -24,6 +24,7 @@
 $wmcId = $_GET["wmc_id"];
 
 $delWmcId = $_POST["del_wmc_id"];
+$clientFilename = $_FILES['local_wmc_filename']['tmp_name'];
 
 $form_target = $_SERVER["PHP_SELF"] . "?" . SID;
 
@@ -51,7 +52,7 @@
 
 <?php
 function mb_listWMCs($wmcIdArray, $form_target){
-	$display = "<h2 style='font-family: Arial, Helvetica, sans-serif; color: #808080;background-color: White;'><font align='left' color='#000000'>Ma</font><font color='#0000CE'>p</font><font color='#C00000'>b</font><font color='#000000'>ender WMC list</font></h2>";
+	$display = "<h2 style='font-family: Arial, Helvetica, sans-serif; color: #808080;background-color: White;'><font align='left' color='#000000'>load WMC from list</font></h2>";
 	$display .= "<table width='90%' style='font-family: Arial, Helvetica, sans-serif;font-size : 12px;color: #808080;' border='1' cellpadding='3' rules='rows'><tr style='background-color:#F0F0F0;' width='80px'><td ><b>WMC name</b></td><td><b>last update</b></td><td colspan=5></td></tr>";
 
 	if (count($wmcIdArray) > 0) {
@@ -118,6 +119,16 @@
 	}
 }
 
+function loadFile($filename) {
+	$handle = fopen($filename, "r");
+	$cnt = 0;
+	while (!feof($handle)) {
+    	$buffer .= fgets($handle, 4096);
+	}
+	fclose ($handle);
+	return $buffer;
+}
+
 $admin = new administration();
 $wmcIdArray = $admin->getWmcByOwner($user_id);
 
@@ -129,7 +140,35 @@
 		echo "</script>";
 	}
 }
+elseif ($clientFilename) {
+	$serverFilename = "../tmp/wmc" . time() . ".xml";
+	copy($clientFilename, $serverFilename);
+	
+	$wmc = new wmc();
+	$wmc->createObjFromWMC_xml(loadFile($serverFilename));
+	
+	$mytarget = getTarget($gui_id);
+	$js = $wmc->createJsObjFromWMC("window.opener.", $mytarget, "load");
+	echo "<script language='javascript'>";
+	echo $js;
+	if ($wmc->getTitle()) {
+		$title = "'" . $wmc->getTitle() . "' ";
+	}
+	echo "alert(\"WMC " . $title . ": load successful.\");\n";
+	echo "window.close();";
+	echo "</script>";
+}
 
+// load a WMC from file
+?>
+<h2 style='font-family: Arial, Helvetica, sans-serif; color: #808080;background-color: White;'><font align='left' color='#000000'>load WMC from file</font></h2>
+<form enctype="multipart/form-data" action="<?php echo $form_target;?>" method=POST target="_self"> 
+<input type='file' name='local_wmc_filename'>
+<input type='submit' value='load'>
+</form>
+<?php
+
+// load a WMC from list
 echo mb_listWMCs($wmcIdArray, $form_target);
 		
 if ($wmcId && in_array($wmcId, $wmcIdArray)){



More information about the Mapbender_commits mailing list