[Mapbender-commits] r5868 - trunk/mapbender/http/plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Apr 6 08:59:22 EDT 2010
Author: christoph
Date: 2010-04-06 08:59:21 -0400 (Tue, 06 Apr 2010)
New Revision: 5868
Modified:
trunk/mapbender/http/plugins/jq_upload.js
trunk/mapbender/http/plugins/jq_upload.php
Log:
Modified: trunk/mapbender/http/plugins/jq_upload.js
===================================================================
--- trunk/mapbender/http/plugins/jq_upload.js 2010-04-06 09:47:59 UTC (rev 5867)
+++ trunk/mapbender/http/plugins/jq_upload.js 2010-04-06 12:59:21 UTC (rev 5868)
@@ -1,4 +1,7 @@
$.fn.upload = function (args) {
+ if (typeof $.fn.upload.initialized === "undefined") {
+ $.fn.upload.initialized = [];
+ }
return this.each(function () {
if (this.id === "upload") {
return;
@@ -6,7 +9,21 @@
var options = args || {};
var $this = $(this);
+ var that = this;
var id = this.id;
+
+ var exists = false;
+ $($.fn.upload.initialized).each(function () {
+ if (that === this) {
+ exists = true;
+ }
+ });
+ if (exists) {
+ return;
+ }
+
+ $.fn.upload.initialized.push(this);
+
var time = 0;
var timeout = options.timeout || 7000;
var timeinterval = options.interval || 200;
@@ -19,6 +36,7 @@
var t = setInterval(function () {
var returnValue = window.frames[id + "_target"].id;
time += timeinterval;
+
if (typeof returnValue !== "undefined") {
clearInterval(t);
time = 0;
@@ -44,6 +62,7 @@
options.callback(null, false, msg);
}
}
+ $("#" + id + "_submit").removeAttr("disabled");
return;
}
if (time >= timeout) {
@@ -52,11 +71,12 @@
msg = "File upload failed, timeout reached (" +
timeout + " ms)";
- new parent.window.opener.parent.Mb_exception(msg);
+ new Mb_exception(msg);
if (typeof options.callback === "function") {
options.callback(null, false, msg);
}
+ $("#" + id + "_submit").removeAttr("disabled");
return;
}
}, timeinterval);
@@ -69,20 +89,23 @@
).submit(function () {
var filename = $("input[name=myfile]", $this).val();
if (filename !== "") {
+ $("#" + id + "_submit").attr("disabled", "disabled");
startUpload();
}
return true;
});
- $form.append($(
+ $form.append(
"<p id='" + id + "_form' align='center'><br/>" +
"<input name='myfile' type='file' size='"+width+"' />" +
- (displaySubmit ? "<input type='submit' value='Upload' />": "") +
+ (displaySubmit ? "<input id='" + id + "_submit' type='submit' value='Upload' />": "") +
- "</p>" +
- "<iframe name='" + id + "_target' src='../html/mod_blank.html' " +
- "style='width:0;height:0;border:0px solid #fff;'></iframe>"
- ));
+ "</p>"
+ );
+ var iframeStr = "<iframe name='" + id + "_target' id='" + id + "_target' src='#' " +
+ "style='width:0;height:0;border:0px solid #fff;'></iframe>";
+
+ $("body").eq(0).append(iframeStr);
$this.append($form);
});
};
Modified: trunk/mapbender/http/plugins/jq_upload.php
===================================================================
--- trunk/mapbender/http/plugins/jq_upload.php 2010-04-06 09:47:59 UTC (rev 5867)
+++ trunk/mapbender/http/plugins/jq_upload.php 2010-04-06 12:59:21 UTC (rev 5868)
@@ -2,7 +2,6 @@
require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
$id = $_GET["id"];
-
if (!preg_match("/[a-zA-Z0-9-_]+/", $id)) {
$message = "cancelled";
}
@@ -26,7 +25,8 @@
// check if file type is valid
foreach ($allowedFileTypes as $item) {
$cancel = true;
- $message = _mb("Files with this extension are not allowed. Must be %s.", implode(", ", $allowedFileTypes));
+// $message = _mb("Files with this extension are not allowed. Must be %s.", implode(", ", $allowedFileTypes));
+ $message = _mb("Dateien in diesem Format werden nicht unterstützt, wählen Sie eines der folgenden Bildformate: %s.", implode(", ", $allowedFileTypes));
if(preg_match("/\.$item\$/i", $clientFilename)) {
$cancel = false;
break;
@@ -40,15 +40,18 @@
$disallowedFileTypes
);
}
+
// check if file type is valid
foreach ($disallowedFileTypes as $item) {
if(preg_match("/\.$item\$/i", $clientFilename)) {
$cancel = true;
- $message = _mb("Files with extension %s are not allowed. Must be %s.", $item, implode(", ", $allowedFileTypes));
+// $message = _mb("Files with extension %s are not allowed. Must be %s.", $item, implode(", ", $allowedFileTypes));
+ $message = _mb("Dateien in dem Format %s werden nicht unterstützt, wählen Sie eines der folgenden Bildformate: %s.", $item, implode(", ", $allowedFileTypes));
break;
}
}
+
$maxSize = intval(ini_get("upload_max_filesize"))*1024;
if (defined("UPLOAD_MAX_SIZE_KB") && UPLOAD_MAX_SIZE_KB < $maxSize) {
@@ -56,7 +59,8 @@
}
if (count($_FILES) === 0 || filesize($uploadedFile) > UPLOAD_MAX_SIZE_KB * 1024) {
$cancel = true;
- $message = _mb("File size limit (%s KB) exceeded.", UPLOAD_MAX_SIZE_KB);
+// $message = _mb("File size limit (%s KB) exceeded.", UPLOAD_MAX_SIZE_KB);
+ $message = _mb("Datei zu groß (maximal %s KB).", UPLOAD_MAX_SIZE_KB);
}
$extension = "";
@@ -69,11 +73,13 @@
if (!$cancel) {
if (!copy($uploadedFile, $serverFullFilename)) {
$status = "cancelled";
- $message = _mb("File could not be stored on server. Please contact the administrator.");
+// $message = _mb("File could not be stored on server. Please contact the administrator.");
+ $message = _mb("Die Datei konnte nicht hochgeladen werden. Bitte wenden Sie sich an den Administrator.");
}
else {
$status = "finished";
- $message = _mb("File has been uploaded.");
+// $message = _mb("File has been uploaded.");
+ $message = _mb("Die Datei wurde erfolgreich hochgeladen.");
}
}
else {
@@ -81,16 +87,16 @@
}
}
?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
- window.id = "<?php
+ var id = "<?php
echo $id . "_" . $serverFullFilename . "_" . $status . "_" . $message;
?>";
- window.filename = "<?php echo $clientFilename; ?>";
+ var filename = "<?php echo $clientFilename; ?>";
</script>
</head>
<body>
-
</body>
</html>
\ No newline at end of file
More information about the Mapbender_commits
mailing list