[Mapbender-commits] r8580 - in trunk/mapbender: http/plugins http/print lib resources/db/pgsql/UTF-8/update
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Mar 4 02:20:56 PST 2013
Author: verenadiewald
Date: 2013-03-04 02:20:56 -0800 (Mon, 04 Mar 2013)
New Revision: 8580
Modified:
trunk/mapbender/http/plugins/mb_print.php
trunk/mapbender/http/print/A4_landscape_template.json
trunk/mapbender/http/print/A4_landscape_template.odg
trunk/mapbender/lib/printbox.js
trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql
Log:
http://trac.osgeo.org/mapbender/ticket/889 + http://trac.osgeo.org/mapbender/ticket/890
Modified: trunk/mapbender/http/plugins/mb_print.php
===================================================================
--- trunk/mapbender/http/plugins/mb_print.php 2013-03-04 10:19:51 UTC (rev 8579)
+++ trunk/mapbender/http/plugins/mb_print.php 2013-03-04 10:20:56 UTC (rev 8580)
@@ -179,9 +179,29 @@
jqForm[0].scale.value = parseInt(obj.scale / 10, 10) * 10;
}
else {
- $("#scale .addedScale").remove();
- $("#scale").append("<option selected class='addedScale' value='"+parseInt(obj.scale / 10, 10) * 10+"'>1 : " + parseInt(obj.scale / 10, 10) * 10 + "</option>");
- }
+ //$("#scale .addedScale").remove();
+ //$("#scale").append("<option selected class='addedScale' value='"+parseInt(obj.scale / 10, 10) * 10+"'>1 : " + parseInt(obj.scale / 10, 10) * 10 + "</option>");
+
+ var currentScale = parseInt($("#scale").val(), 10);
+ var objScale = parseInt(obj.scale / 10, 10) * 10;
+
+ if(obj.scale != currentScale) {
+ var scaleOptions = [];
+ $("#scale option").each( function() {
+ scaleOptions.push(parseInt(this.value, 10));
+ });
+
+ var closest = getClosestNum(objScale,scaleOptions);
+ $("#scale option[value='"+closest+"']").attr('selected', 'selected');
+ if(printBox) {
+ if(objScale != closest) {
+ printBox.setScale(closest);
+ }
+ }
+ }
+
+
+ }
}
if (obj.coordinates) {
if(typeof(jqForm[0].coordinates) != "undefined") {
@@ -193,9 +213,32 @@
});
printBox.paintPoints();
printBox.paintBox();
-
+ printBox.show();
}
};
+
+ function getClosestNum(num, ar) {
+ var i = 0, closest, closestDiff, currentDiff;
+ if(ar.length)
+ {
+ closest = ar[0];
+ for(i;i<ar.length;i++)
+ {
+ closestDiff = Math.abs(num - closest);
+ currentDiff = Math.abs(num - ar[i]);
+ if(currentDiff < closestDiff)
+ {
+ closest = ar[i];
+ }
+ closestDiff = null;
+ currentDiff = null;
+ }
+ //returns first element that is closest to number
+ return closest;
+ }
+ //no length
+ return false;
+ }
/**
* Method: getPDFMapSize
@@ -228,6 +271,20 @@
};
/**
+ * Change status of printbox
+ *
+ * @param {String} newStatus either "hide or "show"
+ */
+ var showHidePrintBox = function (newStatus) {
+ if (newStatus=="hide") {
+ printBox.hide();
+ }
+ else {
+ printBox.show();
+ }
+ };
+
+ /**
* Method: mod_printPDF_init
*
* initializes the print modules, generates template chooser and loads first configuration.
@@ -551,8 +608,8 @@
stripslashes(res.outputFileName);
}
showHideWorking("hide");
- //remove printbox after successful print
- destroyPrintBox();
+ //remove printbox after successful print
+ //destroyPrintBox();
}
else {
/* something went wrong */
@@ -569,6 +626,9 @@
var buildForm = function () {
$(".print_option_dyn").remove();
var str = "";
+ str += '<input type="hidden" name="printboxScale" id="printboxScale">\n';
+ str += '<input type="hidden" name="printboxCoordinates" id="printboxCoordinates">\n';
+ str += '<input type="hidden" name="printboxAngle" id="printboxAngle">\n';
for (var item in actualConfig.controls) {
var element = actualConfig.controls[item];
var element_id = myId + "_" + element.id;
@@ -600,7 +660,8 @@
str += '<select id="'+element.id+'" name="'+element.id+'" size="1">\n';
for (var option_index in element.options) {
option = element.options[option_index];
- str += '<option value="'+option.value+'">'+option.label+'</option>\n';
+ var selected = option.selected ? option.selected : "";
+ str += '<option '+selected+' value="'+option.value+'">'+option.label+'</option>\n';
}
str += '</select><br>\n';
break;
@@ -627,28 +688,28 @@
return false;
}
- var scale = parseInt(this.value, 10);
+ var scale = parseInt(this.value, 10);
if (isNaN(scale) || typeof printBox === "undefined") {
return true;
}
- if(scale < 10) {
- return true;
- }
+ if(scale < 10) {
+ return true;
+ }
printBox.setScale(scale);
return true;
});
}
else {
$("#scale").change(function (e) {
- var scale = parseInt(this.value, 10);
- if (isNaN(scale) || typeof printBox === "undefined") {
- return true;
- }
-
- if(scale < 10) {
- return true;
- }
+ var scale = parseInt(this.value, 10);
+ if (isNaN(scale) || typeof printBox === "undefined") {
+ return true;
+ }
+
+ if(scale < 10) {
+ return true;
+ }
printBox.setScale(scale);
return true;
});
@@ -692,7 +753,28 @@
});
$("#printPDF_handle").click(function () {
- printObj.createPrintBox();
+ if (printBox) {
+ if(printBox.isVisible()) {
+ showHidePrintBox("hide");
+ $("#printboxScale").val($("#printPDF_form #scale").val());
+ $("#printboxCoordinates").val($("#printPDF_form #coordinates").val());
+ $("#printboxAngle").val($("#printPDF_form #angle").val());
+
+ $("#printPDF_form #scale").val("");
+ $("#printPDF_form #coordinates").val("");
+ $("#printPDF_form #angle").val("");
+ }
+ else {
+ showHidePrintBox("show");
+ $("#printPDF_form #scale").val($("#printboxScale").val());
+ $("#printPDF_form #coordinates").val($("#printboxCoordinates").val());
+ $("#printPDF_form #angle").val($("#printboxAngle").val());
+ }
+ }
+ else {
+ printObj.createPrintBox();
+ }
+
});
$("#printPDF_working").bgiframe({
src: "BLOCKED SCRIPT'<html></html>';",
Modified: trunk/mapbender/http/print/A4_landscape_template.json
===================================================================
--- trunk/mapbender/http/print/A4_landscape_template.json 2013-03-04 10:19:51 UTC (rev 8579)
+++ trunk/mapbender/http/print/A4_landscape_template.json 2013-03-04 10:20:56 UTC (rev 8580)
@@ -1,207 +1,237 @@
-{
- "type" : "templatePDF",
- "orientation" : "L",
- "units" : "mm",
- "format" : "a4",
- "controls" : [
- {
- "id" : "title",
- "label" : "Titel",
- "type" : "text",
- "size" : 20,
- "pageElementsLink" : {
- "titel" : "value"
- }
- },
- {
- "id" : "dpi",
- "label" : "DPI",
- "type" : "select",
- "size" : 20,
- "pageElementsLink" : {
- "karte" : "res_dpi"
- },
- "options" : [
- {
- "value" : "72",
- "label" : "72 dpi"
- },
- {
- "value" : "144",
- "label" : "144 dpi"
- },
- {
- "value" : "288",
- "label" : "288 dpi"
- }
- ]
- },
- {
- "id" : "comment1",
- "label" : "Kommentar1",
- "type" : "textarea",
- "size" : 5,
- "pageElementsLink" : {
- "kommentar1" : "value"
- }
- },
- {
- "id" : "comment2",
- "label" : "Kommentar 2",
- "type" : "textarea",
- "size" : 5,
- "pageElementsLink" : {
- "kommentar2" : "value"
- }
- },
- {
- "id" : "angle",
- "label" : "Winkel",
- "type" : "text",
- "pageElementsLink" : {
- "nordpfeil" : "angle",
- "karte" : "angle",
- "minikarte" : "angle"
- }
- },
- {
- "id" : "coordinates",
- "type" : "hidden"
- },
- {
- "id" : "scale",
- "label" : "Maßstab",
- "type" : "text",
- "pageElementsLink" : {
- "scale" : "value"
- }
- }
- ],
- "pages" : [
- {
- "tpl" : "A4_landscape_template.pdf",
- "useTplPage" : 1,
- "elements" : {
- "karte" : {
- "type" : "map",
- "res_dpi" : 72,
- "x_ul" : 8.8,
- "y_ul" : 13.6,
- "width" : 203.5,
- "height" : 180.8,
- "coords" : 1,
- "coords_font_family" : "Arial",
- "coords_font_size" : 8
- },
- "messung" : {
- "type" : "measure",
- "do_fill" : 0,
- "fill_color" : {
- "r" : 255,
- "g" : 0,
- "b" : 0
- },
- "do_stroke" : 0,
- "stroke_color" : {
- "r" : 0,
- "g" : 0,
- "b" : 0
- },
- "line_style" : {
- "width" : 1.0
- }
- },
- "minikarte" : {
- "type" : "overview",
- "res_dpi" : 72,
- "x_ul" : 222.3,
- "y_ul" : 13.6,
- "width" : 67.5,
- "height" : 60
- },
- "titel" : {
- "type" : "text",
- "x_ul" : 9,
- "y_ul" : 10,
- "font_family" : "Arial",
- "font_size" : 14
- },
- "scale" : {
- "type" : "text",
- "x_ul" : 245,
- "y_ul" : 123.8,
- "font_family" : "Arial",
- "font_size" : 12,
- "value" : "scale"
- },
- "date" : {
- "type" : "text",
- "x_ul" : 245,
- "y_ul" : 114,
- "font_family" : "Arial",
- "font_size" : 12,
- "value" : "date"
- },
- "time" : {
- "type" : "text",
- "x_ul" : 270,
- "y_ul" : 114,
- "font_family" : "Arial",
- "font_size" : 11,
- "value" : "time"
- },
- "nordpfeil" : {
- "type" : "image",
- "x_ul" : 230,
- "y_ul" : 85.5,
- "width" : 16,
- "height" : 16,
- "angle" : 0,
- "filename" : "./img/northarrow.png"
- },
- "kommentar1" : {
- "type" : "para",
- "x_ul" : 219,
- "y_ul" : 145,
- "font_family" : "Arial",
- "font_size" : 12,
- "width" : 45,
- "height" : 7,
- "align" : "L",
- "border" : 0,
- "fill" : 1,
- "border_width" : 0.5
- },
- "kommentar2" : {
- "type" : "para",
- "x_ul" : 219,
- "y_ul" : 152.5,
- "font_family" : "Arial",
- "font_size" : 12,
- "width" : 45,
- "height" : 7,
- "align" : "L",
- "border" : 0,
- "fill" : 1,
- "border_width" : 0.5
- }
- }
- },
- {
- "tpl" : "A4_landscape_template.pdf",
- "useTplPage" : 2,
- "elements" : {
- "legende" : {
- "type" : "legend",
- "x_ul" : 10,
- "y_ul" : 38,
- "width" : 90,
- "height" : 160,
- "font_family" : "Arial",
- "font_size" : 9,
- "scale" : 0.5
- }
- }
- }
- ]
+{
+ "type" : "templatePDF",
+ "orientation" : "L",
+ "units" : "mm",
+ "format" : "a4",
+ "controls" : [
+ {
+ "id" : "title",
+ "label" : "Titel",
+ "type" : "text",
+ "size" : 20,
+ "pageElementsLink" : {
+ "titel" : "value"
+ }
+ },
+ {
+ "id" : "dpi",
+ "label" : "DPI",
+ "type" : "select",
+ "size" : 20,
+ "pageElementsLink" : {
+ "karte" : "res_dpi"
+ },
+ "options" : [
+ {
+ "value" : "72",
+ "label" : "72 dpi"
+ },
+ {
+ "value" : "144",
+ "label" : "144 dpi"
+ },
+ {
+ "value" : "288",
+ "label" : "288 dpi"
+ }
+ ]
+ },
+ {
+ "id" : "comment1",
+ "label" : "Kommentar1",
+ "type" : "textarea",
+ "size" : 5,
+ "pageElementsLink" : {
+ "kommentar1" : "value"
+ }
+ },
+ {
+ "id" : "comment2",
+ "label" : "Kommentar 2",
+ "type" : "textarea",
+ "size" : 5,
+ "pageElementsLink" : {
+ "kommentar2" : "value"
+ }
+ },
+ {
+ "id" : "angle",
+ "label" : "Winkel",
+ "type" : "text",
+ "pageElementsLink" : {
+ "nordpfeil" : "angle",
+ "karte" : "angle",
+ "minikarte" : "angle"
+ }
+ },
+ {
+ "id" : "coordinates",
+ "type" : "hidden"
+ },
+ {
+ "id" : "scale",
+ "label" : "Maßstab",
+ "type" : "select",
+ "pageElementsLink" : {
+ "scale" : "value"
+ },
+ "options" : [
+ {
+ "value" : "500",
+ "label" : "1 : 500"
+ },
+ {
+ "value" : "1000",
+ "label" : "1 : 1000"
+ },
+ {
+ "value" : "2000",
+ "label" : "1 : 2000"
+ },
+ {
+ "value" : "5000",
+ "label" : "1 : 5000"
+ },
+ {
+ "value" : "10000",
+ "label" : "1 : 10000"
+ },
+ {
+ "value" : "100000",
+ "label" : "1 : 100000",
+ "selected" : "selected"
+ }
+ ]
+ }
+ ],
+ "pages" : [
+ {
+ "tpl" : "A4_landscape_template.pdf",
+ "useTplPage" : 1,
+ "elements" : {
+ "karte" : {
+ "type" : "map",
+ "res_dpi" : 72,
+ "x_ul" : 8.8,
+ "y_ul" : 13.6,
+ "width" : 203.5,
+ "height" : 180.8,
+ "coords" : 1,
+ "coords_font_family" : "Arial",
+ "coords_font_size" : 8
+ },
+ "messung" : {
+ "type" : "measure",
+ "do_fill" : 0,
+ "fill_color" : {
+ "r" : 255,
+ "g" : 0,
+ "b" : 0
+ },
+ "do_stroke" : 0,
+ "stroke_color" : {
+ "r" : 0,
+ "g" : 0,
+ "b" : 0
+ },
+ "line_style" : {
+ "width" : 1.0
+ }
+ },
+ "permanentImage" : {
+ "type" : "permanentImage"
+ },
+ "minikarte" : {
+ "type" : "overview",
+ "res_dpi" : 72,
+ "x_ul" : 222.3,
+ "y_ul" : 13.6,
+ "width" : 67.5,
+ "height" : 60
+ },
+ "titel" : {
+ "type" : "text",
+ "x_ul" : 9,
+ "y_ul" : 10,
+ "font_family" : "Arial",
+ "font_size" : 14
+ },
+ "scale" : {
+ "type" : "text",
+ "x_ul" : 245,
+ "y_ul" : 123.8,
+ "font_family" : "Arial",
+ "font_size" : 12,
+ "value" : "scale"
+ },
+ "date" : {
+ "type" : "text",
+ "x_ul" : 245,
+ "y_ul" : 114,
+ "font_family" : "Arial",
+ "font_size" : 12,
+ "value" : "date"
+ },
+ "time" : {
+ "type" : "text",
+ "x_ul" : 270,
+ "y_ul" : 114,
+ "font_family" : "Arial",
+ "font_size" : 11,
+ "value" : "time"
+ },
+ "nordpfeil" : {
+ "type" : "image",
+ "x_ul" : 230,
+ "y_ul" : 85.5,
+ "width" : 16,
+ "height" : 16,
+ "angle" : 0,
+ "filename" : "./img/northarrow.png"
+ },
+ "kommentar1" : {
+ "type" : "para",
+ "x_ul" : 219,
+ "y_ul" : 145,
+ "font_family" : "Arial",
+ "font_size" : 12,
+ "width" : 45,
+ "height" : 7,
+ "align" : "L",
+ "border" : 0,
+ "fill" : 1,
+ "border_width" : 0.5
+ },
+ "kommentar2" : {
+ "type" : "para",
+ "x_ul" : 219,
+ "y_ul" : 152.5,
+ "font_family" : "Arial",
+ "font_size" : 12,
+ "width" : 45,
+ "height" : 7,
+ "align" : "L",
+ "border" : 0,
+ "fill" : 1,
+ "border_width" : 0.5
+ }
+ }
+ },
+ {
+ "tpl" : "A4_landscape_template.pdf",
+ "useTplPage" : 2,
+ "elements" : {
+ "legende" : {
+ "type" : "legend",
+ "x_ul" : 10,
+ "y_ul" : 38,
+ "width" : 90,
+ "height" : 160,
+ "font_family" : "Arial",
+ "font_size" : 9,
+ "scale" : 0.5
+ }
+ }
+ }
+ ]
}
Modified: trunk/mapbender/http/print/A4_landscape_template.odg
===================================================================
(Binary files differ)
Modified: trunk/mapbender/lib/printbox.js
===================================================================
--- trunk/mapbender/lib/printbox.js 2013-03-04 10:19:51 UTC (rev 8579)
+++ trunk/mapbender/lib/printbox.js 2013-03-04 10:20:56 UTC (rev 8580)
@@ -642,8 +642,25 @@
activeCanvas.clear();
passiveCanvas.clear();
$("#" + this.id).remove();
- $("#container_" + this.id).remove();
+ $("#container_" + this.id).remove();
+ };
+
+ this.hide = function () {
+ $("#container_" + this.id).hide();
};
+
+ this.show = function () {
+ $("#container_" + this.id).show();
+ };
+
+ this.isVisible = function () {
+ if($("#container_printbox").css("display") == "none") {
+ return false;
+ }
+ else {
+ return true;
+ }
+ };
var switchActiveCanvas = function () {
if (canvasNr == 1) {
Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql 2013-03-04 10:19:51 UTC (rev 8579)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.3_to_2.7.4_pgsql_UTF-8.sql 2013-03-04 10:20:56 UTC (rev 8580)
@@ -70,4 +70,5 @@
ALTER FUNCTION f_collect_layer_keywords(integer)
OWNER TO postgres;
-
+-- legend_url in e_content for printPDF template print
+UPDATE gui_element SET e_content = '<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="opacity" name="opacity" value=""/><input type="hidden" id="map_url" name="map_url" value=""/><input type="hidden" id="overview_url" name="overview_url" value=""/><input type="hidden" id="legend_url" name="legend_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>' WHERE e_id = 'printPDF' and fkey_gui_id = 'template_print';
More information about the Mapbender_commits
mailing list