svn commit: r51 - trunk/mapbender/http/classes/class_stripRequest.php
uli at osgeo.org
uli at osgeo.org
Thu Apr 13 17:00:53 EDT 2006
Author: uli
Date: 2006-04-13 21:00:52+0000
New Revision: 51
Added:
trunk/mapbender/http/classes/class_stripRequest.php
Log:
import Mapbender source without history
Added: trunk/mapbender/http/classes/class_stripRequest.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_stripRequest.php?view=auto&rev=51
==============================================================================
--- (empty file)
+++ trunk/mapbender/http/classes/class_stripRequest.php 2006-04-13 21:00:52+0000
@@ -0,0 +1,134 @@
+<?php
+# $Id: class_stripRequest.php,v 1.14 2006/04/05 08:00:29 uli_rothstein Exp $
+# $Header: /cvsroot/mapbender/mapbender/http/classes/class_stripRequest.php,v 1.14 2006/04/05 08:00:29 uli_rothstein Exp $
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once("class_mb_exception.php");
+
+
+class stripRequest{
+ var $url;
+ var $encodeParams = array("LAYERS", "QUERY_LAYERS");
+ function stripRequest($mr){
+ if(!$mr || $mr == ""){
+ $t = new mb_exception("stripRequest: maprequest lacks ");
+ die;
+ }
+ $this->url = $mr;
+ }
+
+ function set($key,$value){
+ $exists = false;
+ $a = explode("?",$this->url);
+ $patterns = explode("&", $a[1]);
+ for($i=0; $i<count($patterns); $i++){
+ $tmp = explode("=", $patterns[$i]);
+ if(strtoupper($tmp[0]) == strtoupper($key)){
+ $replacement = strtoupper($key) . "=" . $value;
+ $this->url = str_replace($patterns[$i],$replacement, $this->url);
+ $exists = true;
+ }
+ }
+ if($exists == false){
+ $e = new mb_exception("stripRequest: key '".$key."' lacks");
+ return false;
+ }
+ else{
+ return $this->url;
+ }
+ }
+
+ function get($key){
+ $exists = false;
+ $a = explode("?",$this->url);
+ $patterns = explode("&", $a[1]);
+ for($i=0; $i<count($patterns); $i++){
+ $tmp = explode("=", $patterns[$i]);
+ if(strtoupper($tmp[0]) == strtoupper($key)){
+ $exists = true;
+ return $tmp[1];
+ }
+ }
+ if($exists == false){
+ $e = new mb_exception("stripRequest: key '".$key."' lacks");
+ return false;
+ }
+ }
+
+ function setPNG(){
+ $version = $this->get("version");
+ if($version == "1.0.0"){
+ $output = $this->set("format","PNG");
+ return $output;
+ }
+ else{
+ $output = $this->set("format","image/png");
+ return $output;
+ }
+ }
+ function append($param){
+ $this->url .= "&".$param;
+ $this->encodeGET();
+ return $this->url;
+ }
+ function remove($key){
+ $a = explode("?",$this->url);
+ $patterns = explode("&", $a[1]);
+ for($i=0; $i<count($patterns); $i++){
+ $tmp = explode("=", $patterns[$i]);
+ if(strtoupper($tmp[0]) == strtoupper($key)){
+ $replacement = "";
+ $this->url = str_replace($patterns[$i],$replacement, $this->url);
+ }
+ }
+ $this->encodeGET();
+ return $this->url;
+ }
+ function encodeGET(){
+ $a = explode("?",$this->url);
+ $patterns = explode("&", $a[1]);
+ $a[0].= "?";
+ for($i=0; $i<count($patterns); $i++){
+ $tmp = explode("=", $patterns[$i]);
+ if(in_array(strtoupper($tmp[0]),$this->encodeParams)){
+ $val = explode(",", $tmp[1]);
+ $a[0] .= $tmp[0]."=";
+ for($ii=0; $ii<count($val); $ii++){
+ if($ii>0){$a[0].=",";}
+ $a[0].= urlencode($val[$ii]);
+ }
+ if ($i < (count($patterns)-1)) {
+ $a[0] .= "&";
+ }
+ }
+ else{
+ $a[0] .= $tmp[0] . "=" .$tmp[1];
+ if ($i < (count($patterns)-1)) {
+ $a[0] .= "&";
+ }
+ }
+ }
+ $this->url = $a[0];
+ return $this->url;
+ }
+
+ function encodeLegGET(){
+ $this->url = str_replace("&", "\&", $this->url);
+ return $this->url;
+ }
+}
+?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list