[Mapbender-commits] r8084 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Aug 31 04:14:15 EDT 2011


Author: verenadiewald
Date: 2011-08-31 01:14:15 -0700 (Wed, 31 Aug 2011)
New Revision: 8084

Modified:
   trunk/mapbender/http/plugins/mb_print.php
Log:
show printbox when opening print dialog

Modified: trunk/mapbender/http/plugins/mb_print.php
===================================================================
--- trunk/mapbender/http/plugins/mb_print.php	2011-08-31 08:13:51 UTC (rev 8083)
+++ trunk/mapbender/http/plugins/mb_print.php	2011-08-31 08:14:15 UTC (rev 8084)
@@ -3,7 +3,7 @@
  *
  * Description:
  * Mapbender print PDF with PDF templates module.
- * 
+ *
  * Files:
  *  - http/plugins/mb_print.php
  *  - http/print/classes
@@ -12,9 +12,9 @@
  *  - lib/printbox.js
  *
  * SQL:
- * > INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, 
- * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, 
- * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, 
+ * > INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment,
+ * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width,
+ * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file,
  * > e_mb_mod, e_target, e_requires, e_url) VALUES('<appId>','printPDF',
  * > 2,1,'pdf print','Print','div','','',1,1,2,2,5,'',
  * > '<div id="printPDF_working_bg"></div><div id="printPDF_working"><img src="../img/indicator_wheel.gif" style="padding:10px 0 0 10px">Generating PDF</div><div id="printPDF_input"><form id="printPDF_form" action="../print/printFactory.php"><div id="printPDF_selector"></div><div class="print_option"><input type="hidden" id="map_url" name="map_url" value=""/><input type="hidden" id="legend_url" name="legend_url" value=""/><input type="hidden" id="overview_url" name="overview_url" value=""/><input type="hidden" id="map_scale" name="map_scale" value=""/><input type="hidden" name="measured_x_values" /><input type="hidden" name="measured_y_values" /><br /></div><div class="print_option" id="printPDF_formsubmit"><input id="submit" type="submit" value="Print"><br /></div></form><div id="printPDF_result"></div></div>',
@@ -22,8 +22,8 @@
  * > '../../lib/printbox.js,../extensions/jquery-ui-1.7.2.custom/development-bundle/external/bgiframe/jquery.bgiframe.js,../extensions/jquery.form.min.js',
  * > 'mapframe1','','http://www.mapbender.org/index.php/Print');
  * >
- * > INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, 
- * > var_value, context, var_type) VALUES('<appId>', 'printPDF', 
+ * > INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name,
+ * > var_value, context, var_type) VALUES('<appId>', 'printPDF',
  * > 'mbPrintConfig', '{"Standard": "mapbender_template.json"}', '' ,'var');
  * >
  * > INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name,
@@ -45,14 +45,14 @@
  * > INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name,
  * > var_value, context, var_type) VALUES('<appId>', 'body',
  * > 'print_css', '../css/print_div.css', '' ,'file/css');
- * 
+ *
  * Help:
  * http://www.mapbender.org/PrintPDF_with_template
  *
  * Maintainer:
  * http://www.mapbender.org/User:Michael_Schulz
  * http://www.mapbender.org/User:Christoph_Baudson
