[Mapbender-commits] r4762 - in branches/print_dev/http: classes include

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Sep 28 10:36:36 EDT 2009


Author: mschulz
Date: 2009-09-28 10:36:36 -0400 (Mon, 28 Sep 2009)
New Revision: 4762

Added:
   branches/print_dev/http/classes/class_universal_rss_factory.php
   branches/print_dev/http/include/dyn_js_object.php
Log:
merged from trunk

Added: branches/print_dev/http/classes/class_universal_rss_factory.php
===================================================================
--- branches/print_dev/http/classes/class_universal_rss_factory.php	                        (rev 0)
+++ branches/print_dev/http/classes/class_universal_rss_factory.php	2009-09-28 14:36:36 UTC (rev 4762)
@@ -0,0 +1,36 @@
+<?php
+# License:
+# Copyright (c) 2009, Open Source Geospatial Foundation
+# This program is dual licensed under the GNU General Public License 
+# and Simplified BSD license.  
+# http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+
+require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+require_once dirname(__FILE__) . "/../classes/class_rss_factory.php";
+require_once dirname(__FILE__) . "/../classes/class_georss_factory.php";
+
+class UniversalRssFactory {
+
+	public function createFromUrl ($url) {
+		$dom = new DOMDocument();
+		$dom->preserveWhitespace = false;
+		$success = $dom->load($url);
+		if (!$success) {
+			new mb_exception(__FILE__ . ": createFromUrl(): Could not load " . $url);
+			return null;
+		}
+
+		$nodeList = $dom->getElementsByTagName("rss");
+		if ($nodeList->length > 0) {
+			$node = $nodeList->item(0);
+			if ($node->hasAttribute("xmlns:georss")) {
+				$geoRssFactory = new GeoRssFactory();
+				return $geoRssFactory->createFromUrl($url);
+			}
+		}
+		$rssFactory = new RssFactory();
+		return $rssFactory->createFromUrl($url);
+	}
+}
+
+?>
\ No newline at end of file

Added: branches/print_dev/http/include/dyn_js_object.php
===================================================================
--- branches/print_dev/http/include/dyn_js_object.php	                        (rev 0)
+++ branches/print_dev/http/include/dyn_js_object.php	2009-09-28 14:36:36 UTC (rev 4762)
@@ -0,0 +1,86 @@
+<?php
+# $Id: dyn_js.php 3850 2009-04-03 09:02:12Z christoph $
+# $Header: /cvsroot/mapbender/mapbender/http/classes/class_wfs.php,v 1.15 2006/03/09 13:55:46 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(dirname(__FILE__)."/../classes/class_mb_exception.php");
+
+if (isset($gui_id)) {
+	$sql = "SELECT * FROM gui_element_vars WHERE fkey_e_id = $1 AND fkey_gui_id = $2 and var_type='var'";
+	$v = array($e_id, $gui_id);
+	$t = array('s', 's');
+   	$res = db_prep_query($sql, $v, $t);
+	$arrays = array();
+	$varArray = array();
+	while ($row = db_fetch_array($res)) {
+		if (mb_strpos($row["var_name"], "[")) {
+
+			//
+			// backwards compatibility for var names like name[0], name[1] etc
+			//
+			$arrayname = mb_substr($row["var_name"], 0, mb_strpos($row["var_name"], "["));
+			
+			if (!in_array($arrayname, $arrays)) {
+				$arrays[]= $arrayname;
+				$varArray[]= $arrayname  . ": []";
+			}
+			else {
+				for ($i = 0; $i < count($varArray); $i++) {
+					if (mb_substr($varArray[$i], 0, mb_strlen($arrayname) + 1) === $arrayname . ":") {
+						if (is_numeric(stripslashes($row["var_value"]) || 
+							strpos(stripslashes($row["var_value"]), "[") === 0 || 
+							strpos(stripslashes($row["var_value"]), "{") === 0)) {
+							
+							$varArray[$i] = substr_replace(
+								$varArray[$i], 
+								$row["var_name"].": ".stripslashes($row["var_value"]) . "]",
+								-1);
+						}
+						else {
+							$varArray[$i] = substr_replace(
+								$varArray[$i], 
+								$row["var_name"].": '".stripslashes($row["var_value"]) . "']",
+								-1);
+						}
+					}
+				}
+			}
+		}
+		if (is_numeric(stripslashes($row["var_value"]))) {
+			$varArray[]= $row["var_name"].": ".stripslashes($row["var_value"]);
+		}
+		elseif (strpos(stripslashes($row["var_value"]), "[") === 0 || 
+				strpos(stripslashes($row["var_value"]), "{") === 0) {
+			$varArray[]= $row["var_name"].": ".stripslashes($row["var_value"]);
+		}
+		else {
+			$varArray[]= $row["var_name"].": '" . 
+				str_replace(
+					array('"',"'", "\r", "\n", "\0"), 
+					array('\"','\\\'','\r', '\n', '\0'), 
+					stripslashes($row["var_value"])
+				) .	"'";
+		}
+	}
+	echo "$.extend(options, {";
+	echo implode(",\n", $varArray);
+	echo "});";
+}
+else {
+	$e = new mb_exception("Application ID not set while retrieving element vars of module " . $e_id);
+}
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list