Tweichart has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/164905

Change subject: InsertFile JavaApplet changes
......................................................................

InsertFile JavaApplet changes

* signed java applet
* moved .class to .jar to sign
* added .crt file for import
* decompiled .class toi make changes in the applet
* removed some unnecessary code from the applet
* changed return value to a json string
* applet inclusion in js changed
* return values are now handled in the return method in js, no js will be 
called from within the applet

Change-Id: Ia989924e8f588a436b4a11a542c4ea9c0c841d72
---
M InsertLink/resources/BS.InsertLink/FormPanelFileLink.js
A InsertLink/vendor/HWFileChooserApplet.jar
A InsertLink/vendor/src/HWFileChooserApplet.java
A InsertLink/vendor/src/insertLink
A InsertLink/vendor/src/insertLink.crt
5 files changed, 72 insertions(+), 15 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/05/164905/1

diff --git a/InsertLink/resources/BS.InsertLink/FormPanelFileLink.js 
b/InsertLink/resources/BS.InsertLink/FormPanelFileLink.js
index d55cb72..82a4b86 100644
--- a/InsertLink/resources/BS.InsertLink/FormPanelFileLink.js
+++ b/InsertLink/resources/BS.InsertLink/FormPanelFileLink.js
@@ -17,18 +17,7 @@
        beforeInitComponent: function() {
                this.setTitle( mw.message('bs-insertlink-tab-ext-file').plain() 
);
                this.on( 'beforeactivate', function(){
-                       oApplet = document.createElement('applet');
-                       oBody = document.getElementsByTagName('body')[0];
-                       oApplet.setAttribute('code', 
'HWFileChooserApplet.class');
-                       oApplet.setAttribute('id', 'HWFileChooserApplet');
-                       oApplet.setAttribute('name', 'HWFileChooserApplet');
-                       oApplet.setAttribute('scriptable', 'true');
-                       oApplet.setAttribute('mayscript', 'true');
-                       oApplet.setAttribute('codebase', 
wgScriptPath+'/extensions/BlueSpiceExtensions/InsertLink/resources/');
-                       oApplet.setAttribute('style', 
'width:0px;height:0px;padding:0;margin:0;');
-                       oApplet.setAttribute('height', '1');
-                       oApplet.setAttribute('width', '1');
-                       oBody.appendChild(oApplet);
+                       $("body").append('<applet id="HWFileChooserApplet" 
name="HWFileChooserApplet" archive="' + wgScriptPath + 
'/extensions/BlueSpiceExtensions/InsertLink/vendor/HWFileChooserApplet.jar" 
code="biz.hallowelt.InsertLink.HWFileChooserApplet.class" width="1" height="1" 
MAYSCRIPT></applet>');
                }, this);
 
                this.tfTargetUrl = Ext.create( 'Ext.form.field.Text', {
@@ -42,11 +31,14 @@
                        id: 'inputSearchFile',
                        text: 
mw.message('bs-insertlink-label-searchfile').plain(),
                        handler: function(){
-                               
document.HWFileChooserApplet.openDialog('onFileDialogFile', 
'onFileDialogCancel');
+                               var result = 
document.getElementById('HWFileChooserApplet').openDialog();
+                               result = $.parseJSON(result);
+                               if (result.success)
+                                       
Ext.getCmp('BSInserLinkTargetUrl').setValue(result.path);
                        },
                        width: '25%'
                });
-               
+
                this.fcTargetFields = Ext.create('Ext.form.FieldContainer', {
                         layout: 'hbox'
                });
@@ -111,7 +103,7 @@
                target = target.replace(/\\/g, '/');
                target = target.replace(/ /g, '%20');
 
-               return { 
+               return {
                        title: title,
                        href: 'file:///' + target,
                        type: '',
diff --git a/InsertLink/vendor/HWFileChooserApplet.jar 
b/InsertLink/vendor/HWFileChooserApplet.jar
new file mode 100644
index 0000000..42ac1d1
--- /dev/null
+++ b/InsertLink/vendor/HWFileChooserApplet.jar
Binary files differ
diff --git a/InsertLink/vendor/src/HWFileChooserApplet.java 
b/InsertLink/vendor/src/HWFileChooserApplet.java
new file mode 100644
index 0000000..e14af73
--- /dev/null
+++ b/InsertLink/vendor/src/HWFileChooserApplet.java
@@ -0,0 +1,65 @@
+package biz.hallowelt.InsertLink;
+import java.awt.FileDialog;
+import java.awt.Frame;
+import javax.swing.JApplet;
+/**
+ * for testing, comes along with code in init method
+ */
+/*import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JButton;*/
+
+public class HWFileChooserApplet extends JApplet
+{
+  private Frame m_parent;
+  private FileDialog m_fileDialog;
+  private static final long serialVersionUID = -2662327150714792175L;
+  
+  
+  public void init() {
+         /**
+          * for testing, let you create a standalone applet out of the browser
+          */
+         /*System.out.println("in");
+         JButton btn = new JButton("file choose");
+         btn.addActionListener(new ActionListener() {
+                 
+          public void actionPerformed(ActionEvent e)
+          {
+                 HWFileChooserApplet asd = new HWFileChooserApplet();
+                 asd.openDialog();
+          }
+      });
+         this.setSize(100, 100);
+         this.add(btn);*/
+      super.init();
+  }
+  
+  public String openDialog()
+  {
+    if (this.m_parent == null) {
+      this.m_parent = new Frame();
+    }
+    if (this.m_fileDialog == null) {
+      this.m_fileDialog = new FileDialog(this.m_parent, "File Upload", 0);
+    }
+    this.m_fileDialog.setVisible(true);
+    this.m_fileDialog.toFront();
+    String file = this.m_fileDialog.getFile();
+    String directory = this.m_fileDialog.getDirectory();
+    
+
+    this.m_fileDialog.setVisible(false);
+    this.m_parent.setVisible(false);
+    if ((file == null) || (file.length() == 0))
+    {
+      return "{success:false,path:\"\"}";
+    }
+    else
+    {
+      String path = directory + file;
+      path = path.replace("\\", "\\\\");
+      return "{\"success\":\"true\",\"path\":\"" + path + "\"}";
+    }
+  }
+}
diff --git a/InsertLink/vendor/src/insertLink b/InsertLink/vendor/src/insertLink
new file mode 100644
index 0000000..7c2b0dd
--- /dev/null
+++ b/InsertLink/vendor/src/insertLink
Binary files differ
diff --git a/InsertLink/vendor/src/insertLink.crt 
b/InsertLink/vendor/src/insertLink.crt
new file mode 100644
index 0000000..792fdfb
--- /dev/null
+++ b/InsertLink/vendor/src/insertLink.crt
Binary files differ

-- 
To view, visit https://gerrit.wikimedia.org/r/164905
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia989924e8f588a436b4a11a542c4ea9c0c841d72
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Tweichart <weich...@hallowelt.biz>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to