Index: trunk/extensions/WikiLove/WikiLove.hooks.php |
— | — | @@ -43,22 +43,25 @@ |
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | | - * Adds the required module if we are on a user (talk) page. |
| 47 | + * Adds the required module and edit token JS if we are on a user (talk) page. |
48 | 48 | * |
49 | 49 | * @param $output |
50 | 50 | * @param $skin Skin |
51 | 51 | */ |
52 | 52 | public static function beforePageDisplay( $out, $skin ) { |
53 | 53 | global $wgWikiLoveGlobal, $wgUser; |
54 | | - if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) { |
55 | | - return true; |
56 | | - } |
| 54 | + if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) return true; |
57 | 55 | |
58 | 56 | $title = self::getUserTalkPage( $skin->getTitle() ); |
59 | 57 | if ( !is_null( $title ) ) { |
60 | 58 | $out->addModules( 'ext.wikiLove.icon' ); |
61 | 59 | $out->addModules( 'ext.wikiLove.init' ); |
62 | 60 | self::$recipient = $title->getText(); |
| 61 | + $out->addInlineScript( |
| 62 | + 'jQuery( document ).ready( function() { |
| 63 | + jQuery.wikiLove.editToken = ' . FormatJson::encode( $wgUser->edittoken() ) . '; |
| 64 | + } );' |
| 65 | + ); |
63 | 66 | } |
64 | 67 | return true; |
65 | 68 | } |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | currentSubtypeId = null, // id of the currently selected subtype (e.g. 'original' or 'special') |
9 | 9 | currentTypeOrSubtype = null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.) |
10 | 10 | previewData = null, // data of the currently previewed thing is set here |
| 11 | + editToken = '', // edit token used for the final AJAX call (deprecated after 1.17) |
11 | 12 | emailable = false, |
12 | 13 | gallery = {}; |
13 | 14 | |
— | — | @@ -384,7 +385,7 @@ |
385 | 386 | 'text': wikitext, |
386 | 387 | 'message': message, |
387 | 388 | 'subject': subject, |
388 | | - 'token': mw.user.tokens.get( 'editToken' ) |
| 389 | + 'token': $.wikiLove.editToken // after 1.17 this can become mw.user.tokens.get( 'editToken' ) |
389 | 390 | }; |
390 | 391 | |
391 | 392 | if ( email ) { |