[Mapbender-commits] r2674 - in branches/testbaudson_dev:
http/classes http/frames http/javascripts http/php lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Jul 18 06:26:22 EDT 2008
Author: christoph
Date: 2008-07-18 06:26:21 -0400 (Fri, 18 Jul 2008)
New Revision: 2674
Added:
branches/testbaudson_dev/lib/application.php
branches/testbaudson_dev/lib/element.php
branches/testbaudson_dev/lib/mapbender.php
Modified:
branches/testbaudson_dev/http/classes/class_element.php
branches/testbaudson_dev/http/classes/class_gui.php
branches/testbaudson_dev/http/frames/index.php
branches/testbaudson_dev/http/javascripts/geometry.js
branches/testbaudson_dev/http/javascripts/mod_box1.js
branches/testbaudson_dev/http/javascripts/mod_savewmc.php
branches/testbaudson_dev/http/javascripts/mod_wfs_gazetteer_client.php
branches/testbaudson_dev/http/php/mb_validateSession.php
branches/testbaudson_dev/http/php/mod_createUser.php
branches/testbaudson_dev/http/php/mod_renameGUI.php
Log:
refactoring
merged with trunk
Modified: branches/testbaudson_dev/http/classes/class_element.php
===================================================================
--- branches/testbaudson_dev/http/classes/class_element.php 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/classes/class_element.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -1,240 +1,3 @@
-<?php
-# $Id: class_bbox.php 1965 2008-01-15 08:24:29Z christoph $
-# http://www.mapbender.org/index.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__)."/../../core/globalSettings.php");
-
-define("ELEMENT_PATTERN", "/sessionID/");
-
-class Element {
-
- var $guiId;
- var $id;
- var $pos;
- var $isPublic;
- var $comment;
- var $title;
- var $element;
- var $src;
- var $attributes;
- var $left;
- var $top;
- var $width;
- var $height;
- var $zIndex;
- var $moreStyles;
- var $content;
- var $closeTag;
- var $jsFile;
- var $mbMod;
- var $target;
- var $requires;
- var $helpUrl;
-
- public function __contruct() {
-
- }
-
- public function select ($id, $applicationId) {
- $sql = "SELECT fkey_gui_id, e_id, e_pos, e_public, e_comment, e_public, ".
- "gettext($1, e_title) as e_title, e_element, e_src, e_attributes, " .
- "e_left, e_top, e_width, e_height, e_z_index, e_more_styles, " .
- "e_content, e_closetag, e_js_file, e_mb_mod, e_target, " .
- "e_requires, e_url FROM gui_element WHERE e_id = $2 AND " .
- "fkey_gui_id = $3 LIMIT 1";
- $v = array ($_SESSION["mb_lang"], $id, $applicationId);
- $t = array ("s", "s", "s");
- $res = db_prep_query($sql, $v, $t);
- $row = db_fetch_array($res);
- if ($row) {
- $this->guiId = $applicationId;
- $this->id = $row["e_id"];
- $this->pos = $row["e_pos"];
- $this->isPublic = $row["e_public"];
- $this->comment = $row["e_comment"];
- $this->title = $row["e_title"];
- $this->element = $row["e_element"];
- $this->src = $row["e_src"];
- $this->attributes = $row["e_attributes"];
- $this->left = $row["e_left"];
- $this->top = $row["e_top"];
- $this->width = $row["e_width"];
- $this->height = $row["e_height"];
- $this->zIndex = $row["e_z_index"];
- $this->moreStyles = $row["e_more_styles"];
- $this->content = $row["e_content"];
- $this->closeTag = $row["e_closetag"];
- $this->jsFile = $row["e_js_file"];
- $this->mbMod = $row["e_mb_mod"];
- $this->target = $row["e_target"];
- $this->requires = $row["e_requires"];
- $this->helpUrl = $row["e_url"];
- return true;
- }
- return false;
- }
-
- public function __toString () {
- return $this->toHtml();
- }
-
- public function getJavaScriptModules () {
- $jsArray = array();
- if ($this->mbMod != "") {
- $moduleArray = explode(",", $this->mbMod);
- for ($i = 0; $i < count($moduleArray); $i++) {
- $currentFile = dirname(__FILE__) . "/../javascripts/" . trim($moduleArray[$i]);
- if (file_exists($currentFile)) {
- array_push($jsArray, $currentFile);
- }
- else {
- $e = new mb_exception("Javascript module not found: " . $currentFile);
- }
- }
- }
- return $jsArray;
- }
-
- public function toHtmlArray () {
- if ($this->isPublic) {
- return array($this->getHtmlOpenTag(), $this->getHtmlContent(), $this->getHtmlCloseTag());
- }
- return array("", "", "");
- }
-
- public function toHtml () {
- if ($this->isPublic) {
- return implode("", $this->toHtmlArray());
- }
- return "";
- }
-
- private function getHtmlOpenTag () {
- $openTag = "";
-
- if ($this->id) {
- // tag name
- $openTag .= "<" . $this->element . " ";
-
- // id and name
- $openTag .= "id='" . $this->id . "' name='" . $this->id . "' ";
-
- // attributes
- if ($this->attributes) {
- $openTag .= stripslashes($this->replaceSessionStringByUrlParameters($this->attributes)) . " ";
- }
-
- // title
- if ($this->title) {
- $openTag .= "title='" . $this->title . "' ";
- }
-
- // src
- if ($this->src) {
- $openTag .= "src = '" . $this->replaceSessionStringByUrlParameters($this->src);
-
- // for iframes which are not "loadData",
- // add additional parameters
- if ($this->closeTag == "iframe" && $this->id != "loadData") {
- if(mb_strpos($this->src, "?")) {
- $openTag .= "&";
- }
- else {
- $openTag .= "?";
- }
- $openTag .= "e_id_css=" . $this->id . "&" .
- "e_id= " . $this->id . "&" .
- "e_target=" . $this->target . "&" .
- $this->getUrlParameters();
- }
- $openTag .= "' ";
- }
-
- // style
- $openTag .= " style = '";
- if ($this->top != "" && $this->left != "") {
- $openTag .= "position:absolute;" .
- "left:" . $this->left . ";" .
- "top:" . $this->top . ";";
- }
- if ($this->width != "" && $this->height != "") {
- $openTag .= "width:" . $this->width . ";" .
- "height:" . $this->height . ";";
- }
- if ($this->zIndex) {
- $openTag .= "z-index:" . $this->zIndex . ";";
- }
- if ($this->moreStyles) {
- $openTag .= $this->moreStyles;
- }
- $openTag .= "'>";
-
- if ($this->element == "body" && USE_LOAD_MESSAGE) {
- $htmlWhileLoading = "<img src='../img/indicator_wheel.gif'> " .
- "<b>Ma<font color='#0000CE'>p</font><font color='#C00000'>b</font>ender " .
- MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</b>..." .
- "loading application '" . $this->guiId . "'";
-
- $openTag .= "<div id='loading_mapbender' " .
- "style='position:absolute;top:100;left:100'>" .
- $htmlWhileLoading . "</div>" .
- "<div id='complete_mapbender' " .
- "style='display:none'>";
- }
- }
- return $openTag;
- }
-
- private function getHtmlContent () {
- $htmlContent = "";
- if ($this->content != "") {
- $htmlContent .= stripslashes($this->content);
- }
- return $htmlContent;
- }
-
- private function getHtmlCloseTag () {
- if ($this->element == "body" && USE_LOAD_MESSAGE) {
- return "</div></body>";
- }
- if ($this->closeTag != "") {
- return "</" . $this->closeTag . ">";
- }
- return "";
- }
-
- private function getUrlParameters () {
- $urlParameters = SID;
- if (isset($this->guiId)) {
- $urlParameters .= "&guiID=" . $this->guiId;
- }
- if (isset($this->id)) {
- $urlParameters .= "&elementID=" . $this->id;
- }
- return $urlParameters;
- }
-
- private function replaceSessionStringByUrlParameters ($string) {
- $urlParameters = $this->getUrlParameters();
- return preg_replace(ELEMENT_PATTERN, $urlParameters, $string);
- }
-
-}
-
-
+<?php
+include_once(dirname(__FILE__)."/../../lib/element.php");
?>
\ No newline at end of file
Modified: branches/testbaudson_dev/http/classes/class_gui.php
===================================================================
--- branches/testbaudson_dev/http/classes/class_gui.php 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/classes/class_gui.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -1,296 +1,3 @@
<?php
-# $Id$
-# http://www.mapbender.org/index.php/class_gui.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_element.php");
-
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
-
-/**
- * GUI is a set of GUI elements and services.
- */
-class gui {
-
- var $id;
- var $elementArray = array();
-
- public function __construct ($id) {
- if ($id) {
- $this->id = $id;
- $this->elementArray = $this->selectElements();
- }
- }
-
- public function selectElements () {
- $sql = "SELECT e_id FROM gui_element WHERE fkey_gui_id = $1 " .
- "ORDER BY e_pos";
- $v = array($this->id);
- $t = array('s');
- $res = db_prep_query($sql,$v,$t);
- $elementArray = array();
- while ($row = db_fetch_array($res)) {
- array_push($elementArray, $row[0]);
- }
-
- $this->elementArray = array();
- for ($i = 0; $i < count($elementArray); $i++) {
- $currentElement = new Element();
- $currentElement->select($elementArray[$i], $this->id);
- array_push($this->elementArray, $currentElement);
- }
- return $this->elementArray;
- }
-
- public function toHtml () {
- $htmlString = "";
- $htmlString .= $this->elementsToHtml();
- return $htmlString;
- }
-
- public function getJavaScriptModules () {
- $jsArray = array();
- for ($i = 0; $i < count($this->elementArray); $i++) {
- $currentElement = $this->elementArray[$i];
- array_merge($jsArray, $currentElement->getJavaScriptModules());
- }
- return $jsArray;
- }
-
- /**
- * Checks if a GUI with a given ID exists in the database
- *
- * @param integer $gui_id the ID of the GUI that is being checked
- * @return boolean true if a gui '$gui_id' exists; else false
- */
- public function guiExists ($gui_id){
- $sql = "SELECT * FROM gui WHERE gui_id = $1";
- $v = array($gui_id);
- $t = array('s');
- $res = db_prep_query($sql,$v,$t);
- $row = db_fetch_array($res);
- if ($row) {
- return true;
- }
- return false;
- }
-
-
- /**
- * Deletes a GUI $guiId and all its links to users, layers etc.
- *
- * @param Integer $guiId the GUI that is going to be deleted
- * @return boolean true if the deletion succeded, else false
- */
- public function deleteGui ($guiId) {
- $guiList = $guiId;
-
- $sql = array();
- $v = array();
- $t = array();
-
- array_push($sql, "BEGIN");
- array_push($v, array());
- array_push($t, array());
-
- array_push($sql, "DELETE FROM gui WHERE gui_id = $1");
- array_push($v, array($guiList));
- array_push($t, array('s'));
-
- array_push($sql, "DELETE FROM gui_element WHERE fkey_gui_id = $1");
- array_push($v, array($guiList));
- array_push($t, array('s'));
-
- array_push($sql, "DELETE FROM gui_element_vars WHERE fkey_gui_id = $1");
- array_push($v, array($guiList));
- array_push($t, array('s'));
-
- array_push($sql, "DELETE FROM gui_layer WHERE fkey_gui_id = $1");
- array_push($v, array($guiList));
- array_push($t, array('s'));
-
- array_push($sql, "DELETE FROM gui_mb_group WHERE fkey_gui_id = $1");
- array_push($v, array($guiList));
- array_push($t, array('s'));
-
- array_push($sql, "DELETE FROM gui_mb_user WHERE fkey_gui_id = $1");
- array_push($v, array($guiList));
- array_push($t, array('s'));
-
- array_push($sql, "DELETE FROM gui_treegde WHERE fkey_gui_id = $1");
- array_push($v, array($guiList));
- array_push($t, array('s'));
-
- array_push($sql, "DELETE FROM gui_wfs WHERE fkey_gui_id = $1");
- array_push($v, array($guiList));
- array_push($t, array('s'));
-
- array_push($sql, "DELETE FROM gui_wms WHERE fkey_gui_id = $1");
- array_push($v, array($guiList));
- array_push($t, array('s'));
-
- array_push($sql, "COMMIT");
- array_push($v, array());
- array_push($t, array());
-
- // execute all SQLs
- for ($i = 0; $i < count($sql); $i++) {
- $res = db_prep_query($sql[$i], $v[$i], $t[$i]);
- // if an SQL fails, send a ROLLBACK and return false
- if (!$res) {
- db_query("ROLLBACK");
- return false;
- }
- }
- return true;
- }
-
- /** Renames the GUI $guiID to $newGUIName
- *
- * @param Integer $guiId ID of the GUI
- * @param String $newGuiName the new name of the GUI
- * @return boolean true if the renaming succeded, else false
- */
- public function renameGui ($guiId, $newGuiName) {
- if ($this->copyGui($guiId, $newGuiName, true)) {
- $this->deleteGui($guiId);
- return true;
- }
- return false;
- }
-
- /**
- *
- * Copies a GUI $guiId and all its links to users, layers etc. to GUI $newGuiName
- *
- * @param Integer $guiId ID of the GUI
- * @param String $newGuiName the new name of the GUI
- * @param boolean $withUsers true if the users, that may access the GUI $guiId, shall have access to the new GUI; else false.
- *
- * @return boolean true if the renaming succeded, else false
- */
- public function copyGui ($guiId, $newGuiName, $withUsers) {
- $guiList = $guiId;
- if (!$this->guiExists($newGuiName)) {
-
- $sql = array();
- $v = array();
- $t = array();
-
- array_push($sql, "BEGIN");
- array_push($v, array());
- array_push($t, array());
-
- array_push($sql, "INSERT INTO gui (gui_id, gui_name, gui_description, gui_public) SELECT $1, $2, gui_description, gui_public FROM gui WHERE gui_id = $3;");
- array_push($v, array ($newGuiName, $newGuiName, $guiList));
- array_push($t, array ("s", "s", "s"));;
-
- array_push($sql, "INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) SELECT $1, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url FROM gui_element WHERE fkey_gui_id = $2;");
- array_push($v, array($newGuiName, $guiList));
- array_push($t, array("s", "s"));
-
- array_push($sql, "INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) SELECT $1, fkey_e_id, var_name, var_value, context, var_type FROM gui_element_vars WHERE fkey_gui_id = $2;");
- array_push($v, array($newGuiName, $guiList));
- array_push($t, array("s", "s"));
-
- array_push($sql, "INSERT INTO gui_layer (fkey_gui_id, fkey_layer_id, gui_layer_wms_id, gui_layer_status, gui_layer_selectable, gui_layer_visible, gui_layer_queryable, gui_layer_querylayer, gui_layer_minscale, gui_layer_maxscale, gui_layer_priority, gui_layer_style, gui_layer_wfs_featuretype) SELECT $1, fkey_layer_id, gui_layer_wms_id, gui_layer_status, gui_layer_selectable, gui_layer_visible, gui_layer_queryable, gui_layer_querylayer, gui_layer_minscale, gui_layer_maxscale, gui_layer_priority, gui_layer_style, gui_layer_wfs_featuretype FROM gui_layer WHERE fkey_gui_id = $2;");
- array_push($v, array($newGuiName, $guiList));
- array_push($t, array("s", "s"));
-
- if ($withUsers == true) {
- /* group of original gui is copied as well */
- array_push($sql, "INSERT INTO gui_mb_group (fkey_gui_id, fkey_mb_group_id, mb_group_type) SELECT $1, fkey_mb_group_id, mb_group_type FROM gui_mb_group WHERE fkey_gui_id = $2;");
- array_push($v, array($newGuiName, $guiList));
- array_push($t, array("s", "s"));
-
- /* users of original gui are copied as well */
- array_push($sql, "INSERT INTO gui_mb_user (fkey_gui_id, fkey_mb_user_id, mb_user_type) SELECT $1, fkey_mb_user_id, mb_user_type FROM gui_mb_user WHERE fkey_gui_id = $2;");
- array_push($v, array($newGuiName, $guiList));
- array_push($t, array("s", "s"));
- }
- else {
- // users of original gui are not copied, the current user is set as owner
- array_push($sql, "INSERT INTO gui_mb_user (fkey_gui_id, fkey_mb_user_id, mb_user_type) VALUES ($1, $2, 'owner')");
- array_push($v, array($newGuiName, $_SESSION["mb_user_id"]));
- array_push($t, array('s', 'i'));
- }
- array_push($sql, "INSERT INTO gui_treegde (fkey_gui_id, fkey_layer_id, id, lft, rgt, my_layer_title, layer, wms_id) SELECT $1, fkey_layer_id, id, lft, rgt, my_layer_title, layer, wms_id FROM gui_treegde WHERE fkey_gui_id = $2;");
- array_push($v, array($newGuiName, $guiList));
- array_push($t, array("s", "s"));
-
- array_push($sql, "INSERT INTO gui_wfs (fkey_gui_id, fkey_wfs_id) SELECT $1, fkey_wfs_id FROM gui_wfs WHERE fkey_gui_id = $2;");
- array_push($v, array($newGuiName, $guiList));
- array_push($t, array("s", "s"));
-
- array_push($sql, "INSERT INTO gui_wms (fkey_gui_id, fkey_wms_id, gui_wms_position, gui_wms_mapformat, gui_wms_featureinfoformat, gui_wms_exceptionformat, gui_wms_epsg, gui_wms_visible) SELECT $1, fkey_wms_id, gui_wms_position, gui_wms_mapformat, gui_wms_featureinfoformat, gui_wms_exceptionformat, gui_wms_epsg, gui_wms_visible FROM gui_wms WHERE fkey_gui_id = $2;");
- array_push($v, array($newGuiName, $guiList));
- array_push($t, array("s", "s"));
-
- array_push($sql, "COMMIT");
- array_push($v, array());
- array_push($t, array());
-
- // execute all SQLs
- for ($i = 0; $i < count($sql); $i++) {
- $res = db_prep_query($sql[$i], $v[$i], $t[$i]);
- // if an SQL fails, send a ROLLBACK and return false
- if (!$res) {
- db_query("ROLLBACK");
- return false;
- }
- }
- return true;
- }
- else {
- echo "<script language='javascript'>";
- echo "alert('This gui name " . $newGuiName . " is taken!');";
- echo "</script>";
- return false;
- }
- }
-
- private function elementsToHtml () {
- $bodyStringArray = array();
- $elementString = "";
- for ($i = 0; $i < count($this->elementArray); $i++) {
- $currentElement = $this->elementArray[$i];
- if ($currentElement->id != "body") {
- $elementString .= $currentElement->toHtml();
- }
- else {
- $bodyStringArray = $currentElement->toHtmlArray();
- }
- }
- $elementString .= "<form id='sendData' name='sendData' action='' " .
- "method='POST' target='loadData' " .
- "style='position:absolute;left:800px'>" .
- "<input type='hidden' name='data'></form>";
-
- if (count($bodyStringArray) == 3) {
- $elementString = $bodyStringArray[0] .
- $bodyStringArray[1] .
- $elementString .
- $bodyStringArray[2];
-
- }
- return $elementString;
- }
-
-}
+include_once(dirname(__FILE__)."/../../lib/application.php");
?>
\ No newline at end of file
Modified: branches/testbaudson_dev/http/frames/index.php
===================================================================
--- branches/testbaudson_dev/http/frames/index.php 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/frames/index.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -18,9 +18,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("../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../classes/class_locale.php");
-require_once(dirname(__FILE__)."/../classes/class_gui.php");
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../../lib/mapbender.php");
$_SESSION["mb_user_gui"] = $gui_id;
@@ -29,54 +28,10 @@
// if not, return to login screen
//
if (!in_array($gui_id, $_SESSION["mb_user_guis"])) {
- $e = new mb_exception("mb_validateSession.php: User: " . $_SESSION["mb_user_id"] . " not allowed to access GUI " . $gui_id);
+ $e = new mb_exception("index.php: User is not allowed to access application. User ID: " . $_SESSION["mb_user_id"] . ", Application: " . $gui_id);
header("Location: ".LOGIN);
die();
}
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<!--
-Licensing: See the GNU General Public License for more details.
-http://www.gnu.org/copyleft/gpl.html
-or:
-mapbender/licence/
--->
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>">
-<title><?php echo $gui_id;?> - presented by Mapbender</title>
-<?php
-$sql = "SELECT * FROM gui_element_vars WHERE fkey_e_id = 'body' AND fkey_gui_id = $1 and var_type='file/css'";
-$v = array($gui_id);
-$t = array('s');
-$res = db_prep_query($sql,$v,$t);
-$cnt = 0;
-while($row = db_fetch_array($res)){
- echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$row["var_value"]."\">\n";
-}
-?>
-<style type="text/css">
-<!--
-<?php
-$sql = "SELECT * FROM gui_element_vars WHERE fkey_e_id = 'body' AND fkey_gui_id = $1 and var_type='text/css'";
-$v = array($gui_id);
-$t = array('s');
-$res = db_prep_query($sql,$v,$t);
-$cnt = 0;
-while($row = db_fetch_array($res)){
- echo $row["var_value"];
-}
-?>
--->
-</style>
-<script type='text/javascript' src='../javascripts/core.php'></script>
-</head>
-<?php
-$currentApplication = new gui($gui_id);
-echo $currentApplication->toHtml();
-echo "<script type='text/javascript' src='../javascripts/map.php?".$urlParameters."&mb_myBBOX=".$_REQUEST["mb_myBBOX"]."'></script>";
-?>
-</html>
\ No newline at end of file
+$mapbender = new Mapbender($_SESSION, $_GET, $_POST);
+echo $mapbender->toHtml();
+?>
\ No newline at end of file
Modified: branches/testbaudson_dev/http/javascripts/geometry.js
===================================================================
--- branches/testbaudson_dev/http/javascripts/geometry.js 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/javascripts/geometry.js 2008-07-18 10:26:21 UTC (rev 2674)
@@ -1486,7 +1486,7 @@
mG = new MultiGeometry(geomType.point);
mG.addGeometry();
mG.get(-1).addPoint(center);
- highlight.add(mG);
+ highlight.add(mG,snappingColor);
highlight.paint();
};
this.getTolerance = function() {
@@ -1549,6 +1549,11 @@
/**
* @private
*/
+ var snappingColor = aColor;
+
+ /**
+ * @private
+ */
var lineWidth = 2;
/**
Modified: branches/testbaudson_dev/http/javascripts/mod_box1.js
===================================================================
--- branches/testbaudson_dev/http/javascripts/mod_box1.js 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/javascripts/mod_box1.js 2008-07-18 10:26:21 UTC (rev 2674)
@@ -17,13 +17,13 @@
mb_isActive = true;
mb_getMousePos(e,mb_isBF);
mb_start_x = clickX;
- mb_start_y = clickY
+ mb_start_y = clickY;
mb_end_x = mb_start_x+1;
mb_end_y = mb_start_y+1;
mb_offset_left = mb_start_x;
mb_offset_top = mb_start_y;
mb_offset_bottom = mb_start_y;
- mb_offset_right = mb_start_x
+ mb_offset_right = mb_start_x;
mb_drawBox(mb_start_x,mb_start_y,mb_end_x,mb_end_y);
return false;
}
@@ -121,7 +121,7 @@
var maxy = y2;
}
// area or clickpoint ?
- var ret = new Array();
+ var ret = [];
if((maxx - minx) > 3 && (miny - maxy) > 3){
var posMin = makeClickPos2RealWorldPos(mb_isBF,minx,miny);
var posMax = makeClickPos2RealWorldPos(mb_isBF,maxx,maxy);
@@ -139,4 +139,4 @@
return ret;
//zoom(mb_zF,true,1.0,pos[0], pos[1]);
}
-}
\ No newline at end of file
+}
Modified: branches/testbaudson_dev/http/javascripts/mod_savewmc.php
===================================================================
--- branches/testbaudson_dev/http/javascripts/mod_savewmc.php 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/javascripts/mod_savewmc.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -22,9 +22,12 @@
echo "mod_savewmc_target = '".$e_target[0]."';";
?>
+
function setOnUnload() {
if (ie) {
- document.getElementsByTagName('body')[0].onunload = function() {var x = new Function ("", "mod_savewmc_session()"); x(); };
+ document.getElementsByTagName('body')[0].onunload = function() {
+ var x = new Function ("", "mod_savewmc_session()"); x();
+ };
}
else {
document.getElementsByTagName('body')[0].setAttribute("onUnload", "mod_savewmc_session();");
@@ -65,4 +68,4 @@
$.ajaxSetup({async:false}); //TODO: find out why async doesn't work onunload
}
$.post("../php/mod_savewmc_server.php", {"saveInSession":storeInSession, "generalTitle":generalTitle, "extensionData":extensionDataString, "mapObject":$.toJSON(mb_mapObj)}, callbackFunction);
-}
\ No newline at end of file
+}
Modified: branches/testbaudson_dev/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- branches/testbaudson_dev/http/javascripts/mod_wfs_gazetteer_client.php 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/javascripts/mod_wfs_gazetteer_client.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -18,12 +18,18 @@
# 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__)."/../php/mb_validatePermission.php");
+session_start();
+$gui_id = $_SESSION["mb_user_gui"];
-$gui_id = $_SESSION["mb_user_gui"];
$target = $_REQUEST["e_target"];
+$e_id_css = $_REQUEST["e_id_css"];
+$e_id = $_REQUEST["e_id"];
$isLoaded = $_REQUEST["isLoaded"];
+require_once(dirname(__FILE__) . "/../../core/globalSettings.php");
+
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db($DB,$con);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
@@ -38,7 +44,8 @@
<?php
include '../include/dyn_js.php';
include '../include/dyn_php.php';
-
+ include(dirname(__FILE__) . "/../../conf/" . $wfs_spatial_request_conf_filename);
+
echo "var targetString = '" . $target . "';";
echo "var wfsConfIdString = '" . $wfsConfIdString . "';";
echo "var e_id_css = '" . $e_id_css . "';";
@@ -58,21 +65,235 @@
maxHighlightedPoints = 0;
// var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints is not set, see 'edit element vars'.");
}
+// Element var showResultInPopup
+try {if(showResultInPopup){}}catch(e) {showResultInPopup = 1;}
+//element var openLinkFromSearch for opening attribute link directly onclick of searchResult entry
+try{
+ if (openLinkFromSearch){}
+}
+catch(e){
+ openLinkFromSearch =0;
+}
+
var targetArray = targetString.split(",");
var global_wfsConfObj;
var global_selectedWfsConfId;
var point_px = 10;
var resultGeom = null;
var cw_fillcolor = "#cc33cc";
+var frameName = e_id_css;
+var inputNotEnough = [];
+//start button management spatialRequest ////////
+var button_point = "point";
+var button_polygon = "polygon";
+var button_rectangle = "rectangle";
+var button_extent = "extent";
+var mb_wfs_tolerance = 8;
+var activeButton = null;
+var mod_wfs_spatialRequest_geometry = null;
+var mod_wfs_spatialRequest_frameName = "";
+var mod_wfs_spatialRequest_epsg;
+var mod_wfs_spatialRequest_width;
+var mod_wfs_spatialRequest_height;
+
+/**
+ * This Geometry contains the geometry of the optinal spatial constraint
+ */
+var spatialRequestGeom = null;
+
+/**
+ * Something like box, polygon, point, extent
+ */
+var spatialRequestType = null;
+
+/**
+ * This Geometry contains the result from the WFS request
+ */
+var geomArray;
+
+var buttonWfs_id = [];
+var buttonWfs_on = [];
+var buttonWfs_src = [];
+var buttonWfs_title_off = [];
+var buttonWfs_title_on = [];
+var buttonWfs_x = [];
+var buttonWfs_y = [];
+
+function addButtonWfs(id, isOn, src, title, x, y) {
+ buttonWfs_id.push(id);
+ buttonWfs_on.push(isOn);
+ buttonWfs_src.push(src);
+ buttonWfs_title_off.push(title);
+ buttonWfs_title_on.push(title);
+ buttonWfs_x.push(x);
+ buttonWfs_y.push(y);
+}
+// end of button management spatialRequest ///////////
+
parent.mb_registerInitFunctions("window.frames['"+this.name+"'].initModWfsGazetteer()");
+parent.mb_registerInitFunctions("window.frames['"+this.name+"'].init_wfsSpatialRequest()");
-function openwindow(Adresse) {
- Fenster1 = window.open(Adresse, "Informationen", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
- Fenster1.focus();
+function init_wfsSpatialRequest() {
+ //parent.mb_ajax_json("../php/mod_wfsSpatialRequest_messages.php", function(obj, status) {
+ // msgObj = obj;
+ buttonWfs_id = [];
+ buttonWfs_on = [];
+ buttonWfs_src = [];
+ buttonWfs_title_off = [];
+ buttonWfs_title_on = [];
+ buttonWfs_x = [];
+ buttonWfs_y = [];
+ addButtonWfs("rectangle", buttonRectangle.status, buttonRectangle.img, buttonRectangle.title, buttonRectangle.x, buttonRectangle.y);
+ addButtonWfs("polygon", buttonPolygon.status, buttonPolygon.img, buttonPolygon.title, buttonPolygon.x, buttonPolygon.y);
+ addButtonWfs("point", buttonPoint.status, buttonPoint.img, buttonPoint.title, buttonPoint.x, buttonPoint.y);
+ addButtonWfs("extent", buttonExtent.status, buttonExtent.img, buttonExtent.title, buttonExtent.x, buttonExtent.y);
+ displayButtons();
+ //});
}
+
+function wfsInitFunction (j) {
+ var functionCall = "parent.mb_regButton_frame('initWfsButton', '"+frameName+"', "+j+")";
+ var x = new Function ("", functionCall);
+ x();
+}
+
+function initWfsButton(ind, pos) {
+ parent.mb_button[ind] = document.getElementById(buttonWfs_id[pos]);
+ parent.mb_button[ind].img_over = buttonWfs_imgdir + buttonWfs_src[pos].replace(/_off/,"_over");
+ parent.mb_button[ind].img_on = buttonWfs_imgdir + buttonWfs_src[pos].replace(/_off/,"_on");
+ parent.mb_button[ind].img_off = buttonWfs_imgdir + buttonWfs_src[pos];
+ parent.mb_button[ind].img_out = buttonWfs_imgdir + buttonWfs_src[pos];
+ parent.mb_button[ind].status = 0;
+ parent.mb_button[ind].elName = buttonWfs_id[pos];
+ parent.mb_button[ind].frameName = frameName;
+ parent.mb_button[ind].go = new Function ("requestGeometryHighlight.clean(); wfsEnable(parent.mb_button["+ind+"], " + pos + ")");
+ parent.mb_button[ind].stop = new Function ("wfsDisable(parent.mb_button["+ind+"], " + pos + ")");
+ var ind = parent.getMapObjIndexByName("mapframe1");
+ mod_wfs_spatialRequest_width = parent.mb_mapObj[ind].width;
+ mod_wfs_spatialRequest_height = parent.mb_mapObj[ind].height;
+ mod_wfs_spatialRequest_epsg = parent.mb_mapObj[ind].epsg;
+ parent.mb_registerPanSubElement("measuring");
+}
+
+function displayButtons() {
+ for (var i = 0 ; i < buttonWfs_id.length ; i ++) {
+ if (parseInt(buttonWfs_on[i])==1) {
+ var currentImg = document.createElement("img");
+ currentImg.id = buttonWfs_id[i];
+ currentImg.name = buttonWfs_id[i];
+ currentImg.title = buttonWfs_title_off[i];
+ currentImg.src = buttonWfs_imgdir+buttonWfs_src[i];
+ currentImg.style.marginRight = "5px";
+ currentImg.onmouseover = new Function("wfsInitFunction("+i+")");
+
+ document.getElementById("displaySpatialButtons").appendChild(currentImg);
+ }
+ }
+}
+
+function disableButtons() {
+ removeChildNodes(document.getElementById("displaySpatialButtons"));
+}
+
+function wfsEnable(obj) {
+ var el = parent.window.frames["mapframe1"].document;
+ el.onmouseover = null;
+ el.onmousedown = null;
+ el.onmouseup = null;
+ el.onmousemove = null;
+
+ if (obj.id == button_point) {
+ if (activeButton == null) {
+ activeButton = obj;
+ }
+ }
+ if (obj.id == button_polygon) {
+ if (activeButton == null) {
+ activeButton = obj;
+ }
+ }
+ else if (obj.id == button_rectangle){
+ if (activeButton == null) {
+ activeButton = obj;
+ }
+ }
+ else if (obj.id == button_extent){
+ if (activeButton == null) {
+ activeButton = obj;
+ }
+ }
+ callRequestGeometryConstructor(obj.id,"mapframe1");
+}
+
+function callRequestGeometryConstructor(selectedType,target){
+ if(document.getElementById("res")){
+ document.getElementById("res").innerHTML ="";
+ spatialRequestGeom = null;
+ }
+ if(document.getElementById("spatialResHint")){
+ document.getElementById("spatialResHint").innerHTML = "";
+ }
+ spatialRequestType = selectedType;
+ var geometryConstructor = new parent.RequestGeometryConstructor(target);
+ geometryConstructor.getGeometry(selectedType,function(target,queryGeom){
+ if(queryGeom !=''){
+ var spatialRes = document.createElement("span");
+ spatialRes.id = "spatialResHint";
+ spatialRes.name = "spatialResHint";
+ document.getElementById("displaySpatialButtons").appendChild(spatialRes);
+ document.getElementById("spatialResHint").innerHTML = spatialRequestIsSetMessage;
+ spatialRequestGeom = queryGeom;
+ }
+ parent.mb_disableThisButton(selectedType);
+
+ // spatialRequestGeom is a Geometry, but for the highlight
+ // a MultiGeometry is needed.
+ var multiGeom;
+ // a line represents a bbox...but highlight must be a polyon
+ // (extent or box selection)
+ if (spatialRequestGeom.geomType == parent.geomType.line) {
+ multiGeom = new parent.MultiGeometry(parent.geomType.polygon);
+ newGeom = new parent.Geometry(parent.geomType.polygon);
+ var p1 = spatialRequestGeom.get(0);
+ var p2 = spatialRequestGeom.get(1);
+ newGeom.addPoint(p1);
+ newGeom.addPointByCoordinates(p1.x, p2.y);
+ newGeom.addPoint(p2);
+ newGeom.addPointByCoordinates(p2.x, p1.y);
+ newGeom.close();
+ multiGeom.add(newGeom);
+ }
+ // standard case
+ // (polygon and point selection)
+ else {
+ multiGeom = new parent.MultiGeometry(spatialRequestGeom.geomType);
+ multiGeom.add(spatialRequestGeom);
+ }
+
+ // add highlight of geometry
+ requestGeometryHighlight.add(multiGeom);
+ requestGeometryHighlight.paint();
+
+ });
+}
+
+function wfsDisable(obj) {
+ var el = parent.window.frames["mapframe1"].document;
+ el.onmousedown = null;
+ el.ondblclick = null;
+ el.onmousemove = null;
+ parent.writeTag("mapframe1","measure_display","");
+ parent.writeTag("mapframe1","measure_sub","");
+ activeButton = null;
+}
+
+function openwindow(url) {
+ window1 = window.open(url, "Information", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
+ window1.focus();
+}
//----------------------------------------------------------------------------------
function appendWfsConf(newWfsConfIdString) {
@@ -146,7 +367,9 @@
}
document.getElementById("wfsGeomType").style.visibility = "hidden";
document.getElementById("wfsRemove").style.visibility = "hidden";
-
+
+ geomArray = new parent.GeometryArray();
+
parent.mb_ajax_json("../php/mod_wfs_gazetteer_server.php", {command:"getWfsConf",wfsConfIdString:wfsConfIdString}, function(json, status) {
global_wfsConfObj = json;
var wfsCount = 0;
@@ -170,6 +393,12 @@
}
parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
});
+
+ // creates a Highlight object for the request geometry
+ var styleProperties = {"position":"absolute", "top":"0px", "left":"0px", "z-index":100};
+ requestGeometryHighlight = new parent.Highlight(targetArray, "requestGeometryHighlight", styleProperties, 2);
+ parent.mb_registerSubFunctions("window.frames['" + frameName +"'].requestGeometryHighlight.paint()");
+
}
function setWfsInfo() {
@@ -207,7 +436,7 @@
wfsGeomTypeNode.style.visibility = 'visible';
}
else {
- var e = new parent.Mb_exception("WFS gazetteer: geometry type unknown.");
+ var e = new parent.Mb_exception("WFS gazetteer: geometry type unknown.");
}
// set image: remove this WFS
@@ -230,7 +459,7 @@
initModWfsGazetteer();
parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
}
- }
+ }
}
function setWfsConfIdString() {
@@ -248,14 +477,27 @@
var selectNode = document.createElement("select");
selectNode.name = "wfs_conf_sel";
var wfsFormNode = document.getElementById("selectWfsConfForm");
- selectNode.onchange = function() {
+ if (parent.ie) {
+ selectNode.onchange = function() {
global_selectedWfsConfId = this.value;
- setWfsInfo();
+ if(typeof(resultGeometryPopup)!="undefined"){
+ resultGeometryPopup.destroy();
+ }
+ if(typeof(wfsPopup)!="undefined"){
+ wfsPopup.destroy();
+ }
+ setWfsInfo();
appendStyles();
appendWfsForm();
- };
+ };
+ }
+ else{
+ selectNode.setAttribute("onchange", "if(typeof(resultGeometryPopup)!='undefined'){resultGeometryPopup.destroy();}if(typeof(wfsPopup)!='undefined'){wfsPopup.destroy();};global_selectedWfsConfId = this.value;setWfsInfo();appendStyles();appendWfsForm();");
+ }
var isSelected = false;
+
for (var wfsConfId in global_wfsConfObj) {
+
var optionNode = document.createElement("option");
optionNode.value = wfsConfId;
@@ -294,150 +536,712 @@
for (var i = 0; i < wfsConfElementArray.length; i++){
if (parseInt(wfsConfElementArray[i].f_search)) {
var spanNode = document.createElement("span");
- spanNode.setAttribute("id", "ttttt");
+ spanNode.setAttribute("id", wfsConfElementArray[i].element_name+"Span");
spanNode.className = wfsConfElementArray[i].f_label_id;
spanNode.innerHTML = wfsConfElementArray[i].f_label;
- var inputNode = document.createElement("input");
- inputNode.type = "text";
- inputNode.className = wfsConfElementArray[i].f_style_id;
- inputNode.id = wfsConfElementArray[i].element_name;
-
+ if(wfsConfElementArray[i].f_form_element_html.match(/\<select/)){
+ var inputNode = document.createElement("span");
+ inputNode.id = wfsConfElementArray[i].element_name+"Select";
+ inputNode.innerHTML = wfsConfElementArray[i].f_form_element_html;
+ }
+ else if(wfsConfElementArray[i].f_form_element_html.match(/checkbox/)){
+ var inputNode = document.createElement("span");
+ inputNode.id = wfsConfElementArray[i].element_name+"Checkbox";
+ inputNode.innerHTML = wfsConfElementArray[i].f_form_element_html;
+ }
+ else{
+ var inputNode = document.createElement("input");
+ inputNode.type = "text";
+ inputNode.className = wfsConfElementArray[i].f_style_id;
+ inputNode.id = wfsConfElementArray[i].element_name;
+ if(wfsConfElementArray[i].f_form_element_html.match(/datepicker/)){
+ inputNode.readOnly=true;
+ inputNode.style.backgroundColor = "#D3D3D3";
+ inputNode.title = "Use datepicker for selection of date";
+ }
+ }
form.appendChild(spanNode);
form.appendChild(inputNode);
+
+ //build imgNode for datepicker image
+ if(wfsConfElementArray[i].f_form_element_html.match(/datepicker/)){
+ var imgNode = document.createElement("span");
+ imgNode.id = wfsConfElementArray[i].element_name+"Img";
+ imgNode.title = "Click here to open datepicker";
+ imgNode.innerHTML = wfsConfElementArray[i].f_form_element_html;
+ form.appendChild(imgNode);
+ }
form.appendChild(document.createElement("br"));
}
}
var submitButton = document.createElement("input");
submitButton.type = "submit";
+ submitButton.id = "submitButton";
submitButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
submitButton.value = global_wfsConfObj[global_selectedWfsConfId].g_button;
form.appendChild(submitButton);
+
+ var delFilterButton = document.createElement("input");
+ delFilterButton.type = "button";
+ delFilterButton.style.marginLeft = "5px";
+ delFilterButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
+ delFilterButton.value = clearFilterButtonLabel;
+ // Internet explorer
+ if (parent.ie) {$_REQUEST['pdfPathString']
+ delFilterButton.onclick = function() {
+ var x = new Function ("", "clearFilter();");
+ x();
+ };
+ }
+ // Firefox
+ else {
+ delFilterButton.onclick = function () {
+ clearFilter();
+ }
+ }
+ form.appendChild(delFilterButton);
+
+ checkSrs();
}
+function checkSrs(){
+ //check SRS
+ var ind = parent.getMapObjIndexByName("mapframe1");
+ var submit = document.getElementById("submitButton");
+ if(global_wfsConfObj[global_selectedWfsConfId].featuretype_srs.toUpperCase()!=parent.mb_mapObj[ind].getSRS().toUpperCase()){
+ var msg = "Different EPSG of map and wfs featuretype, no spatial request possible!\n";
+ msg += parent.mb_mapObj[ind].getSRS()+" und "+global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
+ alert(msg);
+
+ //disable Submit Button
+ if(submit)submit.disabled = true;
+ }
+ else{
+ //disable Submit Button
+ if(submit)submit.disabled = false;
+ }
+}
+
+function clearFilter(){
+ var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
+ for (var i = 0; i < wfsConfElementArray.length; i++){
+ if (parseInt(wfsConfElementArray[i].f_search)) {
+ if(wfsConfElementArray[i].f_form_element_html.match(/checkbox/)){
+ var elementArray = document.getElementsByName(wfsConfElementArray[i].element_name);
+ for (var j = 0; j < elementArray.length; j++){
+ elementArray[j].checked = "";
+ }
+ document.getElementById('checkAll').checked = "";
+ }
+ else{
+ document.getElementById(wfsConfElementArray[i].element_name).value = "";
+ }
+ }
+ }
+
+ //remove geometry from spatialrequest, remove drawn rectangle or polygon and hint
+ spatialRequestGeom = null;
+ requestGeometryHighlight.clean();
+ requestGeometryHighlight.paint();
+ if(document.getElementById('spatialResHint')){
+ document.getElementById("spatialResHint").innerHTML = "";
+ }
+
+ //remove result popup
+ if(typeof(resultGeometryPopup)!="undefined"){
+ resultGeometryPopup.destroy();
+ }
+ //remove detail popup
+ if(typeof(wfsPopup)!="undefined"){
+ wfsPopup.destroy();
+ }
+
+ if(document.getElementById('spatialResHint')){
+ document.getElementById("spatialResHint").innerHTML = "";
+ }
+ document.getElementById("res").innerHTML = "";
+}
+
+function getNumberOfFilterParameters(){
+ var cnt = 0;
+ var el = global_wfsConfObj[global_selectedWfsConfId].element;
+ inputNotEnough = [];
+ for (var i = 0; i < el.length; i++){
+
+ if( el[i]['f_search'] == 1){
+ if(el[i]['f_form_element_html'].match(/\<select/)){
+ var elementValue = document.getElementById(el[i]['element_name']).options[document.getElementById(el[i]['element_name']).selectedIndex].value;
+ }
+ else if(el[i]['f_form_element_html'].match(/checkbox/)){
+ var elementArray = document.getElementsByName(el[i]['element_name']);
+ var selectedVal = [];
+ for (var j = 0; j < elementArray.length; j++){
+ if (elementArray[j].checked == true){
+ selectedVal.push(elementArray[j].value);
+ }
+ }
+ var elementValue = selectedVal.join(",");
+ }
+ else{
+ var elementValue = document.getElementById(el[i]['element_name']).value;
+ }
+
+ if (elementValue != '') {
+ cnt++;
+ }
+ if(elementValue.length < el[i]['f_min_input']){
+ inputNotEnough.push(el[i]['element_name']+"("+el[i]['f_min_input']+")");
+ }
+ }
+ }
+
+ if(inputNotEnough.length>0){
+ alert("Mandatory fields: "+inputNotEnough.join(', '));
+ return false;
+ }
+
+// if(spatialRequestGeom == null){
+// alert("Bitte räumliche Eingrenzung vornehmen.");
+// return false;
+// }
+
+ return cnt;
+}
+
function validate(){
+ if(geomArray.count()>0){
+ geomArray.empty();
+ }
+ if(typeof(resultGeometryPopup)!="undefined"){
+ resultGeometryPopup.destroy();
+ }
+ if(typeof(wfsPopup)!="undefined"){
+ wfsPopup.destroy();
+ }
global_resultHighlight = new parent.Highlight(targetArray, "wfs_gazetteer_highlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 2);
var filterParameterCount = getNumberOfFilterParameters();
- if(filterParameterCount == 0){
+ if(filterParameterCount == 0 && spatialRequestGeom == null){
+ //if(filterParameterCount == 0){
+ //alert("Please specify at least one filter attribute.");
return false;
}
else{
- var andConditions = "";
+ if(inputNotEnough.length==0){
+ var andConditions = "";
+
+ var el = global_wfsConfObj[global_selectedWfsConfId].element;
+ var srs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
- var el = global_wfsConfObj[global_selectedWfsConfId].element;
-
- for (var i = 0; i < el.length; i++) {
- if (el[i]['f_search'] == 1 && document.getElementById(el[i]['element_name']).value != '') {
-
- var a = new Array();
- a = document.getElementById(el[i]['element_name']).value.split(",");
- var orConditions = "";
- for (var j=0; j < a.length; j++) {
-
- orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
- orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
- orConditions += "<ogc:Literal>*";
- if(el[i]['f_toupper'] == 1){
- orConditions += a[j].toUpperCase();
+ for (var i = 0; i < el.length; i++) {
+ if (el[i]['f_search'] == 1){
+ if(el[i]['f_form_element_html'].match(/\<select/)){
+ var elementValue = document.getElementById(el[i]['element_name']).options[document.getElementById(el[i]['element_name']).selectedIndex].value;
+ }
+ else if(el[i]['f_form_element_html'].match(/checkbox/)){
+ var elementArray = document.getElementsByName(el[i]['element_name']);
+ var selectedVal = [];
+ for (var j = 0; j < elementArray.length; j++){
+ if (elementArray[j].checked == true){
+ selectedVal.push(elementArray[j].value);
+ }
+ }
+ var elementValue = selectedVal.join(",");
}
else{
- orConditions += a[j];
+ var elementValue = document.getElementById(el[i]['element_name']).value;
}
- orConditions += "*</ogc:Literal>";
- orConditions += "</ogc:PropertyIsLike>";
}
- if(a.length > 1){
- andConditions += "<Or>" + orConditions + "</Or>";
+
+ if (el[i]['f_search'] == 1 && elementValue != '') {
+ var a = new Array();
+ a = elementValue.split(",");
+ var orConditions = "";
+ for (var j=0; j < a.length; j++) {
+ if(el[i]['f_operator']=='bothside'){
+ orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+ orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>*";
+ if(el[i]['f_toupper'] == 1){
+ orConditions += a[j].toUpperCase();
+ }
+ else{
+ orConditions += a[j];
+ }
+ orConditions += "*</ogc:Literal>";
+ orConditions += "</ogc:PropertyIsLike>";
+ }
+ else if(el[i]['f_operator']=='rightside'){
+ orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+ orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>";
+ if(el[i]['f_toupper'] == 1){
+ orConditions += a[j].toUpperCase();
+ }
+ else{
+ orConditions += a[j];
+ }
+ orConditions += "*</ogc:Literal>";
+ orConditions += "</ogc:PropertyIsLike>";
+ }
+ else if(el[i]['f_operator']=='greater_than'){
+ orConditions += "<ogc:PropertyIsGreaterThan>";
+ orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>";
+ if(el[i]['f_toupper'] == 1){
+ orConditions += a[j].toUpperCase();
+ }
+ else{
+ orConditions += a[j];
+ }
+ orConditions += "</ogc:Literal>";
+ orConditions += "</ogc:PropertyIsGreaterThan>";
+ }
+ else if(el[i]['f_operator']=='less_than'){
+ orConditions += "<ogc:PropertyIsLessThan>";
+ orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>";
+ if(el[i]['f_toupper'] == 1){
+ orConditions += a[j].toUpperCase();
+ }
+ else{
+ orConditions += a[j];
+ }
+ orConditions += "</ogc:Literal>";
+ orConditions += "</ogc:PropertyIsLessThan>";
+ }
+ else if(el[i]['f_operator']=='less_equal_than'){
+ orConditions += "<ogc:PropertyIsLessThanOrEqualTo>";
+ orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>";
+ if(el[i]['f_toupper'] == 1){
+ orConditions += a[j].toUpperCase();
+ }
+ else{
+ orConditions += a[j];
+ }
+ orConditions += "</ogc:Literal>";
+ orConditions += "</ogc:PropertyIsLessThanOrEqualTo>";
+ }
+ else if(el[i]['f_operator']=='greater_equal_than'){
+ orConditions += "<ogc:PropertyIsGreaterThanOrEqualTo>";
+ orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>";
+ if(el[i]['f_toupper'] == 1){
+ orConditions += a[j].toUpperCase();
+ }
+ else{
+ orConditions += a[j];
+ }
+ orConditions += "</ogc:Literal>";
+ orConditions += "</ogc:PropertyIsGreaterThanOrEqualTo>";
+ }
+ else if(el[i]['f_operator']=='equal'){
+ orConditions += "<ogc:PropertyIsEqualTo>";
+ orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>";
+ if(el[i]['f_toupper'] == 1){
+ orConditions += a[j].toUpperCase();
+ }
+ else{
+ orConditions += a[j];
+ }
+ orConditions += "</ogc:Literal>";
+ orConditions += "</ogc:PropertyIsEqualTo>";
+ }
+ else{
+ orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+ orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>*";
+ if(el[i]['f_toupper'] == 1){
+ orConditions += a[j].toUpperCase();
+ }
+ else{
+ orConditions += a[j];
+ }
+ orConditions += "*</ogc:Literal>";
+ orConditions += "</ogc:PropertyIsLike>";
+ }
+ }
+ if(a.length > 1){
+ andConditions += "<Or>" + orConditions + "</Or>";
+ }
+ else {
+ andConditions += orConditions;
+ }
}
- else {
- andConditions += orConditions;
- }
}
- }
-
- var u = global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature + parent.mb_getConjunctionCharacter(global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature);
- u += "REQUEST=getFeature&Typename="+global_wfsConfObj[global_selectedWfsConfId].featuretype_name+"&Version=1.0.0&service=WFS";
- u += "&filter=";
-
- if (filterParameterCount > 1) {
- andConditions = "<And>" + andConditions + "</And>";
- }
-
- var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
-
- document.getElementById("res").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
- var parameters = {command:"getSearchResults", "wfs_conf_id":global_selectedWfsConfId, "frame":this.name, "url":u, "filter":filter, "backlink":""};
- parent.mb_ajax_get("../php/mod_wfs_gazetteer_server.php", parameters, function (jsCode, status) {
- document.getElementById("res").innerHTML = "<table><tr><td>Arranging search results...</td></tr></table>";
- eval(jsCode);
-
- for (var i=0; i < parent.wms.length; i++) {
- for (var j=0; j < parent.wms[i].objLayer.length; j++) {
-
- var currentLayer = parent.wms[i].objLayer[j];
- var wms_id = parent.wms[i].wms_id;
-
- if (currentLayer.gui_layer_wfs_featuretype == global_selectedWfsConfId) {
- var layer_name = currentLayer.layer_name;
- parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'querylayer',1);
- parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'visible',1);
+ if(spatialRequestGeom!=null){
+ if(spatialRequestGeom.geomType == "polygon"){
+ if(buttonPolygon.filteroption=='within'){
+ andConditions += "<Within><ogc:PropertyName>";
+ for (var j=0; j < el.length; j++) {
+ if(el[j]['f_geom']==1){
+ var elementName = el[j]['element_name'];
+ andConditions += el[j]['element_name'];
+ }
+ }
+ andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+ andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ for(var k=0; k<spatialRequestGeom.count(); k++){
+ if(k>0) andConditions += " ";
+ andConditions += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+ }
+ andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+ andConditions += "</gml:Polygon></Within>";
}
+ else if(buttonPolygon.filteroption=='intersects'){
+ andConditions += "<Intersects><ogc:PropertyName>";
+ for (var j=0; j < el.length; j++) {
+ if(el[j]['f_geom']==1){
+ var elementName = el[j]['element_name'];
+ andConditions += el[j]['element_name'];
+ }
+ }
+ andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+ andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ for(var k=0; k<spatialRequestGeom.count(); k++){
+ if(k>0) andConditions += " ";
+ andConditions += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+ }
+ andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+ andConditions += "</gml:Polygon></Intersects>";
+ }
+ }
+ else if(spatialRequestGeom.geomType == "line"){
+ var rectangle = [];
+ rectangle = spatialRequestGeom.getBBox();
+
+ if(buttonRectangle.filteroption=='within'){
+ andConditions += "<Within><ogc:PropertyName>";
+ for (var j=0; j < el.length; j++) {
+ if(el[j]['f_geom']==1){
+ var elementName = el[j]['element_name'];
+ andConditions += el[j]['element_name'];
+ }
+ }
+ andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+ andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ andConditions += rectangle[0].x+","+rectangle[0].y;
+ andConditions += " ";
+ andConditions += rectangle[0].x+","+rectangle[1].y;
+ andConditions += " ";
+ andConditions += rectangle[1].x+","+rectangle[1].y;
+ andConditions += " ";
+ andConditions += rectangle[1].x+","+rectangle[0].y;
+ andConditions += " ";
+ andConditions += rectangle[0].x+","+rectangle[0].y;
+ andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+ andConditions += "</gml:Polygon></Within>";
+ }
+ else if(buttonRectangle.filteroption=='intersects'){
+ andConditions += "<Intersects><ogc:PropertyName>";
+ for (var j=0; j < el.length; j++) {
+ if(el[j]['f_geom']==1){
+ var elementName = el[j]['element_name'];
+ andConditions += el[j]['element_name'];
+ }
+ }
+ andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+ andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ andConditions += rectangle[0].x+","+rectangle[0].y;
+ andConditions += " ";
+ andConditions += rectangle[0].x+","+rectangle[1].y;
+ andConditions += " ";
+ andConditions += rectangle[1].x+","+rectangle[1].y;
+ andConditions += " ";
+ andConditions += rectangle[1].x+","+rectangle[0].y;
+ andConditions += " ";
+ andConditions += rectangle[0].x+","+rectangle[0].y;
+ andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+ andConditions += "</gml:Polygon></Intersects>";
+ }
}
+ else if(spatialRequestGeom.geomType == "point"){
+ var tmp = spatialRequestGeom.get(0);
+ var mapPos = parent.makeRealWorld2mapPos("mapframe1",tmp.x, tmp.y);
+ var buffer = mb_wfs_tolerance/2;
+ var mapPosXAddPix = mapPos[0] + buffer;
+ var mapPosYAddPix = mapPos[1] +buffer;
+ var mapPosXRemovePix = mapPos[0] - buffer;
+ var mapPosYRemovePix = mapPos[1] - buffer;
+ var realWorld1 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYRemovePix);
+ var realWorld2 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld3 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld4 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
+ andConditions += "<Intersects><ogc:PropertyName>";
+ for (var j=0; j < el.length; j++) {
+ if(el[j]['f_geom']==1){
+ var elementName = el[j]['element_name'];
+ andConditions += el[j]['element_name'];
+ }
+ }
+ andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ andConditions += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] + " ";
+ andConditions += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+ andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
+ }
+ //andConditions += "<ogc:Not><ogc:PropertyIsNull>";
+ //andConditions += "<ogc:PropertyName>" + elementName + "</ogc:PropertyName>";
+ //andConditions += "</ogc:PropertyIsNull></ogc:Not>";
}
- var body = "";
- if (typeof(geom) == 'object') {
- resultGeom = geom; // set the global variable
- for (var i=0; i < geom.count(); i++) {
- body += "<div id='geom"+i+"'style='cursor:pointer;' ";
- if ((i % 2) === 0) {
- body += "class='even'";
+ var u = global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature + parent.mb_getConjunctionCharacter(global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature);
+ u += "REQUEST=getFeature&Typename="+global_wfsConfObj[global_selectedWfsConfId].featuretype_name+"&Version=1.0.0&service=WFS";
+ u += "&filter=";
+
+ if (filterParameterCount > 1 || spatialRequestGeom != null) {
+ andConditions = "<And>" + andConditions + "</And>";
+ }
+
+ var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
+
+ document.getElementById("res").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
+ var parameters = {command:"getSearchResults", "wfs_conf_id":global_selectedWfsConfId, "frame":this.name, "url":u, "filter":filter, "backlink":""};
+ parent.mb_ajax_get("../php/mod_wfs_gazetteer_server.php", parameters, function (jsCode, status) {
+ document.getElementById("res").innerHTML = "<table><tr><td>Arranging search results...</td></tr></table>";
+
+ if(status=='success'){
+ for (var i=0; i < parent.wms.length; i++) {
+ for (var j=0; j < parent.wms[i].objLayer.length; j++) {
+ var currentLayer = parent.wms[i].objLayer[j];
+ var wms_id = parent.wms[i].wms_id;
+ if (currentLayer.gui_layer_wfs_featuretype == global_selectedWfsConfId) {
+ var layer_name = currentLayer.layer_name;
+ parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'querylayer',1);
+ parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'visible',1);
+ }
+ }
}
- else {
- body += "class='uneven'";
+ var geoObj = eval('(' + jsCode + ')');
+ if (jsCode) {
+ if (typeof(geoObj) == 'object') {
+ geomArray.importGeoJSON(geoObj);
+ document.getElementById("res").innerHTML = '';
+ displayResult(geomArray);
+ }
+ else {
+ document.getElementById("res").innerHTML = '';
+ displayResult();
+ }
}
- body += " onmouseover=\"setResult('over', this.id)\" ";
- body += " onmouseout=\"setResult('out', this.id)\" ";
- body += " onclick=\"setResult('click', this.id)\">";
- for (var j=0; j < geom.get(i).e.count(); j++) {
- body += geom.get(i).e.getValue(j) + " ";
+ else {
+ document.getElementById("res").innerHTML = '';
+ alert("No results.");
}
- body += "</div>";
- }
+ }
+ });
+ }
+ else{
+ return false;
+ }
+ }
+ //spatialRequestGeom = null;
+ return false;
+}
+
+function displayResult(geom){
+ geomArray = geom;
+ if(geomArray!=null && geomArray.count()>0){
+ var contentHtml = createListOfGeometries();
+ }
+ else{
+ var contentHtml = "No results.";
+ }
+
+ if(showResultInPopup==1){
+ if (typeof(resultGeometryPopup) == "undefined") {
+ resultGeometryPopup = new parent.mb_popup(searchPopupTitle,contentHtml,searchPopupWidth,searchPopupHeight,searchPopupX,searchPopupY);
+ }
+ else {
+ resultGeometryPopup.destroy();
+ resultGeometryPopup = new parent.mb_popup(searchPopupTitle,contentHtml,searchPopupWidth,searchPopupHeight,searchPopupX,searchPopupY);
+ }
+ resultGeometryPopup.show();
+
+ }
+ else{
+ document.getElementById("res").innerHTML = contentHtml;
+ }
+
+}
+
+function createListOfGeometries(){
+ if(showResultInPopup==1){
+ var domPath = "window.frames['"+frameName+"'].";
+ }
+ else{
+ var domPath = "";
+ }
+ var listOfGeom = "<form name='resultListForm'><table style='background-color:#EEEEEE;'>\n";
+ var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+ var labelArray = [];
+ if (geomArray.count() > 0) {
+
+ if(showResultInPopup==1){
+ listOfGeom += "<tr>";
+ var labelObj = getListTitle();
+ for (var k = 1 ; k < labelObj.length; k ++) {
+ listOfGeom += "<td>";
+ listOfGeom += labelObj[k];
+ listOfGeom += "</td>";
}
- else {
- body = "Kein Ergebnis.";
+ listOfGeom += "</tr>";
+ }
+
+ for (var i = 0 ; i < geomArray.count(); i ++) {
+ if (geomArray.get(i).get(-1).isComplete()) {
+ listOfGeom += "<tr>\n";
+ var resultElObj = getListValues(geomArray.get(i));
+ for (var l = 1 ; l < resultElObj.length; l ++) {
+ if(resultElObj[l]!=''){
+ listOfGeom += "<td style='cursor:pointer;\n";
+ if(showResultInPopup==1){
+ if ((i % 2) === 0) {
+ listOfGeom += "color:blue'";
+ }
+ else {
+ listOfGeom += "color:red'";
+ }
+ }
+ else{
+ if ((i % 2) === 0) {
+ listOfGeom += "' class='even'";
+ }
+ else {
+ listOfGeom += "' class='uneven'";
+ }
+ }
+ listOfGeom += " onmouseover=\""+domPath+"setResult('over',"+i+")\" ";
+ listOfGeom += " onmouseout=\""+domPath+"setResult('out',"+i+")\" ";
+ listOfGeom += " onclick=\""+domPath+"setResult('click',"+i+"); "+domPath+"showWfs("+i+");\" ";
+ listOfGeom += ">"+ resultElObj[l] +"</td>";
+ }
+ }
+ listOfGeom += "\t</tr>\n";
}
- document.getElementById('res').innerHTML = body;
- });
+ }
}
- return false;
+ listOfGeom += "</table></form>\n";
+ return listOfGeom;
}
-function getNumberOfFilterParameters(){
- var cnt = 0;
- var el = global_wfsConfObj[global_selectedWfsConfId].element;
+function getListTitle(){
+ var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+ var labelArray = [];
+ for (var j = 0 ; j < wfsConf.element.length ; j++) {
+ if(wfsConf.element[j].f_show == 1 && wfsConf.element[j].f_label!=''){
+ var labelPos = wfsConf.element[j].f_respos;
+ labelArray[labelPos] = wfsConf.element[j].f_label;
+ }
+ }
+ return labelArray;
+}
+
+function getListValues(geom){
+ var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+ var resultArray = [];
+ for (var i = 0 ; i < wfsConf.element.length ; i++) {
+ if (wfsConf.element[i].f_show == 1 && geom.e.getElementValueByName(wfsConf.element[i].element_name) !=false) {
+ var pos = wfsConf.element[i].f_respos;
+ if(pos>0){
+ resultArray[pos] = geom.e.getElementValueByName(wfsConf.element[i].element_name);
+ }
+ }
+ }
+ return resultArray;
+}
- for (var i = 0; i < el.length; i++){
- if( el[i]['f_search'] == 1){
- if (document.getElementById(el[i]['element_name']).value != '') {
- cnt++;
+function showWfs(geometryIndex) {
+ var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+ var wfsElement = geomArray.get(geometryIndex).e;
+ var showDetailsObj = [];
+ var details = 0;
+ for (var i = 0 ; i <wfsConf.element.length; i ++) {
+ if(wfsConf.element[i].f_show_detail == 1 && wfsElement.getElementValueByName(wfsConf.element[i].element_name)!=''){
+ var elPos = wfsConf.element[i].f_detailpos;
+ if(elPos>0){
+ var currentObj = {};
+// showDetailsObj[elPos] = {};
+ currentObj.elPos = elPos;
+ currentObj.data = {};
+ //var elementVal = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
+ //showDetailsObj[elPos][wfsConf.element[i].f_label] = elementVal;
+ if(wfsConf.element[i].f_form_element_html.indexOf("href")!=-1){
+ var newPath = wfsElement.getElementValueByName(wfsConf.element[i].element_name).replace(/%computername%/,"Rechnername");
+ var setUrl = wfsConf.element[i].f_form_element_html.replace(/href\s*=\s*['|"]\s*['|"]/, "href='"+newPath+"' target='_blank'");
+ if(setUrl.match(/><\/a>/)){
+ var newLink = setUrl.replace(/><\/a>/, ">"+wfsElement.getElementValueByName(wfsConf.element[i].element_name)+"</a>");
+ }
+ else{
+ var newLink = setUrl;
+ }
+ if(openLinkFromSearch=='1'){
+ window.open(elementVal, elementVal,"width=500, height=400,left=100,top=100,scrollbars=yes");
+ }
+// showDetailsObj[elPos][wfsConf.element[i].f_label] = newLink;
+ currentObj.data[wfsConf.element[i].f_label] = newLink;
+ }
+ else{
+// showDetailsObj[elPos][wfsConf.element[i].f_label] = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
+ currentObj.data[wfsConf.element[i].f_label] = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
+ }
+ showDetailsObj.push(currentObj);
}
+ details = 1;
}
+ else{
+ details = 0;
+ }
}
- return cnt;
+ var resultHtml = "";
+ resultHtml += "<table style='background-color:#EEEEEE;'>\n";
+// for (var elPos in showDetailsObj) {
+
+ showDetailsObj.sort(showDetailObjSort);
+ for (var i=0; i < showDetailsObj.length; i++) {
+// var currentDetail = showDetailsObj[elPos];
+ var currentDetail = showDetailsObj[i].data;
+ for(var key in currentDetail){
+ var currentDetailName = key;
+ var currentDetailValue = currentDetail[key];
+ resultHtml +="<tr><td>\n";
+ resultHtml += currentDetailName;
+ resultHtml +="</td>\n";
+ resultHtml += "<td>\n";
+ resultHtml += currentDetailValue;
+ resultHtml += "</td></tr>\n";
+ }
+ }
+ if(details != 1){
+ resultHtml +="<tr><td>No detail information</td></tr>\n";
+ }
+ resultHtml += "</table>\n";
+ if(showResultInPopup==1){
+ if (typeof(wfsPopup) == "undefined") {
+ wfsPopup = new parent.mb_popup(detailPopupTitle,resultHtml,detailPopupWidth,detailPopupHeight,detailPopupX,detailPopupY);
+ }
+ else {
+ wfsPopup.destroy();
+ wfsPopup = new parent.mb_popup(detailPopupTitle,resultHtml,detailPopupWidth,detailPopupHeight,detailPopupX,detailPopupY);
+ }
+ wfsPopup.show();
+ }
}
+
+function showDetailObjSort (a, b) {
+ return (parseInt(a.elPos) - parseInt(b.elPos));
+}
+
/*
* event -> {over || out || click}
* geom -> commaseparated coordinates x1,y1,x2,y2 ...
*/
-function setResult(event, id){
- var index = parseInt(id.slice(4));
-
- var currentGeom = resultGeom.get(index);
+function setResult(event, index){
+ var currentGeom = geomArray.get(index);
if (maxHighlightedPoints > 0 && currentGeom.getTotalPointCount() > maxHighlightedPoints) {
currentGeom = currentGeom.getBBox4();
}
@@ -463,14 +1267,23 @@
}
return true;
}
+
+function callPick(obj){
+ dTarget = obj;
+ var dp = window.open('../tools/datepicker/datepicker.php?m=Jan_Feb_Mar_Apr_May_June_July_Aug_Sept_Oct_Nov_Dec&d=Mon_Tue_Wed_Thu_Fri_Sat_Sun&t=today','dp','left=200,top=200,width=230,height=210,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0');
+ dp.focus();
+ return false;
+}
+
</script>
</head>
<body leftmargin='0' topmargin='10' bgcolor='#ffffff'>
<form name='selectWfsConfForm' id='selectWfsConfForm'></form>
+<div name='displaySpatialButtons' id='displaySpatialButtons' style='width:180px'></div>
+<a name='wfsInfo' id='wfsInfo'></a>
+<img src = "" name='wfsRemove' id='wfsRemove'>
<img src = "" name='wfsGeomType' id='wfsGeomType'>
-<img src = "" name='wfsRemove' id='wfsRemove'>
-<a name='wfsInfo' id='wfsInfo'></a>
<form name='wfsForm' id='wfsForm' onsubmit='return validate()'></form>
<div name='res' id='res' style='width:180px'></div>
</body>
-</html>
\ No newline at end of file
+</html>
Modified: branches/testbaudson_dev/http/php/mb_validateSession.php
===================================================================
--- branches/testbaudson_dev/http/php/mb_validateSession.php 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/php/mb_validateSession.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -19,7 +19,6 @@
require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-
$e = new mb_notice("mb_validateSession.php: checking file " . $_SERVER["PHP_SELF"]);
//
Modified: branches/testbaudson_dev/http/php/mod_createUser.php
===================================================================
--- branches/testbaudson_dev/http/php/mod_createUser.php 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/php/mod_createUser.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -121,7 +121,7 @@
$res_group = db_prep_query($sql_group,$v,$t);
// CB (begin)
// adding new GUIs for new user (copies of gui and gui1 with owner rights)
- $gui = new gui();
+ $gui = new Application();
$admin = new administration();
//create new name for gui
$gui_id1 = $admin->getGuiIdByGuiName("gui");
Modified: branches/testbaudson_dev/http/php/mod_renameGUI.php
===================================================================
--- branches/testbaudson_dev/http/php/mod_renameGUI.php 2008-07-17 12:29:29 UTC (rev 2673)
+++ branches/testbaudson_dev/http/php/mod_renameGUI.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -154,7 +154,7 @@
###rename
if($rename || $copy){
- $gui = new gui();
+ $gui = new Application();
if ($copy) {
if ($_POST['withU'] == 'true') $gui->copyGui($guiList, $newGuiName, true);
Added: branches/testbaudson_dev/lib/application.php
===================================================================
--- branches/testbaudson_dev/lib/application.php (rev 0)
+++ branches/testbaudson_dev/lib/application.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -0,0 +1,322 @@
+<?php
+# $Id: class_gui.php 2541 2008-06-23 15:59:25Z christoph $
+# http://www.mapbender.org/index.php/class_gui.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__)."/../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../lib/element.php");
+
+/**
+ * GUI is a set of GUI elements and services.
+ */
+class Application {
+
+ var $id;
+ var $elementArray = array();
+
+ public function __construct ($id) {
+ if ($id) {
+ $this->id = $id;
+ $this->elementArray = $this->selectElements();
+ }
+ }
+
+ public function getTitle () {
+ return $this->id . " - " . _mb("presented by Mapbender");
+ }
+
+ public function getId () {
+ return $this->id;
+ }
+
+ public function selectElements () {
+ $sql = "SELECT e_id FROM gui_element WHERE fkey_gui_id = $1 " .
+ "ORDER BY e_pos";
+ $v = array($this->id);
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+ $elementArray = array();
+ while ($row = db_fetch_array($res)) {
+ array_push($elementArray, $row[0]);
+ }
+
+ $this->elementArray = array();
+ for ($i = 0; $i < count($elementArray); $i++) {
+ $currentElement = new Element();
+ $currentElement->select($elementArray[$i], $this->id);
+ array_push($this->elementArray, $currentElement);
+ }
+ return $this->elementArray;
+ }
+
+ public function stylesToHtml () {
+ $htmlString = "";
+ $sql = "SELECT * FROM gui_element_vars WHERE fkey_e_id = 'body' AND fkey_gui_id = $1 and var_type='file/css'";
+ $v = array($this->id);
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+ while($row = db_fetch_array($res)){
+ $url = $row["var_value"];
+ if (file_exists($url)) {
+ $htmlString .= "<link rel='stylesheet' type='text/css' href='" . $url . "'>";
+ }
+ else {
+ $e = new mb_exception("stylesToHtml: file not found: " . $url);
+ }
+ }
+ $htmlString .= "<style type='text/css'><!--";
+ $sql = "SELECT * FROM gui_element_vars WHERE fkey_e_id = 'body' AND fkey_gui_id = $1 and var_type='text/css'";
+ $v = array($this->id);
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+ while($row = db_fetch_array($res)){
+ $htmlString .= $row["var_value"];
+ }
+ $htmlString .= "--></style>";
+ return $htmlString;
+ }
+
+ public function getJavaScriptModules () {
+ $jsArray = array();
+ for ($i = 0; $i < count($this->elementArray); $i++) {
+ $currentElement = $this->elementArray[$i];
+ array_merge($jsArray, $currentElement->getJavaScriptModules());
+ }
+ return $jsArray;
+ }
+
+ /**
+ * Checks if a GUI with a given ID exists in the database
+ *
+ * @param integer $gui_id the ID of the GUI that is being checked
+ * @return boolean true if a gui '$gui_id' exists; else false
+ */
+ public function guiExists ($gui_id){
+ $sql = "SELECT * FROM gui WHERE gui_id = $1";
+ $v = array($gui_id);
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+ $row = db_fetch_array($res);
+ if ($row) {
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * Deletes a GUI $guiId and all its links to users, layers etc.
+ *
+ * @param Integer $guiId the GUI that is going to be deleted
+ * @return boolean true if the deletion succeded, else false
+ */
+ public function deleteGui ($guiId) {
+ $guiList = $guiId;
+
+ $sql = array();
+ $v = array();
+ $t = array();
+
+ array_push($sql, "BEGIN");
+ array_push($v, array());
+ array_push($t, array());
+
+ array_push($sql, "DELETE FROM gui WHERE gui_id = $1");
+ array_push($v, array($guiList));
+ array_push($t, array('s'));
+
+ array_push($sql, "DELETE FROM gui_element WHERE fkey_gui_id = $1");
+ array_push($v, array($guiList));
+ array_push($t, array('s'));
+
+ array_push($sql, "DELETE FROM gui_element_vars WHERE fkey_gui_id = $1");
+ array_push($v, array($guiList));
+ array_push($t, array('s'));
+
+ array_push($sql, "DELETE FROM gui_layer WHERE fkey_gui_id = $1");
+ array_push($v, array($guiList));
+ array_push($t, array('s'));
+
+ array_push($sql, "DELETE FROM gui_mb_group WHERE fkey_gui_id = $1");
+ array_push($v, array($guiList));
+ array_push($t, array('s'));
+
+ array_push($sql, "DELETE FROM gui_mb_user WHERE fkey_gui_id = $1");
+ array_push($v, array($guiList));
+ array_push($t, array('s'));
+
+ array_push($sql, "DELETE FROM gui_treegde WHERE fkey_gui_id = $1");
+ array_push($v, array($guiList));
+ array_push($t, array('s'));
+
+ array_push($sql, "DELETE FROM gui_wfs WHERE fkey_gui_id = $1");
+ array_push($v, array($guiList));
+ array_push($t, array('s'));
+
+ array_push($sql, "DELETE FROM gui_wms WHERE fkey_gui_id = $1");
+ array_push($v, array($guiList));
+ array_push($t, array('s'));
+
+ array_push($sql, "COMMIT");
+ array_push($v, array());
+ array_push($t, array());
+
+ // execute all SQLs
+ for ($i = 0; $i < count($sql); $i++) {
+ $res = db_prep_query($sql[$i], $v[$i], $t[$i]);
+ // if an SQL fails, send a ROLLBACK and return false
+ if (!$res) {
+ db_query("ROLLBACK");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /** Renames the GUI $guiID to $newGUIName
+ *
+ * @param Integer $guiId ID of the GUI
+ * @param String $newGuiName the new name of the GUI
+ * @return boolean true if the renaming succeded, else false
+ */
+ public function renameGui ($guiId, $newGuiName) {
+ if ($this->copyGui($guiId, $newGuiName, true)) {
+ $this->deleteGui($guiId);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * Copies a GUI $guiId and all its links to users, layers etc. to GUI $newGuiName
+ *
+ * @param Integer $guiId ID of the GUI
+ * @param String $newGuiName the new name of the GUI
+ * @param boolean $withUsers true if the users, that may access the GUI $guiId, shall have access to the new GUI; else false.
+ *
+ * @return boolean true if the renaming succeded, else false
+ */
+ public function copyGui ($guiId, $newGuiName, $withUsers) {
+ $guiList = $guiId;
+ if (!$this->guiExists($newGuiName)) {
+
+ $sql = array();
+ $v = array();
+ $t = array();
+
+ array_push($sql, "BEGIN");
+ array_push($v, array());
+ array_push($t, array());
+
+ array_push($sql, "INSERT INTO gui (gui_id, gui_name, gui_description, gui_public) SELECT $1, $2, gui_description, gui_public FROM gui WHERE gui_id = $3;");
+ array_push($v, array ($newGuiName, $newGuiName, $guiList));
+ array_push($t, array ("s", "s", "s"));;
+
+ array_push($sql, "INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) SELECT $1, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url FROM gui_element WHERE fkey_gui_id = $2;");
+ array_push($v, array($newGuiName, $guiList));
+ array_push($t, array("s", "s"));
+
+ array_push($sql, "INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type) SELECT $1, fkey_e_id, var_name, var_value, context, var_type FROM gui_element_vars WHERE fkey_gui_id = $2;");
+ array_push($v, array($newGuiName, $guiList));
+ array_push($t, array("s", "s"));
+
+ array_push($sql, "INSERT INTO gui_layer (fkey_gui_id, fkey_layer_id, gui_layer_wms_id, gui_layer_status, gui_layer_selectable, gui_layer_visible, gui_layer_queryable, gui_layer_querylayer, gui_layer_minscale, gui_layer_maxscale, gui_layer_priority, gui_layer_style, gui_layer_wfs_featuretype) SELECT $1, fkey_layer_id, gui_layer_wms_id, gui_layer_status, gui_layer_selectable, gui_layer_visible, gui_layer_queryable, gui_layer_querylayer, gui_layer_minscale, gui_layer_maxscale, gui_layer_priority, gui_layer_style, gui_layer_wfs_featuretype FROM gui_layer WHERE fkey_gui_id = $2;");
+ array_push($v, array($newGuiName, $guiList));
+ array_push($t, array("s", "s"));
+
+ if ($withUsers == true) {
+ /* group of original gui is copied as well */
+ array_push($sql, "INSERT INTO gui_mb_group (fkey_gui_id, fkey_mb_group_id, mb_group_type) SELECT $1, fkey_mb_group_id, mb_group_type FROM gui_mb_group WHERE fkey_gui_id = $2;");
+ array_push($v, array($newGuiName, $guiList));
+ array_push($t, array("s", "s"));
+
+ /* users of original gui are copied as well */
+ array_push($sql, "INSERT INTO gui_mb_user (fkey_gui_id, fkey_mb_user_id, mb_user_type) SELECT $1, fkey_mb_user_id, mb_user_type FROM gui_mb_user WHERE fkey_gui_id = $2;");
+ array_push($v, array($newGuiName, $guiList));
+ array_push($t, array("s", "s"));
+ }
+ else {
+ // users of original gui are not copied, the current user is set as owner
+ array_push($sql, "INSERT INTO gui_mb_user (fkey_gui_id, fkey_mb_user_id, mb_user_type) VALUES ($1, $2, 'owner')");
+ array_push($v, array($newGuiName, $_SESSION["mb_user_id"]));
+ array_push($t, array('s', 'i'));
+ }
+ array_push($sql, "INSERT INTO gui_treegde (fkey_gui_id, fkey_layer_id, id, lft, rgt, my_layer_title, layer, wms_id) SELECT $1, fkey_layer_id, id, lft, rgt, my_layer_title, layer, wms_id FROM gui_treegde WHERE fkey_gui_id = $2;");
+ array_push($v, array($newGuiName, $guiList));
+ array_push($t, array("s", "s"));
+
+ array_push($sql, "INSERT INTO gui_wfs (fkey_gui_id, fkey_wfs_id) SELECT $1, fkey_wfs_id FROM gui_wfs WHERE fkey_gui_id = $2;");
+ array_push($v, array($newGuiName, $guiList));
+ array_push($t, array("s", "s"));
+
+ array_push($sql, "INSERT INTO gui_wms (fkey_gui_id, fkey_wms_id, gui_wms_position, gui_wms_mapformat, gui_wms_featureinfoformat, gui_wms_exceptionformat, gui_wms_epsg, gui_wms_visible) SELECT $1, fkey_wms_id, gui_wms_position, gui_wms_mapformat, gui_wms_featureinfoformat, gui_wms_exceptionformat, gui_wms_epsg, gui_wms_visible FROM gui_wms WHERE fkey_gui_id = $2;");
+ array_push($v, array($newGuiName, $guiList));
+ array_push($t, array("s", "s"));
+
+ array_push($sql, "COMMIT");
+ array_push($v, array());
+ array_push($t, array());
+
+ // execute all SQLs
+ for ($i = 0; $i < count($sql); $i++) {
+ $res = db_prep_query($sql[$i], $v[$i], $t[$i]);
+ // if an SQL fails, send a ROLLBACK and return false
+ if (!$res) {
+ db_query("ROLLBACK");
+ return false;
+ }
+ }
+ return true;
+ }
+ else {
+ echo "<script language='javascript'>";
+ echo "alert('This gui name " . $newGuiName . " is taken!');";
+ echo "</script>";
+ return false;
+ }
+ }
+
+ public function elementsToHtml () {
+ $bodyStringArray = array();
+ $elementString = "";
+ for ($i = 0; $i < count($this->elementArray); $i++) {
+ $currentElement = $this->elementArray[$i];
+ if ($currentElement->id != "body") {
+ $elementString .= $currentElement->toHtml();
+ }
+ else {
+ $bodyStringArray = $currentElement->toHtmlArray();
+ }
+ }
+ $elementString .= "<form id='sendData' name='sendData' action='' " .
+ "method='POST' target='loadData' " .
+ "style='position:absolute;left:800px'>" .
+ "<input type='hidden' name='data'></form>";
+
+ if (count($bodyStringArray) == 3) {
+ $elementString = $bodyStringArray[0] .
+ $bodyStringArray[1] .
+ $elementString .
+ $bodyStringArray[2];
+
+ }
+ return $elementString;
+ }
+
+}
+?>
\ No newline at end of file
Added: branches/testbaudson_dev/lib/element.php
===================================================================
--- branches/testbaudson_dev/lib/element.php (rev 0)
+++ branches/testbaudson_dev/lib/element.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -0,0 +1,245 @@
+<?php
+# $Id: class_bbox.php 1965 2008-01-15 08:24:29Z christoph $
+# http://www.mapbender.org/index.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__)."/../core/globalSettings.php");
+
+define("ELEMENT_PATTERN", "/sessionID/");
+
+class Element {
+
+ var $guiId;
+ var $id;
+ var $pos;
+ var $isPublic;
+ var $comment;
+ var $title;
+ var $element;
+ var $src;
+ var $attributes;
+ var $left;
+ var $top;
+ var $width;
+ var $height;
+ var $zIndex;
+ var $moreStyles;
+ var $content;
+ var $closeTag;
+ var $jsFile;
+ var $mbMod;
+ var $target;
+ var $requires;
+ var $helpUrl;
+
+ public function __contruct() {
+
+ }
+
+ public function select ($id, $applicationId) {
+ $sql = "SELECT fkey_gui_id, e_id, e_pos, e_public, e_comment, e_public, ".
+ "gettext($1, e_title) as e_title, e_element, e_src, e_attributes, " .
+ "e_left, e_top, e_width, e_height, e_z_index, e_more_styles, " .
+ "e_content, e_closetag, e_js_file, e_mb_mod, e_target, " .
+ "e_requires, e_url FROM gui_element WHERE e_id = $2 AND " .
+ "fkey_gui_id = $3 LIMIT 1";
+ $v = array ($_SESSION["mb_lang"], $id, $applicationId);
+ $t = array ("s", "s", "s");
+ $res = db_prep_query($sql, $v, $t);
+ $row = db_fetch_array($res);
+ if ($row) {
+ $this->guiId = $applicationId;
+ $this->id = $row["e_id"];
+ $this->pos = $row["e_pos"];
+ $this->isPublic = $row["e_public"];
+ $this->comment = $row["e_comment"];
+ $this->title = $row["e_title"];
+ $this->element = $row["e_element"];
+ $this->src = $row["e_src"];
+ $this->attributes = $row["e_attributes"];
+ $this->left = $row["e_left"];
+ $this->top = $row["e_top"];
+ $this->width = $row["e_width"];
+ $this->height = $row["e_height"];
+ $this->zIndex = $row["e_z_index"];
+ $this->moreStyles = $row["e_more_styles"];
+ $this->content = $row["e_content"];
+ $this->closeTag = $row["e_closetag"];
+ $this->jsFile = $row["e_js_file"];
+ $this->mbMod = $row["e_mb_mod"];
+ $this->target = $row["e_target"];
+ $this->requires = $row["e_requires"];
+ $this->helpUrl = $row["e_url"];
+ return true;
+ }
+ return false;
+ }
+
+ public function __toString () {
+ return $this->toHtml();
+ }
+
+ public function getJavaScriptModules () {
+ $jsArray = array();
+ if ($this->mbMod != "") {
+ $moduleArray = explode(",", $this->mbMod);
+ for ($i = 0; $i < count($moduleArray); $i++) {
+ $currentFile = dirname(__FILE__) . "/../javascripts/" . trim($moduleArray[$i]);
+ if (file_exists($currentFile)) {
+ array_push($jsArray, $currentFile);
+ }
+ else {
+ $e = new mb_exception("Javascript module not found: " . $currentFile);
+ }
+ }
+ }
+ return $jsArray;
+ }
+
+ public function toHtmlArray () {
+ if ($this->isPublic) {
+ return array($this->getHtmlOpenTag(), $this->getHtmlContent(), $this->getHtmlCloseTag());
+ }
+ return array("", "", "");
+ }
+
+ public function toHtml () {
+ if ($this->isPublic) {
+ return implode("", $this->toHtmlArray());
+ }
+ return "";
+ }
+
+ private function getHtmlOpenTag () {
+ $openTag = "";
+
+ if ($this->id) {
+ // tag name
+ $openTag .= "<" . $this->element . " ";
+
+ // id and name
+ $openTag .= "id='" . $this->id . "' name='" . $this->id . "' ";
+
+ // attributes
+ if ($this->attributes) {
+ $openTag .= stripslashes($this->replaceSessionStringByUrlParameters($this->attributes)) . " ";
+ }
+
+ // title
+ if ($this->title) {
+ $openTag .= "title='" . $this->title . "' ";
+ }
+
+ // alt for images
+ if ($this->element == "img") {
+ $openTag .= "alt='" . $this->title . "' ";
+ }
+
+ // src
+ if ($this->src) {
+ $openTag .= "src = '" . $this->replaceSessionStringByUrlParameters($this->src);
+
+ // for iframes which are not "loadData",
+ // add additional parameters
+ if ($this->closeTag == "iframe" && $this->id != "loadData") {
+ if(mb_strpos($this->src, "?")) {
+ $openTag .= "&";
+ }
+ else {
+ $openTag .= "?";
+ }
+ $openTag .= "e_id_css=" . $this->id . "&" .
+ "e_id= " . $this->id . "&" .
+ "e_target=" . $this->target . "&" .
+ $this->getUrlParameters();
+ }
+ $openTag .= "' ";
+ }
+
+ // style
+ $openTag .= " style = '";
+ if ($this->top != "" && $this->left != "") {
+ $openTag .= "position:absolute;" .
+ "left:" . $this->left . ";" .
+ "top:" . $this->top . ";";
+ }
+ if ($this->width != "" && $this->height != "") {
+ $openTag .= "width:" . $this->width . ";" .
+ "height:" . $this->height . ";";
+ }
+ if ($this->zIndex) {
+ $openTag .= "z-index:" . $this->zIndex . ";";
+ }
+ if ($this->moreStyles) {
+ $openTag .= $this->moreStyles;
+ }
+ $openTag .= "'>";
+
+ if ($this->element == "body" && USE_LOAD_MESSAGE) {
+ $htmlWhileLoading = "<img src='../img/indicator_wheel.gif'> " .
+ "<b>Ma<font color='#0000CE'>p</font><font color='#C00000'>b</font>ender " .
+ MB_VERSION_NUMBER . " " . strtolower(MB_VERSION_APPENDIX) . "</b>..." .
+ "loading application '" . $this->guiId . "'";
+
+ $openTag .= "<div id='loading_mapbender' " .
+ "style='position:absolute;top:100;left:100'>" .
+ $htmlWhileLoading . "</div>" .
+ "<div id='complete_mapbender' " .
+ "style='display:none'>";
+ }
+ }
+ return $openTag;
+ }
+
+ private function getHtmlContent () {
+ $htmlContent = "";
+ if ($this->content != "") {
+ $htmlContent .= stripslashes($this->content);
+ }
+ return $htmlContent;
+ }
+
+ private function getHtmlCloseTag () {
+ if ($this->element == "body" && USE_LOAD_MESSAGE) {
+ return "</div></body>";
+ }
+ if ($this->closeTag != "") {
+ return "</" . $this->closeTag . ">";
+ }
+ return "";
+ }
+
+ private function getUrlParameters () {
+ $urlParameters = SID;
+ if (isset($this->guiId)) {
+ $urlParameters .= "&guiID=" . $this->guiId;
+ }
+ if (isset($this->id)) {
+ $urlParameters .= "&elementID=" . $this->id;
+ }
+ return $urlParameters;
+ }
+
+ private function replaceSessionStringByUrlParameters ($string) {
+ $urlParameters = $this->getUrlParameters();
+ return preg_replace(ELEMENT_PATTERN, $urlParameters, $string);
+ }
+
+}
+
+
+?>
\ No newline at end of file
Added: branches/testbaudson_dev/lib/mapbender.php
===================================================================
--- branches/testbaudson_dev/lib/mapbender.php (rev 0)
+++ branches/testbaudson_dev/lib/mapbender.php 2008-07-18 10:26:21 UTC (rev 2674)
@@ -0,0 +1,86 @@
+<?php
+# $Id: class_checkInput.php 1742 2007-10-26 10:16:07Z christoph $
+# http://www.mapbender.org/index.php/class_checkInput
+# 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__) . "/../core/globalSettings.php");
+require_once(dirname(__FILE__) . "/application.php");
+
+class Mapbender {
+
+ private $currentApplication;
+ private $session;
+ private $get;
+ private $post;
+
+ public function __construct($session, $get, $post) {
+ $this->session = $session;
+ $this->get = $get;
+ $this->post = $post;
+
+ if ($this->session["mb_user_gui"]) {
+ $this->currentApplication = new Application($this->session["mb_user_gui"]);
+ }
+ else {
+ $e = new mb_exception("Mapbender: application id undefined.");
+ }
+ }
+
+ /**
+ * Returns a website containing the current application
+ *
+ * @return String the HTML code
+ */
+ public function toHtml () {
+ $htmlString = "";
+ $htmlString .= "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
+ <html>
+ <head>
+ <!--
+ Licensing: See the GNU General Public License for more details.
+ http://www.gnu.org/copyleft/gpl.html
+ or:
+ mapbender/licence/
+ -->
+ <meta http-equiv='cache-control' content='no-cache'>
+ <meta http-equiv='pragma' content='no-cache'>
+ <meta http-equiv='expires' content='0'>
+ <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
+ <title>" . $this->currentApplication->getTitle() . "</title>";
+
+ // add CSS files of all modules and CSS of body
+ $htmlString .= $this->currentApplication->stylesToHtml();
+
+ // add core JS functionality
+ $htmlString .= "<script type='text/javascript' src='../javascripts/core.php'></script>
+ </head>";
+
+ // add elements
+ $htmlString .= $this->currentApplication->elementsToHtml();
+
+ // add JavaScript
+ $htmlString .= "<script type='text/javascript' src='../javascripts/map.php?" .
+ SID . "&guiID=" . $this->currentApplication->getId();
+ if ($this->get["mb_myBBOX"]) {
+ $htmlString .= "&mb_myBBOX=" . $this->get["mb_myBBOX"];
+ }
+ $htmlString .= "'></script>";
+ $htmlString .= "</html>";
+ return $htmlString;
+ }
+}
+?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list