Luis Felipe Schenone has uploaded a new change for review.

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

Change subject: Initial commit
......................................................................

Initial commit

Change-Id: I66ac225f8884930ddff0d124eb114a571aae2d1f
---
A .gitignore
A MsWikiEditor.body.php
A MsWikiEditor.i18n.php
A MsWikiEditor.js
A MsWikiEditor.php
A README.md
A i18n/de.json
A i18n/en.json
A i18n/es.json
A i18n/qqq.json
A images/Achtung-Link.gif
A images/Btn_toolbar_gallery.png
A images/Button_strike.png
A images/Button_vote_biblio.png
A images/E-Mail.png
A images/Information-Link.gif
A images/Kalender.gif
A images/Link_button_oldschool.gif
A images/Wiki-Editor-Buttons_Achtung_22.png
A images/Wiki-Editor-Buttons_E-Mail_22.png
A images/Wiki-Editor-Buttons_Gallery_22.png
A images/Wiki-Editor-Buttons_Info_22.png
A images/Wiki-Editor-Buttons_Kalender_22.png
A images/Wiki-Editor-Buttons_Li.png
A images/Wiki-Editor-Buttons_Strike_22.png
A images/Wiki-Editor-Buttons_Upload_22.png
A images/password.png
A images/username.png
28 files changed, 236 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MsWikiEditor 
refs/changes/37/174937/1

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..496ee2c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.DS_Store
\ No newline at end of file
diff --git a/MsWikiEditor.body.php b/MsWikiEditor.body.php
new file mode 100644
index 0000000..ca26f20
--- /dev/null
+++ b/MsWikiEditor.body.php
@@ -0,0 +1,20 @@
+<?php
+
+class MsWikiEditor {
+
+       static function start() {
+               global $wgOut, $wgScriptPath, $wgMSWE_add, $wgMSWE_remove, 
$wgMSWE_buttons;
+
+               $mswe_add = json_encode( $wgMSWE_add );
+               $mswe_remove = json_encode( $wgMSWE_remove );
+               $mswe_buttons = json_encode( $wgMSWE_buttons );
+               $wgOut->addScript( "<script>
+                       var mswe_add = JSON.parse('$mswe_add');
+                       var mswe_remove = JSON.parse('$mswe_remove');
+                       var mswe_buttons = JSON.parse('$mswe_buttons'); 
+                       </script>"
+               );
+               $wgOut->addModules( 'ext.MsWikiEditor' );
+               return true;
+       }
+}
\ No newline at end of file
diff --git a/MsWikiEditor.i18n.php b/MsWikiEditor.i18n.php
new file mode 100644
index 0000000..455283b
--- /dev/null
+++ b/MsWikiEditor.i18n.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * This is a backwards-compatibility shim, generated by:
+ * 
https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
+ *
+ * Beginning with MediaWiki 1.23, translation strings are stored in json files,
+ * and the EXTENSION.i18n.php file only exists to provide compatibility with
+ * older releases of MediaWiki. For more information about this migration, see:
+ * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
+ *
+ * This shim maintains compatibility back to MediaWiki 1.17.
+ */
+$messages = array();
+if ( !function_exists( 'wfJsonI18nShim9bfcb6d3a88a9ce0' ) ) {
+       function wfJsonI18nShim9bfcb6d3a88a9ce0( $cache, $code, &$cachedData ) {
+               $codeSequence = array_merge( array( $code ), 
$cachedData['fallbackSequence'] );
+               foreach ( $codeSequence as $csCode ) {
+                       $fileName = dirname( __FILE__ ) . 
"/extensions/MsWikiEditor/i18n/$csCode.json";
+                       if ( is_readable( $fileName ) ) {
+                               $data = FormatJson::decode( file_get_contents( 
$fileName ), true );
+                               foreach ( array_keys( $data ) as $key ) {
+                                       if ( $key === '' || $key[0] === '@' ) {
+                                               unset( $data[$key] );
+                                       }
+                               }
+                               $cachedData['messages'] = array_merge( $data, 
$cachedData['messages'] );
+                       }
+
+                       $cachedData['deps'][] = new FileDependency( $fileName );
+               }
+               return true;
+       }
+
+       $GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 
'wfJsonI18nShim9bfcb6d3a88a9ce0';
+}
\ No newline at end of file
diff --git a/MsWikiEditor.js b/MsWikiEditor.js
new file mode 100755
index 0000000..e99b7bf
--- /dev/null
+++ b/MsWikiEditor.js
@@ -0,0 +1,83 @@
+// Check if we are in edit mode and the required modules are available and 
then customize the toolbar
+if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
+       mw.loader.using( 'user.options', function () {
+               if ( mw.user.options.get( 'usebetatoolbar' ) ) {
+                       mw.loader.using( 'ext.wikiEditor.toolbar', function () {
+                               $( document ).ready( mswe_modifyToolbar );
+                       });
+               }
+       });
+}
+
+var mswe_setGroup = false;
+
+function mswe_modifyToolbar() {
+       mswe_addGroup();
+       mswe_addAllButtons( mswe_buttons );
+       jQuery.each( mswe_remove, function ( i, val ) {
+               if ( val === 'reference' ) {
+                       $( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
+                               'section': 'main',
+                               'group': 'insert',
+                               'tool': 'reference'
+                       });
+               } else {
+                       mswe_removeSection( val );
+               }
+       });
+}
+
+function mswe_addAllButtons( mswe_buttons ) {
+       jQuery.each( mswe_add, function ( i, val ) {
+               mswe_addThisButton( val );
+       });
+}
+
+function mswe_addThisButton( titleButton ) {
+       var anam = mswe_buttons[ titleButton ][0];
+       var aprex = mswe_buttons[ titleButton ][1];
+       var aperix = mswe_buttons[ titleButton ][2];
+       var apostx = mswe_buttons[ titleButton ][3];
+       var aimg = mswe_buttons[ titleButton ][4];
+
+       // To add a button to an existing toolbar group:
+       $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+               'section': 'main',
+               'group': 'additional',
+               'tools': {
+                       'anam': {
+                               'label': anam, // Or use labelMsg for a 
localized label, see above
+                               'type': 'button',
+                               'icon': aimg,
+                               'action': {
+                                       'type': 'encapsulate',
+                                       'options': {
+                                               'pre': aprex, 
+                                               'peri': aperix,
+                                               'post': apostx,
+                                       }
+                               }
+                       }
+               }
+       });
+}
+
+function mswe_removeSection( nam ) {
+       $( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
+               'section': nam
+       });
+}
+
+function mswe_addGroup() {
+       if ( mswe_setGroup === false ) {
+               // To add a group to an existing toolbar section:
+               mswe_setGroup = true;
+               $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+                       'section': 'main',
+                       'groups': {
+                               'additional': {}
+                       }
+               });
+       }
+       $( '.wikiEditor-ui-toolbar .group-additional' ).css( 'border-left', 
'1px solid #DDDDDD' );
+}
\ No newline at end of file
diff --git a/MsWikiEditor.php b/MsWikiEditor.php
new file mode 100755
index 0000000..de65f6e
--- /dev/null
+++ b/MsWikiEditor.php
@@ -0,0 +1,28 @@
+<?php
+
+$wgExtensionCredits['interface'][] = array(
+       'name' => 'MsWikiEditor',
+       'url' => 'https://www.mediawiki.org/wiki/Extension:MsWikiEditor',
+       'version' => '2.0',
+       'descriptionmsg' => 'mswe-desc',
+       'license-name' => 'GPLv2+',
+       'author' => array( '[mailto:w...@ratin.de Martin Schwindl]', 
'[mailto:w...@keyler-consult.de Martin Keyler]', 
'[https://www.mediawiki.org/wiki/User:Luis_Felipe_Schenone Luis Felipe 
Schenone]' ),
+);
+
+$wgResourceModules['ext.MsWikiEditor'] = array(
+       'scripts' => 'MsWikiEditor.js',
+       'localBasePath' => __DIR__,
+       'remoteExtPath' => 'MsWikiEditor',
+);
+
+$wgAutoloadClasses['MsWikiEditor'] = __DIR__ . '/MsWikiEditor.body.php';
+
+$wgExtensionMessagesFiles['MsWikiEditor'] = __DIR__ . '/MsWikiEditor.i18n.php';
+$wgMessagesDirs['MsWikiEditor'] = __DIR__ . '/i18n';
+
+$wgHooks['EditPage::showEditForm:initial'][] = 'MsWikiEditor::start';
+
+// Default configuration
+$wgMSWE_buttons = array();
+$wgMSWE_add = array();
+$wgMSWE_remove = array();
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100755
index 0000000..aeaaf10
--- /dev/null
+++ b/README.md
@@ -0,0 +1,37 @@
+MsWikiEditor
+============
+
+MsWikiEditor is a MediaWiki extension that allows you to easily add or remove 
buttons from the WikiEditor.
+
+Installation
+------------
+To install MsWikiEditor, add the following to your LocalSettings.php:
+
+require_once "$IP/extensions/MsWikiEditor/MsWikiEditor.php";
+
+Configuration
+-------------
+To add a button, first define it in the $wgMSWE_buttons array in your 
LocalSettings.php. Here are a few examples:
+
+$wgMSWE_buttons['date'] = array( 'Current date', date( 'Y-m-d' ), '', '', 
$wgScriptPath . 
'/extensions/MsWikiEditor/images/Wiki-Editor-Buttons_Kalender_22.png' );
+$wgMSWE_buttons['gallery'] = array( 'Gallery', '<gallery>\\n', 
'File:Example1.jpg|Caption1\\nFile:Example2.png|Caption2\\n', '</gallery>', 
$wgScriptPath . 
'/extensions/MsWikiEditor/images/Wiki-Editor-Buttons_Gallery_22.png' );
+$wgMSWE_buttons['strike'] = array( 'Strike', '<strike>', 'Text', '</strike>', 
$wgScriptPath . 
'/extensions/MsWikiEditor/images/Wiki-Editor-Buttons_Strike_22.png' );
+$wgMSWE_buttons['email'] = array( 'Email', '[mailto:', 'addr...@domain.com', 
']', $wgScriptPath . 
'/extensions/MsWikiEditor/images/Wiki-Editor-Buttons_E-Mail_22.png' );
+$wgMSWE_buttons['mslink'] = array( 'MsLink', '{{#l:', 'Filename.ext', '}}', 
$wgScriptPath . '/extensions/MsWikiEditor/images/Wiki-Editor-Buttons_Li.png' );
+$wgMSWE_buttons['template'] = array( 'Your template', '{{Your template|', 
'Parameters', '}}', $wgScriptPath . 
'/extensions/MsWikiEditor/images/Wiki-Editor-Buttons_Achtung_22.png' );
+
+Then include its name in the $wgMSWE_add array, like so:
+
+$wgMSWE_add = array( 'date', 'gallery', 'strike', 'email', 'mslink', 
'template' );
+
+To remove a button, include its name in the $wgMSWE_remove array, below the 
require_once line. For example:
+
+$wgMSWE_remove = array( 'help', 'characters', 'reference', 'advanced' );
+
+By default, all arrays are empty.
+
+Credits
+-------
+* Developed and coded by Martin Schwindl (w...@ratin.de)
+* Idea, project management and bug fixing by Martin Keyler 
(w...@keyler-consult.de)
+* Updated, debugged and enhanced by Luis Felipe Schenone (scheno...@gmail.com)
\ No newline at end of file
diff --git a/i18n/de.json b/i18n/de.json
new file mode 100644
index 0000000..3ace987
--- /dev/null
+++ b/i18n/de.json
@@ -0,0 +1,8 @@
+{
+       "@metadata": {
+               "authors": [
+                       "Luis Felipe Schenone"
+               ]
+       },
+       "mswe-desc": "Die Wiki-Editor Toolbar kann hiermit leicht angepasst 
werden"
+}
\ No newline at end of file
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..43be1a2
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,8 @@
+{
+       "@metadata": {
+               "authors": [
+                       "Luis Felipe Schenone"
+               ]
+       },
+       "mswe-desc": "Easily add or remove buttons to the WikiEditor"
+}
\ No newline at end of file
diff --git a/i18n/es.json b/i18n/es.json
new file mode 100644
index 0000000..4ca13ef
--- /dev/null
+++ b/i18n/es.json
@@ -0,0 +1,8 @@
+{
+       "@metadata": {
+               "authors": [
+                       "Luis Felipe Schenone"
+               ]
+       },
+       "mswe-desc": "Agrega o remueve botones del WikiEditor con facilidad"
+}
\ No newline at end of file
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 0000000..b956edc
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,8 @@
+{
+       "@metadata": {
+               "authors": [
+                       "Luis Felipe Schenone"
+               ]
+       },
+       "msl-desc": 
"{{desc|name=MsWikiEditor|url=https://www.mediawiki.org/wiki/Extension:MsWikiEditor}}";
+}
diff --git a/images/Achtung-Link.gif b/images/Achtung-Link.gif
new file mode 100755
index 0000000..1d31a13
--- /dev/null
+++ b/images/Achtung-Link.gif
Binary files differ
diff --git a/images/Btn_toolbar_gallery.png b/images/Btn_toolbar_gallery.png
new file mode 100755
index 0000000..035b343
--- /dev/null
+++ b/images/Btn_toolbar_gallery.png
Binary files differ
diff --git a/images/Button_strike.png b/images/Button_strike.png
new file mode 100755
index 0000000..0de9c6d
--- /dev/null
+++ b/images/Button_strike.png
Binary files differ
diff --git a/images/Button_vote_biblio.png b/images/Button_vote_biblio.png
new file mode 100755
index 0000000..9d60f35
--- /dev/null
+++ b/images/Button_vote_biblio.png
Binary files differ
diff --git a/images/E-Mail.png b/images/E-Mail.png
new file mode 100755
index 0000000..5b80278
--- /dev/null
+++ b/images/E-Mail.png
Binary files differ
diff --git a/images/Information-Link.gif b/images/Information-Link.gif
new file mode 100755
index 0000000..5a7ca14
--- /dev/null
+++ b/images/Information-Link.gif
Binary files differ
diff --git a/images/Kalender.gif b/images/Kalender.gif
new file mode 100755
index 0000000..3873ebe
--- /dev/null
+++ b/images/Kalender.gif
Binary files differ
diff --git a/images/Link_button_oldschool.gif b/images/Link_button_oldschool.gif
new file mode 100755
index 0000000..ee3131b
--- /dev/null
+++ b/images/Link_button_oldschool.gif
Binary files differ
diff --git a/images/Wiki-Editor-Buttons_Achtung_22.png 
b/images/Wiki-Editor-Buttons_Achtung_22.png
new file mode 100755
index 0000000..d16e376
--- /dev/null
+++ b/images/Wiki-Editor-Buttons_Achtung_22.png
Binary files differ
diff --git a/images/Wiki-Editor-Buttons_E-Mail_22.png 
b/images/Wiki-Editor-Buttons_E-Mail_22.png
new file mode 100755
index 0000000..b188a4c
--- /dev/null
+++ b/images/Wiki-Editor-Buttons_E-Mail_22.png
Binary files differ
diff --git a/images/Wiki-Editor-Buttons_Gallery_22.png 
b/images/Wiki-Editor-Buttons_Gallery_22.png
new file mode 100755
index 0000000..13cb382
--- /dev/null
+++ b/images/Wiki-Editor-Buttons_Gallery_22.png
Binary files differ
diff --git a/images/Wiki-Editor-Buttons_Info_22.png 
b/images/Wiki-Editor-Buttons_Info_22.png
new file mode 100755
index 0000000..0ace01d
--- /dev/null
+++ b/images/Wiki-Editor-Buttons_Info_22.png
Binary files differ
diff --git a/images/Wiki-Editor-Buttons_Kalender_22.png 
b/images/Wiki-Editor-Buttons_Kalender_22.png
new file mode 100755
index 0000000..dd86e55
--- /dev/null
+++ b/images/Wiki-Editor-Buttons_Kalender_22.png
Binary files differ
diff --git a/images/Wiki-Editor-Buttons_Li.png 
b/images/Wiki-Editor-Buttons_Li.png
new file mode 100755
index 0000000..07967bb
--- /dev/null
+++ b/images/Wiki-Editor-Buttons_Li.png
Binary files differ
diff --git a/images/Wiki-Editor-Buttons_Strike_22.png 
b/images/Wiki-Editor-Buttons_Strike_22.png
new file mode 100755
index 0000000..b73604e
--- /dev/null
+++ b/images/Wiki-Editor-Buttons_Strike_22.png
Binary files differ
diff --git a/images/Wiki-Editor-Buttons_Upload_22.png 
b/images/Wiki-Editor-Buttons_Upload_22.png
new file mode 100755
index 0000000..636963c
--- /dev/null
+++ b/images/Wiki-Editor-Buttons_Upload_22.png
Binary files differ
diff --git a/images/password.png b/images/password.png
new file mode 100755
index 0000000..af990d2
--- /dev/null
+++ b/images/password.png
Binary files differ
diff --git a/images/username.png b/images/username.png
new file mode 100755
index 0000000..79c4c66
--- /dev/null
+++ b/images/username.png
Binary files differ

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I66ac225f8884930ddff0d124eb114a571aae2d1f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MsWikiEditor
Gerrit-Branch: master
Gerrit-Owner: Luis Felipe Schenone <scheno...@gmail.com>

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

Reply via email to