0
@@ -143,6 +143,11 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
private String allowedFileExtensions = UploadPolicy.DEFAULT_ALLOWED_FILE_EXTENSIONS;
0
+ * Contains the allowedFileExtensions applet parameter.
0
+ private String ignoredDirectoryRegex = UploadPolicy.DEFAULT_IGNORED_DIRECTORY_REGEX;
0
* Indicate whether the log window is shown or not to the user. In all cases
0
* it remains in memory, and stores all debug information. This allows a log
0
* information, in case of an error occurs.
0
@@ -275,8 +280,8 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
private int upload_cancelled=0; // The number of files that have been cancelled
0
private int queue_errors=0; // The number of files that caused fileQueueError to be fired
0
- private String javascriptInstanceName = "JUpload.instances['jupload_0']"; // TODO - change this to Null, and make it be set.
0
+ private String javascriptInstancePrefix = "JUpload.instances"; //
0
// //////////////////////////////////////////////////////////////////////////////////////////////
0
// /////////////////// INTERNAL ATTRIBUTE
0
@@ -462,6 +467,8 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
setFilenameFormvarName(UploadPolicyFactory.getParameter(theApplet,PROP_FORM_VAR_NAME, null,
0
+ setIgnoreDirectoryRegex(UploadPolicyFactory.getParameter(theApplet, PROP_IGNORE_DIRECTORY_REGEX, null,
0
// get the filenameEncoding. If not null, it should be a valid argument
0
// for the URLEncoder.encode method.
0
@@ -699,16 +706,16 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
- //if ( args.length==0) {s_args = "null";} else {s_args = "["+s_args+"]";}
0
- if (use_instance && (null!=this.javascriptInstanceName)){ // Do instance call, JUpload.instances['jupload_0'].function.apply(JUpload.instances['jupload_0'],args)
0
- instanced_function = this.javascriptInstanceName+"."+function+"("+s_args+")";
0
+ if (use_instance && (null!=this.applet.getParameter("NAME"))){ // Do instance call, JUpload.instances['jupload_0'].function.apply(JUpload.instances['jupload_0'],args)
0
+ instanced_function = this.javascriptInstancePrefix+"[\""+this.applet.getParameter("NAME")+"\"]."+function+"("+s_args+")";
0
// turn into function.apply(JUpload['jupload_0'],(args))
0
} else { // do a class call, like JUpload.JUploadReady.apply(JUpload.instances['jupload_0'],null)
0
//instanced_function = function+".apply("+this.javascriptInstanceName+","+s_args+")";
0
instanced_function = function+"("+s_args+")";
0
// A JavaScript expression was specified. Execute it.
0
- display
Warn("performCallback with "+instanced_function);
0
+ display
Debug("performCallback with "+instanced_function,20);
0
return_val = JSObject.getWindow(getApplet()).eval(instanced_function);
0
} catch (Exception ee) {
0
@@ -1389,6 +1396,8 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
+ getAllowHttpPersistent(), 20);
0
displayDebug(PROP_ALLOWED_FILE_EXTENSIONS + ": "
0
+ getAllowedFileExtensions(), 20);
0
+ displayDebug(PROP_IGNORE_DIRECTORY_REGEX + ": "
0
+ + getIgnoreDirectoryRegex(), 20);
0
displayDebug(PROP_DEBUG_LEVEL + ": " + this.debugLevel
0
+ " (debugfile: " + debugFile.getAbsolutePath() + ")", 1);
0
displayDebug(PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT + ": "
0
@@ -1487,14 +1496,10 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
return (String) s_callbacks.get(property_name);
0
- public String getJavascripInstanceName() {
0
- return this.javascriptInstanceName;
0
+ public String getJavascriptInstanceName() {
0
+ return this.applet.getParameter("NAME");
0
- public void setJavascripInstanceName(String the_name) {
0
- this.javascriptInstanceName=the_name;
0
public void setFilenamePrefix(String prefix){
0
this.filenamePrefix = prefix;
0
@@ -1521,6 +1526,13 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
public boolean getAllowHttpPersistent() {
0
return this.allowHttpPersistent;
0
+ protected void setIgnoreDirectoryRegex(String ignoreDirectoryRegex) {
0
+ this.ignoredDirectoryRegex=ignoreDirectoryRegex;
0
+ protected String getIgnoreDirectoryRegex() {
0
+ return this.ignoredDirectoryRegex;
0
/** @see UploadPolicy#getAllowedFileExtensions() */
0
public String getAllowedFileExtensions() {
0
@@ -2143,7 +2155,25 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
public JUploadFileChooser createFileChooser() {
0
return new JUploadFileChooser(this);
0
+ * This method returns the response for the
0
+ * {@link JUploadFileFilter#accept(File)} which just calls this method. This
0
+ * method checks that the file isn't excluded by the ignoreDirectoryRegex
0
+ * @see UploadPolicy#fileFilterAccept(File)
0
+ public boolean directoryFilterAccept(File file) {
0
+ if (file.isDirectory()) {
0
+ displayDebug("Directory filter directory: " + file.getName()+"\n regex: "+this.ignoredDirectoryRegex, 10);
0
+ if (this.ignoredDirectoryRegex.length()>0 && file.getName().matches(this.ignoredDirectoryRegex)){
0
+ displayDebug("Ignored", 10);
0
* This method returns the response for the
0
* {@link JUploadFileFilter#accept(File)} which just calls this method. This
0
@@ -2154,8 +2184,9 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
public boolean fileFilterAccept(File file) {
0
if (file.isDirectory()) {
0
- } else if (this.allowedFileExtensions == null
0
+ return directoryFilterAccept(file);
0
+ else if (this.allowedFileExtensions == null
0
|| this.allowedFileExtensions.equals("")) {
0
@@ -2176,11 +2207,14 @@ public class DefaultUploadPolicy implements UploadPolicy {
0
/** @see UploadPolicy#fileFilterGetDescription() */
0
public String fileFilterGetDescription() {
0
- if (this.allowedFileExtensions == null
0
- || this.allowedFileExtensions.equals(""))
0
+ String fileFilterDesc =
0
+ (this.allowedFileExtensions == null
0
+ || this.allowedFileExtensions.equals("") ? "" : "JUpload file filter (" + this.allowedFileExtensions + ")");
0
+ String directoryFilterDesc = (this.ignoredDirectoryRegex == null
0
+ || this.ignoredDirectoryRegex.equals("") ? "" : "JUpload directory filter ignore (" + this.ignoredDirectoryRegex + ")");
0
- return
"JUpload file filter (" + this.allowedFileExtensions + ")";
0
+ return
fileFilterDesc+" "+directoryFilterDesc;
Comments
No one has commented yet.