- * 
+ *
  * Parameters:
  * mbPrintConfig      - *[optional]* object with name and filename of template,
  * 							like 	{
@@ -62,8 +62,8 @@
  *
  * License:
  * Copyright (c) 2009, Open Source Geospatial Foundation
- * This program is dual licensed under the GNU General Public License 
- * and Simplified BSD license.  
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
  * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
  */
 
@@ -99,10 +99,10 @@
 var PrintPDF = function (options) {
 
 	var that = this;
-	
+
 	/**
  	 * Property: actualConfig
-	 * 
+	 *
 	 * object, holds the actual configuration after loading the json file
 	 */
 	var actualConfig;
@@ -113,14 +113,14 @@
 	eventInit.register(function () {
 		mod_printPDF_init();
 	});
-	
+
 	/**
  	 * Property: printBox
-	 * 
+	 *
 	 * the movable printframe
-	 */	
+	 */
 	var printBox = null;
-	
+
 	eventAfterMapRequest.register(function () {
 		if (printBox !== null) {
 			printBox.repaint();
@@ -128,8 +128,8 @@
 	});
 	/**
  	 * Method: createPrintBox
-	 * 
-	 * creates a printBox in the current view, calculates the scale 
+	 *
+	 * creates a printBox in the current view, calculates the scale
 	 * (tbd. if not set from the config) so that the printbox fits in the mapframe.
 	 * Width and height are taken from the configuration.
 	 */
@@ -156,8 +156,8 @@
 				target : myTarget,
 				printWidth : getPDFMapSize("width")/10,
 				printHeight : getPDFMapSize("height")/10,
-				scale : $scaleInput.size() > 0 && !isNaN(parseInt($scaleInput.val(), 10)) ? 
-					parseInt($scaleInput.val(), 10) : 
+				scale : $scaleInput.size() > 0 && !isNaN(parseInt($scaleInput.val(), 10)) ?
+					parseInt($scaleInput.val(), 10) :
 					Math.pow(10, Math.floor(Math.log(map.getScale())/Math.LN10)),
 				afterChangeAngle : function (obj) {
 					if (typeof(obj) == "object") {
@@ -188,12 +188,12 @@
 
 	/**
  	 * Method: getPDFMapSize
-	 * 
+	 *
 	 * checks the actual config for the size w/h values.
 	 *
 	 * Parameters:
 	 * key      - string, the key which value to retrieve (currently width or height)
-	 */	
+	 */
 	var getPDFMapSize = function (key) {
 		for (var page in actualConfig.pages) {
 			for (var pageElement in actualConfig.pages[page].elements) {
@@ -201,28 +201,28 @@
 					return actualConfig.pages[page].elements[pageElement][key];
 				}
 			}
-		} 
+		}
 	};
 
 	/**
  	 * Method: destroyPrintBox
-	 * 
+	 *
 	 * removes an existing printBox.
-	 */	
+	 */
 	var destroyPrintBox = function () {
 		if (printBox) {
 			printBox.destroy();
 		}
 	};
-	
+
 	/**
  	 * Method: mod_printPDF_init
-	 * 
+	 *
 	 * initializes the print modules, generates template chooser and loads first configuration.
-	 */	
+	 */
 	var mod_printPDF_init = function () {
 		/* first we'd need to build the configuration selection */
-		buildConfigSelector();	
+		buildConfigSelector();
 		/* second we'd need to read the json configuration */
 		that.loadConfig(mbPrintConfigFilenames[0]);
 		/* than we need the translation of the print button */
@@ -236,15 +236,15 @@
 
 	/**
  	 * Method: loadConfig
-	 * 
+	 *
 	 * GETs the config, build corresponding form, remove an existing printBox
-	 */		
+	 */
 	this.loadConfig = function (configFilename, callback) {
-		// the dataType to $.get is given explicitely, because there were instances of Mapbender that were returning 
+		// the dataType to $.get is given explicitely, because there were instances of Mapbender that were returning
 		// either json or a string, which trips up $.parseJSON which was being used in the callback
 		$.get(mbPrintConfigPath + configFilename, function(json, status){
 		    actualConfig = json;
-		    buildForm(); 
+		    buildForm();
 		    hookForm();
 			if (typeof callback === "function") {
 				printBox = null;
@@ -256,9 +256,9 @@
 
 	/**
  	 * Method: hookForm
-	 * 
+	 *
 	 * utility method to connect the form plugin to the print form.
-	 */	
+	 */
 	var hookForm = function () {
 		var o = {
 	   		url:			'../print/printFactory.php?e_id='+myId,
@@ -274,9 +274,9 @@
 		};
 		$("#"+myId+"_form").ajaxForm(o);
 	};
-	
+
 	/**
-	 * Change status of the working elements. These should begin with "$myId_working" 
+	 * Change status of the working elements. These should begin with "$myId_working"
 	 *
 	 * @param {String} newStatus either "hide or "show"
 	 */
@@ -285,10 +285,10 @@
 	    	$("[id^='"+myId+"_working']").hide();
 		}
 	    else {
-	    	$("[id^='"+myId+"_working']").show();	
+	    	$("[id^='"+myId+"_working']").show();
 		}
 	};
-	
+
 	/**
 	 * update form values helper function
 	 *
@@ -299,7 +299,7 @@
 				formData[j].value = value;
 				break;
 			}
-		}	
+		}
 	};
 
 	var getCurrentResolution = function (type) {
@@ -374,31 +374,31 @@
 	 */
 	var validate = function (formData, jqForm, params) {
 		showHideWorking("show");
-		
+
 		// map urls
 		var ind = getMapObjIndexByName(myTarget);
 		var f = jqForm[0];
 		f.map_url.value = '';
-		
+
 		var scale = f.scale.value || mb_mapObj[ind].getScale();
 		scale = parseInt(scale, 10);
-		
+
 		var legendUrlArray = [];
 		f.overview_url.value = '';
 		for(var i=0; i < mb_mapObj[ind].wms.length; i++){
 			var currentWms = mb_mapObj[ind].wms[i];
 			if(mb_mapObj[ind].wms[i].gui_wms_visible > 0){
-				if (mb_mapObj[ind].wms[i].mapURL != false && mb_mapObj[ind].wms[i].mapURL != 'false' && mb_mapObj[ind].wms[i].mapURL != ''){   
+				if (mb_mapObj[ind].wms[i].mapURL != false && mb_mapObj[ind].wms[i].mapURL != 'false' && mb_mapObj[ind].wms[i].mapURL != ''){
 					if(f.map_url.value != ""){
 						f.map_url.value += '___';
-					}      
+					}
 					var currentMapUrl = mb_mapObj[ind].getMapUrl(i, mb_mapObj[ind].getExtentInfos(), scale);
-					
+
 					currentMapUrl = replaceMapFileForHighQualityPrint(currentMapUrl, "map");
 					f.map_url.value += currentMapUrl
 
 					var wmsLegendObj = [];
-					
+
 					var layers = currentWms.getLayers(mb_mapObj[ind], scale);
 					for (var j = 0; j < layers.length; j++) {
 						var currentLayer = currentWms.getLayerByLayerName(layers[j]);
@@ -423,7 +423,7 @@
 						var tmpObj = {};
 						tmpObj[currentWms.wms_currentTitle] = wmsLegendObj;
 						legendUrlArray.push(tmpObj);
-					
+
 					}
 				}
 			}
@@ -432,7 +432,7 @@
 		updateFormField(formData, "legend_url", legendUrlArrayJson);
 		updateFormField(formData, "map_url", f.map_url.value);
 		updateFormField(formData, "scale", scale);
-		
+
 		//overview_url
 		var ind_overview = getMapObjIndexByName('overview');
 		if(mb_mapObj[ind_overview].mapURL != false ){
@@ -443,7 +443,7 @@
 
 			updateFormField(formData, "overview_url", f.overview_url.value);
 		}
-		
+
 		updateFormField(formData, "map_scale", mb_getScale(myTarget));
 		// write the measured coordinates
 		if (typeof(mod_measure_RX) !== "undefined") {
@@ -463,9 +463,9 @@
 			}
 			updateFormField(formData, "measured_x_values", tmp_x);
 			updateFormField(formData, "measured_y_values", tmp_y);
-		}	
-		
-		
+		}
+
+
 		if (f.map_url.value!="") {
 			//return true;
 		} else {
@@ -476,16 +476,16 @@
 
 	/**
  	 * Method: showResult
-	 * 
-	 * load the generated PDF from the returned URL as an attachment, 
+	 *
+	 * load the generated PDF from the returned URL as an attachment,
 	 * that triggers a download popup or is displayed in PDF plugin.
-	 */		
+	 */
 	var showResult = function (res, text) {
 		if (text == 'success') {
 			var $downloadFrame = $("#" + myId + "_frame");
 			if ($downloadFrame.size() === 0) {
 				$downloadFrame = $(
-					"<iframe id='" + myId + "_frame' name='" + 
+					"<iframe id='" + myId + "_frame' name='" +
 					myId + "_frame' width='0' height='0' style='display:none'></iframe>"
 				).appendTo("body");
 			}
@@ -502,7 +502,7 @@
 					});
 			}
 			else {
-				window.frames[myId + "_frame"].location.href = 
+				window.frames[myId + "_frame"].location.href =
 					stripslashes(res.outputFileName);
 			}
 			showHideWorking("hide");
@@ -514,11 +514,11 @@
 			$("#"+myId+"_result").html(text);
 		}
 	};
-	
+
 	/**
 	 * Generates form elements as specified in the config controls object.
 	 * Adds the elements before the submit button.
-	 * 
+	 *
 	 * @param {Object} json the config object in json
 	 */
 	var buildForm = function () {
@@ -528,10 +528,10 @@
 			var element = actualConfig.controls[item];
 			var element_id = myId + "_" + element.id;
 			if (element.type != "hidden") {
-				str += '<div class="print_option_dyn">\n';	
+				str += '<div class="print_option_dyn">\n';
 				str += '<label class="print_label" for="'+element.id+'">'+element.label+'</label>\n';
 			} else {
-				str += '<div class="print_option_dyn" style="display:none;">\n';	
+				str += '<div class="print_option_dyn" style="display:none;">\n';
 			}
 			switch (element.type) {
 				case "text":
@@ -539,10 +539,10 @@
 					break;
 				case "hidden":
 					str += '<input type="'+element.type+'" name="'+element.id+'" id="'+element.id+'">\n';
-					break;				
+					break;
 				case "textarea":
 					str += '<textarea id="'+element.id+'" name="'+element.id+'" size="'+element.size+'"></textarea><br>\n';
-					break;				
+					break;
 				case "select":
 					str += '<select id="'+element.id+'" name="'+element.id+'" size="1">\n';
 					for (var option_index in element.options) {
@@ -588,7 +588,7 @@
 			});
 		}
 	};
-	
+
 	/**
 	 * Generates the configuration select element from the gui element vars
 	 * mbPrintConfigFilenames and mbPrintConfigTitles
@@ -605,19 +605,19 @@
 			$("#printPDF_selector").append(str).find("#printPDF_template").change(function () {
 				printObj.loadConfig(mbPrintConfigFilenames[this.selectedIndex], function () {
 					printObj.createPrintBox()
-				});			
+				});
 			});
 			$("#printPDF_handle").click(function () {
 				printObj.createPrintBox();
 			});
-			$("#printPDF_working").bgiframe({ 
+			$("#printPDF_working").bgiframe({
 				src: "BLOCKED SCRIPT'&lt;html&gt;&lt;/html&gt;';",
 				width: 200,
 				height: 200
 			});
 		}
 	};
-	
+
 	var stripslashes = function ( str ) {
 	    return (str+'').replace(/\0/g, '0').replace(/\\([\\'"])/g, '$1');
 	};



More information about the Mapbender_commits mailing list