r89034 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89033‎ | r89034 | r89035 >
Date:11:46, 28 May 2011
Author:janpaul123
Status:ok
Tags:
Comment:
Modified paths:
  • /trunk/extensions/WikiLove/WikiLove.hooks.php (modified) (history)
  • /trunk/extensions/WikiLove/WikiLove.php (modified) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/WikiLove.php
@@ -67,6 +67,7 @@
6868 $wgHooks['SkinTemplateTabs'][] = 'WikiLoveHooks::skinTemplateTabs';
6969 $wgHooks['BeforePageDisplay'][] = 'WikiLoveHooks::beforePageDisplay';
7070 $wgHooks['LoadExtensionSchemaUpdates'][] = 'WikiLoveHooks::loadExtensionSchemaUpdates';
 71+$wgHooks['MakeGlobalVariablesScript'][] = 'WikiLoveHooks::makeGlobalVariablesScript';
7172
7273 // api modules
7374 $wgAPIModules['wikilove'] = 'WikiLoveApi';
Index: trunk/extensions/WikiLove/WikiLove.hooks.php
@@ -7,6 +7,8 @@
88 */
99
1010 class WikiLoveHooks {
 11+ private static $recipient = '';
 12+
1113 /**
1214 * LoadExtensionSchemaUpdates hook
1315 *
@@ -56,16 +58,20 @@
5759 if ( !is_null( $title ) ) {
5860 $out->addModules( 'ext.wikiLove.icon' );
5961 $out->addModules( 'ext.wikiLove.init' );
60 - $out->addInlineScript(
61 - 'jQuery( document ).ready( function() {
62 - jQuery.wikiLove.setUsername( ' . FormatJson::encode( $title->getText() ) . ' );
63 - } );'
64 - );
 62+ self::$recipient = $title->getText();
6563 }
6664 return true;
6765 }
6866
6967 /**
 68+ * Exports wikilove-recipient variable to JS
 69+ */
 70+ public static function makeGlobalVariablesScript( &$vars ) {
 71+ $vars['wikilove-recipient'] = self::$recipient;
 72+ return true;
 73+ }
 74+
 75+ /**
7076 * Adds a tab the old way (before MW 1.18)
7177 */
7278 public static function skinTemplateTabs( $skin, &$contentActions ) {
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
@@ -8,8 +8,7 @@
99 currentTypeOrSubtype = null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.)
1010 previewData = null, // data of the currently previewed thing is set here
1111 emailable = false,
12 - gallery = {},
13 - username = '';
 12+ gallery = {};
1413
1514 return {
1615 optionsHook: function() { return {}; }, // hook that can be overridden by the user to modify options
@@ -331,7 +330,7 @@
332331 msg = msg.replace( '$5', myBackgroundColor ); // replace the background color
333332 msg = msg.replace( '$6', myBorderColor ); // replace the border color
334333
335 - msg = msg.replace( '$7', username ); // replace the username we're sending to
 334+ msg = msg.replace( '$7', mw.config.get( 'wikilove-recipient' ) ); // replace the username we're sending to
336335
337336 return msg;
338337 },
@@ -516,13 +515,6 @@
517516 $.wikiLove.openDialog();
518517 e.preventDefault();
519518 });
520 - },
521 -
522 - /*
523 - * Public function to set the username by finding the base title server-side.
524 - */
525 - setUsername: function( name ) {
526 - username = name;
527519 }
528520
529521 /*

Status & tagging log