jenkins-bot has submitted this change and it was merged.
Change subject: replace applet with jnlp loader, no chrome support so far
......................................................................
replace applet with jnlp loader, no chrome support so far
generate absolute path to jar file in jnlp file
correct licence header
move jnlp generator to update.php hook and correct indention
save jnlp file to BlueSpiceFoundation/data dir, correct code convention as
described in comments
add gitignore build path and remove temp .class files
Change-Id: I43576483f31786324129d8757792a8971e3660ce
replace applet with jnlp loader, no chrome support so far
Change-Id: I43576483f31786324129d8757792a8971e3660ce
---
M .gitignore
M InsertLink/InsertLink.class.php
M InsertLink/InsertLink.setup.php
M InsertLink/resources/BS.InsertLink/FormPanelFileLink.js
M InsertLink/resources/BS.InsertLink/Window.js
D InsertLink/vendor/BsFileChooserApplet.jar
A InsertLink/vendor/bsFileLinkChooser.jar
D InsertLink/vendor/src/BsFileChooserApplet.java
A InsertLink/vendor/src/JWSFileChooser.java
A InsertLink/vendor/src/bsFileLinkChooser.crt
A InsertLink/vendor/src/bsFileLinkChooserKeyStore
D InsertLink/vendor/src/insertLink
D InsertLink/vendor/src/insertLink.crt
13 files changed, 160 insertions(+), 76 deletions(-)
Approvals:
Mglaser: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.gitignore b/.gitignore
index 67b484a..3bbc034 100755
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@
TEST
html/
latex/
+InsertLink/vendor/src/build/
diff --git a/InsertLink/InsertLink.class.php b/InsertLink/InsertLink.class.php
index f0021dd..53d618e 100644
--- a/InsertLink/InsertLink.class.php
+++ b/InsertLink/InsertLink.class.php
@@ -6,7 +6,7 @@
* Description: Dialogbox to enter a link.
* Authors: Markus Glaser, Sebastian Ulbricht
*
- * Copyright (C) 2010 Hallo Welt! � Medienwerkstatt GmbH, All rights reserved.
+ * Copyright (C) 2010 Hallo Welt! GmbH, All rights reserved.
*
* 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
@@ -108,4 +108,32 @@
$this->getOutput()->addJsConfigVars( 'bsInsertLinkEnableJava',
BsConfig::get( 'MW::InsertLink::EnableJava' ) );
return true;
}
+
+ public static function onLoadExtensionSchemaUpdates(DatabaseUpdater
$updater) {
+ //Create bsFileLnkChooser.jnlp File with proper path
+ //Important: $wgServer should be public url, not localhost
+ global $wgServer, $wgScriptPath, $IP;
+ $bsFileLinkChooser = '
+ <?xml version="1.0" encoding="utf-8"?>
+ <jnlp codebase="" href="" >
+ <information>
+ <title>BSFileLinkChooser</title>
+ <vendor>HalloWelt GmbH</vendor>
+ <homepage href="http://hallowelt.com"/>
+ <description>Simple FileChooser
Application</description>
+ <description
kind="short">BSFileLinkChooser</description>
+ <offline-allowed/>
+ </information>
+ <security>
+ <all-permissions/>
+ </security>
+ <resources>
+ <j2se version="1.6+"/>
+ <jar
href="'.$wgServer.$wgScriptPath.'/extensions/BlueSpiceExtensions/InsertLink/vendor/bsFileLinkChooser.jar"
main="true"/>
+ </resources>
+ <application-desc
main-class="bsFileLinkChooser.JWSFileChooser"/>
+ </jnlp>';
+ file_put_contents( __DIR__ .
"/../../BlueSpiceFoundation/data/bsFileLinkChooser.jnlp", $bsFileLinkChooser);
+ $updater->output( "InsertLink jnlp file created.\n" );
+ }
}
\ No newline at end of file
diff --git a/InsertLink/InsertLink.setup.php b/InsertLink/InsertLink.setup.php
index 607e839..a650206 100644
--- a/InsertLink/InsertLink.setup.php
+++ b/InsertLink/InsertLink.setup.php
@@ -44,4 +44,6 @@
'position' => 'top'
) + $aResourceModuleTemplate;
-unset( $aResourceModuleTemplate );
\ No newline at end of file
+unset( $aResourceModuleTemplate );
+
+$wgHooks['LoadExtensionSchemaUpdates'][] =
'InsertLink::onLoadExtensionSchemaUpdates';
\ No newline at end of file
diff --git a/InsertLink/resources/BS.InsertLink/FormPanelFileLink.js
b/InsertLink/resources/BS.InsertLink/FormPanelFileLink.js
index cbff325..08c5ef1 100644
--- a/InsertLink/resources/BS.InsertLink/FormPanelFileLink.js
+++ b/InsertLink/resources/BS.InsertLink/FormPanelFileLink.js
@@ -3,7 +3,7 @@
*
* Part of BlueSpice for MediaWiki
*
- * @author Patric Wirth <[email protected]>
+ * @author Patric Wirth <[email protected]>, Leonid Verhovskij
<[email protected]>
* @package Bluespice_Extensions
* @subpackage InsertLink
* @copyright Copyright (C) 2013 Hallo Welt! - Medienwerkstatt GmbH, All
rights reserved.
@@ -14,54 +14,37 @@
Ext.define( 'BS.InsertLink.FormPanelFileLink', {
extend: 'BS.InsertLink.FormPanelBase',
protocols: [ 'file:///' ],
- bIsJavaEnabled: false,
+ bIsJavaEnabled: navigator.javaEnabled(),
beforeInitComponent: function() {
this.setTitle( mw.message('bs-insertlink-tab-ext-file').plain()
);
- this.on( 'beforeactivate', function () {
- if ( !this.bIsJavaEnabled ) {
- return;
- }
- var applet = $("<applet>");
- applet.attr('id', 'BsFileChooserApplet');
- applet.attr('name', 'BsFileChooserApplet');
- applet.attr( 'archive', mw.config.get( "wgScriptPath" )
+ '/extensions/BlueSpiceExtensions/InsertLink/vendor/BsFileChooserApplet.jar' );
- applet.attr('code',
'biz.hallowelt.InsertLink.BsFileChooserApplet.class');
- applet.attr('width', '1');
- applet.attr('height', '1');
- applet.attr('mayscript', 'mayscript');
- $("body").append(applet);
- }, this);
this.tfTargetUrl = Ext.create( 'Ext.form.field.Text', {
id: 'BSInserLinkTargetUrl',
name: 'inputTargetUrl',
- fieldLabel:
mw.message('bs-insertlink-label-file').plain(),
+ fieldLabel: mw.message( 'bs-insertlink-label-file'
).plain(),
value: '',
width: this.bIsJavaEnabled ? '75%' : '100%'
});
this.btnSearchFile = Ext.create( 'Ext.button.Button', {
id: 'inputSearchFile',
- text:
mw.message('bs-insertlink-label-searchfile').plain(),
- handler: function() {
- try {
- var result = document.getElementById(
'BsFileChooserApplet' ).openDialog(mw.message( "bs-insertlink-select-a-page"
).plain());
- } catch ( e ) {
- bs.util.alert(
'bs-insertlink-no-applet',
- {
- text:
mw.message( "bs-insertlink-no-applet" ).plain(),
- titleMsg:
'bs-extjs-error'
- }
- );
- }
- result = $.parseJSON( result );
- if ( result.success )
- this.tfTargetUrl.setValue( result.path
);
+ text: mw.message( 'bs-insertlink-label-searchfile'
).plain(),
+ handler: function(){
+ //select input text for override
+ this.tfTargetUrl.focus( true );
+ //open java app for file selection
+ var jnlpPath =
"/extensions/BlueSpiceFoundation/data/bsFileLinkChooser.jnlp";
+ var downloadUrl = mw.config.get( "wgScriptPath"
) + jnlpPath;
+ var downloadFrame = document.createElement(
"iframe" );
+ downloadFrame.setAttribute( 'src', downloadUrl
);
+ downloadFrame.setAttribute( 'class',
"screenReaderText" );
+ downloadFrame.setAttribute( 'style',
"display:none;" );
+ document.body.appendChild( downloadFrame );
},
scope: this,
width: '25%'
});
- this.fcTargetFields = Ext.create('Ext.form.FieldContainer', {
+ this.fcTargetFields = Ext.create( 'Ext.form.FieldContainer', {
layout: 'hbox'
});
this.fcTargetFields.add( this.tfTargetUrl );
@@ -70,9 +53,9 @@
}
this.pnlMainConf.items = [];
- this.pnlMainConf.items.push(this.fcTargetFields);
+ this.pnlMainConf.items.push( this.fcTargetFields );
- this.callParent(arguments);
+ this.callParent( arguments );
},
resetData: function() {
this.tfTargetUrl.reset();
diff --git a/InsertLink/resources/BS.InsertLink/Window.js
b/InsertLink/resources/BS.InsertLink/Window.js
index 158abac..f8c7123 100644
--- a/InsertLink/resources/BS.InsertLink/Window.js
+++ b/InsertLink/resources/BS.InsertLink/Window.js
@@ -46,7 +46,7 @@
];
if ( mw.config.get( "wgUrlProtocols" ).indexOf( 'file' ) !== -1
) {
- this.fpnlFileLink = Ext.create(
'BS.InsertLink.FormPanelFileLink', { bIsJavaEnabled: mw.config.get(
'bsInsertLinkEnableJava' ) } );
+ this.fpnlFileLink = Ext.create(
'BS.InsertLink.FormPanelFileLink' );
items.push( this.fpnlFileLink );
}
diff --git a/InsertLink/vendor/BsFileChooserApplet.jar
b/InsertLink/vendor/BsFileChooserApplet.jar
deleted file mode 100644
index 38dcb8d..0000000
--- a/InsertLink/vendor/BsFileChooserApplet.jar
+++ /dev/null
Binary files differ
diff --git a/InsertLink/vendor/bsFileLinkChooser.jar
b/InsertLink/vendor/bsFileLinkChooser.jar
new file mode 100755
index 0000000..3f76cc4
--- /dev/null
+++ b/InsertLink/vendor/bsFileLinkChooser.jar
Binary files differ
diff --git a/InsertLink/vendor/src/BsFileChooserApplet.java
b/InsertLink/vendor/src/BsFileChooserApplet.java
deleted file mode 100644
index 07c6632..0000000
--- a/InsertLink/vendor/src/BsFileChooserApplet.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package biz.hallowelt.InsertLink;
-
-import java.awt.FileDialog;
-import java.awt.Frame;
-import javax.swing.JApplet;
-
-public class BsFileChooserApplet extends JApplet {
- private Frame m_parent;
- private FileDialog m_fileDialog;
- private static final long serialVersionUID = -2662327150714792175L;
-
- public void init() {
- super.init();
- }
-
- public String openDialog(String title) {
- if (this.m_parent == null) {
- this.m_parent = new Frame();
- }
- if (this.m_fileDialog == null) {
- this.m_fileDialog = new FileDialog(this.m_parent,
title, 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/JWSFileChooser.java
b/InsertLink/vendor/src/JWSFileChooser.java
new file mode 100644
index 0000000..9c6b7ab
--- /dev/null
+++ b/InsertLink/vendor/src/JWSFileChooser.java
@@ -0,0 +1,108 @@
+package bsFileLinkChooser;
+
+/**
+ * PasteImage Extension for BlueSpice
+ *
+ * FileChooser for BlueSpice FileLink
+ *
+ * - show file select dialog,
+ * - copy selected file path to clipboard
+ * - perform paste event on users keyboard
+ *
+ * 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 of the License, 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * This file is part of BlueSpice for MediaWiki
+ * For further information visit http://www.blue-spice.org
+ *
+ * @author Leonid Verhovskij <[email protected]>
+ * @version 2.23.2
+ * @package BlueSpice
+ * @subpackage FileLink
+ * @copyright Copyright (C) 2016 Hallo Welt! GmbH, All rights reserved.
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or
later
+ * @filesource
+ */
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.io.File;
+import javax.swing.*;
+import javax.swing.SwingUtilities;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.ClipboardOwner;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.StringSelection;
+
+public class JWSFileChooser extends JPanel implements ActionListener,
ClipboardOwner {
+ private static final long serialVersionUID = 1L;
+ // Create a file chooser
+ final JFileChooser fc = new JFileChooser();
+
+ public JWSFileChooser() {
+ super(new BorderLayout());
+ // show file select dialog
+ int returnVal = fc.showOpenDialog(this);
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ File file = fc.getSelectedFile();
+ StringSelection stringSelection = new
StringSelection(file.getAbsolutePath());
+ Clipboard clipboard =
Toolkit.getDefaultToolkit().getSystemClipboard();
+ clipboard.setContents(stringSelection, this);
+ try {
+ Robot rob = new Robot();
+ //give user some time to click in some field
and insert content there
+ rob.delay(1000);
+ //do the magic
+ rob.keyPress(KeyEvent.VK_CONTROL);
+ rob.keyPress(KeyEvent.VK_V);
+ rob.keyRelease(KeyEvent.VK_CONTROL);
+ rob.keyRelease(KeyEvent.VK_V);
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ }
+ }
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+ }
+
+ /**
+ * Create the GUI and show it. For thread safety, this method should be
+ * invoked from the event dispatch thread.
+ */
+ private static void createAndShowGUI() {
+ new JWSFileChooser();
+ }
+
+ public static void main(String[] args) {
+ // Schedule a job for the event dispatch thread:
+ // creating and showing this application's GUI.
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ // Turn off metal's use of bold fonts
+ UIManager.put("swing.boldMetal", Boolean.FALSE);
+ createAndShowGUI();
+ }
+ });
+ }
+
+ @Override
+ public void lostOwnership(Clipboard clipboard, Transferable contents) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/InsertLink/vendor/src/bsFileLinkChooser.crt
b/InsertLink/vendor/src/bsFileLinkChooser.crt
new file mode 100644
index 0000000..9eecf17
--- /dev/null
+++ b/InsertLink/vendor/src/bsFileLinkChooser.crt
Binary files differ
diff --git a/InsertLink/vendor/src/bsFileLinkChooserKeyStore
b/InsertLink/vendor/src/bsFileLinkChooserKeyStore
new file mode 100644
index 0000000..f985a0f
--- /dev/null
+++ b/InsertLink/vendor/src/bsFileLinkChooserKeyStore
Binary files differ
diff --git a/InsertLink/vendor/src/insertLink b/InsertLink/vendor/src/insertLink
deleted file mode 100644
index 7c2b0dd..0000000
--- a/InsertLink/vendor/src/insertLink
+++ /dev/null
Binary files differ
diff --git a/InsertLink/vendor/src/insertLink.crt
b/InsertLink/vendor/src/insertLink.crt
deleted file mode 100644
index 792fdfb..0000000
--- a/InsertLink/vendor/src/insertLink.crt
+++ /dev/null
Binary files differ
--
To view, visit https://gerrit.wikimedia.org/r/273486
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I43576483f31786324129d8757792a8971e3660ce
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Ljonka <[email protected]>
Gerrit-Reviewer: Dvogel hallowelt <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits