[Mapbender-commits] r2867 - branches/nimix_dev/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Aug 18 12:03:32 EDT 2008
Author: nimix
Date: 2008-08-18 12:03:32 -0400 (Mon, 18 Aug 2008)
New Revision: 2867
Removed:
branches/nimix_dev/http/classes/class_wmc.php
Modified:
branches/nimix_dev/http/classes/class_SaveLegend.php
branches/nimix_dev/http/classes/class_administration.php
branches/nimix_dev/http/classes/class_bbox.php
branches/nimix_dev/http/classes/class_checkInput.php
branches/nimix_dev/http/classes/class_connector.php
branches/nimix_dev/http/classes/class_gml2.php
branches/nimix_dev/http/classes/class_gui.php
branches/nimix_dev/http/classes/class_keyword.php
branches/nimix_dev/http/classes/class_kml.php
branches/nimix_dev/http/classes/class_kml_geometry.php
branches/nimix_dev/http/classes/class_kml_line.php
branches/nimix_dev/http/classes/class_kml_linearring.php
branches/nimix_dev/http/classes/class_kml_multigeometry.php
branches/nimix_dev/http/classes/class_kml_ows.php
branches/nimix_dev/http/classes/class_kml_parser_ows.php
branches/nimix_dev/http/classes/class_kml_placemark.php
branches/nimix_dev/http/classes/class_kml_point.php
branches/nimix_dev/http/classes/class_kml_polygon.php
branches/nimix_dev/http/classes/class_layer_monitor.php
branches/nimix_dev/http/classes/class_locale.php
branches/nimix_dev/http/classes/class_log.php
branches/nimix_dev/http/classes/class_map.php
branches/nimix_dev/http/classes/class_metadata.php
branches/nimix_dev/http/classes/class_monitor.php
branches/nimix_dev/http/classes/class_point.php
branches/nimix_dev/http/classes/class_weldMaps2Image.php
branches/nimix_dev/http/classes/class_weldMaps2PNG.php
branches/nimix_dev/http/classes/class_wfs.php
branches/nimix_dev/http/classes/class_wfs_conf.php
branches/nimix_dev/http/classes/class_wmcToXml.php
branches/nimix_dev/http/classes/class_wms.php
Log:
merge
Modified: branches/nimix_dev/http/classes/class_SaveLegend.php
===================================================================
--- branches/nimix_dev/http/classes/class_SaveLegend.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_SaveLegend.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -22,8 +22,9 @@
* getlegendurl
*
**/
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
require_once(dirname(__FILE__)."/class_stripRequest.php");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
require_once(dirname(__FILE__)."/class_connector.php");
class SaveLegend{
@@ -63,4 +64,4 @@
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_administration.php
===================================================================
--- branches/nimix_dev/http/classes/class_administration.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_administration.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -16,12 +16,9 @@
# 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__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/class_user.php");
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
-
require(dirname(__FILE__) . "/phpmailer-1.72/class.phpmailer.php");
/**
@@ -706,52 +703,14 @@
return $user->getWmcByOwner();
}
- function getGuisByPermission($mb_user_id,$ignoreublic){
- $arrayGuis = array();
- $mb_user_groups = array();
- $sql_groups = "SELECT fkey_mb_group_id FROM mb_user_mb_group WHERE fkey_mb_user_id = $1 ";
- $v = array($mb_user_id);
- $t = array("i");
- $res_groups = db_prep_query($sql_groups,$v,$t);
- $cnt_groups = 0;
- while($row = db_fetch_array($res_groups)){
- $mb_user_groups[$cnt_groups] = $row["fkey_mb_group_id"];
- $cnt_groups++;
+ /**
+ * @deprecated
+ */
+ function getGuisByPermission($mb_user_id,$ignorepublic){
+ $e = new mb_notice("administration->getGuisByPermission is deprecated, use user->getApplicationsByPermission instead!");
+ $user = new User($mb_user_id);
+ return $user->getApplicationsByPermission($ignorepublic);
}
- if($cnt_groups > 0){
- $v = array();
- $t = array();
- $sql_g = "SELECT gui.gui_id FROM gui JOIN gui_mb_group ";
- $sql_g .= " ON gui.gui_id = gui_mb_group.fkey_gui_id WHERE gui_mb_group.fkey_mb_group_id IN (";
- for($i=0; $i<count($mb_user_groups);$i++){
- if($i > 0){$sql_g .= ",";}
- $sql_g .= "$".strval($i+1);
- array_push($v,$mb_user_groups[$i]);
- array_push($t,"i");
- }
- $sql_g .= ") GROUP BY gui.gui_id";
- $res_g = db_prep_query($sql_g,$v,$t);
- while($row = db_fetch_array($res_g)){
- array_push($arrayGuis,$row["gui_id"]);
- }
- }
- $sql_guis = "SELECT gui.gui_id FROM gui JOIN gui_mb_user ON gui.gui_id = gui_mb_user.fkey_gui_id";
- $sql_guis .= " WHERE (gui_mb_user.fkey_mb_user_id = $1) ";
- if (!isset($ignore_public) OR $ignore_public== false){
- $sql_guis .= " AND gui.gui_public = 1 ";
- }
- $sql_guis .= " GROUP BY gui.gui_id";
- $v = array($mb_user_id);
- $t = array("i");
- $res_guis = db_prep_query($sql_guis,$v,$t);
- $guis = array();
- while($row = db_fetch_array($res_guis)){
- if(!in_array($row['gui_id'],$arrayGuis)){
- array_push($arrayGuis,$row["gui_id"]);
- }
- }
- return $arrayGuis;
- }
function getWmsByOwnGuis($array_gui_ids){
if(count($array_gui_ids)>0){
@@ -1185,44 +1144,15 @@
/** identifies the Conf-FeatureServices where the current user is owner
*
+ * @deprecated
* @param integer userid the user-ID of the current user
* @return integer[] the IDs of the wfs_conf-table
*/
function getWfsConfByPermission($userid){
-
-
- $guisByPer = array();
-// 1.
- $guisByPer = $this->getGuisByPermission($userid, true);
-
-// 2.
- if(count($guisByPer)>0){
- $v = array();
- $t = array();
- $sql = "SELECT wfs_conf.wfs_conf_id FROM gui_wfs_conf, wfs_conf " .
- "where wfs_conf.wfs_conf_id = gui_wfs_conf.fkey_wfs_conf_id " .
- "and gui_wfs_conf.fkey_gui_id IN(";
- for($i=0; $i<count($guisByPer); $i++){
- if($i>0){ $sql .= ",";}
- $sql .= "$".strval($i+1);
-
- array_push($v, $guisByPer[$i]);
- array_push($t, "s");
+ $e = new mb_notice("administration->getWfsConfByPermission is deprecated, use user->getWfsConfByPermission instead!");
+ $user = new User($userid);
+ return $user->getWfsConfByPermission();
}
- $sql .= ") GROUP BY wfs_conf.wfs_conf_id ORDER BY wfs_conf.wfs_conf_id";
-
-
- $res = db_prep_query($sql,$v,$t);
- $ownWFSconfs = array();
- $i=0;
- while($row = db_fetch_array($res)){
-
- $ownWFSconfs[$i] = $row['wfs_conf_id'];
- $i++;
}
- }
- return $ownWFSconfs;
+?>
- }
-}
-?>
\ No newline at end of file
Modified: branches/nimix_dev/http/classes/class_bbox.php
===================================================================
--- branches/nimix_dev/http/classes/class_bbox.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_bbox.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,11 +17,7 @@
# 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__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
-require_once(dirname(__FILE__)."/../classes/class_point.php");
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
/**
* A bounding box consisting of an lower left and an upper right point, and an EPSG.
Modified: branches/nimix_dev/http/classes/class_checkInput.php
===================================================================
--- branches/nimix_dev/http/classes/class_checkInput.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_checkInput.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,6 +17,8 @@
# 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__)."/../../core/globalSettings.php");
+
class checkInput{
var $v;
function checkInput($q,$v,$t){
@@ -51,4 +53,4 @@
}
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_connector.php
===================================================================
--- branches/nimix_dev/http/classes/class_connector.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_connector.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,11 +17,8 @@
# 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__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-mb_internal_encoding("UTF-8");
-
/**
* Establishes a connection to a given URL (and loads the content).
* Supports HTTP (GET and POST), cURL and socket connections.
@@ -48,6 +45,11 @@
if ($url&&$url!=="") {
$this->load($url);
}
+
+ // fill array (HOSTs not for Proxy)
+ if (http_ip!=""){
+ $NOT_PROXY_HOSTS_array = split(",", NOT_PROXY_HOSTS);
+ }
}
/**
@@ -56,7 +58,12 @@
public function load($url) {
switch ($this->connectionType) {
case "CURL":
- $this->file = $this->getCURL($url);
+ if (in_array($host, $NOT_PROXY_HOSTS_array)){
+ $this->file = $this->getHTTP($url);
+ }
+ else {
+ $this->file = $this->getCURL($url);
+ }
break;
case "HTTP":
$this->file = $this->getHTTP($url);
@@ -264,4 +271,4 @@
}
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_gml2.php
===================================================================
--- branches/nimix_dev/http/classes/class_gml2.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_gml2.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -16,10 +16,11 @@
# 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");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
require_once(dirname(__FILE__)."/../classes/class_connector.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+
class gml2 {
var $geomtype_point = 'Point';
var $geomtype_polygon = 'Polygon';
Modified: branches/nimix_dev/http/classes/class_gui.php
===================================================================
--- branches/nimix_dev/http/classes/class_gui.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_gui.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,12 +17,8 @@
# 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__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/../classes/class_element.php");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
-
/**
* GUI is a set of GUI elements and services.
*/
@@ -293,4 +289,4 @@
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_keyword.php
===================================================================
--- branches/nimix_dev/http/classes/class_keyword.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_keyword.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -16,9 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
/**
* class to handle keywords for services
@@ -293,7 +291,7 @@
global $con;
$sql = "DELETE FROM keyword WHERE NOT EXISTS (SELECT fkey_keyword_id FROM layer_keyword WHERE keyword.keyword_id = layer_keyword.fkey_keyword_id);";
//$sql .= " AND NOT EXISTS (SELECT fkey_keyword_id FROM wms_keyword WHERE keyword.keyword_id = wms_keyword.fkey_keyword_id);";
- $res = db_prep_query($sql);
+ $res = db_query($sql);
if($res!=FALSE){
return true;
}
Modified: branches/nimix_dev/http/classes/class_kml.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -16,8 +16,9 @@
# 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__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
class kml {
var $kml_id;
@@ -172,4 +173,4 @@
}
// end class
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_kml_geometry.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml_geometry.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml_geometry.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,7 +17,7 @@
# 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");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/../classes/class_kml_polygon.php");
require_once(dirname(__FILE__)."/../classes/class_kml_linearring.php");
@@ -57,4 +57,4 @@
return get_class($this);
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_kml_line.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml_line.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml_line.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,7 +17,8 @@
# 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");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
require_once(dirname(__FILE__)."/../classes/class_point.php");
require_once(dirname(__FILE__)."/../classes/class_kml_geometry.php");
@@ -117,4 +118,4 @@
*/
protected $pointArray = array();
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_kml_linearring.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml_linearring.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml_linearring.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,7 +17,8 @@
# 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");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
require_once(dirname(__FILE__)."/../classes/class_kml_line.php");
/**
@@ -50,4 +51,4 @@
return "";
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_kml_multigeometry.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml_multigeometry.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml_multigeometry.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,7 +17,8 @@
# 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");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
require_once(dirname(__FILE__)."/../classes/class_kml_geometry.php");
/**
@@ -79,4 +80,4 @@
private $geometryArray = array();
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_kml_ows.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml_ows.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml_ows.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,12 +17,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-session_start();
-mb_internal_encoding("UTF-8");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
require_once(dirname(__FILE__)."/../extensions/JSON.php");
-require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
require_once(dirname(__FILE__)."/../classes/class_point.php");
require_once(dirname(__FILE__)."/../classes/class_kml_geometry.php");
@@ -490,4 +487,4 @@
*/
private $placemarkArray = array();
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_kml_parser_ows.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml_parser_ows.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml_parser_ows.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,8 +17,8 @@
# 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__)."/../extensions/JSON.php");
-require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
require_once(dirname(__FILE__)."/../classes/class_point.php");
require_once(dirname(__FILE__)."/../classes/class_kml_polygon.php");
require_once(dirname(__FILE__)."/../classes/class_kml_linearring.php");
@@ -39,7 +39,7 @@
public function parseGeoJSON ($geoJSON, $kmlId) {
// $e = new mb_notice("GEOJSON: " . $geoJSON);
- $json = new Services_JSON();
+ $json = new Mapbender_JSON();
$geometryFromGeoJSON = $json->decode($geoJSON);
$id = 0;
Modified: branches/nimix_dev/http/classes/class_kml_placemark.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml_placemark.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml_placemark.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,7 +17,7 @@
# 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");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
/**
* A Placemark consists of a geometry of type {@link KMLPoint}, {@link KMLPolygon},
@@ -116,4 +116,4 @@
private $geometry;
private $properties = array();
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_kml_point.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml_point.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml_point.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -19,7 +19,7 @@
* 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");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/../classes/class_kml_geometry.php");
/**
@@ -88,4 +88,4 @@
*/
private $point;
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_kml_polygon.php
===================================================================
--- branches/nimix_dev/http/classes/class_kml_polygon.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_kml_polygon.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/../classes/class_kml_geometry.php");
require_once(dirname(__FILE__)."/../classes/class_kml_linearring.php");
@@ -100,4 +100,4 @@
*/
private $innerBoundaryArray = array();
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_layer_monitor.php
===================================================================
--- branches/nimix_dev/http/classes/class_layer_monitor.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_layer_monitor.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,6 +17,8 @@
# 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__)."/../../core/globalSettings.php");
+
class Layer_load_count {
function __construct () {
@@ -52,4 +54,4 @@
}
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_locale.php
===================================================================
--- branches/nimix_dev/http/classes/class_locale.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_locale.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,8 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
/**
* sets the locale, depending on various settings:
@@ -37,10 +36,18 @@
var $status = "No locale set.";
function Mb_locale($languageId) {
+ if (!$languageId) {
+ $languageId = LANGUAGE;
+ }
$e = new Mb_notice("class_locale: setting locale to " . $languageId);
- if (!$this->setCurrentLocale($languageId)) {
- $e = new Mb_exception("Locale could not be set. Language ID: '" . $languageId . "'");
+ if (USE_I18N) {
+ if (!$this->setCurrentLocale($languageId)) {
+ $e = new Mb_exception("Locale could not be set. Language ID: '" . $languageId . "'");
+ }
}
+ else {
+ $this->setCurrentLocale($this->defaultLanguage);
+ }
}
/**
@@ -85,7 +92,7 @@
$this->os = $this->guessHostOS();
}
- if ($this->os != null && isset($languageId)) {
+ if (!USE_I18N || ($this->os != null && isset($languageId))) {
if ($this->isKnownLanguage($languageId)) {
if ($this->systemLocales == null) {
@@ -93,14 +100,16 @@
}
$locale = $this->systemLocales[$this->knownLanguages[$languageId]][$this->os];
- if (setlocale(LC_ALL, $locale)) {
- $this->name = $locale;
+ $selectedLocale = setlocale(LC_MESSAGES, $locale);
+ if ($selectedLocale) {
+ $this->name = $selectedLocale;
$_SESSION["mb_lang"] = $languageId;
$_SESSION["mb_locale"] = $this->name;
$e = new Mb_notice("locale " . $this->name . " ok on " . $this->os);
// from http://de3.php.net/manual/de/function.gettext.php
- bindtextdomain("Mapbender", dirname(__FILE__)."/../../resources/locale/");
- textdomain("Mapbender");
+ $path = bindtextdomain("Mapbender", dirname(__FILE__)."/../../resources/locale/");
+ $enc = bind_textdomain_codeset("Mapbender", "UTF-8");
+ $dom = textdomain("Mapbender");
return true;
}
}
@@ -126,7 +135,7 @@
else if (strncasecmp(php_uname(), 'FreeBSD', 7) == 0)
return 'bsd';
else {
- throw new Mb_exception('unknown platform: could not interpret uname. php_uname() returned '. php_uname().'. Please report to MB developers');
+ $e = new mb_exception('unknown platform: could not interpret uname. php_uname() returned '. php_uname().'. Please report to MB developers');
return null;
}
}
@@ -204,4 +213,4 @@
}
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_log.php
===================================================================
--- branches/nimix_dev/http/classes/class_log.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_log.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -22,6 +22,7 @@
* [15/Jul/2004: 10:00:08 +0200] 192.168.2.102 urldecode(username) userid
*modul "GET /map/http/ HTTP/1.1"
*/
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
class log {
var $dir = "../../log/";
@@ -91,4 +92,4 @@
}
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_map.php
===================================================================
--- branches/nimix_dev/http/classes/class_map.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_map.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -380,7 +380,7 @@
private static function selectByApplication ($appId, $frameName) {
// find the mapframe in the application elements...
$sql = "SELECT * FROM gui_element WHERE fkey_gui_id = $1 AND " .
- "e_id = $2 LIMIT 1";
+ "e_id = $2 AND e_public = 1 LIMIT 1";
$v = array($appId, $frameName);
$t = array('s', 's');
$res = db_prep_query($sql,$v,$t);
@@ -408,7 +408,7 @@
// $e = new mb_exception("guess this is the OV");
$pattern = "/[\.\/a-zA-Z_]*\?wms=([0-9]*)[^0-9]*/";
$ovIndex = preg_replace($pattern, "\$1", $row["e_src"]);
- $e = new mb_exception("OV index: " . $ovIndex);
+// $e = new mb_exception("OV index: " . $ovIndex);
if (!$ovIndex) {
$ovIndex = 0;
}
@@ -421,8 +421,14 @@
$currentMap->wmsArray = $wmsArray;
- // TO DO: EXTENT!
-
+ // EXTENT
+ $minx = $wmsArray[0]->objLayer[0]->layer_epsg[0]["minx"];
+ $miny = $wmsArray[0]->objLayer[0]->layer_epsg[0]["miny"];
+ $maxx = $wmsArray[0]->objLayer[0]->layer_epsg[0]["maxx"];
+ $maxy = $wmsArray[0]->objLayer[0]->layer_epsg[0]["maxy"];
+ $epsg = $wmsArray[0]->objLayer[0]->layer_epsg[0]["epsg"];
+ $mapExtent = new Mapbender_bbox($minx, $miny, $maxx, $maxy, $epsg);
+ $currentMap->setExtent($mapExtent);
return $currentMap;
}
else {
@@ -432,4 +438,4 @@
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_metadata.php
===================================================================
--- branches/nimix_dev/http/classes/class_metadata.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_metadata.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -16,14 +16,9 @@
# 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__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/class_administration.php");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
-
/**
* class to handle keywords for services
*/
Modified: branches/nimix_dev/http/classes/class_monitor.php
===================================================================
--- branches/nimix_dev/http/classes/class_monitor.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_monitor.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,9 +17,10 @@
# 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__)."/../../core/globalSettings.php");
+
require_once(dirname(__FILE__)."/../classes/class_wms.php");
require_once(dirname(__FILE__)."/../classes/class_bbox.php");
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
define("MONITOR_DEFAULT_SCALE", 500000);
define("MONITOR_IMG_WIDTH", 20);
@@ -475,4 +476,4 @@
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_point.php
===================================================================
--- branches/nimix_dev/http/classes/class_point.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_point.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,10 +17,7 @@
# 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__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
/**
* A Mapbender_point is a 2-dimensional point with an EPSG.
@@ -175,4 +172,4 @@
return (string) "(" . $this->x . "," . $this->y . "," . $this->epsg . ")";
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_weldMaps2Image.php
===================================================================
--- branches/nimix_dev/http/classes/class_weldMaps2Image.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_weldMaps2Image.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,10 +17,9 @@
# 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__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/class_stripRequest.php");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
require_once(dirname(__FILE__)."/class_connector.php");
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
/*
* Class generats Images (jpegs/pngs/geotiff)
@@ -198,4 +197,4 @@
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_weldMaps2PNG.php
===================================================================
--- branches/nimix_dev/http/classes/class_weldMaps2PNG.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_weldMaps2PNG.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -23,10 +23,9 @@
* get/post '___' separated maprequests
*
**/
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/class_stripRequest.php");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
require_once(dirname(__FILE__)."/class_connector.php");
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
class weldMaps2PNG{
@@ -80,4 +79,4 @@
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_wfs.php
===================================================================
--- branches/nimix_dev/http/classes/class_wfs.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_wfs.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -21,9 +21,8 @@
* class for wfs-objects
*/
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/class_connector.php");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
require_once(dirname(__FILE__)."/class_administration.php");
class wfs {
Modified: branches/nimix_dev/http/classes/class_wfs_conf.php
===================================================================
--- branches/nimix_dev/http/classes/class_wfs_conf.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_wfs_conf.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,9 +17,9 @@
# 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__)."/class_mb_exception.php");
-require_once(dirname(__FILE__)."/class_user.php");
-require_once(dirname(__FILE__)."/class_administration.php");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_user.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
class WfsConf {
@@ -42,7 +42,7 @@
*
* @return Object WFS conf data.
* @param $idOrIdArray Object May be an integer or an array of integers representing WFS conf IDs.
- */
+ */
public function load ($idOrIdArray) {
// Check parameter and set idArray
if (isset($idOrIdArray)){
@@ -51,6 +51,7 @@
if (!is_array($idOrIdArray) && is_numeric($idOrIdArray)) {
$idArray = array(intval($idOrIdArray));
}
+
// parameter is an array of numbers
if (is_array($idOrIdArray)) {
$idArray = array();
@@ -66,7 +67,7 @@
if ($_SESSION["mb_user_id"]) {
$user = new User($_SESSION["mb_user_id"]);
$idArray = array_intersect($idArray, $user->getWfsConfByPermission());
- }
+ }
return $this->getWfsConfFromDB($idArray);
}
@@ -92,24 +93,24 @@
* @param $idArray Array an array of integer values representing WFS conf IDs.
*/
private static function getWfsConfFromDbByArray ($idArray) {
- $sql = "SELECT * FROM wfs_conf ";
- $sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
- $sql .= "WHERE wfs_conf.wfs_conf_id IN (";
-
- $v = array();
- $t = array();
- for ($i = 0; $i < count($idArray); $i++) {
- if ($i > 0) {$sql .= ", ";}
- $sql .= "$" . ($i+1);
- array_push($v, $idArray[$i]);
- array_push($t, 'i');
- }
- $sql .= ")";
-
- $res = db_prep_query($sql, $v, $t);
-
+ $sql = "SELECT * FROM wfs_conf ";
+ $sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
+ $sql .= "WHERE wfs_conf.wfs_conf_id IN (";
+
+ $v = array();
+ $t = array();
+ for ($i = 0; $i < count($idArray); $i++) {
+ if ($i > 0) {$sql .= ", ";}
+ $sql .= "$" . ($i+1);
+ array_push($v, $idArray[$i]);
+ array_push($t, 'i');
+ }
+ $sql .= ")";
+
+ $res = db_prep_query($sql, $v, $t);
+
$rowArray = array();
- while ($row = db_fetch_array($res)) {
+ while ($row = db_fetch_array($res)) {
array_push($rowArray, $row);
}
return $rowArray;
@@ -120,7 +121,7 @@
*
* @return Array
* @param $id Integer the WFS conf ID.
- */
+ */
private static function getWfsConfElementFromDb ($id) {
$sql = "SELECT * FROM wfs_conf_element ";
$sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
@@ -131,7 +132,7 @@
$v = array($id);
$t = array('i');
$res = db_prep_query($sql, $v, $t);
-
+
$elementArray = array();
while ($row = db_fetch_array($res)) {
$currentElement = array("element_name" => $row["element_name"],
@@ -143,55 +144,55 @@
"f_label_id" => $row["f_label_id"],
"f_geom" => $row["f_geom"],
"f_show" => $row["f_show"],
- "f_mandatory" => $row_conf_element["f_mandatory"],
- "f_respos" => $row_conf_element["f_respos"],
- "f_min_input" => $row_conf_element["f_min_input"],
- "f_form_element_html" => $row_conf_element["f_form_element_html"],
- "f_show_detail" => $row_conf_element["f_show_detail"],
- "f_detailpos" => $row_conf_element["f_detailpos"],
- "f_operator" => $row_conf_element["f_operator"],
+ "f_mandatory" => $row["f_mandatory"],
+ "f_respos" => $row["f_respos"],
+ "f_min_input" => $row["f_min_input"],
+ "f_form_element_html" => $row["f_form_element_html"],
+ "f_auth_varname" => $row["f_auth_varname"],
+ "f_detailpos" => $row["f_detailpos"],
+ "f_operator" => $row["f_operator"],
"f_show_detail" => $row["f_show_detail"]
- );
- array_push($elementArray, $currentElement);
- }
+ );
+ array_push($elementArray, $currentElement);
+ }
return $elementArray;
}
-
+
/**
* Gets the database content of a WFS feature type given by a WFS ID and a featuretype ID.
*
* @return Array
* @param $wfsId Integer the WFS ID.
* @param $featuretypeId Integer the WFS featuretype ID.
- */
+ */
private static function getWfsFeatureTypeFromDb($wfsId, $featuretypeId) {
$sql = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
$v = array($wfsId, $featuretypeId);
$t = array("i", "i");
-
+
$res = db_prep_query($sql, $v, $t);
-
+
$currentRow = array();
-
+
if($row = db_fetch_array($res)){
$currentRow["featuretype_name"] = $row["featuretype_name"];
$currentRow["featuretype_srs"] = $row["featuretype_srs"];
- }
+ }
return $currentRow;
- }
+ }
/**
* get WFS conf data from database
*/
private function getWfsConfFromDB ($idArray) {
-
+
// if a user has access to some WFS confs...
if (count($idArray) > 0) {
-
+
// get WFS conf data from DB
$rowArray = self::getWfsConfFromDbByArray($idArray);
-
+
for ($i=0; $i < count($rowArray); $i++) {
// WFS conf data
@@ -227,11 +228,11 @@
else {
$e = new mb_warning("class_wfs_conf.php: getWfsConfFromDB: You don't have access to any WFS confs. Check EDIT WFS.");
return array();
+ }
}
+
}
-}
-
/**
* @deprecated
*/
@@ -377,4 +378,4 @@
}
}
}
-?>
\ No newline at end of file
+?>
Deleted: branches/nimix_dev/http/classes/class_wmc.php
===================================================================
--- branches/nimix_dev/http/classes/class_wmc.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_wmc.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -1,1375 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/class_wmc.php
-# 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__) . "/../../conf/mapbender.conf");
-require_once(dirname(__FILE__) . "/../classes/class_wms.php");
-require_once(dirname(__FILE__) . "/../classes/class_mb_exception.php");
-require_once(dirname(__FILE__) . "/../classes/class_layer_monitor.php");
-require_once(dirname(__FILE__) . "/../classes/class_point.php");
-require_once(dirname(__FILE__) . "/../classes/class_bbox.php");
-require_once(dirname(__FILE__) . "/../extensions/JSON.php");
-
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
-
-function mb_utf8_encode ($str) {
- if(CHARSET=="UTF-8") return utf8_encode($str);
- return $str;
-}
-function mb_utf8_decode ($str) {
- if(CHARSET=="UTF-8") return utf8_decode($str);
- return $str;
-}
-function sepNameSpace($s){
- $c = strpos($s,":");
- if($c>0)return substr($s,$c+1);
- return $s;
-}
-
-/**
- * Implementation of a Web Map Context Document, WMC 1.1.0
- */
-class wmc {
-
- var $xml;
-
- var $wmc_id;
- var $wmc_version;
- var $wmc_windowWidth;
- var $wmc_windowHeight;
- var $wmc_bBox_SRS;
- var $wmc_bBox_minx;
- var $wmc_bBox_maxx;
- var $wmc_bBox_miny;
- var $wmc_bBox_maxy;
- var $wmc_name;
- var $wmc_title;
- var $wmc_abstract;
- var $wmc_general_extension = array();
- var $wmc_logourl;
- var $wmc_logourl_format;
- var $wmc_logourl_type;
- var $wmc_logourl_width;
- var $wmc_logourl_height;
- var $wmc_descriptionurl;
- var $wmc_descriptionurl_format;
- var $wmc_descriptionurl_type;
- var $wmc_keyword = array();
- var $wmc_contactposition;
- var $wmc_contactvoicetelephone;
- var $wmc_contactemail;
- var $wmc_contactfacsimiletelephone;
- var $wmc_contactperson;
- var $wmc_contactorganization;
- var $wmc_contactaddresstype;
- var $wmc_contactaddress;
- var $wmc_contactcity;
- var $wmc_contactstateorprovince;
- var $wmc_contactpostcode;
- var $wmc_contactcountry;
-
-
- var $wmc_wms_title = array();
- var $wmc_layer_queryable = array();
- var $wmc_layer_hidden = array();
- var $wmc_wms_id = array();
- var $wmc_wms_service = array();
- var $wmc_wms_version = array();
- var $wmc_wms_layer_id = array();
- var $wmc_layer_wfs_featuretype = array();
- var $wmc_layer_id = array();
- var $wmc_layer_pos = array();
- var $wmc_layer_parent = array();
- var $wmc_layer_querylayer = array();
- var $wmc_layer_title = array();
- var $wmc_layer_name = array();
- var $wmc_layer_abstract = array();
- var $wmc_layer_srs = array();
- var $wmc_wms_serviceURL = array();
- var $wmc_layer_format_current = array();
- var $wmc_layer_dataurl = array();
- var $wmc_layer_metadataurl = array();
- var $wmc_layer_minscale = array();
- var $wmc_layer_maxscale = array();
- var $wmc_gui_layer_minscale = array();
- var $wmc_gui_layer_maxscale = array();
- var $wmc_layer_format = array();
- var $wmc_layer_style_current = array();
- var $wmc_layer_style_name = array();
- var $wmc_layer_style_title = array();
- var $wmc_layer_style_legendurl = array();
- var $wmc_layer_style_legendurl_width = array();
- var $wmc_layer_style_legendurl_height = array();
- var $wmc_layer_style_legendurl_format = array();
- var $wmc_layer_style_legendurl_type = array();
- var $wmc_layer_style_sld_url = array();
- var $wmc_layer_style_sld_type = array();
- var $wmc_layer_style_sld_title = array();
-
- var $wmc_wms_count = 0;
-
- /*
- var $data_type = array();
- var $data_format = array();
-
- var $objLayer = array();
-
- var $gui_wms_mapformat;
- var $gui_wms_featureinfoformat;
- var $gui_wms_exceptionformat;
- var $gui_wms_epsg;
-
- var $default_epsg = 0;
- */
- var $monitoringIsOn = false;
-
-function wmc() {
-}
-
-/**
- * Saves the current WMC in the log folder.
- *
- * @return string the filename of the WMC document.
- */
-function saveAsFile() {
- $filename = "wmc_" . date("Y_m_d_H_i_s") . ".log";
- $logfile = "../../log/" . $filename;
-
- if($h = fopen($logfile,"a")){
- $content = $this->xml;
- if(!fwrite($h,$content)){
- $e = new mb_exception("class_wmc.php: failed to write wmc.");
- return false;
- }
- fclose($h);
- }
- return $filename;
-}
-
-/**
- * @return string the title of the WMC.
- */
-function getTitle() {
- return $this->wmc_title;
-}
-
-/**
- * @return Integer the number of (unique?) WMS contained in this WMC.
- */
-function getNumberOfWms () {
- return $this->wmc_wms_count;
-}
-
-/**
- * Creates a WMC object from a JS map object {@see map.js}
- *
- * @param object $mapObject a map object
- * @param integer $user_id the ID of the current user
- * @param string $generalTitle the desired title of the WMC
- * @param object $extensionData data exclusive to Mapbender, which will be
- * mapped into the extension part of the WMC
- */
-function createWMCFromObj($mapObject, $user_id, $generalTitle, $extensionData) {
- $this->wmc_id = $user_id . '_' . time();
-
- $generalWidth = $mapObject->width;
- $generalHeight = $mapObject->height;
- $generalBboxSrs = $mapObject->epsg;
-
- $arrayBBox = explode(",", $mapObject->extent);
- $generalBboxMinx = floatval($arrayBBox[0]);
- $generalBboxMiny = floatval($arrayBBox[1]);
- $generalBboxMaxx = floatval($arrayBBox[2]);
- $generalBboxMaxy = floatval($arrayBBox[3]);
-
- $generalName = "Mapbender WMC"; // TO do : insert proper data
- $generalKeywords = array("Mapbender", "WMC"); // TO do : insert proper data
- $generalAbstract = ""; // TO do : insert proper data
- $generalLogoUrl = ""; // TO do : insert proper data
- $generalLogoUrlWidth = ""; // TO do : insert proper data
- $generalLogoUrlHeight = ""; // TO do : insert proper data
- $generalLogoUrlFormat = ""; // TO do : insert proper data
- $generalDescriptionUrl = ""; // TO do : insert proper data
- $generalContactPerson = "";
- $generalContactOrganization = "";
- $generalContactPosition = "";
- $generalContactAddressType = "";
- $generalContactAddress = "";
- $generalContactCity = "";
- $generalContactStateOrProvince = "";
- $generalContactPostCode = "";
- $generalContactCountry = "";
- $generalContactVoiceTelephone = "";
- $generalContactFacsimileTelephone = "";
- $generalContactElectronicMailAddress = "";
-
- $extension_namespace = "mapbender";
-
- // LayerList variables
- $layerHidden = "";
- $layerQueryable = "";
- $layerAbstract = "";
- $layerName = "";
- $layerSrs = "";
- $layerDataUrl = "";
- $layerMetadataUrl = "";
- $layerFormat = "";
- $layerFormat_current = "";
- $layerStyle_current = "";
- $layerStyle_name = "";
- $layerStyle_title = "";
- $layerStyle_legendURL = "";
- $layerStyle_legendURL_width = "";
- $layerStyle_legendURL_height = "";
- $layerStyle_legendURL_format = "";
-
- // generate XML
- $doc = new DOMDocument("1.0", CHARSET);
- $doc->preserveWhiteSpace = false;
-
- // ViewContext
- $e_view_context = $doc->createElementNS("http://www.opengis.net/context", "ViewContext");
-
-
- $e_view_context->setAttribute("version", "1.0.0");
- $e_view_context->setAttribute("id", $this->wmc_id);
- $e_view_context->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
- $e_view_context->setAttribute("xmlns:mapbender", "http://www.mapbender.org");
- $e_view_context->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
- $e_view_context->setAttribute("xsi:SchemaLocation", "http://schemas.opengis.net/context/1.0.0/context.xsd");
-
- // General
- $e_general = $doc->createElement("General");
-
- $e_window = $doc->createElement("Window");
- if (!empty($generalWidth) && !empty($generalHeight)) {
- $e_window->setAttribute("width", $generalWidth);
- $e_window->setAttribute("height", $generalHeight);
- }
- $e_general->appendChild($e_window);
-
- $e_bbox = $doc->createElement("BoundingBox");
- $e_bbox->setAttribute("SRS", $generalBboxSrs);
- $e_bbox->setAttribute("minx", $generalBboxMinx);
- $e_bbox->setAttribute("miny", $generalBboxMiny);
- $e_bbox->setAttribute("maxx", $generalBboxMaxx);
- $e_bbox->setAttribute("maxy", $generalBboxMaxy);
- $e_general->appendChild($e_bbox);
-
- $e_name = $doc->createElement("Name", $generalName);
- $e_general->appendChild($e_name);
-
- $e_title = $doc->createElement("Title", $generalTitle);
- $e_general->appendChild($e_title);
-
- $e_keyword_list = $doc->createElement("KeywordList");
- for ($i=0; $i < count($generalKeywords); $i++) {
- $e_keyword = $doc->createElement("Keyword", $generalKeywords[$i]);
- $e_keyword_list->appendChild($e_keyword);
- }
- $e_general->appendChild($e_keyword_list);
-
- if ($generalAbstract){
- $e_abstract = $doc->createElement("Abstract", $generalAbstract);
- $e_general->appendChild($e_abstract);
- }
-
- if ($generalLogoUrlWidth && $generalLogoUrlHeight && $generalLogoUrlFormat && $generalLogoUrl){
- $e_logo_url = $doc->createElement("LogoURL");
- $e_logo_url->setAttribute("width", $generalLogoUrlWidth);
- $e_logo_url->setAttribute("height", $generalLogoUrlHeight);
- $e_logo_url->setAttribute("format", $generalLogoUrlFormat);
-
- $e_logo_url_or = $doc->createElement("OnlineResource");
- $e_logo_url_or->setAttributeNS("http://www.opengis.net/context", "xmlns:xlink", "http://www.w3.org/1999/xlink");
- $e_logo_url_or->setAttribute("xlink:type", "simple");
- $e_logo_url_or->setAttribute("xlink:href", $generalLogoUrl);
- $e_logo_url->appendChild($e_logo_url_or);
-
- $e_general->appendChild($e_logo_url);
- }
-
- if ($generalDescriptionUrl){
- $e_description_url = $doc->createElement("DescriptionURL");
-
- $e_description_url_or = $doc->createElement("OnlineResource");
- $e_description_url_or->setAttributeNS("http://www.opengis.net/context", "xmlns:xlink", "http://www.w3.org/1999/xlink");
- $e_description_url_or->setAttribute("xlink:type", "simple");
- $e_description_url_or->setAttribute("xlink:href", $generalDescriptionUrl);
- $e_description_url->appendChild($e_description_url_or);
-
- $e_general->appendChild($e_description_url);
- }
-
- if ($generalContactElectronicMailAddress || $generalContactOrganization ||
- $generalContactPerson || $generalContactPosition || $generalContactAddressType ||
- $generalContactAddress || $generalContactCity || $generalContactStateOrProvince ||
- $generalContactPostCode || $generalContactCountry || $generalContactVoiceTelephone ||
- $generalContactFacsimileTelephone || $generalContactElectronicMailAddress) {
-
- $e_contact = $doc->createElement("ContactInformation");
-
- if ($generalContactPerson || $generalContactOrganization){
- $e_contact_person_primary = $doc->createElement("ContactPersonPrimary");
-
- if ($generalContactPerson){
- $e_contact_person = $doc->createElement("ContactPerson", $generalContactPerson);
- $e_contact_person_primary->appendChild($e_contact_person);
- }
- if ($generalContactOrganization){
- $e_contact_organization = $doc->createElement("ContactOrganization", $generalContactOrganization);
- $e_contact_person_primary->appendChild($e_contact_organization);
- }
- $e_contact->appendChild($e_contact_person_primary);
- }
-
- if ($generalContactPosition){
- $e_contact_position = $doc->createElement("ContactPosition", $generalContactPosition);
- $e_contact->appendChild($e_contact_position);
- }
-
- if ($generalContactAddressType || $generalContactAddress ||
- $generalContactCity || $generalContactStateOrProvince ||
- $generalContactPostCode || $generalContactCountry) {
-
- $e_contact_address = $doc->createElement("ContactAddress");
-
- if ($generalContactAddressType){
- $e_address_type = $doc->createElement("AddressType", $generalContactAddressType);
- $e_contact_address->appendChild($e_address_type);
- }
- if ($generalContactAddress){
- $e_address = $doc->createElement("Address", $generalContactAddress);
- $e_contact_address->appendChild($e_address);
- }
- if ($generalContactCity){
- $e_city = $doc->createElement("City", $generalContactCity);
- $e_contact_address->appendChild($e_city);
- }
- if ($generalContactStateOrProvince){
- $e_state = $doc->createElement("StateOrProvince", $generalContactStateOrProvince);
- $e_contact_address->appendChild($e_state);
- }
- if ($generalContactPostCode){
- $e_postcode = $doc->createElement("PostCode", $generalContactPostCode);
- $e_contact_address->appendChild($e_postcode);
- }
- if ($generalContactCountry){
- $e_country = $doc->createElement("Country", $generalContactCountry);
- $e_contact_address->appendChild($e_country);
- }
- $e_contact->appendChild($e_contact_address);
- }
-
- if ($generalContactVoiceTelephone){
- $e_voice_telephone = $doc->createElement("ContactVoiceTelephone", $generalContactVoiceTelephone);
- $e_contact->appendChild($e_voice_telephone);
- }
- if ($generalContactFacsimileTelephone){
- $e_facsimile_telephone = $doc->createElement("ContactFacsimileTelephone", $generalContactFacsimileTelephone);
- $e_contact->appendChild($e_facsimile_telephone);
- }
- if ($generalContactElectronicMailAddress){
- $e_email = $doc->createElement("ContactElectronicMailAddress", $generalContactElectronicMailAddress);
- $e_contact->appendChild($e_email);
- }
- $e_general->appendChild($e_contact);
- }
-
-
- if (count($extensionData) > 0) {
- //$e = new mb_exception("writing wmc...");
- $e_extensionGeneral = $doc->createElement("Extension");
-
- foreach ($extensionData as $keyExtensionData => $valueExtensionData) {
- $e_currentExtensionTag = $doc->createElement($extension_namespace.":".$keyExtensionData, $valueExtensionData);
- $e_extensionGeneral->appendChild($e_currentExtensionTag);
- }
- $e_general->appendChild($e_extensionGeneral);
- }
- $e_view_context->appendChild($e_general);
-
-
- // LayerList
- $e_layer_list = $doc->createElement("LayerList");
-
- for ($i=0; $i < count($mapObject->wms); $i++){
- $wmsId = $mapObject->wms[$i]->wms_id;
- $wms_epsg = array();
- $wms_epsg[0] = $mapObject->epsg;
-
- if ($mapObject->wms[$i]->gui_wms_epsg != $mapObject->epsg){
- $wms_epsg[1] = $mapObject->wms[$i]->gui_wms_epsg;
- }
-
- for ($q = 0; $q < count($mapObject->wms[$i]->gui_epsg); $q++){
- $isInArray = false;
-
- for ($r=0 ; $r < count($wms_epsg); $r++){
- if ($wms_epsg[$r] == $mapObject->wms[$i]->gui_epsg[$q]){
- $isInArray = true;
- }
- }
- if ($isInArray == false){
- array_push($wms_epsg, $mapObject->wms[$i]->gui_epsg[$q]);
- }
- }
- for ($j = 0; $j < count($mapObject->wms[$i]->objLayer); $j++){
- if ($mapObject->wms[$i]->objLayer[$j]->layer_parent != ''){
- if ($mapObject->wms[$i]->objLayer[$j]->gui_layer_visible == "1"){
- $layerHidden = 0;
- }
- else{
- $layerHidden = 1;
- }
- $layerQueryable = $mapObject->wms[$i]->objLayer[$j]->layer_queryable;
- $layerQuerylayer = $mapObject->wms[$i]->objLayer[$j]->gui_layer_querylayer;
- $layerId = $mapObject->wms[$i]->objLayer[$j]->layer_uid;
- $layerName = $mapObject->wms[$i]->objLayer[$j]->layer_name;
- $layerTitle = $mapObject->wms[$i]->objLayer[$j]->layer_title;
- $layerAbstract = $mapObject->wms[$i]->wms_abstract; //To Do: insert actual abstract
- $layerDataUrl = $mapObject->wms[$i]->objLayer[$j]->layer_dataurl_href;
- $layerMetadataUrl = $mapObject->wms[$i]->objLayer[$j]->layer_metadataurl;
- $layerMinscale = $mapObject->wms[$i]->objLayer[$j]->layer_minscale;
- $layerMaxscale = $mapObject->wms[$i]->objLayer[$j]->layer_maxscale;
- $guiLayerMinscale = $mapObject->wms[$i]->objLayer[$j]->gui_layer_minscale;
- $guiLayerMaxscale = $mapObject->wms[$i]->objLayer[$j]->gui_layer_maxscale;
- $wmsVersion = $mapObject->wms[$i]->wms_version;
- $wmsTitle = $mapObject->wms[$i]->wms_title;
- $wmsLayerId = $mapObject->wms[$i]->objLayer[0]->layer_uid;
- $wmsOnlineResource = $mapObject->wms[$i]->wms_getmap;
- $layerPos = $mapObject->wms[$i]->objLayer[$j]->layer_pos;
- $layerParent = $mapObject->wms[$i]->objLayer[$j]->layer_parent;
- $queryLayer = $mapObject->wms[$i]->objLayer[$j]->gui_layer_querylayer;
- $wfsFeatureType = $mapObject->wms[$i]->objLayer[$j]->gui_layer_wfs_featuretype;
-
- $e_layer = $doc->createElement("Layer");
- $e_layer->setAttribute("queryable", $layerQueryable);
- $e_layer->setAttribute("hidden", $layerHidden);
-
- $e_service = $doc->createElement("Server");
- $e_service->setAttribute("service", "OGC:WMS");
- $e_service->setAttribute("version", $wmsVersion);
- $e_service->setAttribute("title", $wmsTitle);
-
- $e_service_or = $doc->createElement("OnlineResource");
- $e_service_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
- $e_service_or->setAttribute("xlink:type", "simple");
- $e_service_or->setAttribute("xlink:href", $wmsOnlineResource);
-
- $e_service->appendChild($e_service_or);
- $e_layer->appendChild($e_service);
-
- $e_layer_name = $doc->createElement("Name", $layerName);
- $e_layer->appendChild($e_layer_name);
-
- $e_layer_title = $doc->createElement("Title", $layerTitle);
- $e_layer->appendChild($e_layer_title);
-
- if ($layerAbstract){
- $e_layer_abstract = $doc->createElement("Abstract", $layerAbstract);
- $e_layer->appendChild($e_layer_abstract);
- }
-
- $e_layer_srs = $doc->createElement("SRS", implode(" ", $wms_epsg));
- $e_layer->appendChild($e_layer_name);
-
- if ($layerDataUrl){
- $e_layer_data_url = $doc->createElement("DataURL");
-
- $e_layer_data_url_or = $doc->createElement("OnlineResource");
- $e_layer_data_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
- $e_layer_data_url_or->setAttribute("xlink:type", "simple");
- $e_layer_data_url_or->setAttribute("xlink:href", $layerDataUrl);
-
- $e_layer_data_url->appendChild($e_layer_data_url_or);
- $e_layer->appendChild($e_layer_data_url);
- }
-
- if ($layerMetadataUrl){
- $e_layer_metadata_url = $doc->createElement("MetadataURL");
-
- $e_layer_metadata_url_or = $doc->createElement("OnlineResource");
- $e_layer_metadata_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
- $e_layer_metadata_url_or->setAttribute("xlink:type", "simple");
- $e_layer_metadata_url_or->setAttribute("xlink:href", $layerMetadataUrl);
-
- $e_layer_metadata_url->appendChild($e_layer_metadata_url_or);
- $e_layer->appendChild($e_layer_metadata_url);
- }
-
- $e_extension = $doc->createElement("Extension");
-
- $e_scalehint = $doc->createElement($extension_namespace.":ScaleHint");
- $e_scalehint->setAttribute("min", $layerMinscale);
- $e_scalehint->setAttribute("max", $layerMaxscale);
- $e_extension->appendChild($e_scalehint);
-
- $e_gui_scalehint = $doc->createElement($extension_namespace.":guiScaleHint");
- $e_gui_scalehint->setAttribute("min", $guiLayerMinscale);
- $e_gui_scalehint->setAttribute("max", $guiLayerMaxscale);
- $e_extension->appendChild($e_gui_scalehint);
-
- $e_layer_id = $doc->createElement($extension_namespace.":layer_id", $layerId);
- $e_extension->appendChild($e_layer_id);
-
- $e_wms_layer_id = $doc->createElement($extension_namespace.":wms_layer_id", $wmsLayerId);
- $e_extension->appendChild($e_wms_layer_id);
-
- $e_layer_pos = $doc->createElement($extension_namespace.":layer_pos", $layerPos);
- $e_extension->appendChild($e_layer_pos);
-
- $e_layer_parent = $doc->createElement($extension_namespace.":layer_parent", $layerParent);
- $e_extension->appendChild($e_layer_parent);
-
- $e_wms_id = $doc->createElement($extension_namespace.":wms_id", $wmsId);
- $e_extension->appendChild($e_wms_id);
-
- $e_querylayer = $doc->createElement($extension_namespace.":querylayer", $layerQuerylayer);
- $e_extension->appendChild($e_querylayer);
-
- if ($wfsFeatureType) {
- $e_wfsFeatureType = $doc->createElement($extension_namespace.":wfsFeatureType", $wfsFeatureType);
- $e_extension->appendChild($e_wfsFeatureType);
- }
-
- $e_layer->appendChild($e_extension);
-
- //layerFormat
- $e_layer_format = $doc->createElement("FormatList");
-
- $data_format_current = false;
-
- for ($k = 0; $k < count($mapObject->wms[$i]->data_format); $k++){
-
- if ($mapObject->wms[$i]->data_type[$k] == "map") {
- $layerFormat = $mapObject->wms[$i]->data_format[$k];
-
- $e_format = $doc->createElement("Format", $layerFormat);
-
- if ($data_format_current == false && (
- ($mapObject->wms[$i]->data_format[$k] == $mapObject->wms[$i]->gui_wms_mapformat) ||
- ($k == (count($mapObject->wms[$i]->data_format)-1))
- )){
-
- $e_format->setAttribute("current", "1");
- $data_format_current = true;
- }
- $e_layer_format->appendChild($e_format);
- }
- }
- $e_layer->appendChild($e_layer_format);
-
-
- // LayerStyle
- $e_layer_stylelist = $doc->createElement("StyleList");
-
- for ($k = 0; $k < count($mapObject->wms[$i]->objLayer[$j]->layer_style); $k++){
-
- if ($k == 0){
- $layerStyle_current = 1; // To do: insert proper data
- }
- else{
- $layerStyle_current = 0; // To do: insert proper data
- }
-
- $e_layer_style = $doc->createElement("Style");
-
- $layerStyleSLD = "";
-
- if ($layerStyleSLD){
- $layerStyleSLDUrl = ""; // To Do: Insert Proper Data
-
- $e_layer_style_or = $doc->createElement("OnlineResource");
- $e_layer_style_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
- $e_layer_style_or->setAttribute("xlink:type", "simple");
- $e_layer_style_or->setAttribute("xlink:href", $layerStyleSLDUrl);
- $e_layer_style->appendChild($e_layer_style_or);
- }
- else{
- //TODO: determine correct layer style entries
- $layerStyle_name = $mapObject->wms[$i]->objLayer[$j]->layer_style[$k]->name;
- $layerStyle_title = $mapObject->wms[$i]->objLayer[$j]->layer_style[$k]->title;
- $layerStyle_legendUrl = $mapObject->wms[$i]->objLayer[$j]->layer_style[$k]->legendurl;
- $layerStyle_legendUrl_width = ""; // To Do: add proper data
- $layerStyle_legendUrl_height = ""; // To Do: add proper data
- $layerStyle_legendUrl_format = ""; // To Do: add proper data
-
- if ($layerStyle_current == 1){
- $e_layer_style->setAttribute("current", "1");
- }
-
- $e_layer_style_name = $doc->createElement("Name", $layerStyle_name);
- $e_layer_style->appendChild($e_layer_style_name);
-
- $e_layer_style_title = $doc->createElement("Title", $layerStyle_title);
- $e_layer_style->appendChild($e_layer_style_title);
-
-
- $e_layer_style_legendurl = $doc->createElement("LegendUrl");
- $e_layer_style_legendurl->setAttribute("width", $layerStyle_legendUrl_width);
- $e_layer_style_legendurl->setAttribute("height", $layerStyle_legendUrl_height);
- $e_layer_style_legendurl->setAttribute("format", $layerStyle_legendUrl_format);
-
- $e_layer_style_legendurl_or = $doc->createElement("OnlineResource");
- $e_layer_style_legendurl_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
- $e_layer_style_legendurl_or->setAttribute("xlink:type", "simple");
- $e_layer_style_legendurl_or->setAttribute("xlink:href", $layerStyle_legendUrl);
- $e_layer_style_legendurl->appendChild($e_layer_style_legendurl_or);
- $e_layer_style->appendChild($e_layer_style_legendurl);
- }
- $e_layer_stylelist->appendChild($e_layer_style);
- }
- $e_layer->appendChild($e_layer_stylelist);
-
- $e_layer_list->appendChild($e_layer);
- }
- }
- }
- $e_view_context->appendChild($e_layer_list);
-
-
- $doc->appendChild($e_view_context);
- $this->xml = $doc->saveXML();
-
- // for debugging: saving WMC as file
- // (comment when no longer needed)
- $filename = $this->saveAsFile();
- if ($filename) {
- $e = new mb_notice("class_wmc: saving WMC as file " . $filename);
- }
-}
-
-/**
- * Loads a WMC from the database.
- *
- * @param integer $wmc_id the ID of the WMC document in the database table "mb_user_wmc"
- */
-function createObjFromWMC_id($wmc_id){
-
- global $DBSERVER,$DB,$OWNER,$PW;
- $con = db_connect($DBSERVER,$OWNER,$PW);
- db_select_db(DB, $con);
-
- $sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_id = $1";
- $v = array($wmc_id);
- $t = array("i");
- $res = db_prep_query($sql, $v, $t);
- $wmc = db_fetch_row($res);
- $this->createObjFromWMC_xml($wmc[0]);
- $this->monitoringIsOn = true;
-}
-
-/**
- * Loads a WMC from an actual WMC XML document.
- *
- * @param string $data the data from the XML file
- */
-function createObjFromWMC_xml($data){
-# $data = str_replace("&", "&", $data);
-
- // store xml
- $this->xml = $data;
-
- // for debugging: saving WMC as file
- // (comment when no longer needed)
- $filename = $this->saveAsFile();
- if ($filename) {
- $e = new mb_notice("class_wmc: saving WMC as file " . $filename);
- }
-
-
-
- $values = NULL;
- $tags = NULL;
- $parser = xml_parser_create(CHARSET);
- xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
- xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
- xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
- xml_parse_into_struct($parser,$data,$values,$tags);
- $code = xml_get_error_code ($parser);
- if ($code) {
- $line = xml_get_current_line_number($parser);
- $mb_exception = new mb_exception(xml_error_string($code) . " in line " . $line);
- return false;
- }
- xml_parser_free($parser);
-
- $section = NULL;
- $format = NULL;
- $cnt_format = 0;
- $parent = array();
- $myParent = array();
- $cnt_layer = -1;
- $request = NULL;
- $layer_style = array();
- $extension = false;
-
- $general = false;
- $layerlist = false;
- $layer = false;
- $formatlist = false;
- $dataurl = false;
- $metadataurl = false;
- $stylelist = false;
- $cnt_style = -1;
-
- foreach ($values as $element) {
- $verbose .= ".";
- if(strtoupper($element[tag]) == "VIEWCONTEXT" && $element[type] == "open"){
- $this->wmc_id = $element[attributes]["id"];
- $this->wmc_version = $element[attributes]["version"];
- }
- if(strtoupper($element[tag]) == "GENERAL" && $element[type] == "open"){
- $general = true;
- }
- if(strtoupper($element[tag]) == "LAYERLIST" && $element[type] == "open"){
- $layerlist = true;
- }
- if ($general) {
- if(strtoupper($element[tag]) == "WINDOW"){
- $this->wmc_windowWidth = $element[attributes]["width"];
- $this->wmc_windowHeight = $element[attributes]["height"];
- }
- if(strtoupper($element[tag]) == "BOUNDINGBOX"){
- $this->wmc_bBox_SRS = $element[attributes]["SRS"];
- $this->wmc_bBox_minx = $element[attributes]["minx"];
- $this->wmc_bBox_miny = $element[attributes]["miny"];
- $this->wmc_bBox_maxx = $element[attributes]["maxx"];
- $this->wmc_bBox_maxy = $element[attributes]["maxy"];
- }
- if(strtoupper($element[tag]) == "NAME"){
- $this->wmc_name = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "TITLE"){
- $this->wmc_title = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "ABSTRACT"){
- $this->wmc_abstract = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "CONTACTINFORMATION" && $element['type'] == "open"){
- $contactinformation = true;
- }
- if ($contactinformation) {
- if(strtoupper($element[tag]) == "CONTACTPOSITION"){
- $this->wmc_contactposition = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "CONTACTVOICETELEPHONE"){
- $this->wmc_contactvoicetelephone = $element[value];
- }
- if(strtoupper($element[tag]) == "CONTACTFACSIMILETELEPHONE"){
- $this->wmc_contactfacsimiletelephone = $element[value];
- }
- if(strtoupper($element[tag]) == "CONTACTELECTRONICMAILADDRESS"){
- $this->wmc_contactemail = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "open"){
- $contactpersonprimary = true;
- }
- if ($contactpersonprimary) {
- if(strtoupper($element[tag]) == "CONTACTPERSON"){
- $this->wmc_contactperson = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "CONTACTORGANIZATION"){
- $this->wmc_contactorganization = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "close"){
- $contactpersonprimary = false;
- }
- }
- if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "open"){
- $contactaddress = true;
- }
- if ($contactaddress) {
- if(strtoupper($element[tag]) == "ADDRESSTYPE"){
- $this->wmc_contactaddresstype = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "ADDRESS"){
- $this->wmc_contactaddress = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "CITY"){
- $this->wmc_contactcity = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "STATEORPROVINCE"){
- $this->wmc_contactstateorprovince = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "POSTCODE"){
- $this->wmc_contactpostcode = $element[value];
- }
- if(strtoupper($element[tag]) == "COUNTRY"){
- $this->wmc_contactcountry = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "close"){
- $contactaddress = false;
- }
- }
- }
- if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "open"){
- $logourl = true;
- $this->wmc_logourl_width = $element[attributes]["width"];
- $this->wmc_logourl_height = $element[attributes]["height"];
- $this->wmc_logourl_format = $element[attributes]["format"];
- }
- if ($logourl) {
- if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "close"){
- $logourl = false;
- }
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_logourl_type = $element[attributes]["xlink:type"];
- $this->wmc_logourl = $element[attributes]["xlink:href"];
- }
- }
- if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "open"){
- $descriptionurl = true;
- $this->wmc_descriptionurl_format = $element[attributes]["format"];
- }
- if ($descriptionurl) {
- if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "close"){
- $descriptionurl = false;
- }
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_descriptionurl_type = $element[attributes]["xlink:type"];
- $this->wmc_descriptionurl = $element[attributes]["xlink:href"];
- }
- }
- if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "open"){
- $keywordlist = true;
- }
- if ($keywordlist) {
- if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "close"){
- $keywordlist = false;
- $cnt_keyword = -1;
- }
- if(strtoupper($element[tag]) == "KEYWORD"){
- $cnt_keyword++;
- $this->wmc_keyword[$cnt_keyword] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- }
-
- if(strtoupper($element[tag]) == "EXTENSION" && $element['type'] == "close"){
- $generalExtension = false;
- }
- if ($generalExtension) {
- $this->wmc_general_extension[sepNameSpace($element[tag])] = $element[value];
-// $e = new mb_exception("WMC: " . $element[tag] . ": " . $element[value]);
- }
- if(strtoupper($element[tag]) == "EXTENSION" && $element['type'] == "open"){
- $generalExtension = true;
- }
-
- if(strtoupper($element[tag]) == "GENERAL" && $element['type'] == "close"){
- $general = false;
- }
- }
- if ($layerlist) {
- if(strtoupper($element[tag]) == "LAYERLIST" && $element['type'] == "close"){
- $layerlist = false;
- }
- if(strtoupper($element[tag]) == "LAYER" && $element[type] == "open"){
- $cnt_layer++;
- $this->wmc_layer_queryable[$cnt_layer] = $element[attributes]["queryable"];
- $this->wmc_layer_hidden[$cnt_layer] = $element[attributes]["hidden"];
- $layer = true;
- $cnt_epsg = 0;
- }
- if ($layer) {
- if(strtoupper($element[tag]) == "LAYER" && $element[type] == "close"){
- $layer = false;
- }
- if ($formatlist) {
- if(strtoupper($element[tag]) == "FORMAT"){
- $cnt_format++;
- $this->wmc_layer_format_current[$cnt_layer][$cnt_format] = $element[attributes]["current"];
- $this->wmc_layer_format[$cnt_layer][$cnt_format] = $element[value];
- }
- if(strtoupper($element[tag]) == "FORMATLIST" && $element[type] == "close"){
- $formatlist = false;
- }
- }
- elseif ($metadataurl) {
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_layer_metadataurl[$cnt_layer] = $element[attributes]["xlink:href"];
- }
- if(strtoupper($element[tag]) == "METADATAURL" && $element[type] == "close"){
- $metadataurl = false;
- }
- }
- elseif ($dataurl) {
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_layer_dataurl[$cnt_layer] = $element[attributes]["xlink:href"];
- }
- if(strtoupper($element[tag]) == "DATAURL" && $element[type] == "close"){
- $dataurl = false;
- }
- }
- elseif ($stylelist) {
- if(strtoupper($element[tag]) == "STYLE" && $element[type] == "open"){
- $cnt_style++;
- $style = true;
- $this->wmc_layer_style_current[$cnt_layer][$cnt_style] = $element[attributes]["current"];
- }
- if ($style) {
- if(strtoupper($element[tag]) == "STYLE" && $element[type] == "close"){
- $style = false;
- }
- if(strtoupper($element[tag]) == "SLD" && $element[type] == "open"){
- $sld = true;
- }
- if ($sld) {
- if(strtoupper($element[tag]) == "SLD" && $element[type] == "close"){
- $sld = false;
- }
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_layer_style_sld_type[$cnt_layer][$cnt_style] = $element[attributes]["xlink:type"];
- $this->wmc_layer_style_sld_url[$cnt_layer][$cnt_style] = $element[attributes]["xlink:href"];
- }
- if(strtoupper($element[tag]) == "TITLE"){
- $this->wmc_layer_style_sld_title[$cnt_layer][$cnt_style] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- }
- else {
- if(strtoupper($element[tag]) == "NAME"){
- $this->wmc_layer_style_name[$cnt_layer][$cnt_style] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "TITLE"){
- $this->wmc_layer_style_title[$cnt_layer][$cnt_style] = $element[value];
- }
- if(strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "open"){
- $legendurl = true;
- $this->wmc_layer_style_legendurl_width[$cnt_layer][$cnt_style] = $element[attributes]["width"];
- $this->wmc_layer_style_legendurl_height[$cnt_layer][$cnt_style] = $element[attributes]["height"];
- $this->wmc_layer_style_legendurl_format[$cnt_layer][$cnt_style] = $element[attributes]["format"];
- }
- if ($legendurl) {
- if(strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "close"){
- $legendurl = false;
- }
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_layer_style_legendurl_type[$cnt_layer][$cnt_style] = $element[attributes]["xlink:type"];
- $this->wmc_layer_style_legendurl[$cnt_layer][$cnt_style] = $element[attributes]["xlink:href"];
- }
- }
- }
- }
- if(strtoupper($element[tag]) == "STYLELIST" && $element[type] == "close"){
- $stylelist = false;
- }
- }
- else {
- if(strtoupper($element[tag]) == "SERVER" && $element[type] == "open"){
- $server = true;
- $this->wmc_wms_service[$cnt_layer] = $element[attributes]["service"];
- $this->wmc_wms_version[$cnt_layer] = $element[attributes]["version"];
- $this->wmc_wms_title[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[attributes]["title"]));
- }
- if ($server) {
- if(strtoupper($element[tag]) == "SERVER" && $element[type] == "close"){
- $server = false;
- }
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_wms_serviceURL[$cnt_layer] = $element[attributes]["xlink:href"];
- }
- }
- if(strtoupper($element[tag]) == "NAME"){
- $this->wmc_layer_name[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "TITLE"){
- $this->wmc_layer_title[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "ABSTRACT"){
- $this->wmc_layer_abstract[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "SRS"){
- $epsgArray = explode(" ", $element[value]);
-
- for ($c = 0 ; $c < count($epsgArray) ; $c ++) {
- $this->wmc_layer_srs[$cnt_layer][$cnt_epsg] = $epsgArray[$c];
- $cnt_epsg++;
- }
- }
- if (strtoupper($element[tag]) == "EXTENSION" && $element[type] == "open") {
- $extension = true;
- }
- if (strtoupper($element[tag]) == "EXTENSION" && $element[type] == "close") {
- $extension = false;
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "SCALEHINT"){
- $this->wmc_layer_minscale[$cnt_layer] = $element[attributes]["min"];
- $this->wmc_layer_maxscale[$cnt_layer] = $element[attributes]["max"];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "GUISCALEHINT"){
- $this->wmc_gui_layer_minscale[$cnt_layer] = $element[attributes]["min"];
- $this->wmc_gui_layer_maxscale[$cnt_layer] = $element[attributes]["max"];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "LAYER_ID"){
- $this->wmc_layer_id[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WMS_LAYER_ID"){
- $this->wmc_wms_layer_id[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "LAYER_POS"){
- $this->wmc_layer_pos[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "LAYER_PARENT"){
- $this->wmc_layer_parent[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "QUERYLAYER"){
- $this->wmc_layer_querylayer[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WMS_ID"){
- $this->wmc_wms_id[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WFSFEATURETYPE"){
- $this->wmc_layer_wfs_featuretype[$cnt_layer] = $element[value];
- }
- if(strtoupper($element[tag]) == "METADATAURL" && $element[type] == "open"){
- $metadataurl = true;
- }
- if(strtoupper($element[tag]) == "DATAURL" && $element[type] == "open"){
- $dataurl = true;
- }
- if(strtoupper($element[tag]) == "FORMATLIST" && $element[type] == "open"){
- $formatlist = true;
- $cnt_format = -1;
- }
- if(strtoupper($element[tag]) == "STYLELIST" && $element[type] == "open"){
- $stylelist = true;
- $cnt_style = -1;
- }
- }
- }
- }
- }
- return true;
- //return $verbose;
- }
-
- /**
- * Creates JS code manipulating the map and wms objects,
- * by this displaying the WMC
- *
- * @param string $target the link to the map object, f.e. "parent." or "window.opener."
- * @param string $mapObj the name of the map object, f.e. "mapframe1"
- * @param string $action "load", "merge" or "append"
- *
- * @return string the JS code
- */
- function createJsObjFromWMC($target, $mapObj, $action){
-
- /*
- * counts how often a layer has been loaded
- */
- if ($this->monitoringIsOn) {
- $monitor = new Layer_load_count();
- for ($i = 0; $i < count($this->wmc_layer_id); $i++) {
- $monitor->increment($this->wmc_layer_id[$i]);
- }
- }
-
- $wmc_string = "";
- $validActions = array("load", "merge", "append");
- if (!in_array($action, $validActions)) {
- $wmc_string .= "alert('invalid action: ".$action."');";
- }
- else {
-
- // general extension
- if (count($this->wmc_general_extension) > 0) {
- $json = new Services_JSON();
- $wmc_string .= $target . "restoredWmcExtensionData = " . $json->encode($this->wmc_general_extension) . ";\n";
- }
-
- $wmc_string .= "var index = " . $target . "getMapObjIndexByName('" . $mapObj . "');\n";
- if ($action == "load") {
- // delete all previous wms
- $wmc_string .= "while(" . $target . "mb_mapObj[index].wms.length > 0){" . $target . "mb_mapObjremoveWMS(index,0);}";
- $wmc_string .= $target . "deleteWmsObject();\n";
- }
- if ($action == "merge") {
- $wmc_string .= "var wms_exists = false;\n"; // true if this wms exists in the mapObj
- $wmc_string .= "var current_wms_index = null;\n"; // if wms_exists: index of the wms in the map obj; else: null
- $wmc_string .= "var layer_exists = false;\n"; // true if this layer exists in an existing wms of the mapObj
- $wmc_string .= "var current_layer_index = null;\n"; // if layer_exists: index of the layer of the wms in the mapObj; else: null
- }
- $new_wms = "";
- $cnt_wms = -1;
- $added_wms = array();
-
- // for all layers in wmc, find individual wms...
- for ($i = 0; $i < count($this->wmc_layer_title); $i++) {
- $current_wms = $this->wmc_wms_serviceURL[$i];
- // ...this is something like 'for every wms'
- if (!in_array($current_wms , $added_wms)) {
- $layerlist = "";
- $querylayerlist = "";
- $srs_array = array();
-
- if ($action == "merge") {
- $wmc_string .= "wms_exists = false;\n";
- $wmc_string .= "current_wms_index = null;\n";
- $wmc_string .= "for (var m=0; m < " . $target . "mb_mapObj[index].wms.length; m++) {\n";
- $wmc_string .= "\tif ('" . $this->wmc_wms_serviceURL[$i] . "' == " . $target . "mb_mapObj[index].wms[m].wms_getmap) {\n";
- $wmc_string .= "\t\twms_exists = true;\n";
- $wmc_string .= "\t\tcurrent_wms_index = m;\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "}\n";
- $wmc_string .= "if (!wms_exists) {\n";
- }
-
- $mywms = new wms();
-
- if(!$this->wmc_layer_title[$i] || $this->wmc_layer_title[$i] == ""){
- echo "alert('Error: no valid capabilities-document !!');\n";
- die; exit;
- }
-
- for($j=0;$j<count($this->wmc_layer_format[$i]);$j++){
- if ($this->wmc_layer_format_current[$i][$j] == 1) {
- $wms_data_format = $this->wmc_layer_format[$i][$j];
- }
- }
- // add wms
- $wmc_string .= "\t" . $target . "add_wms('".
- $this->wmc_wms_id[$i]."','".
- $this->wmc_wms_version[$i] ."','".
- $this->wmc_wms_title[$i] ."','".
- $this->wmc_layer_abstract[$i] ."','".
- $this->wmc_wms_serviceURL[$i] ."','" .
- $this->wmc_wms_serviceURL[$i] ."','" .
- $this->wmc_layer_style_legendurl[$i][0] ."','','".
- $wms_data_format ."','text/html','application/vnd.ogc.se_xml','".
- $this->wmc_bBox_SRS ."','1','100','');\n";
-
- $added_wms[count($added_wms)] = $current_wms;
- $cnt_wms++;
- $cnt_layers = 0;
- $cnt_query_layers = 0;
- if ($action == "merge") {
- $wmc_string .= "}\n";
- }
-
- // add epsg
- $wmc_string .= $target . "wms_addSRS('".
- $this->wmc_bBox_SRS ."','".
- $this->wmc_bBox_minx ."','".
- $this->wmc_bBox_miny ."','".
- $this->wmc_bBox_maxx ."','".
- $this->wmc_bBox_maxy ."','".
- "');\n";
-
- // for each layer...
- for ($ii = 0; $ii < count($this->wmc_layer_title); $ii++) {
- $layer_wms = $this->wmc_wms_serviceURL[$ii];
- // ... of this wms
- if ($current_wms == $layer_wms) {
-
- // add format (FIXME: is this working?)
- $z = count($this->wmc_layer_format[$ii]);
- for($j=0;$j<$z;$j++){
- $wmc_string .= $target . "wms_add_data_type_format('map','". $this->wmc_layer_format[$ii][$j] ."');\n";
- }
-
- if ($cnt_layers == 0) {
- if ($action == "merge") {
- $wmc_string .= "if (!wms_exists) {\n\t";
- }
- // add parent layer
- $wmc_string .= $target . "wms_add_layer('','".
- $this->wmc_wms_layer_id[$i]."','','".
- $this->wmc_wms_title[$i] ."','','0','0','0','0','','".
- $this->wmc_wms_id[$i]."','1','', '1','1','0','0','0','0','');\n";
- if ($action == "merge") {
- $wmc_string .= "}\n";
- }
- }
-
- $cnt_layers++;
-
- if ($action == "merge") {
- $wmc_string .= "if (wms_exists) {\n";
-
- // check if this layer already exists in this wms
- $wmc_string .= "\tlayer_exists = false;\n";
- $wmc_string .= "\tcurrent_layer_index = null;\n";
- $wmc_string .= "\tfor (var m=0; m < " . $target . "mb_mapObj[index].wms[current_wms_index].objLayer.length; m++) {\n";
- $wmc_string .= "\t\tif ('" . $this->wmc_layer_name[$ii] . "' == " . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[m].layer_name) {\n";
- $wmc_string .= "\t\t\tlayer_exists = true;\n";
- $wmc_string .= "\t\t\tcurrent_layer_index = m;\n";
- $wmc_string .= "\t\t}\n";
- $wmc_string .= "\t}\n";
-
- if ($this->wmc_layer_querylayer[$ii]!="") {
- $querylayer_yn = $this->wmc_layer_querylayer[$ii];
- }
- else {
- $querylayer_yn = $this->wmc_layer_queryable[$ii];
- }
- $wmc_string .= "\tif (layer_exists) {\n";
- // check if the visibility or the queryability are different to the existing layer
- $wmc_string .= "\t\tif (" . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_visible != '" . intval(!$this->wmc_layer_hidden[$ii]) . "'";
- $wmc_string .= " || " . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer != '" . $querylayer_yn . "') {\n";
-
- // if yes, update the visibility and queryability
- $wmc_string .= "\t\t\t" . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_visible = " . intval(!$this->wmc_layer_hidden[$ii]) . ";\n";
- $wmc_string .= "\t\t\t" . $target . "mb_mapObj[index].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer = " . $querylayer_yn . ";\n";
- $wmc_string .= "\t\t}\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "}\n";
- $wmc_string .= "\telse {\n";
- }
-
- // add layer
- $wmc_string .= "\t" . $target . "wms_add_layer('".
- ($this->wmc_layer_parent[$ii]!=""?$this->wmc_layer_parent[$ii]:"0") . "','".
- $this->wmc_layer_id[$ii] . "','".
- $this->wmc_layer_name[$ii] . "','".
- $this->wmc_layer_title[$ii] ."','".
- $this->wmc_layer_dataurl[$ii] . "','".
- ($this->wmc_layer_pos[$ii]!=""?$this->wmc_layer_pos[$ii]:intval($cnt_layers)) ."','".
- $this->wmc_layer_queryable[$ii] ."','".
- $this->wmc_layer_minscale[$ii] ."','".
- $this->wmc_layer_maxscale[$ii] ."','".
- $this->wmc_layer_metadataurl[$ii] ."','".
- $this->wmc_wms_id[$i] ."','1','', '1','".
- intval(!$this->wmc_layer_hidden[$ii]) ."','".
- $this->wmc_layer_queryable[$ii] ."','".
- ($this->wmc_layer_querylayer[$ii]!=""?$this->wmc_layer_querylayer[$ii]:$this->wmc_layer_queryable[$ii]) ."','".
- ($this->wmc_gui_layer_minscale[$ii]!=""?$this->wmc_gui_layer_minscale[$ii]:$this->wmc_layer_minscale[$ii]) ."','".
- ($this->wmc_gui_layer_maxscale[$ii]!=""?$this->wmc_gui_layer_maxscale[$ii]:$this->wmc_layer_maxscale[$ii]) ."','".
- $this->wmc_layer_wfs_featuretype[$ii] . "');\n";
-
- if ($action == "merge") {
- $wmc_string .= "\t}\n";
- }
-
- // if layer is queryable, add it to querylayerlist
- if (($this->wmc_layer_querylayer[$ii]!=""?$this->wmc_layer_querylayer[$ii]:$this->wmc_layer_queryable[$ii])) {
- $cnt_query_layers++;
- if (!in_array($this->wmc_layer_name[$ii], explode(",",$querylayerlist))) {
- if ($querylayerlist == "") {$querylayerlist = $this->wmc_layer_name[$ii];} else {$querylayerlist .= "," . $this->wmc_layer_name[$ii];}
- }
- }
- // if layer is visible, add it to layerlist
- if (intval(!$this->wmc_layer_hidden[$ii]) && !in_array($this->wmc_layer_name[$ii], explode(",",$layerlist))) {
- if ($layerlist == "") {$layerlist = $this->wmc_layer_name[$ii];} else {$layerlist .= "," . $this->wmc_layer_name[$ii];}
- }
-
- // add layer style (FIXME: is this working?)
- for($j=0; $j<count($this->wmc_layer_style_name[$ii]);$j++){
- $wmc_string .= $target . "wms_addLayerStyle('".$this->wmc_layer_style_name[$ii][$j] ."','".$this->wmc_layer_style_title[$ii][$j] ."','".$j."','".$cnt_layers."', '" . $this->wmc_layer_style_legendurl[$ii][$j] . "', '" . $this->wmc_layer_style_legendurl_format[$ii][$j] . "');\n";
- }
- }
- }
- // add wms to mapObj with all layers and querylayers
- if ($action == "merge") {
- $wmc_string .= "if (!wms_exists) {\n";
- }
- $wmc_string .= $target. "mb_mapObjaddWMSwithLayers('" . $mapObj . "', '" . $layerlist . "', '" . $querylayerlist . "');\n";
- if ($action == "merge") {
- $wmc_string .= "}\n";
- $wmc_string .= "else {\n";
- $wmc_string .= $target. "mb_mapObj[index].layers[current_wms_index] = \"" . $layerlist . "\";\n";
- $wmc_string .= $target. "mb_mapObj[index].querylayers[current_wms_index] = \"" . $querylayerlist . "\";\n";
- $wmc_string .= "}\n";
- }
- }
- }
- $wmc_string .= "var old_mapObj = ".$target."cloneObject(".$target."mb_mapObj);\n";
- $wmc_string .= $target . "deleteMapObj();\n";
- $wmc_string .= "for (var i=0; i<old_mapObj.length; i++) {\n";
- $wmc_string .= "\tif (old_mapObj[i].frameName != 'overview') {\n";
- $wmc_string .= "\t\t" . $target . "mb_registerMapObj(old_mapObj[i].frameName, old_mapObj[i].elementName, null, " . $this->wmc_windowWidth . ", " . $this->wmc_windowHeight . ");\n";
- $wmc_string .= "\t\t" . $target . "document.getElementById(old_mapObj[i].frameName).style.width = " . $this->wmc_windowWidth . ";\n";
- $wmc_string .= "\t\t" . $target . "document.getElementById(old_mapObj[i].frameName).style.height = " . $this->wmc_windowHeight . ";\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "\telse {\n";
- $wmc_string .= "\t\tvar found = false;\n";
- $wmc_string .= "\t\tfor (var j=0; j < " . $target . "wms.length && found == false; j++) {\n";
- $wmc_string .= "\t\t\tif (" . $target . "wms[j].wms_getmap == old_mapObj[i].wms[0].wms_getmap) {\n";
- $wmc_string .= "\t\t\t\t" . $target . "mb_registerMapObj('overview', old_mapObj[i].elementName, j, old_mapObj[i].width, old_mapObj[i].width);\n";
- $wmc_string .= "\t\t\t\tfound = true;\n";
- $wmc_string .= "\t\t\t}\n";
- $wmc_string .= "\t\t}\n";
- $wmc_string .= "\t\tif (!found) {\n";
- $wmc_string .= "\t\t\t" . $target . "mb_registerMapObj('overview', old_mapObj[i].elementName, 0, old_mapObj[i].width, old_mapObj[i].width);\n";
- $wmc_string .= "\t\t}\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "}\n";
-
- $ov_bbox = array();
- // compute the union of the overview and the mapframe bbox for the new overview bbox
- if ($this->wmc_general_extension["ov_minx"] && $this->wmc_general_extension["ov_miny"] &&
- $this->wmc_general_extension["ov_maxx"] && $this->wmc_general_extension["ov_maxy"]) {
-
- // box for overview
- $ov_min = new Mapbender_point($this->wmc_general_extension["ov_minx"], $this->wmc_general_extension["ov_miny"], $this->wmc_bBox_SRS);
- $ov_max = new Mapbender_point($this->wmc_general_extension["ov_maxx"], $this->wmc_general_extension["ov_maxy"], $this->wmc_bBox_SRS);
- $ov_box = new Mapbender_bbox($ov_min, $ov_max, $this->wmc_bBox_SRS);
-
- // box for mapframe
- $mf_min = new Mapbender_point($this->wmc_bBox_minx, $this->wmc_bBox_miny, $this->wmc_bBox_SRS);
- $mf_max = new Mapbender_point($this->wmc_bBox_maxx, $this->wmc_bBox_maxy, $this->wmc_bBox_SRS);
- $mf_box = new Mapbender_bbox($mf_min, $mf_max, $this->wmc_bBox_SRS);
-
- $unionBox = Mapbender_bbox::union(array($ov_box, $mf_box));
-
- array_push($ov_bbox, $unionBox->min->x);
- array_push($ov_bbox, $unionBox->min->y);
- array_push($ov_bbox, $unionBox->max->x);
- array_push($ov_bbox, $unionBox->max->y);
- }
- else {
-/*
- $sql = "SELECT minx, miny, maxx, maxy FROM layer_epsg WHERE fkey_layer_id = $1 AND epsg = $2 LIMIT 1";
- $v = array($this->wmc_layer_id[0], $this->wmc_bBox_SRS);
- $t = array('i', 's');
- $res = db_prep_query($sql, $v, $t);
- $row = db_fetch_array($res);
- if ($row["minx"] && $row["miny"] && $row["maxx"] && $row["maxy"]) {
- $ov_bbox = array($row["minx"],$row["miny"],$row["maxx"],$row["maxy"]);
- }
- else if ($this->wmc_layer_id[0] && $this->wmc_bBox_SRS){
- $ov_bbox = array($this->wmc_bBox_minx, $this->wmc_bBox_miny, $this->wmc_bBox_maxx, $this->wmc_bBox_maxy);
- }
- else {
-*/
- $ov_bbox = array(2412139.175257732, 5365000, 2767860.824742268, 5700000);
-// }
- }
-
- $wmc_string .= "for (var i=0; i<old_mapObj.length; i++) {\n";
- $wmc_string .= "\tif (old_mapObj[i].frameName != 'overview') {\n";
- $wmc_string .= "\t\t".$target."mb_calculateExtent(old_mapObj[i].frameName, ";
- $wmc_string .= $this->wmc_bBox_minx .",".$this->wmc_bBox_miny .",";
- $wmc_string .= $this->wmc_bBox_maxx .",".$this->wmc_bBox_maxy.");\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "\telse {\n";
- $wmc_string .= "\t\t".$target."mb_calculateExtent(old_mapObj[i].frameName, ";
- $wmc_string .= $ov_bbox[0] .",".$ov_bbox[1] .",";
- $wmc_string .= $ov_bbox[2] .",".$ov_bbox[3] .");\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "\t". $target . "setMapRequest(old_mapObj[i].frameName);\n";
- $wmc_string .= "}\n";
- $wmc_string .= $target . "mb_execloadWmsSubFunctions();\n";
- }
-// $e = new mb_exception("js code: " . $wmc_string);
- return $wmc_string;
- }
-}
-// end class
-?>
Modified: branches/nimix_dev/http/classes/class_wmcToXml.php
===================================================================
--- branches/nimix_dev/http/classes/class_wmcToXml.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_wmcToXml.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -108,17 +108,22 @@
}
private function createGeneralNode () {
+ $extensionData = array();
if ($this->wmc->overviewMap !== null) {
$ovExtent = $this->wmc->overviewMap->getExtent();
- $extensionData->ov_minx = $ovExtent->min->x;
- $extensionData->ov_miny = $ovExtent->min->y;
- $extensionData->ov_maxx = $ovExtent->max->x;
- $extensionData->ov_maxy = $ovExtent->max->y;
- $extensionData->ov_srs = $ovExtent->epsg;
- $extensionData->ov_framename = $this->wmc->overviewMap->getFrameName();
- $extensionData->ov_width = $this->wmc->overviewMap->getWidth();
- $extensionData->ov_height = $this->wmc->overviewMap->getHeight();
+ $extensionData["ov_minx"] = $ovExtent->min->x;
+ $extensionData["ov_miny"] = $ovExtent->min->y;
+ $extensionData["ov_maxx"] = $ovExtent->max->x;
+ $extensionData["ov_maxy"] = $ovExtent->max->y;
+ $extensionData["ov_srs"] = $ovExtent->epsg;
+ $extensionData["ov_framename"] = $this->wmc->overviewMap->getFrameName();
+ $extensionData["ov_width"] = $this->wmc->overviewMap->getWidth();
+ $extensionData["ov_height"] = $this->wmc->overviewMap->getHeight();
}
+
+ if ($this->wmc->mainMap !== null) {
+ $extensionData["main_framename"] = $this->wmc->mainMap->getFrameName();
+ }
// General
$e_general = $this->doc->createElement("General");
@@ -364,6 +369,8 @@
$layerExtensionData["gui_selectable"] = $currentLayer->gui_layer_selectable;
$layerExtensionData["gui_queryable"] = $currentLayer->gui_layer_queryable;
$layerExtensionData["gui_status"] = $currentLayer->gui_layer_status;
+ $layerExtensionData["layer_epsg"] = $currentLayer->layer_epsg;
+
if ($currentMap->isOverview()) {
$layerExtensionData["isOverviewLayer"] = 1;
}
@@ -375,7 +382,7 @@
$e_extension = $this->doc->createElement("Extension");
foreach ($layerExtensionData as $keyExtensionData => $valueExtensionData) {
- $e_currentExtensionTag = $this->doc->createElement($this->wmc->extensionNamespace.":".$keyExtensionData, $valueExtensionData);
+ $e_currentExtensionTag = $this->addExtension($keyExtensionData, $valueExtensionData);
$e_extension->appendChild($e_currentExtensionTag);
}
return $e_extension;
@@ -383,6 +390,23 @@
return null;
}
+ private function addExtension ($key, $value) {
+ if (is_array($value)) {
+ if (is_numeric($key)) {
+ $key = "data" . $key;
+ }
+ $e_currentExtensionTag = $this->doc->createElement($this->wmc->extensionNamespace.":".$key);
+ foreach ($value as $childKey => $childValue) {
+ $newNode = $this->addExtension($childKey, $childValue);
+ $e_currentExtensionTag->appendChild($newNode);
+ }
+ }
+ else {
+ $e_currentExtensionTag = $this->doc->createElement($this->wmc->extensionNamespace.":".$key, $value);
+ }
+ return $e_currentExtensionTag;
+ }
+
private function createLayerStyleNode ($currentWms, $currentLayer) {
$e_layer_stylelist = $this->doc->createElement("StyleList");
@@ -533,4 +557,4 @@
}
}
-?>
\ No newline at end of file
+?>
Modified: branches/nimix_dev/http/classes/class_wms.php
===================================================================
--- branches/nimix_dev/http/classes/class_wms.php 2008-08-18 16:00:13 UTC (rev 2866)
+++ branches/nimix_dev/http/classes/class_wms.php 2008-08-18 16:03:32 UTC (rev 2867)
@@ -17,15 +17,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/class_connector.php");
require_once(dirname(__FILE__)."/class_user.php");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
require_once(dirname(__FILE__)."/class_administration.php");
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
-
class wms {
var $lastURL;
var $wms_id;
@@ -240,7 +236,7 @@
$values = null;
$tags = null;
$admin = new administration();
- $this->wms_getcapabilities_doc = $admin->char_encode($data);
+ $this->wms_getcapabilities_doc = $data;
$this->wms_upload_url = $url;
$this->wms_certificateFile = $cert;
$this->wms_certificatePassphrase = $pass;
@@ -250,7 +246,7 @@
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
- xml_parse_into_struct($parser,$this->wms_getcapabilities_doc,$values,$tags);
+ xml_parse_into_struct($parser,$data,$values,$tags);
$code = xml_get_error_code($parser);
if ($code) {
@@ -635,13 +631,13 @@
if(!$this->wms_title || $this->wms_title == "" || !$this->wms_getmap || $this->wms_getmap == ""){
$this->wms_status = false;
$this->optimizeWMS();
-
+ $e = new mb_exception("class_wms: createObjFromXML: WMS " . $url . " could not be loaded.");
return false;
}
else{
$this->wms_status = true;
$this->optimizeWMS();
-
+ $e = new mb_notice("class_wms: createObjFromXML: WMS " . $url . " has been loaded successfully.");
return true;
}
}
@@ -867,19 +863,40 @@
}
$newLayer->layer_abstract = $currentLayer["abstract"];
-
//
// set layer epsg
//
$newLayer->layer_epsg = array();
- if ($currentExtent !== null) {
- $currentLayerEpsg = array();
- $currentLayerEpsg["epsg"] = $currentExtent->epsg;
- $currentLayerEpsg["minx"] = $currentExtent->min->x;
- $currentLayerEpsg["miny"] = $currentExtent->min->y;
- $currentLayerEpsg["maxx"] = $currentExtent->max->x;
- $currentLayerEpsg["maxy"] = $currentExtent->max->y;
- array_push($newLayer->layer_epsg, $currentLayerEpsg);
+ if ($currentLayer["extension"]["EPSG"]) {
+ $layerEpsgArray = array();
+ $layerMinXArray = array();
+ $layerMinYArray = array();
+ $layerMaxXArray = array();
+ $layerMaxYArray = array();
+ if (!is_array($currentLayer["extension"]["EPSG"])) {
+ $layerEpsgArray[0] = $currentLayer["extension"]["EPSG"];
+ $layerMinXArray[0] = $currentLayer["extension"]["MINX"];
+ $layerMinYArray[0] = $currentLayer["extension"]["MINY"];
+ $layerMaxXArray[0] = $currentLayer["extension"]["MAXX"];
+ $layerMaxYArray[0] = $currentLayer["extension"]["MAXY"];
+ }
+ else {
+ $layerEpsgArray = $currentLayer["extension"]["EPSG"];
+ $layerMinXArray = $currentLayer["extension"]["MINX"];
+ $layerMinYArray = $currentLayer["extension"]["MINY"];
+ $layerMaxXArray = $currentLayer["extension"]["MAXX"];
+ $layerMaxYArray = $currentLayer["extension"]["MAXY"];
+ }
+
+ for ($i=0; $i < count($layerEpsgArray); $i++) {
+ $currentLayerEpsg = array();
+ $currentLayerEpsg["epsg"] = $layerEpsgArray[$i];
+ $currentLayerEpsg["minx"] = floatval($layerMinXArray[$i]);
+ $currentLayerEpsg["miny"] = floatval($layerMinYArray[$i]);
+ $currentLayerEpsg["maxx"] = floatval($layerMaxXArray[$i]);
+ $currentLayerEpsg["maxy"] = floatval($layerMaxYArray[$i]);
+ array_push($newLayer->layer_epsg, $currentLayerEpsg);
+ }
}
@@ -1121,7 +1138,8 @@
*/
function writeObjInDB($gui_id){
global $con;
-
+ $admin = new administration();
+
$this->checkObj();
db_begin();
@@ -1134,7 +1152,7 @@
$sql .= "wms_supportsld, wms_userlayer, wms_userstyle, wms_remotewfs, wms_certificatefile, wms_certificatepassphrase) ";
$sql .= "VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28, $29, $30)";
$v = array($this->wms_version,$this->wms_title,$this->wms_abstract,$this->wms_getcapabilities,
- $this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,$this->wms_getcapabilities_doc,
+ $this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,$admin->char_encode($this->wms_getcapabilities_doc),
$this->wms_upload_url,$this->fees,$this->accessconstraints,$this->contactperson,$this->contactposition,
$this->contactorganization,$this->address,$this->city,$this->stateorprovince,$this->postcode,$this->country,
$this->contactvoicetelephone,$this->contactfacsimiletelephone,$this->contactelectronicmailaddress,
@@ -1460,6 +1478,7 @@
}
}
function updateObjInDB($myWMS){
+ $admin = new administration();
db_begin();
$sql = "UPDATE wms SET ";
@@ -1482,7 +1501,7 @@
$v = array($this->wms_version,$this->wms_getcapabilities,
$this->wms_getmap,$this->wms_getfeatureinfo,$this->wms_getlegendurl,
- $this->wms_getcapabilities_doc,$this->wms_upload_url,$_SESSION["mb_user_id"],strtotime("now"),
+ $admin->char_encode($this->wms_getcapabilities_doc),$this->wms_upload_url,$_SESSION["mb_user_id"],strtotime("now"),
$this->wms_supportsld,$this->wms_userlayer,$this->wms_userstyle,$this->wms_remotewfs,
$this->wms_certificateFile, $this->wms_certificatePassphrase,$myWMS);
$t = array('s','s','s','s','s','s','s','i','i','s','s','s','s','s','s','i');
@@ -1822,6 +1841,9 @@
$this->wms_getfeatureinfo = $row2["wms_getfeatureinfo"];
$this->wms_getlegendurl = $row2["wms_getlegendurl"];
}
+ // TO DO: Capabilities document needs to
+ // be encoded to the original encoding
+ // if different from the database encoding
$this->wms_getcapabilities_doc = $row2["wms_getcapabilities_doc"];
$this->wms_filter = $row2["wms_filter"];
$this->wms_supportsld = $row2["wms_supportsld"];
@@ -1963,6 +1985,9 @@
$this->wms_getfeatureinfo = $row2["wms_getfeatureinfo"];
$this->wms_getlegendurl = $row2["wms_getlegendurl"];
}
+ // TO DO: Capabilities document needs to
+ // be encoded to the original encoding
+ // if different from the database encoding
$this->wms_getcapabilities_doc = $row2["wms_getcapabilities_doc"];
$this->wms_filter = $row2["wms_filter"];
$this->wms_supportsld = $row2["wms_supportsld"];
@@ -1976,6 +2001,18 @@
$this->gui_wms_epsg=$row["gui_wms_epsg"];
$this->gui_wms_sldurl = $row["gui_wms_sldurl"];
+ if($this->wms_version == "1.0.0"){
+ $this->gui_wms_mapformat = "PNG";
+ $this->gui_wms_featureinfoformat = "MIME";
+ $this->gui_wms_exceptionformat = "INIMAGE";
+ }
+ /*define defaults for wms-version 1.1.0 and 1.1.1*/
+ else{
+ $this->gui_wms_mapformat = "image/png";
+ $this->gui_wms_featureinfoformat = "text/html";
+ $this->gui_wms_exceptionformat = "application/vnd.ogc.se_inimage";
+ }
+
$count_wms++;
}
@@ -2210,4 +2247,4 @@
}
}
-?>
\ No newline at end of file
+?>
More information about the Mapbender_commits
mailing list