[Mapbender-commits] r7914 - in branches/2.7: http/include http/plugins http/print http/print/classes resources/db/pgsql/UTF-8/update

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jul 7 08:34:02 EDT 2011


Author: verenadiewald
Date: 2011-07-07 05:34:02 -0700 (Thu, 07 Jul 2011)
New Revision: 7914

Modified:
   branches/2.7/http/include/dyn_php.php
   branches/2.7/http/plugins/mb_print.php
   branches/2.7/http/print/classes/mbLegendDecorator.php
   branches/2.7/http/print/classes/mbMapDecorator.php
   branches/2.7/http/print/classes/mbOverviewDecorator.php
   branches/2.7/http/print/classes/mbTemplatePdf.php
   branches/2.7/http/print/printFactory.php
   branches/2.7/resources/db/pgsql/UTF-8/update/update_2.7.1_to_2.7.2_pgsql_UTF-8.sql
Log:
http://trac.osgeo.org/mapbender/ticket/828

Modified: branches/2.7/http/include/dyn_php.php
===================================================================
--- branches/2.7/http/include/dyn_php.php	2011-07-06 07:47:52 UTC (rev 7913)
+++ branches/2.7/http/include/dyn_php.php	2011-07-07 12:34:02 UTC (rev 7914)
@@ -24,7 +24,8 @@
 	$t = array('s', 's');
    	$res = db_prep_query($sql,$v,$t);
 
-	echo "\n";
+	# there used to be a echo "\n"; here, but that doesn't make any common sense (problem with return value of printFactory.php)
+	//echo "\n";
 	while($row = db_fetch_array($res))
 	{
 		if (preg_match("/\w+\[\d+\]/", $row["var_name"])) {

Modified: branches/2.7/http/plugins/mb_print.php
===================================================================
--- branches/2.7/http/plugins/mb_print.php	2011-07-06 07:47:52 UTC (rev 7913)
+++ branches/2.7/http/plugins/mb_print.php	2011-07-07 12:34:02 UTC (rev 7914)
@@ -223,7 +223,7 @@
 		// 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;
@@ -240,11 +240,15 @@
 	 */	
 	var hookForm = function () {
 		var o = {
-	   		url:			'../print/printFactory.php', 
+	   		url:			'../print/printFactory.php?e_id='+myId,
 	   		type:			'post',
 	   		dataType:		'json',
 	   		beforeSubmit: 	validate,
 	   		success:    	showResult
+                        //timeout:        1,
+                        //error:          function() {
+                        //        showHideWorking("hide");
+                        //}
 		};
 		$("#"+myId+"_form").ajaxForm(o);
 	};

Modified: branches/2.7/http/print/classes/mbLegendDecorator.php
===================================================================
--- branches/2.7/http/print/classes/mbLegendDecorator.php	2011-07-06 07:47:52 UTC (rev 7913)
+++ branches/2.7/http/print/classes/mbLegendDecorator.php	2011-07-07 12:34:02 UTC (rev 7914)
@@ -86,6 +86,7 @@
 
 			}
 		}
+                $this->pdf->unlink($legendFilename);
 	}
 }
 

Modified: branches/2.7/http/print/classes/mbMapDecorator.php
===================================================================
--- branches/2.7/http/print/classes/mbMapDecorator.php	2011-07-06 07:47:52 UTC (rev 7913)
+++ branches/2.7/http/print/classes/mbMapDecorator.php	2011-07-07 12:34:02 UTC (rev 7914)
@@ -120,6 +120,8 @@
 			$this->pdf->objPdf->Text($this->conf->x_ul + $width - ($this->pdf->objPdf->GetStringWidth($myMaxx)), $this->conf->y_ul - 2, $myMaxx);
 
 		}
+
+                $this->pdf->unlink($this->filename);
 	}
 	
 }

