[Mapbender-commits] r9937 - in trunk/mapbender/http/php: . wrappers

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Aug 9 05:43:50 PDT 2018


Author: armin11
Date: 2018-08-09 05:43:50 -0700 (Thu, 09 Aug 2018)
New Revision: 9937

Added:
   trunk/mapbender/http/php/wrappers/
   trunk/mapbender/http/php/wrappers/includes.php
   trunk/mapbender/http/php/wrappers/mbw_split.php
Modified:
   trunk/mapbender/http/php/
   trunk/mapbender/http/php/mod_gazetteerMetadata_search.php
Log:
First fixes for php7 compatibility thanx to http://www.benndorf.de

Index: trunk/mapbender/http/php
===================================================================
--- trunk/mapbender/http/php	2018-08-09 12:30:02 UTC (rev 9936)
+++ trunk/mapbender/http/php	2018-08-09 12:43:50 UTC (rev 9937)

Property changes on: trunk/mapbender/http/php
___________________________________________________________________
Added: gedit
Modified: trunk/mapbender/http/php/mod_gazetteerMetadata_search.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerMetadata_search.php	2018-08-09 12:30:02 UTC (rev 9936)
+++ trunk/mapbender/http/php/mod_gazetteerMetadata_search.php	2018-08-09 12:43:50 UTC (rev 9937)
@@ -71,7 +71,7 @@
 		$sql_wms .= "wms_title ILIKE '%".$query."%' OR wms_abstract ILIKE '%".$query."%'";
 	}
 	else{
-		$wmsColumnArray = split(",", $searchColumnsWms);
+		$wmsColumnArray = mbw_split(",", $searchColumnsWms);
 		for($j = 0; $j < count($wmsColumnArray); $j++) {
 			if ($j > 0) {
 				$sql_wms .= " OR ";
@@ -127,7 +127,7 @@
 						"layer_abstract ILIKE '%".$query."%' "; 
 	}
 	else{
-		$layerColumnArray = split(",", $searchColumnsLayer);
+		$layerColumnArray = mbw_split(",", $searchColumnsLayer);
 		for($k = 0; $k < count($layerColumnArray); $k++) {
 			if ($k > 0) {
 				$sql_layer .= " OR ";

Added: trunk/mapbender/http/php/wrappers/includes.php
===================================================================
--- trunk/mapbender/http/php/wrappers/includes.php	                        (rev 0)
+++ trunk/mapbender/http/php/wrappers/includes.php	2018-08-09 12:43:50 UTC (rev 9937)
@@ -0,0 +1,7 @@
+<?php
+//
+// wrappers to cover version dependent functions
+//
+require_once dirname(__FILE__) . "/mbw_split.php";
+
+?>
\ No newline at end of file

Added: trunk/mapbender/http/php/wrappers/mbw_split.php
===================================================================
--- trunk/mapbender/http/php/wrappers/mbw_split.php	                        (rev 0)
+++ trunk/mapbender/http/php/wrappers/mbw_split.php	2018-08-09 12:43:50 UTC (rev 9937)
@@ -0,0 +1,59 @@
+<?php
+
+/* 
+ *  Copyright (C) 2017 WhereGroup
+ * 
+ *  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.
+ */
+
+/**
+ * Description of mb_split
+ * Wrapper for the php7 deprecated split function to use in arbitrary PHP 
+ * environments.
+ * @author Tobias Rieck tobias.rieck at benndorf.de
+ */
+function mbw_split() {
+    
+    $phpversion = phpversion();
+    $pars = func_get_args();
+    $result = null;
+
+    if (strpos($phpversion, "5.") === 0) {
+        switch ($phpversion[2]) {
+            case "0":
+            case "1":
+            case "2":
+               $result =  split($pars);
+               break;
+            default:
+                if (isset($pars[2]) && $pars[2] <= 0) {
+                    $result = explode($pars[0],$pars[1]);
+                }
+                else {
+                    $result = explode($pars[0],$pars[1],$pars[2]);
+                }
+        }
+    }
+    else if (strpos($phpversion, "7.") === 0) {
+        if (isset($pars[2]) && $pars[2] <= 0) {
+            $result = explode($pars[0],$pars[1]);
+        }
+        else {
+            $result = explode($pars[0],$pars[1],$pars[2]);
+        }
+    }
+    
+    return $result;
+}
\ No newline at end of file



More information about the Mapbender_commits mailing list