[Mapbender-commits] r3561 - in branches/print_dev/http/print: . classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Feb 17 11:47:22 EST 2009


Author: mschulz
Date: 2009-02-17 11:47:22 -0500 (Tue, 17 Feb 2009)
New Revision: 3561

Added:
   branches/print_dev/http/print/classes/mbParagraphDecorator.php
Modified:
   branches/print_dev/http/print/classes/mbTemplatePdf.php
   branches/print_dev/http/print/testConfigTemplate.json
Log:
added a text paragraph with configurable border and background decorator

Added: branches/print_dev/http/print/classes/mbParagraphDecorator.php
===================================================================
--- branches/print_dev/http/print/classes/mbParagraphDecorator.php	                        (rev 0)
+++ branches/print_dev/http/print/classes/mbParagraphDecorator.php	2009-02-17 16:47:22 UTC (rev 3561)
@@ -0,0 +1,56 @@
+<?php
+
+class mbParagraphDecorator extends mbTemplatePdfDecorator {
+
+	protected $pageElementType = "para";
+	protected $elementId;
+	/* a decorator should declare which parameters could be overwritten through the request object */
+	protected $overrideMembersFromRequest = array("value");
+	/* the actual text that should be printed */
+	protected $value = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, ...";
+	
+	public function __construct($pdfObj, $elementId, $mapConf, $controls) {
+		parent::__construct($pdfObj, $mapConf, $controls);
+		$this->elementId = $elementId;
+		$this->override();		
+		$this->decorate();	
+	}
+	
+	public function override() {
+		/* returns an array of (request key, member id) arrays */ 
+		$idsFromRequest = $this->getPageElementLink($this->elementId);
+		foreach ($idsFromRequest as $requestKey => $memberId) {
+			$e = new mb_notice("mbParagraphDecorator: checking overrides: ".$requestKey.$memberId);
+		}
+		foreach ($_REQUEST as $k => $v) {
+			$e = new mb_notice("mbParagraphDecorator: checking Request: ".$k."=".$v);
+		}
+		
+		foreach ($this->overrideMembersFromRequest as $overrideMemberFromRequest) {
+			foreach ($idsFromRequest as $requestKey => $memberId) {
+				$e = new mb_notice("mbParagraphDecorator: before override: set ".$memberId." to ".$requestKey);
+				if ($overrideMemberFromRequest==$memberId && isset($_REQUEST[$requestKey]) && $_REQUEST[$requestKey] != "") { 
+					$this->{$overrideMemberFromRequest} = $_REQUEST[$requestKey];
+					$e = new mb_notice("mbParagraphDecorator: override from Request: ".$overrideMemberFromRequest." to ".$this->{$overrideMemberFromRequest});
+				}
+				else {
+					$this->{$overrideMemberFromRequest} = $this->conf->{$memberId};
+				}	
+			}	
+		}
+	}
+	
+	public function decorate() {
+		$this->pdf->objPdf->setTextColor(0, 0, 0);
+		$this->pdf->objPdf->setFillColor(255, 255, 255);
+		$this->pdf->objPdf->setDrawColor(0, 0, 0);
+		$this->pdf->objPdf->SetLineWidth($this->conf->border_width);
+		$this->pdf->objPdf->SetXY($this->conf->x_ul, $this->conf->y_ul);
+		$this->pdf->objPdf->setFont($this->conf->font_family, "", $this->conf->font_size);
+		$this->pdf->objPdf->Cell($this->conf->width, $this->conf->height, $this->value, $this->conf->border, 0, $this->conf->align, $this->conf->fill);
+	}
+	
+
+}
+
+?>
\ No newline at end of file

Modified: branches/print_dev/http/print/classes/mbTemplatePdf.php
===================================================================
--- branches/print_dev/http/print/classes/mbTemplatePdf.php	2009-02-17 15:37:47 UTC (rev 3560)
+++ branches/print_dev/http/print/classes/mbTemplatePdf.php	2009-02-17 16:47:22 UTC (rev 3561)
@@ -47,7 +47,10 @@
 						break;
 					case "text":
 						$err = new mbTextDecorator($this, $pageElementId, $pageElementConf, $controls);
-						break;							
+						break;		
+					case "para":
+						$err = new mbParagraphDecorator($this, $pageElementId, $pageElementConf, $controls);
+						break;													
 				}
             }
             

Modified: branches/print_dev/http/print/testConfigTemplate.json
===================================================================
--- branches/print_dev/http/print/testConfigTemplate.json	2009-02-17 15:37:47 UTC (rev 3560)
+++ branches/print_dev/http/print/testConfigTemplate.json	2009-02-17 16:47:22 UTC (rev 3561)
@@ -69,9 +69,22 @@
     			"type" : "text", 
     			"x_ul" : 10.1,
 	    		"y_ul" : 10,
-	    		"font_family" : "arial",
+	    		"font_family" : "Arial",
 	    		"font_size" : 14
-	   			}	   			
+	   			},
+	   		"kommentar" : {
+    			"type" : "para", 
+    			"x_ul" : 10.1,
+	    		"y_ul" : 129.2,
+	    		"font_family" : "Arial",
+	    		"font_size" : 11,
+	    		"width" : 100,
+	    		"height" : 10,
+	    		"align" : "L",
+	    		"border" : 1,
+	    		"fill" : 1,
+	    		"border_width" : 0.5
+	   			}		   						
 	   		}
 	   	}
 	]



More information about the Mapbender_commits mailing list