Modified: branches/2.7/http/print/classes/mbOverviewDecorator.php
===================================================================
--- branches/2.7/http/print/classes/mbOverviewDecorator.php	2011-07-06 07:47:52 UTC (rev 7913)
+++ branches/2.7/http/print/classes/mbOverviewDecorator.php	2011-07-07 12:34:02 UTC (rev 7914)
@@ -92,6 +92,8 @@
 		}		
 		
 		$this->pdf->objPdf->Image($this->filename, $this->conf->x_ul, $this->conf->y_ul, $width, $height, 'png');
+
+                 $this->pdf->unlink($this->filename);
 	}
 	
 	protected function rotate($point, $center, $angle) {

Modified: branches/2.7/http/print/classes/mbTemplatePdf.php
===================================================================
--- branches/2.7/http/print/classes/mbTemplatePdf.php	2011-07-06 07:47:52 UTC (rev 7913)
+++ branches/2.7/http/print/classes/mbTemplatePdf.php	2011-07-07 12:34:02 UTC (rev 7914)
@@ -5,7 +5,8 @@
 class mbTemplatePdf extends mbPdf {
 
 	/* it seems several decorators are going to need this information */
-	public $mapInfo = array();	
+	public $mapInfo = array();
+        public $unlinkFiles = false;
 
 	public function __construct($jsonConf) {
 		$this->confPdf = $jsonConf;
@@ -98,6 +99,12 @@
 			$this->isSaved = true;
 		}
 	}
+
+        public function unlink($filename) {
+            if($this->unlinkFiles && $this->unlinkFiles == 'true') {
+               unlink($filename);
+            }
+        }
 }
 
 

Modified: branches/2.7/http/print/printFactory.php
===================================================================
--- branches/2.7/http/print/printFactory.php	2011-07-06 07:47:52 UTC (rev 7913)
+++ branches/2.7/http/print/printFactory.php	2011-07-07 12:34:02 UTC (rev 7914)
@@ -2,10 +2,10 @@
 
 require_once dirname(__FILE__) . "/../php/mb_validateSession.php";
 require_once dirname(__FILE__) . "/classes/factoryClasses.php";
+require_once dirname(__FILE__) . "/../include/dyn_php.php";
 
 $pf = new mbPdfFactory();
 
-
 $confFile = basename($_REQUEST["printPDF_template"]);
 if (!preg_match("/^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9]+)$/", $confFile) || 
 	!file_exists($_REQUEST["printPDF_template"])) {
@@ -18,6 +18,8 @@
 
 $pdf = $pf->create($_REQUEST["printPDF_template"]);
 
+$pdf->unlinkFiles = $unlink;
+
 $pdf->render();
 try {
 	$pdf->save();

Modified: branches/2.7/resources/db/pgsql/UTF-8/update/update_2.7.1_to_2.7.2_pgsql_UTF-8.sql
===================================================================
--- branches/2.7/resources/db/pgsql/UTF-8/update/update_2.7.1_to_2.7.2_pgsql_UTF-8.sql	2011-07-06 07:47:52 UTC (rev 7913)
+++ branches/2.7/resources/db/pgsql/UTF-8/update/update_2.7.1_to_2.7.2_pgsql_UTF-8.sql	2011-07-07 12:34:02 UTC (rev 7914)
@@ -63,3 +63,10 @@
 	SELECT fkey_gui_id FROM gui_element WHERE e_id = 'jq_ui_dialog'
  ));
 
+
+-- new element var unlink for gui element template printPDF
+INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type)
+SELECT gui_element.fkey_gui_id, 'printPDF', 'unlink', 'true', 'delete print pngs after pdf creation' ,'php_var'
+FROM gui_element WHERE gui_element.e_id = 'printPDF' AND gui_element.e_js_file = '../plugins/mb_print.php' AND gui_element.fkey_gui_id
+NOT IN (SELECT fkey_gui_id FROM gui_element_vars
+WHERE var_name = 'unlink' AND fkey_e_id = 'printPDF');



More information about the Mapbender_commits mailing list