[Mapbender-commits] r3120 - in branches/dev_lenkne/http:
javascripts php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Sun Oct 5 18:25:46 EDT 2008
Author: lenkne
Date: 2008-10-05 18:25:46 -0400 (Sun, 05 Oct 2008)
New Revision: 3120
Added:
branches/dev_lenkne/http/javascripts/mod_validate_admin.js
branches/dev_lenkne/http/javascripts/validate.js
Modified:
branches/dev_lenkne/http/javascripts/core.php
branches/dev_lenkne/http/php/mod_digitize_messages.php
branches/dev_lenkne/http/php/mod_setLocale.php
Log:
Modified: branches/dev_lenkne/http/javascripts/core.php
===================================================================
--- branches/dev_lenkne/http/javascripts/core.php 2008-10-03 15:02:26 UTC (rev 3119)
+++ branches/dev_lenkne/http/javascripts/core.php 2008-10-05 22:25:46 UTC (rev 3120)
@@ -1,24 +1,28 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/Map.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.
-
-ob_start();
-header('Content-type: application/x-javascript');
-require_once(dirname(__FILE__) . "/../../lib/event.js");
-require_once(dirname(__FILE__) . "/../../lib/core.js");
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/Map.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.
+
+ob_start();
+header('Content-type: application/x-javascript');
+require_once("http://code.jquery.com/jquery-latest.js");
+//require_once(dirname(__FILE__) . "/../extensions/jquery.metadata.js");
+require_once(dirname(__FILE__) . "/../extensions/jquery.validate.min.js");
+require_once(dirname(__FILE__) . "/../javascripts/event.js");
+require_once(dirname(__FILE__) . "/../javascripts/core.js");
+require_once(dirname(__FILE__) . "/../javascripts/validate.js");
?>
\ No newline at end of file
Added: branches/dev_lenkne/http/javascripts/mod_validate_admin.js
===================================================================
--- branches/dev_lenkne/http/javascripts/mod_validate_admin.js (rev 0)
+++ branches/dev_lenkne/http/javascripts/mod_validate_admin.js 2008-10-05 22:25:46 UTC (rev 3120)
@@ -0,0 +1,234 @@
+/*
+ * jQuery Form Validation plug-in version 1.1.5
+ * Last Update : July 13, 2008
+ * New features:
+ * onError event
+ * Add call back support - callback function is called when validation is error, return true form will be submited otherwise not.
+ * Error list in the alert msg
+ * Alias to field name
+ * Select diff html attributes for validation rules instead off using custom html attributes
+ *
+ * Bug Fixed:
+ * now support radio buttons
+ * defval to work with LabelIn plugin
+ * now support textarea
+ *
+ * Copyright (c) 2007 E-wave web design
+ * http://www.ewave.com.au/
+ *
+ * Licensed under the GPL license:
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * @requires jQuery v 1.2.1 or later
+ * @name formValidation
+ * @usage $('#form1').formValidation({
+ * newmask : /[0-9]{1}-[0-9]{1}/, // 1-1
+ * err_class : "invalidInput"
+ * });
+ *
+ * HTML
+ * <form id="form1">
+ * <input id="input1" type="text" required="true" mask="email"></input>
+ * <input id="input2" type="text" required="true" mask="email" equal="input2"></input>
+ * <input type="submit" value="Submit>
+ * </form>
+ *
+ * Description
+ * Validate form fields accordiing to 4 keys
+ * required - check that text field is not empty. checkbox checked, and select val is not empty
+ * equal - checks that field value equal to another field with this id
+ * mask - compre value to mask using reg exp
+ * defval - ignore default value
+ *
+ * Prevent Submit and Display alert when not validate and change class of field to invalid class
+ *
+ * @param String version
+ * Plugin Version
+ *
+ * @param String err_class
+ * invalid input class name
+ *
+ * @param String displayAlert
+ * display alert when submit form is invalid
+ * default true
+ *
+ * @param String err_message
+ * alert message
+ *
+ * @param reg-exp email
+ * email pattern
+ *
+ * @param reg-exp domain
+ * domain pattern
+ *
+ * @param reg-exp phone
+ * phone pattern
+ *
+ * @param reg-exp zip
+ * zip pattern
+ *
+ * @param reg-exp numeric
+ * numeric pattern
+ *
+ * @param reg-exp image
+ * image file name pattern
+ *
+ * @param reg-exp pdf
+ * pdf file name pattern
+ *
+ * @param alias, required, mask, equal, defval
+ * validation rules map to input attributes
+ *
+ */
+if (!window.jQuery) {
+ throw("jQuery must be referenced before using formValidation");
+} else {
+
+ (function() {
+ jQuery.fn.formValidation = function(settings, err_msgs) {
+
+ var iForm = this;
+ var err_list = '';
+
+ settings = jQuery.extend({
+ version : '1.1.2',
+ email : /^([\w.])+\@(([\w])+\.)[a-zA-Z0-9]{2,}/,
+ domain : /^(http:\/\/)([\w]+\.){1,}[A-Z]{2,4}\b/gi,
+ phone : /^\+[0-9]{1,3}\.[1-9]{1,2}\.[0-9]{6,}$/gi,
+ zip : /^[0-9]{4,}$/gi,
+ numeric : /^[0-9]+$/gi,
+ image : /[\w]+\.(gif|jpg|bmp|png|jpeg)$/gi,
+ ewvt : /[\w]+\.(htm|html|php|txt)$/gi,
+ media : /[\w]+\.(avi|mov|mpeg|wmv)$/gi,
+ pdf : /[\w]+\.(pdf)$/gi,
+ enable : false,
+ err_class : "invalidInput",
+ err_list : false,
+ alias : 'name',
+ required : 'required',
+ mask : 'mask',
+ equal : 'equal',
+ defval : 'defval',
+ callback : '',
+ err_message : "Please fill all required fields! (Marked with red background colour)\n",
+ display_alert : true //onsubmit if invalid form display an error message
+ }, settings);
+
+ err_msgs = jQuery.extend({
+ required : 'is required',
+ mask : 'Invalid',
+ equal : 'is not equal to'
+ }, err_msgs);
+
+ return iForm.submit( function () {
+ settings['enable'] = true;
+ err_list = '';
+ var frm = true;
+ $(this).find('*').filter("input, select, textarea").each(function() {
+ ret = isValid($(this));
+ if (!ret)
+ frm = ret;
+ });
+
+ if (frm && (typeof settings['callback'] == 'string' && eval('typeof ' + settings['callback']) == 'function')) // form validation ok and callback function defined
+ frm = eval(settings['callback'] + '()'); //call external validation function
+ else if (settings['display_alert']) // error validation and display alert on
+ alert(settings['err_message'] + err_list); // display message
+
+ return frm;
+ }).find('*').filter("input, select, textarea").each(function() {
+ $(this).click(function() {
+ isValid($(this));
+ }).change(function() {
+ isValid($(this));
+ }).keyup(function() {
+ isValid($(this));
+ }).focus(function() {
+ isValid($(this));
+ }).blur(function() {
+ isValid($(this));
+ });
+ });
+
+ function isValid(obj) { // check if field is valid
+ if (!settings['enable'])
+ return true;
+
+ if (required(obj) && mask(obj) && equal(obj)) {
+ obj.removeClass(settings['err_class']);
+ return true;
+ } else {
+ obj.addClass(settings['err_class']);
+ return false;
+ }
+ }
+ //field is required
+ function required(obj) {
+ if (!(obj.attr(settings['required']) == "true")) //if not required return true
+ return true;
+
+ if(obj.is("input[@type=checkbox]") || obj.is('input[@type=radio]')) { //if checkbox and checked
+ if (obj.attr('checked'))
+ return true;
+ } else if((obj.is("input") || obj.is("select") || obj.is("textarea")) && (!obj.is("button"))) // if not empty
+ if (obj.val() != '' && (!(defval(obj))))
+ return true;
+
+
+
+ if (settings['err_list'])
+ err_list += '- "' + obj.attr(settings['alias']) + '" ' + err_msgs['required'] + '\n';
+
+ return false;
+ }
+ //compare field to mask provided in the extend array
+ function mask(obj) {
+ tname = obj.attr('mask'); //read mask name from input field
+ if (tname == undefined || obj.val() == '')
+ return true;
+
+ tmask = settings[obj.attr(settings['mask'])]; // get mask pattern from settings
+
+ ret = tmask.test(obj.val()); //test reg exp
+ ret1 = tmask.exec(obj.val());
+ if (ret)
+ return true;
+
+ if (settings['err_list'])
+ err_list += '- ' + err_msgs['mask'] + ' "' + obj.attr(settings['alias']) + '"\n';
+
+ return false;
+ }
+ //copare field to another field read from the equal attribute
+ function equal(obj) {
+ tname = obj.attr(settings['equal']); //get comparison field
+ tval = $('#'+tname).val();
+
+ if (tname == undefined)
+ return true;
+
+ if (tval == obj.val())
+ return true;
+
+ if (settings['err_list'])
+ err_list += '- "' + obj.attr(settings['alias']) + '" ' + err_msgs['equal'] + ' ' + $('#'+tname).attr('alias') + '\n';
+ return false;
+ }
+ //compare field with defval attr, make sure that val was altered
+ function defval(obj) {
+ tdefval = obj.attr(settings['defval']); //get comparison field
+ tval = obj.val();
+
+ if (tdefval == undefined)
+ return false;
+
+ if (tval != tdefval)
+ return false;
+
+ return true;
+ }
+ }
+ })(jQuery);
+}
+
+
Added: branches/dev_lenkne/http/javascripts/validate.js
===================================================================
--- branches/dev_lenkne/http/javascripts/validate.js (rev 0)
+++ branches/dev_lenkne/http/javascripts/validate.js 2008-10-05 22:25:46 UTC (rev 3120)
@@ -0,0 +1,17 @@
+
+ // I set the debug option to true, so the data is not commited,
+// enabling me to review the outcome.
+//$.validator.setDefaults({
+// debug: true
+//});
+
+//$.validator.setDefaults({
+// submitHandler: function() { alert("submitted!"); }
+//});
+
+
+
+//$().ready(function() {
+// // validate the comment form when it is submitted
+ $("#userForm").validate();
+//});
Modified: branches/dev_lenkne/http/php/mod_digitize_messages.php
===================================================================
--- branches/dev_lenkne/http/php/mod_digitize_messages.php 2008-10-03 15:02:26 UTC (rev 3119)
+++ branches/dev_lenkne/http/php/mod_digitize_messages.php 2008-10-05 22:25:46 UTC (rev 3120)
@@ -19,6 +19,7 @@
require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
+require_once(dirname(__FILE__) . "/../../core/i18n.php");
$e = new mb_notice("locale: " . $_SESSION["mb_locale"] . "; lang: " . $_SESSION["mb_lang"]);
$e = new mb_notice(setlocale(LC_ALL, $_SESSION["mb_locale"]));
@@ -67,6 +68,8 @@
$msg_obj["measureTagLabelTotal"] = _mb("Total: ");
$msg_obj["digitizeDefaultGeometryName"] = _mb("new");
+$e = new mb_notice("DOG2: " . $msg_obj["buttonDig_wfs_title"]);
+
$json = new Mapbender_JSON();
$output = $json->encode($msg_obj);
Modified: branches/dev_lenkne/http/php/mod_setLocale.php
===================================================================
--- branches/dev_lenkne/http/php/mod_setLocale.php 2008-10-03 15:02:26 UTC (rev 3119)
+++ branches/dev_lenkne/http/php/mod_setLocale.php 2008-10-05 22:25:46 UTC (rev 3120)
@@ -1,29 +1,29 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/localeSwitch
-# 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__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__) . "/../classes/class_locale.php");
-
-$_SESSION["mb_lang"] = $_REQUEST["lang"];
-$localeObj = new Mb_locale($_SESSION["mb_lang"]);
-session_write_close();
-
-header("Content-type='text/plain';Charset=utf-8");
-echo $localeObj->name;
-?>
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/localeSwitch
+# 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__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__) . "/../classes/class_locale.php");
+
+$_SESSION["mb_lang"] = $_REQUEST["lang"];
+$localeObj = new Mb_locale($_SESSION["mb_lang"]);
+session_write_close();
+
+header("Content-type='text/plain';Charset='utf-8'");
+echo $localeObj->name;
+?>
More information about the Mapbender_commits
mailing list