[Mapbender-commits] r9156 - in trunk/mapbender/http: extensions/jquery-validate geoportal plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Feb 26 05:46:06 PST 2015
Author: syed
Date: 2015-02-26 05:46:06 -0800 (Thu, 26 Feb 2015)
New Revision: 9156
Modified:
trunk/mapbender/http/extensions/jquery-validate/jquery.validate.js
trunk/mapbender/http/geoportal/mod_showPreview.php
trunk/mapbender/http/plugins/kmlTree.js
trunk/mapbender/http/plugins/mb_metadata_layer.js
trunk/mapbender/http/plugins/mb_metadata_layer.php
trunk/mapbender/http/plugins/mb_metadata_layerPreview.js
trunk/mapbender/http/plugins/mb_metadata_wmc_edit.js
trunk/mapbender/http/plugins/mb_metadata_wmc_edit.php
Log:
add upload preview image(saarland)
Modified: trunk/mapbender/http/extensions/jquery-validate/jquery.validate.js
===================================================================
--- trunk/mapbender/http/extensions/jquery-validate/jquery.validate.js 2015-02-23 15:43:43 UTC (rev 9155)
+++ trunk/mapbender/http/extensions/jquery-validate/jquery.validate.js 2015-02-26 13:46:06 UTC (rev 9156)
@@ -30,30 +30,30 @@
if ( validator ) {
return validator;
}
-
+
validator = new $.validator( options, this[0] );
- $.data(this[0], 'validator', validator);
-
+ $.data(this[0], 'validator', validator);
+
if ( validator.settings.onsubmit ) {
-
+
// allow suppresing validation by adding a cancel class to the submit button
this.find("input, button").filter(".cancel").click(function() {
validator.cancelSubmit = true;
});
-
+
// when a submitHandler is used, capture the submitting button
if (validator.settings.submitHandler) {
this.find("input, button").filter(":submit").click(function() {
validator.submitButton = this;
});
}
-
+
// validate the form on submit
this.submit( function( event ) {
if ( validator.settings.debug )
// prevent form submit to be able to see console output
event.preventDefault();
-
+
function handle() {
if ( validator.settings.submitHandler ) {
if (validator.submitButton) {
@@ -69,7 +69,7 @@
}
return true;
}
-
+
// prevent submit for invalid forms or custom submit handlers
if ( validator.cancelSubmit ) {
validator.cancelSubmit = false;
@@ -87,7 +87,7 @@
}
});
}
-
+
return validator;
},
// http://docs.jquery.com/Plugins/Validation/valid
@@ -116,7 +116,7 @@
// http://docs.jquery.com/Plugins/Validation/rules
rules: function(command, argument) {
var element = this[0];
-
+
if (command) {
var settings = $.data(element.form, 'validator').settings;
var staticRules = settings.rules;
@@ -141,7 +141,7 @@
return filtered;
}
}
-
+
var data = $.validator.normalizeRules(
$.extend(
{},
@@ -150,14 +150,14 @@
$.validator.attributeRules(element),
$.validator.staticRules(element)
), element);
-
+
// make sure required is at front
if (data.required) {
var param = data.required;
delete data.required;
data = $.extend({required: param}, data);
}
-
+
return data;
}
});
@@ -180,7 +180,7 @@
};
$.validator.format = function(source, params) {
- if ( arguments.length == 1 )
+ if ( arguments.length == 1 )
return function() {
var args = $.makeArray(arguments);
args.unshift(source);
@@ -199,7 +199,7 @@
};
$.extend($.validator, {
-
+
defaults: {
messages: {},
groups: {},
@@ -215,7 +215,7 @@
ignoreTitle: false,
onfocusin: function(element) {
this.lastActive = element;
-
+
// hide error label and remove error class on focus if enabled
if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
@@ -272,11 +272,11 @@
max: $.validator.format("Please enter a value less than or equal to {0}."),
min: $.validator.format("Please enter a value greater than or equal to {0}.")
},
-
+
autoCreateRanges: false,
-
+
prototype: {
-
+
init: function() {
this.labelContainer = $(this.settings.errorLabelContainer);
this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
@@ -287,7 +287,7 @@
this.pending = {};
this.invalid = {};
this.reset();
-
+
var groups = (this.groups = {});
$.each(this.settings.groups, function(key, value) {
$.each(value.split(/\s/), function(index, name) {
@@ -298,11 +298,13 @@
$.each(rules, function(key, value) {
rules[key] = $.validator.normalizeRule(value);
});
-
+
function delegate(event) {
var validator = $.data(this[0].form, "validator"),
eventType = "on" + event.type.replace(/^validate/, "");
- validator.settings[eventType] && validator.settings[eventType].call(validator, this[0] );
+ // this fixes handling the deleted validator:
+ if (!validator) return;
+ validator.settings[eventType] && validator.settings[eventType].call(validator, this[0], event);
}
$(this.currentForm)
.validateDelegate(":text, :password, :file, select, textarea", "focusin focusout keyup", delegate)
@@ -322,15 +324,15 @@
this.showErrors();
return this.valid();
},
-
+
checkForm: function() {
this.prepareForm();
for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
this.check( elements[i] );
}
- return this.valid();
+ return this.valid();
},
-
+
// http://docs.jquery.com/Plugins/Validation/Validator/element
element: function( element ) {
element = this.clean( element );
@@ -372,7 +374,7 @@
? this.settings.showErrors.call( this, this.errorMap, this.errorList )
: this.defaultShowErrors();
},
-
+
// http://docs.jquery.com/Plugins/Validation/Validator/resetForm
resetForm: function() {
if ( $.fn.resetForm )
@@ -382,30 +384,30 @@
this.hideErrors();
this.elements().removeClass( this.settings.errorClass );
},
-
+
numberOfInvalids: function() {
return this.objectLength(this.invalid);
},
-
+
objectLength: function( obj ) {
var count = 0;
for ( var i in obj )
count++;
return count;
},
-
+
hideErrors: function() {
this.addWrapper( this.toHide ).hide();
},
-
+
valid: function() {
return this.size() == 0;
},
-
+
size: function() {
return this.errorList.length;
},
-
+
focusInvalid: function() {
if( this.settings.focusInvalid ) {
try {
@@ -419,18 +421,18 @@
}
}
},
-
+
findLastActive: function() {
var lastActive = this.lastActive;
return lastActive && $.grep(this.errorList, function(n) {
return n.element.name == lastActive.name;
}).length == 1 && lastActive;
},
-
+
elements: function() {
var validator = this,
rulesCache = {};
-
+
// select all valid inputs inside the form (no submit or reset buttons)
// workaround $Query([]).add until http://dev.jquery.com/ticket/2114 is solved
return $([]).add(this.currentForm.elements)
@@ -439,24 +441,24 @@
.not( this.settings.ignore )
.filter(function() {
!this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
-
+
// select only the first element for each name, and only those with rules specified
if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
return false;
-
+
rulesCache[this.name] = true;
return true;
});
},
-
+
clean: function( selector ) {
return $( selector )[0];
},
-
+
errors: function() {
return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
},
-
+
reset: function() {
this.successList = [];
this.errorList = [];
@@ -465,32 +467,32 @@
this.toHide = $([]);
this.currentElements = $([]);
},
-
+
prepareForm: function() {
this.reset();
this.toHide = this.errors().add( this.containers );
},
-
+
prepareElement: function( element ) {
this.reset();
this.toHide = this.errorsFor(element);
},
-
+
check: function( element ) {
element = this.clean( element );
-
+
// if radio/checkbox, validate first element in group instead
if (this.checkable(element)) {
element = this.findByName( element.name )[0];
}
-
+
var rules = $(element).rules();
var dependencyMismatch = false;
for( method in rules ) {
var rule = { method: method, parameters: rules[method] };
try {
var result = $.validator.methods[method].call( this, element.value.replace(/\r/g, ""), element, rule.parameters );
-
+
// if a method indicates that the field is optional and therefore valid,
// don't mark it as valid when there are no other rules
if ( result == "dependency-mismatch" ) {
@@ -498,12 +500,12 @@
continue;
}
dependencyMismatch = false;
-
+
if ( result == "pending" ) {
this.toHide = this.toHide.not( this.errorsFor(element) );
return;
}
-
+
if( !result ) {
this.formatAndAdd( element, rule );
return false;
@@ -520,20 +522,20 @@
this.successList.push(element);
return true;
},
-
+
// return the custom message for the given element and validation method
// specified in the element's "messages" metadata
customMetaMessage: function(element, method) {
if (!$.metadata)
return;
-
+
var meta = this.settings.meta
? $(element).metadata()[this.settings.meta]
: $(element).metadata();
-
+
return meta && meta.messages && meta.messages[method];
},
-
+
// return the custom message for the given element name and validation method
customMessage: function( name, method ) {
var m = this.settings.messages[name];
@@ -541,7 +543,7 @@
? m
: m[method]);
},
-
+
// return the first defined argument, allowing empty strings
findDefined: function() {
for(var i = 0; i < arguments.length; i++) {
@@ -550,7 +552,7 @@
}
return undefined;
},
-
+
defaultMessage: function( element, method) {
return this.findDefined(
this.customMessage( element.name, method ),
@@ -561,7 +563,7 @@
"<strong>Warning: No message defined for " + element.name + "</strong>"
);
},
-
+
formatAndAdd: function( element, rule ) {
var message = this.defaultMessage( element, rule.method ),
theregex = /\$?\{(\d+)\}/g;
@@ -569,22 +571,22 @@
message = message.call(this, rule.parameters, element);
} else if (theregex.test(message)) {
message = jQuery.format(message.replace(theregex, '{$1}'), rule.parameters);
- }
+ }
this.errorList.push({
message: message,
element: element
});
-
+
this.errorMap[element.name] = message;
this.submitted[element.name] = message;
},
-
+
addWrapper: function(toToggle) {
if ( this.settings.wrapper )
toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
return toToggle;
},
-
+
defaultShowErrors: function() {
for ( var i = 0; this.errorList[i]; i++ ) {
var error = this.errorList[i];
@@ -608,23 +610,23 @@
this.hideErrors();
this.addWrapper( this.toShow ).show();
},
-
+
validElements: function() {
return this.currentElements.not(this.invalidElements());
},
-
+
invalidElements: function() {
return $(this.errorList).map(function() {
return this.element;
});
},
-
+
showLabel: function(element, message) {
var label = this.errorsFor( element );
if ( label.length ) {
// refresh error/success class
label.removeClass().addClass( this.settings.errorClass );
-
+
// check if we have a generated label, replace the message then
label.attr("generated") && label.html(message);
} else {
@@ -651,14 +653,14 @@
}
this.toShow = this.toShow.add(label);
},
-
+
errorsFor: function(element) {
var name = this.idOrName(element);
return this.errors().filter(function() {
return $(this).attr('for') == name;
});
},
-
+
idOrName: function(element) {
return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
},
@@ -666,7 +668,7 @@
checkable: function( element ) {
return /radio|checkbox/i.test(element.type);
},
-
+
findByName: function( name ) {
// select by name and filter by form for performance over form.find("[name=...]")
var form = this.currentForm;
@@ -674,7 +676,7 @@
return element.form == form && element.name == name && element || null;
});
},
-
+
getLength: function(value, element) {
switch( element.nodeName.toLowerCase() ) {
case 'select':
@@ -685,13 +687,13 @@
}
return value.length;
},
-
+
depend: function(param, element) {
return this.dependTypes[typeof param]
? this.dependTypes[typeof param](param, element)
: true;
},
-
+
dependTypes: {
"boolean": function(param, element) {
return param;
@@ -703,18 +705,18 @@
return param(element);
}
},
-
+
optional: function(element) {
return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch";
},
-
+
startRequest: function(element) {
if (!this.pending[element.name]) {
this.pendingRequest++;
this.pending[element.name] = true;
}
},
-
+
stopRequest: function(element, valid) {
this.pendingRequest--;
// sometimes synchronization fails, make sure pendingRequest is never < 0
@@ -729,7 +731,7 @@
this.formSubmitted = false;
}
},
-
+
previousValue: function(element) {
return $.data(element, "previousValue") || $.data(element, "previousValue", {
old: null,
@@ -737,9 +739,9 @@
message: this.defaultMessage( element, "remote" )
});
}
-
+
},
-
+
classRuleSettings: {
required: {required: true},
email: {email: true},
@@ -752,13 +754,13 @@
digits: {digits: true},
creditcard: {creditcard: true}
},
-
+
addClassRules: function(className, rules) {
className.constructor == String ?
this.classRuleSettings[className] = rules :
$.extend(this.classRuleSettings, className);
},
-
+
classRules: function(element) {
var rules = {};
var classes = $(element).attr('class');
@@ -769,35 +771,35 @@
});
return rules;
},
-
+
attributeRules: function(element) {
var rules = {};
var $element = $(element);
-
+
for (method in $.validator.methods) {
var value = $element.attr(method);
if (value) {
rules[method] = value;
}
}
-
+
// maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
delete rules.maxlength;
}
-
+
return rules;
},
-
+
metadataRules: function(element) {
if (!$.metadata) return {};
-
+
var meta = $.data(element.form, 'validator').settings.meta;
return meta ?
$(element).metadata()[meta] :
$(element).metadata();
},
-
+
staticRules: function(element) {
var rules = {};
var validator = $.data(element.form, 'validator');
@@ -806,7 +808,7 @@
}
return rules;
},
-
+
normalizeRules: function(rules, element) {
// handle dependency check
$.each(rules, function(prop, val) {
@@ -832,12 +834,12 @@
}
}
});
-
+
// evaluate parameters
$.each(rules, function(rule, parameter) {
rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
});
-
+
// clean number parameters
$.each(['minlength', 'maxlength', 'min', 'max'], function() {
if (rules[this]) {
@@ -849,7 +851,7 @@
rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
}
});
-
+
if ($.validator.autoCreateRanges) {
// auto-create ranges
if (rules.min && rules.max) {
@@ -863,15 +865,15 @@
delete rules.maxlength;
}
}
-
+
// To support custom messages in metadata ignore rule methods titled "messages"
if (rules.messages) {
delete rules.messages;
}
-
+
return rules;
},
-
+
// Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
normalizeRule: function(data) {
if( typeof data == "string" ) {
@@ -883,7 +885,7 @@
}
return data;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Validator/addMethod
addMethod: function(name, method, message) {
$.validator.methods[name] = method;
@@ -912,20 +914,20 @@
return $.trim(value).length > 0;
}
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/remote
remote: function(value, element, param) {
if ( this.optional(element) )
return "dependency-mismatch";
-
+
var previous = this.previousValue(element);
if (!this.settings.messages[element.name] )
this.settings.messages[element.name] = {};
previous.originalMessage = this.settings.messages[element.name].remote;
this.settings.messages[element.name].remote = previous.message;
-
- param = typeof param == "string" && {url:param} || param;
-
+
+ param = typeof param == "string" && {url:param} || param;
+
if ( previous.old !== value ) {
previous.old = value;
var validator = this;
@@ -968,65 +970,65 @@
minlength: function(value, element, param) {
return this.optional(element) || this.getLength($.trim(value), element) >= param;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
maxlength: function(value, element, param) {
return this.optional(element) || this.getLength($.trim(value), element) <= param;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
rangelength: function(value, element, param) {
var length = this.getLength($.trim(value), element);
return this.optional(element) || ( length >= param[0] && length <= param[1] );
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/min
min: function( value, element, param ) {
return this.optional(element) || value >= param;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/max
max: function( value, element, param ) {
return this.optional(element) || value <= param;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/range
range: function( value, element, param ) {
return this.optional(element) || ( value >= param[0] && value <= param[1] );
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/email
email: function(value, element) {
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/url
url: function(value, element) {
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]
|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/date
date: function(value, element) {
return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/dateISO
dateISO: function(value, element) {
return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/number
number: function(value, element) {
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/digits
digits: function(value, element) {
return this.optional(element) || /^\d+$/.test(value);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/creditcard
// based on http://en.wikipedia.org/wiki/Luhn
creditcard: function(value, element) {
@@ -1054,13 +1056,13 @@
return (nCheck % 10) == 0;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/accept
accept: function(value, element, param) {
param = typeof param == "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
- return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
+ return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
equalTo: function(value, element, param) {
// bind to the blur event of the target in order to revalidate whenever the target field is updated
@@ -1070,9 +1072,9 @@
});
return value == target.val();
}
-
+
}
-
+
});
// deprecated, use $.validator.format instead
@@ -1082,7 +1084,7 @@
// ajax mode: abort
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
-// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
+// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
;(function($) {
var ajax = $.ajax;
var pendingRequests = {};
@@ -1104,14 +1106,14 @@
// IE has native support, in other browsers, use event caputuring (neither bubbles)
// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
-// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
+// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
;(function($) {
// only implement if not provided by jQuery core (since 1.4)
// TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {
$.each({
focus: 'focusin',
- blur: 'focusout'
+ blur: 'focusout'
}, function( original, fix ){
$.event.special[fix] = {
setup:function() {
Modified: trunk/mapbender/http/geoportal/mod_showPreview.php
===================================================================
--- trunk/mapbender/http/geoportal/mod_showPreview.php 2015-02-23 15:43:43 UTC (rev 9155)
+++ trunk/mapbender/http/geoportal/mod_showPreview.php 2015-02-26 13:46:06 UTC (rev 9156)
@@ -6,9 +6,9 @@
if (isset($_REQUEST["resource"]) & $_REQUEST["resource"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["resource"];
- if (!($testMatch == 'layer' or $testMatch == 'wmc' or $testMatch == 'layerlegend')){
- echo 'resource: <b>'.$testMatch.'</b> is not valid.<br/>';
- die();
+ if (!($testMatch == 'layer' or $testMatch == 'wmc' or $testMatch == 'layerlegend')){
+ echo 'resource: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
}
$resource = $testMatch;
$testMatch = NULL;
@@ -16,15 +16,14 @@
if (isset($_REQUEST["id"]) & $_REQUEST["id"] != "") {
//validate to integer
$testMatch = $_REQUEST["id"];
- $pattern = '/^[0-9]*$/';
- if (!preg_match($pattern,$testMatch)){
- echo 'id: <b>'.$testMatch.'</b> is not valid.<br/>';
- die();
+ $pattern = '/^[0-9]*$/';
+ if (!preg_match($pattern,$testMatch)){
+ echo 'id: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
}
$id = $testMatch;
$testMatch = NULL;
}
-
if ($resource == 'layer'){
if (file_exists(PREVIEW_DIR."/".$id."_layer_map_preview.jpg")) {
header("Expires: -1");
@@ -32,7 +31,15 @@
header("Pragma: no-cache");
header('Content-Type: image/jpeg');
readfile(PREVIEW_DIR."/".$id."_layer_map_preview.jpg");
- } else {
+
+ } else if (file_exists(PREVIEW_DIR."/".$id."_layer_map_preview.png")){
+ header("Expires: -1");
+ header("Cache-Control: no-cache; must-revalidate");
+ header("Pragma: no-cache");
+ header('Content-Type: image/jpeg');
+ readfile(PREVIEW_DIR."/".$id."_layer_map_preview.png");
+
+ }else {
if (file_exists(PREVIEW_DIR."/"."keinevorschau.jpg")) {
header("Expires: -1");
header("Cache-Control: no-cache; must-revalidate");
@@ -51,7 +58,15 @@
header("Pragma: no-cache");
header('Content-Type: image/jpeg');
readfile(PREVIEW_DIR."/".$id."_wmc_preview.jpg");
- } else {
+ } else if (file_exists(PREVIEW_DIR."/".$id."_wmc_preview.png")){
+
+ header("Expires: -1");
+ header("Cache-Control: no-cache; must-revalidate");
+ header("Pragma: no-cache");
+ header('Content-Type: image/jpeg');
+ readfile(PREVIEW_DIR."/".$id."_wmc_preview.png");
+
+ }else {
if (file_exists(PREVIEW_DIR."/"."keinevorschau.jpg")) {
header("Expires: -1");
header("Cache-Control: no-cache; must-revalidate");
@@ -71,6 +86,12 @@
header("Pragma: no-cache");
header('Content-Type: image/jpeg');
readfile(PREVIEW_DIR."/".$id."_layer_legend_preview.jpg");
+ }else if (file_exists(PREVIEW_DIR."/".$id."_layer_legend_preview.png")) {
+ header("Expires: -1");
+ header("Cache-Control: no-cache; must-revalidate");
+ header("Pragma: no-cache");
+ header('Content-Type: image/jpeg');
+ readfile(PREVIEW_DIR."/".$id."_layer_legend_preview.png");
} else {
if (file_exists(PREVIEW_DIR."/"."keinevorschau.jpg")) {
header("Expires: -1");
Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js 2015-02-23 15:43:43 UTC (rev 9155)
+++ trunk/mapbender/http/plugins/kmlTree.js 2015-02-26 13:46:06 UTC (rev 9156)
@@ -223,7 +223,7 @@
});
// var exportDataLinkContent = '<div><input size="35" type="text" value="http://192.168.0.117/mapbender/php/mod_GetPublishedData.php?wmc_id='+wmc_id+'&outputFormat='+format+'/></div>';
- var exportDataLinkContent = '<div><label for="exportLinkInput">Link: </label><input id="exportLinkInput" size="35" type="text" value="http://192.168.0.117/mapbender/php/mod_GetPublishedData.php?wmc_id='+wmc_id+'&outputFormat='+format+'"></div>';
+ var exportDataLinkContent = '<div><label for="exportLinkInput">Link: </label><input id="exportLinkInput" size="35" type="text" value="http://'+window.location.hostname+'/mapbender/php/mod_GetPublishedData.php?wmc_id='+wmc_id+'&outputFormat='+format+'"></div>';
// var exportDataLinkContent = '<div>test</div>';
$(exportDataLinkDlg).append(exportDataLinkContent);
});
Modified: trunk/mapbender/http/plugins/mb_metadata_layer.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_layer.js 2015-02-23 15:43:43 UTC (rev 9155)
+++ trunk/mapbender/http/plugins/mb_metadata_layer.js 2015-02-26 13:46:06 UTC (rev 9156)
@@ -6,7 +6,7 @@
* Files:
*
* SQL:
- *
+ *
* Help:
*
* Maintainer:
@@ -22,207 +22,217 @@
var $metadataLayer = $(this);
var $metadataForm = $("<form>No layer selected.</form>").appendTo($metadataLayer);
-var MetadataLayerApi = function (o) {
- var that = this;
- var validator;
- var formReady = false;
- var wmsId;
- var layerId;
-
- var disabledFields = [
- "layer_custom_category_id",
- "layer_inspire_category_id",
- "layer_md_topic_category_id",
- "layer_keyword",
- "layer_abstract",
- "layer_title"
- ];
+var MetadataLayerApi = function(o) {
+ var that = this;
+ var validator;
+ var formReady = false;
+ var wmsId;
+ var layerId;
- this.events = {
- initialized: new Mapbender.Event(),
- submit: new Mapbender.Event(),
- showOriginalLayerMetadata : new Mapbender.Event()
- };
-
- this.valid = function () {
- if (validator && validator.numberOfInvalids() > 0) {
- $metadataForm.valid();
- return false;
- }
- return true;
- };
+ var disabledFields = [
+ "layer_custom_category_id",
+ "layer_inspire_category_id",
+ "layer_md_topic_category_id",
+ "layer_keyword",
+ "layer_abstract",
+ "layer_title"
+ ];
- this.serialize = function (callback) {
- $metadataForm.submit();
- var data = null;
- if (this.valid()) {
- data = {
- layer: $metadataForm.easyform("serialize")
- };
- }
- if ($.isFunction(callback)) {
- callback(data);
- }
- return data !== null ? data.layer : data;
- };
+ this.events = {
+ initialized: new Mapbender.Event(),
+ submit: new Mapbender.Event(),
+ showOriginalLayerMetadata: new Mapbender.Event()
+ };
- this.fillForm = function (obj) {
- $(disabledFields).each(function () {
- $("#" + this).removeAttr("disabled");
- });
+ this.valid = function() {
+ if (validator && validator.numberOfInvalids() > 0) {
+ $metadataForm.valid();
+ return false;
+ }
+ return true;
+ };
- layerId = obj.layer_id;
+ this.serialize = function(callback) {
+ $metadataForm.submit();
+ var data = null;
+ if (this.valid()) {
+ data = {
+ layer: $metadataForm.easyform("serialize")
+ };
+ }
+ if ($.isFunction(callback)) {
+ callback(data);
+ }
+ return data !== null ? data.layer : data;
+ };
- $metadataForm.easyform("reset");
-
- // get metadata from server
- var req = new Mapbender.Ajax.Request({
- url: "../plugins/mb_metadata_server.php",
- method: "getLayerMetadata",
- parameters: {
- "id": layerId
- },
- callback: function (obj, result, message) {
- if (!result) {
- return;
- }
- $metadataForm.easyform("fill", obj);
- //delete entries of #layer_id_p if given
- $('#layer_id_p').children().remove();
- $('#layer_id_p').append('<a target=\"_blank\"href=\"../php/mod_showMetadata.php?resource=layer&layout=tabs&id='+layerId+'\">Metadata Preview Layer '+layerId+'</a>');
- //delete metadataURL entries
- $('.metadataEntry').remove();
- //fill MetadataURLs into metadata_selectbox_id
- that.fillMetadataURLs(obj);
- that.valid();
- that.enableResetButton();
- }
- });
- req.send();
- };
- //function generate updated metadataUrl entries TODO: this function is defined in mb_metadata_layer.js before but it cannot be called - maybe s.th. have to be changed
- this.fillMetadataURLs = function (obj) {
- layerId = obj.layer_id;
- //for size of md_metadata records:
- for (i=0;i<obj.md_metadata.metadata_id.length;i++) {
- if (obj.md_metadata.origin[i] == "capabilities") {
- if (obj.md_metadata.internal[i] == 1) {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/server_map-ilink.png' title='link to metadata from capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
- } else {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td></tr>").appendTo($("#metadataTable"));
- }
- }
- if (obj.md_metadata.origin[i] == "external") {
- if (obj.md_metadata.internal[i] == 1) {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/link-ilink.png' title='link to external linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
- } else {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
- }
- }
- if (obj.md_metadata.origin[i] == "upload") {
- if (obj.md_metadata.internal[i] == 1) {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/up-ilink.png' title='link to external uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
- } else {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/button_blue_red/up.png' title='uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
- }
- }
- if (obj.md_metadata.origin[i] == "metador") {
- if (obj.md_metadata.internal[i] == 1) {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/edit-select-all-ilink.png' title='link to external edited metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
- } else {
- $("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ this.fillForm = function(obj) {
+ $(disabledFields).each(function() {
+ $("#" + this).removeAttr("disabled");
+ });
- }
- }
- }
- $("<img class='metadataEntry' title='new' src='../img/add.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",true);return false;'/>").appendTo($("#metadataTable"));
- }
+ layerId = obj.layer_id;
- this.enableResetButton = function () {
- $("#resetIsoTopicCats").click(function () {
- $("#layer_md_topic_category_id option").removeAttr("selected");
- });
- $("#resetCustomCats").click(function () {
- $("#layer_custom_category_id option").removeAttr("selected");
- });
- $("#resetInspireCats").click(function () {
- $("#layer_inspire_category_id option").removeAttr("selected");
- });
- }
-
- this.fill = function (obj) {
- $metadataForm.easyform("fill", obj);
- };
-
- var showOriginalLayerMetadata = function () {
- that.events.showOriginalLayerMetadata.trigger({
- data : {
- wmsId : wmsId,
- layerData : $metadataForm.easyform("serialize")
- }
- });
- };
+ $metadataForm.easyform("reset");
- this.getWmsId = function() {
- return wmsId;
- }
+ // get metadata from server
+ var req = new Mapbender.Ajax.Request({
+ url: "../plugins/mb_metadata_server.php",
+ method: "getLayerMetadata",
+ parameters: {
+ "id": layerId
+ },
+ callback: function(obj, result, message) {
+ if (!result) {
+ return;
+ }
+ $metadataForm.easyform("fill", obj);
+ //delete entries of #layer_id_p if given
+ $('#layer_id_p').children().remove();
+ $('#layer_id_p').append('<a target=\"_blank\"href=\"../php/mod_showMetadata.php?resource=layer&layout=tabs&id=' + layerId + '\">Metadata Preview Layer ' + layerId + '</a>');
+ //delete metadataURL entries
+ $('.metadataEntry').remove();
+ //fill MetadataURLs into metadata_selectbox_id
+ that.fillMetadataURLs(obj);
+ that.valid();
+ that.enableResetButton();
+ }
+ });
+ req.send();
+ };
+ //function generate updated metadataUrl entries TODO: this function is defined in mb_metadata_layer.js before but it cannot be called - maybe s.th. have to be changed
+ this.fillMetadataURLs = function(obj) {
+ layerId = obj.layer_id;
+ //for size of md_metadata records:
+ for (i = 0; i < obj.md_metadata.metadata_id.length; i++) {
+ if (obj.md_metadata.origin[i] == "capabilities") {
+ if (obj.md_metadata.internal[i] == 1) {
+ $("<tr class='metadataEntry'><td>" + obj.md_metadata.metadata_id[i] + "</td><td><img src='../img/server_map-ilink.png' title='link to metadata from capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "' target='_blank'>" + obj.md_metadata.uuid[i] + "</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "&validate=true' target='_blank'>validate</a></td><td></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage(" + obj.md_metadata.metadata_id[i] + "," + layerId + ");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ } else {
+ $("<tr class='metadataEntry'><td>" + obj.md_metadata.metadata_id[i] + "</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "' target='_blank'>" + obj.md_metadata.uuid[i] + "</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "&validate=true' target='_blank'>validate</a></td><td></td></tr>").appendTo($("#metadataTable"));
+ }
+ }
+ if (obj.md_metadata.origin[i] == "external") {
+ if (obj.md_metadata.internal[i] == 1) {
+ $("<tr class='metadataEntry'><td>" + obj.md_metadata.metadata_id[i] + "</td><td><img src='../img/link-ilink.png' title='link to external linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "' target='_blank'>" + obj.md_metadata.uuid[i] + "</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon(" + obj.md_metadata.metadata_id[i] + "," + layerId + ",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage(" + obj.md_metadata.metadata_id[i] + "," + layerId + ");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ } else {
+ $("<tr class='metadataEntry'><td>" + obj.md_metadata.metadata_id[i] + "</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "' target='_blank'>" + obj.md_metadata.uuid[i] + "</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon(" + obj.md_metadata.metadata_id[i] + "," + layerId + ",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata(" + obj.md_metadata.metadata_id[i] + "," + layerId + ");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ }
+ }
+ if (obj.md_metadata.origin[i] == "upload") {
+ if (obj.md_metadata.internal[i] == 1) {
+ $("<tr class='metadataEntry'><td>" + obj.md_metadata.metadata_id[i] + "</td><td><img src='../img/up-ilink.png' title='link to external uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "' target='_blank'>" + obj.md_metadata.uuid[i] + "</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage(" + obj.md_metadata.metadata_id[i] + "," + layerId + ");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ } else {
+ $("<tr class='metadataEntry'><td>" + obj.md_metadata.metadata_id[i] + "</td><td><img src='../img/button_blue_red/up.png' title='uploaded data'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "' target='_blank'>" + obj.md_metadata.uuid[i] + "</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "&validate=true' target='_blank'>validate</a></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata(" + obj.md_metadata.metadata_id[i] + "," + layerId + ");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ }
+ }
+ if (obj.md_metadata.origin[i] == "metador") {
+ if (obj.md_metadata.internal[i] == 1) {
+ $("<tr class='metadataEntry'><td>" + obj.md_metadata.metadata_id[i] + "</td><td><img src='../img/edit-select-all-ilink.png' title='link to external edited metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "' target='_blank'>" + obj.md_metadata.uuid[i] + "</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon(" + obj.md_metadata.metadata_id[i] + "," + layerId + ",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteInternalMetadataLinkage(" + obj.md_metadata.metadata_id[i] + "," + layerId + ");return false;'/></td></tr>").appendTo($("#metadataTable"));
+ } else {
+ $("<tr class='metadataEntry'><td>" + obj.md_metadata.metadata_id[i] + "</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "' target='_blank'>" + obj.md_metadata.uuid[i] + "</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id=" + obj.md_metadata.uuid[i] + "&validate=true' target='_blank'>validate</a></td><td><img class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon(" + obj.md_metadata.metadata_id[i] + "," + layerId + ",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata(" + obj.md_metadata.metadata_id[i] + "," + layerId + ");return false;'/></td></tr>").appendTo($("#metadataTable"));
- this.getLayerId = function() {
- return layerId;
- }
+ }
+ }
+ }
+ $("<img class='metadataEntry' title='new' src='../img/add.png' onclick='initMetadataAddon(" + obj.md_metadata.metadata_id[i] + "," + layerId + ",true);return false;'/>").appendTo($("#metadataTable"));
+ }
- this.init = function (obj) {
- delete layerId;
- //delete metadataURL entries
- $('.metadataEntry').remove();
- $metadataForm.easyform("reset");
+ this.enableResetButton = function() {
+ $("#resetIsoTopicCats").click(function() {
+ $("#layer_md_topic_category_id option").removeAttr("selected");
+ });
+ $("#resetCustomCats").click(function() {
+ $("#layer_custom_category_id option").removeAttr("selected");
+ });
+ $("#resetInspireCats").click(function() {
+ $("#layer_inspire_category_id option").removeAttr("selected");
+ });
+ }
- wmsId = obj;
-
- if (!wmsId) {
- return;
- }
-
- var formData = arguments.length >= 2 ? arguments[1] : undefined;
+ this.fill = function(obj) {
+ $metadataForm.easyform("fill", obj);
+ };
- if (!formReady) {
- $metadataForm.load("../plugins/mb_metadata_layer.php", function () {
- $metadataForm.find(".help-dialog").helpDialog();
+ var showOriginalLayerMetadata = function() {
+ that.events.showOriginalLayerMetadata.trigger({
+ data: {
+ wmsId: wmsId,
+ layerData: $metadataForm.easyform("serialize")
+ }
+ });
+ };
- $metadataForm.find(".original-metadata-layer").bind("click", function() {
- showOriginalLayerMetadata();
- });
+ this.getWmsId = function() {
+ return wmsId;
+ }
- validator = $metadataForm.validate({
- submitHandler: function () {
- return false;
- }
- });
+ this.getLayerId = function() {
+ return layerId;
+ }
- that.events.initialized.trigger({
- wmsId: wmsId
- });
- formReady = true;
- });
- return;
- }
- $(disabledFields).each(function () {
- $("#" + this).attr("disabled", "disabled");
- });
- that.events.initialized.trigger({
- wmsId: wmsId
- });
- };
-
- Mapbender.events.localize.register(function () {
- that.valid();
- var formData = $metadataForm.easyform("serialize");
- formReady = false;
- that.init(wmsId, formData);
- });
- Mapbender.events.init.register(function () {
- that.valid();
- });
+ this.init = function(obj) {
+ delete layerId;
+ //delete metadataURL entries
+ $('.metadataEntry').remove();
+ $metadataForm.easyform("reset");
+
+ wmsId = obj;
+
+ if (!wmsId) {
+ return;
+ }
+
+ var formData = arguments.length >= 2 ? arguments[1] : undefined;
+
+ if (!formReady) {
+ $metadataForm.load("../plugins/mb_metadata_layer.php", function() {
+
+ // add tabs to preview fieldset
+ $('#previewTabs').tabs();
+ // add an event-handler to the form -> interaction with the form can be handled somewhere else --> mb_metadata_layerPreview.js
+ $('#mb_md_layer_preview').trigger('uploadFormReady', $('#previewImgForm'));
+ $('#mb_md_layer_preview').trigger('fileChange', $('#previewImgForm input[type=file]'));
+
+
+ $metadataForm.find(".help-dialog").helpDialog();
+
+ $metadataForm.find(".original-metadata-layer").bind("click", function() {
+ showOriginalLayerMetadata();
+ });
+
+ validator = $metadataForm.validate({
+ submitHandler: function() {
+ return false;
+ }
+ });
+
+ that.events.initialized.trigger({
+ wmsId: wmsId
+ });
+ formReady = true;
+ });
+ return;
+ }
+ $(disabledFields).each(function() {
+ $("#" + this).attr("disabled", "disabled");
+ });
+ that.events.initialized.trigger({
+ wmsId: wmsId
+ });
+ };
+
+ Mapbender.events.localize.register(function() {
+ that.valid();
+ var formData = $metadataForm.easyform("serialize");
+ formReady = false;
+ that.init(wmsId, formData);
+ });
+ Mapbender.events.init.register(function() {
+ that.valid();
+ });
};
$metadataLayer.mapbender(new MetadataLayerApi(options));
+
+
Modified: trunk/mapbender/http/plugins/mb_metadata_layer.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_layer.php 2015-02-23 15:43:43 UTC (rev 9155)
+++ trunk/mapbender/http/plugins/mb_metadata_layer.php 2015-02-26 13:46:06 UTC (rev 9156)
@@ -1,16 +1,16 @@
<?php
require_once dirname(__FILE__) . "/../../core/globalSettings.php";
-
+
function displayCategories ($sql) {
if (Mapbender::session()->get("mb_lang") === "de") {
$sql = str_replace("category_code_en", "category_code_de", $sql);
}
-
+
$str = "";
$res = db_query($sql);
while ($row = db_fetch_assoc($res)) {
- $str .= "<option value='" . $row["id"] . "'>" .
- htmlentities($row["name"], ENT_QUOTES, CHARSET) .
+ $str .= "<option value='" . $row["id"] . "'>" .
+ htmlentities($row["name"], ENT_QUOTES, CHARSET) .
"</option>";
}
return $str;
@@ -75,16 +75,37 @@
</table>
</p>
</fieldset>
- </div>
+ </div>
</p>
</fieldset>
</div>
<div id="preview">
<fieldset class="">
<legend><?php echo _mb("Preview");?></legend>
- <div id="map"></div>
- <div id="toolbar_upper"></div>
- <div id="toolbar_lower"></div>
+ <div id="previewTabs">
+ <ul>
+ <li><a href="#previewTabs-1">Bild erstellen</a></li>
+ <li><a href="#previewTabs-2">Bild hochladen</a></li>
+ </ul>
+ <div id="previewTabs-1">
+ <div id="map"></div>
+ <div id="toolbar_upper"></div>
+ <div id="toolbar_lower"></div>
+ </div>
+ <div id="previewTabs-2">
+ <div id="previewImgUpload">
+ <form id="previewImgForm" action='../php/mb_metadata_uploadLayerPreview.php' enctype="multipart/form-data">
+ <input type="file" name="image">
+ <input type="submit" value="Upload">
+ <input type="hidden" name="source_id" value="source_id" >
+ <div id="upload"></div>
+ </form>
+ </div>
+ <div id="textarea">
+ </div>
+ </div>
+
+ </div>
</fieldset>
</div>
<div id="classification">
Modified: trunk/mapbender/http/plugins/mb_metadata_layerPreview.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_layerPreview.js 2015-02-23 15:43:43 UTC (rev 9155)
+++ trunk/mapbender/http/plugins/mb_metadata_layerPreview.js 2015-02-26 13:46:06 UTC (rev 9156)
@@ -1,133 +1,259 @@
-
var $metadataLayerPreview = $(this);
$metadataLayerPreview.css('border', 'white');
-var MetadataLayerPreviewApi = function (o){
+var MetadataLayerPreviewApi = function(o) {
- var that = this;
- options = o || {};
- options.map = options.map || "";
- options.buttons = options.buttons || [];
+ var that = this;
+ options = o || {};
+ options.map = options.map || "";
+ options.buttons = options.buttons || [];
- this.wmsId = null;
+ this.wmsId = null;
- var changeEpsgAndZoomToExtent = function (layer, map) {
- layer.gui_layer_visible = 1;
- var len = layer.layer_epsg.length;
- if (len === 0) {
- // could not zoom to extent
- return;
- }
- for (var j = 0; j < len; j++) {
- var currentEpsg = layer.layer_epsg[j];
- if (currentEpsg.epsg === map.epsg) {
- var newExtent = new Mapbender.Extent(
- currentEpsg.minx,
- currentEpsg.miny,
- currentEpsg.maxx,
- currentEpsg.maxy
- );
- map.calculateExtent(newExtent);
- return;
- }
- }
- // current SRS is not supported, switch to a supported SRS
- var newEpsg = layer.layer_epsg[0];
- var newExtent = new Mapbender.Extent(
- newEpsg.minx,
- newEpsg.miny,
- newEpsg.maxx,
- newEpsg.maxy
- );
- map.setSrs({
- srs: newEpsg.epsg,
- extent: newExtent
- });
- };
+ var changeEpsgAndZoomToExtent = function(layer, map) {
+ layer.gui_layer_visible = 1;
+ var len = layer.layer_epsg.length;
+ if (len === 0) {
+ // could not zoom to extent
+ return;
+ }
+ for (var j = 0; j < len; j++) {
+ var currentEpsg = layer.layer_epsg[j];
+ if (currentEpsg.epsg === map.epsg) {
+ var newExtent = new Mapbender.Extent(
+ currentEpsg.minx,
+ currentEpsg.miny,
+ currentEpsg.maxx,
+ currentEpsg.maxy
+ );
+ map.calculateExtent(newExtent);
+ return;
+ }
+ }
+ // current SRS is not supported, switch to a supported SRS
+ var newEpsg = layer.layer_epsg[0];
+ var newExtent = new Mapbender.Extent(
+ newEpsg.minx,
+ newEpsg.miny,
+ newEpsg.maxx,
+ newEpsg.maxy
+ );
+ map.setSrs({
+ srs: newEpsg.epsg,
+ extent: newExtent
+ });
+ };
- // enable layer,. disabling all others
- this.layer = function(layer){
- var layername = layer.layer_name;
-
- if(layername === undefined){
- return 'currentlayername';
- }
- var map = $('#'+options.map).mapbender();
- var wms = map.wms[map.wms.length -1];
- for (var i in wms.objLayer){
- if(wms.objLayer[i].layer_name == layername){
- changeEpsgAndZoomToExtent(wms.objLayer[i], map);
- }
- else{
- wms.objLayer[i].gui_layer_visible = 0;
- }
- }
- map.restateLayers(wms.wms_id);
+ // enable layer,. disabling all others
+ this.layer = function(layer) {
+ var layername = layer.layer_name;
+
+ if (layername === undefined) {
+ return 'currentlayername';
+ }
+ var map = $('#' + options.map).mapbender();
+ var wms = map.wms[map.wms.length - 1];
+ for (var i in wms.objLayer) {
+ if (wms.objLayer[i].layer_name == layername) {
+ changeEpsgAndZoomToExtent(wms.objLayer[i], map);
+ } else {
+ wms.objLayer[i].gui_layer_visible = 0;
+ }
+ }
+ map.restateLayers(wms.wms_id);
map.setMapRequest();
- };
+ };
- // set wms, throwing out all others
- this.wms = function(wmsid){
- if(wmsid === undefined){
- return 'currentwmsid';
- }
-
- $('#' + options.map).each(function () {
- var map = $(this).mapbender();
- if (!map) {
- return;
- }
- var wms = map.wms;
- for(var i = wms.length -1 ; i > 0; i--){
- delete wms[i];
- wms.length--;
- }
- mod_addWMSById_ajax('', wmsid, {
- zoomToExtent: 1
- });
- });
- };
+ // set wms, throwing out all others
+ this.wms = function(wmsid) {
+ if (wmsid === undefined) {
+ return 'currentwmsid';
+ }
- this.init = function(obj){
-
- if (this.init.done !== true) {
- var $map = $('#' + options.map);
- $map.css('position','relative');
- $map.css('display','');
- $map.css('top','');
- $map.css('left','');
- $('img',$map).css({
- 'height': $map.css('height'),
- 'width': $map.css('width')
- });
-
- var $target = $('#map');
- $target.append($map);
-
- $(options.toolbarUpper).each(function () {
- $("#" + this).css({
- "position": "relative",
- "display":"",
- "top":"",
- "left":""
- }).appendTo($("#toolbar_upper"));
- });
- $(options.toolbarLower).each(function () {
- $("#" + this).css({
- "position": "relative",
- "display":"",
- "top":"",
- "left":""
- }).appendTo($("#toolbar_lower"));
- });
- this.init.done = true;
- }
-
- if(typeof parseInt(obj, 10) == 'number') {
- that.wms(obj);
- }
-
- };
+ $('#' + options.map).each(function() {
+ var map = $(this).mapbender();
+ if (!map) {
+ return;
+ }
+ var wms = map.wms;
+ for (var i = wms.length - 1; i > 0; i--) {
+ delete wms[i];
+ wms.length--;
+ }
+ mod_addWMSById_ajax('', wmsid, {
+ zoomToExtent: 1
+ });
+ });
+ };
+
+ this.init = function(obj) {
+
+ if (this.init.done !== true) {
+ var $map = $('#' + options.map);
+ $map.css('position', 'relative');
+ $map.css('display', '');
+ $map.css('top', '');
+ $map.css('left', '');
+ $('img', $map).css({
+ 'height': $map.css('height'),
+ 'width': $map.css('width')
+ });
+
+ var $target = $('#map');
+ $target.append($map);
+
+ $(options.toolbarUpper).each(function() {
+ $("#" + this).css({
+ "position": "relative",
+ "display": "",
+ "top": "",
+ "left": ""
+ }).appendTo($("#toolbar_upper"));
+ });
+ $(options.toolbarLower).each(function() {
+ $("#" + this).css({
+ "position": "relative",
+ "display": "",
+ "top": "",
+ "left": ""
+ }).appendTo($("#toolbar_lower"));
+ });
+ this.init.done = true;
+ }
+
+ if (typeof parseInt(obj, 10) == 'number') {
+ that.wms(obj);
+ }
+
+ };
};
$metadataLayerPreview.mapbender(new MetadataLayerPreviewApi(options));
+
+//console.log($metadataLayerPreview);
+
+
+// upload an image to the preview fieldset
+// submit the preview form
+//$('#mb_md_layer').find('#previewImgForm').bind('submit', function(event) {
+// event.preventDefault();
+//console.log('test');
+//});
+
+
+$metadataLayerPreview.bind('uploadFormReady', function(e, form) {
+ $(form).bind('submit', function() {
+ event.preventDefault();
+ if ($('input[id="layer_id"]').val() == undefined) { // in wmc_metadata
+
+ if ($('input[id="wmc_id"]').val() !== "") {
+
+ if ($('#previewImgForm input[type=file]').val() !== "") {
+
+ fileUpload(form, '../php/mb_metadata_uploadLayerPreview.php', 'upload', 'wmc');
+
+ }
+
+ } else {
+
+ alert('Pleaese choose a wmc before uploading an image');
+ }
+ } else {
+
+ if ($('input[id="layer_id"]').val() !== "") {
+
+ if ($('#previewImgForm input[type=file]').val() !== "") {
+
+ fileUpload(form, '../php/mb_metadata_uploadLayerPreview.php', 'upload', 'wms');
+
+ }
+
+ } else {
+
+ alert('Pleaese choose a layer before uploading an image');
+ }
+ }
+
+ });
+});
+
+$metadataLayerPreview.bind('fileChange', function(e, fileInput) {
+ $(fileInput).bind('change', function() {
+ var fr = new FileReader();
+ fr.onload = function() { // file is loaded
+
+ if (!fileInput.files[0].name.match(/\.(jpg|jpeg|png|gif)$/)) {
+ $(fileInput).val("");
+ alert('File is not an image. Please choose an image!');
+ return;
+ }
+ var img = new Image();
+ img.onload = function() {
+ // check the file format
+ // if ((img.width > 200 && img.height > 200) || (img.width < 200 && img.height < 200)) {
+ if ((img.width != 200 || img.height != 200)) {
+
+ alert('Choosed image size doesn\'t fit. The image will be scaled to 200px * 200px.');
+ // fileInput.files[0] = img;
+ } else if ($('#previewImgForm input[type=file]')[0].files[0].name.split('.').pop() == 'bmp') {
+
+ alert('Bitmaps are not supported. Please choose a valid filetype (jpg,png,gif)');
+ }
+
+ };
+
+ img.src = fr.result; // is the data URL because called with readAsDataURL
+ };
+
+ fr.readAsDataURL(this.files[0]);
+
+
+
+ });
+});
+
+
+
+function fileUpload(form, action_url, div_id, type) {
+
+ var iframe = document.createElement("iframe");
+ iframe.setAttribute("id", "upload_iframe");
+ iframe.setAttribute("name", "upload_iframe");
+ iframe.setAttribute("width", "0");
+ iframe.setAttribute("height", "0");
+ iframe.setAttribute("border", "0");
+ iframe.setAttribute("style", "width: 0; height: 0; border: none;");
+ form.parentNode.appendChild(iframe);
+ window.frames['upload_iframe'].name = "upload_iframe";
+ iframeId = document.getElementById("upload_iframe");
+ var eventHandler = function() {
+ if (iframeId.detachEvent) iframeId.detachEvent("onload", eventHandler);
+ else iframeId.removeEventListener("load", eventHandler, false);
+ if (iframeId.contentDocument) {
+ content = iframeId.contentDocument.body.innerHTML;
+ } else if (iframeId.contentWindow) {
+ content = iframeId.contentWindow.document.body.innerHTML;
+ } else if (iframeId.document) {
+ content = iframeId.document.body.innerHTML;
+ }
+ document.getElementById(div_id).innerHTML = content;
+ setTimeout('iframeId.parentNode.removeChild(iframeId)', 250);
+ }
+ if (iframeId.addEventListener) iframeId.addEventListener("load", eventHandler, true);
+ if (iframeId.attachEvent) iframeId.attachEvent("onload", eventHandler);
+ form.setAttribute("target", "upload_iframe");
+ form.setAttribute("action", action_url);
+ form.setAttribute("method", "post");
+ form.setAttribute("enctype", "multipart/form-data");
+ form.setAttribute("encoding", "multipart/form-data");
+ //set the layer_id
+ if (type === 'wms') {
+
+ $('#previewImgForm input[type=hidden]').val($('input[id="layer_id"]').val());
+ } else {
+ $('#previewImgForm input[type=hidden]').val($('input[id="wmc_id"]').val());
+ }
+ form.submit();
+
+ document.getElementById(div_id).innerHTML = "Uploading...";
+}
Modified: trunk/mapbender/http/plugins/mb_metadata_wmc_edit.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wmc_edit.js 2015-02-23 15:43:43 UTC (rev 9155)
+++ trunk/mapbender/http/plugins/mb_metadata_wmc_edit.js 2015-02-26 13:46:06 UTC (rev 9156)
@@ -6,7 +6,7 @@
* Files:
*
* SQL:
- *
+ *
* Help:
*
* Maintainer:
@@ -22,148 +22,157 @@
var $metadataEdit = $(this);
var $metadataForm = $("<form>No WMC selected.</form>").appendTo($metadataEdit);
-var MetadataEditApi = function (o) {
- var that = this;
- var validator;
- var formReady = false;
- var wmcId;
-
- this.events = {
- showOriginalMetadata : new Mapbender.Event(),
- submit: new Mapbender.Event()
- };
+var MetadataEditApi = function(o) {
+ var that = this;
+ var validator;
+ var formReady = false;
+ var wmcId;
- this.valid = function () {
- if (validator && validator.numberOfInvalids() > 0) {
- $metadataForm.valid();
- return false;
- }
- return true;
- };
-
- this.serialize = function (callback) {
- $metadataForm.submit();
- var data = null;
- if (this.valid()) {
- data = {
- wmc: $metadataForm.easyform("serialize")
- };
- }
- if ($.isFunction(callback)) {
- callback(data);
- }
- return data !== null ? data.wmc : data;
- };
-
- // second optional parameter formData
- var fillForm = function (obj) {
-
- if (arguments.length >= 2) {
- $metadataForm.easyform("reset");
- $metadataForm.easyform("fill", arguments[1]);
- that.valid();
- return;
- }
-
- // get metadata from server
- var req = new Mapbender.Ajax.Request({
- url: "../plugins/mb_metadata_wmc_server.php",
- method: "getWmcMetadata",
- parameters: {
- "id": obj
- },
- callback: function (obj, result, message) {
- if (!result) {
- return;
- }
- $metadataForm.easyform("reset");
- $metadataForm.easyform("fill", obj);
- that.valid();
- that.enableResetButton();
- that.enableShowMetadataLink();
- }
- });
- req.send();
- };
-
- this.enableResetButton = function () {
- $("#resetIsoTopicCats").click(function () {
- $("#isoTopicCats option").removeAttr("selected");
- });
- $("#resetCustomCats").click(function () {
- $("#customCats option").removeAttr("selected");
- });
- $("#resetInspireCats").click(function () {
- $("#inspireCats option").removeAttr("selected");
- });
- }
-
- this.enableShowMetadataLink = function () {
- var linkHref = "../php/mod_showMetadata.php?languageCode=" + Mapbender.languageId + "&resource=wmc&id=" + wmcId;
- $("#wmc_showMetadata").attr("href",linkHref);
- }
+ this.events = {
+ showOriginalMetadata: new Mapbender.Event(),
+ submit: new Mapbender.Event()
+ };
- this.fill = function (obj) {
- $metadataForm.easyform("fill", obj);
- };
-
- var showOriginalMetadata = function () {
- that.events.showOriginalMetadata.trigger({
- data : {
- wmcId : wmcId,
- wmcData : $metadataForm.easyform("serialize")
- }
- });
- };
-
- this.init = function (obj) {
- wmcId = obj;
-
- var formData = arguments.length >= 2 ? arguments[1] : undefined;
-
- if (!formReady) {
- $metadataForm.empty().append($metadataEdit.children("div")).children().show();
- $metadataForm.find(".help-dialog").helpDialog();
- $metadataForm.find(".original-metadata-wmc").bind("click", function() {
- showOriginalMetadata();
- });
- validator = $metadataForm.validate({
- submitHandler: function () {
- return false;
- }
- });
- if (formData !== undefined) {
- fillForm(obj, formData);
- }
- else {
- fillForm(obj);
- }
- formReady = true;
- return;
- }
- fillForm(obj);
- };
-
- Mapbender.events.localize.register(function () {
- if (!wmcId) {
- return;
- }
- that.valid();
- var formData = $metadataForm.easyform("serialize");
- formReady = false;
- that.init(wmcId, formData);
- });
- Mapbender.events.init.register(function () {
- that.valid();
- $("<div></div>").insertAfter($metadataForm).hide().load("../plugins/mb_metadata_wmc_edit.php");
- var loadwmc = $("#loadwmc").mapbender();
- var map = $("#mapframe1").mapbender();
- var width = map.getWidth();
- var height = map.getHeight();
- loadwmc.events.loaded.register(function () {
- map.setDimensions(width, height);
- });
- });
+ this.valid = function() {
+ if (validator && validator.numberOfInvalids() > 0) {
+ $metadataForm.valid();
+ return false;
+ }
+ return true;
+ };
+
+ this.serialize = function(callback) {
+ $metadataForm.submit();
+ var data = null;
+ if (this.valid()) {
+ data = {
+ wmc: $metadataForm.easyform("serialize")
+ };
+ }
+ if ($.isFunction(callback)) {
+ callback(data);
+ }
+ return data !== null ? data.wmc : data;
+ };
+
+ // second optional parameter formData
+ var fillForm = function(obj) {
+
+ if (arguments.length >= 2) {
+ $metadataForm.easyform("reset");
+ $metadataForm.easyform("fill", arguments[1]);
+ that.valid();
+ return;
+ }
+
+ // get metadata from server
+ var req = new Mapbender.Ajax.Request({
+ url: "../plugins/mb_metadata_wmc_server.php",
+ method: "getWmcMetadata",
+ parameters: {
+ "id": obj
+ },
+ callback: function(obj, result, message) {
+ if (!result) {
+ return;
+ }
+ $metadataForm.easyform("reset");
+ $metadataForm.easyform("fill", obj);
+ that.valid();
+ that.enableResetButton();
+ that.enableShowMetadataLink();
+ }
+ });
+ req.send();
+ };
+
+ this.enableResetButton = function() {
+ $("#resetIsoTopicCats").click(function() {
+ $("#isoTopicCats option").removeAttr("selected");
+ });
+ $("#resetCustomCats").click(function() {
+ $("#customCats option").removeAttr("selected");
+ });
+ $("#resetInspireCats").click(function() {
+ $("#inspireCats option").removeAttr("selected");
+ });
+ }
+
+ this.enableShowMetadataLink = function() {
+ var linkHref = "../php/mod_showMetadata.php?languageCode=" + Mapbender.languageId + "&resource=wmc&id=" + wmcId;
+ $("#wmc_showMetadata").attr("href", linkHref);
+ }
+
+ this.fill = function(obj) {
+ $metadataForm.easyform("fill", obj);
+ };
+
+ var showOriginalMetadata = function() {
+ that.events.showOriginalMetadata.trigger({
+ data: {
+ wmcId: wmcId,
+ wmcData: $metadataForm.easyform("serialize")
+ }
+ });
+ };
+
+ this.init = function(obj) {
+ wmcId = obj;
+
+ var formData = arguments.length >= 2 ? arguments[1] : undefined;
+
+ if (!formReady) {
+ $metadataForm.empty().append($metadataEdit.children("div")).children().show();
+ $metadataForm.find(".help-dialog").helpDialog();
+ $metadataForm.find(".original-metadata-wmc").bind("click", function() {
+ showOriginalMetadata();
+ });
+ validator = $metadataForm.validate({
+ submitHandler: function() {
+ return false;
+ }
+ });
+ if (formData !== undefined) {
+ fillForm(obj, formData);
+ } else {
+ fillForm(obj);
+ }
+ formReady = true;
+ return;
+ }
+ fillForm(obj);
+ };
+
+ Mapbender.events.localize.register(function() {
+ if (!wmcId) {
+ return;
+ }
+ that.valid();
+ var formData = $metadataForm.easyform("serialize");
+ formReady = false;
+ that.init(wmcId, formData);
+ });
+ Mapbender.events.init.register(function() {
+ that.valid();
+ $("<div></div>").insertAfter($metadataForm).hide().load("../plugins/mb_metadata_wmc_edit.php", function() {
+
+
+ // add tabs to preview fieldset
+ $('#previewTabs').tabs();
+ // add an event-handler to the form -> interaction with the form can be handled somewhere else --> mb_metadata_layerPreview.js
+ $('#mb_md_wmc_preview').trigger('uploadFormReady', $('#previewImgForm'));
+ $('#mb_md_wmc_preview').trigger('fileChange', $('#previewImgForm input[type=file]'));
+
+
+ });
+ var loadwmc = $("#loadwmc").mapbender();
+ var map = $("#mapframe1").mapbender();
+ var width = map.getWidth();
+ var height = map.getHeight();
+ loadwmc.events.loaded.register(function() {
+ map.setDimensions(width, height);
+ });
+ });
};
$metadataEdit.mapbender(new MetadataEditApi(options));
Modified: trunk/mapbender/http/plugins/mb_metadata_wmc_edit.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_wmc_edit.php 2015-02-23 15:43:43 UTC (rev 9155)
+++ trunk/mapbender/http/plugins/mb_metadata_wmc_edit.php 2015-02-26 13:46:06 UTC (rev 9156)
@@ -1,16 +1,16 @@
<?php
require_once dirname(__FILE__) . "/../../core/globalSettings.php";
-
+
function displayCategories ($sql) {
if (Mapbender::session()->get("mb_lang") === "de") {
$sql = str_replace("category_code_en", "category_code_de", $sql);
}
-
+
$str = "";
$res = db_query($sql);
while ($row = db_fetch_assoc($res)) {
- $str .= "<option value='" . $row["id"] . "'>" .
- htmlentities($row["name"], ENT_QUOTES, CHARSET) .
+ $str .= "<option value='" . $row["id"] . "'>" .
+ htmlentities($row["name"], ENT_QUOTES, CHARSET) .
"</option>";
}
return $str;
@@ -26,7 +26,7 @@
<img class="original-metadata-wmc" src="../img/book.png"></img>
<img class="help-dialog" title="<?php #echo _mb("Help");?>" help="{text:'<?php #echo _mb("The original WMC-Metadata from the last update could be recovered or updated, so that the original Service-Metadata will be shown outward again.");?>'}" src="../img/questionmark.png"></img>
</p>
--->
+-->
<p>
<a id='wmc_showMetadata' class='cancelClickEvent' target='_blank' href=''><?php echo _mb("Metadata");?></a>
</p>
@@ -55,9 +55,30 @@
<div id="preview">
<fieldset class="">
<legend><?php echo _mb("Preview");?></legend>
- <div id="map"></div>
- <div id="toolbar_upper"></div>
- <div id="toolbar_lower"></div>
+ <div id="previewTabs">
+ <ul>
+ <li><a href="#previewTabs-1">Bild erstellen</a></li>
+ <li><a href="#previewTabs-2">Bild hochladen</a></li>
+ </ul>
+ <div id="previewTabs-1">
+ <div id="map"></div>
+ <div id="toolbar_upper"></div>
+ <div id="toolbar_lower"></div>
+ </div>
+ <div id="previewTabs-2">
+ <div id="previewImgUpload">
+ <form id="previewImgForm" action='../php/mb_metadata_uploadLayerPreview.php' enctype="multipart/form-data">
+ <input type="file" name="image">
+ <input type="submit" value="Upload">
+ <input type="hidden" name="source_id" value="source_id" >
+ <div id="upload"></div>
+ </form>
+ </div>
+ <div id="textarea">
+ </div>
+ </div>
+
+ </div>
</fieldset>
</div>
@@ -66,7 +87,7 @@
<legend><?php echo _mb("Classification");?></legend>
<p>
<label for="isoTopicCats" class="label_classification"><?php echo _mb("ISO Topic Category");?>:</label>
-
+
<img class="metadata_img" title="<?php echo _mb("Inspire");?>" src="../img/misc/inspire_eu_klein.png"></img>
<select class="metadata_selectbox" id="isoTopicCats" name="isoTopicCats" size="2" multiple="multiple">
<?php
More information about the Mapbender_commits
mailing list