http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88565

Revision: 88565
Author:   krinkle
Date:     2011-05-22 08:47:08 +0000 (Sun, 22 May 2011)
Log Message:
-----------
Using the new mw.user.tokens (Introduced in r88553).

Modified Paths:
--------------
    trunk/extensions/WikiLove/WikiLove.hooks.php
    trunk/extensions/WikiLove/wikiLove.js

Modified: trunk/extensions/WikiLove/WikiLove.hooks.php
===================================================================
--- trunk/extensions/WikiLove/WikiLove.hooks.php        2011-05-22 08:41:37 UTC 
(rev 88564)
+++ trunk/extensions/WikiLove/WikiLove.hooks.php        2011-05-22 08:47:08 UTC 
(rev 88565)
@@ -41,23 +41,20 @@
        }
        
        /**
-        * Adds the required module and edit token JS if we are on a user 
(talk) page.
+        * Adds the required module if we are on a user (talk) page.
         *
         * @param $output
         * @param $skin Skin
         */
        public static function beforePageDisplay( $out, $skin ) {
                global $wgWikiLoveGlobal, $wgUser;
-               if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 
'wikilove-enabled' ) ) return true;
+               if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 
'wikilove-enabled' ) ) {
+                       return true;
+               }
                
                $title = self::getUserTalkPage( $skin->getTitle() );
                if ( !is_null( $title ) ) {
                        $out->addModules( 'ext.wikiLove' );
-                       $out->addInlineScript(
-                       'jQuery( document ).ready( function() {
-                               jQuery.wikiLove.editToken = ' . 
FormatJson::encode( $wgUser->edittoken() ) . ';
-                       } );'
-               );
                }
                return true;
        }

Modified: trunk/extensions/WikiLove/wikiLove.js
===================================================================
--- trunk/extensions/WikiLove/wikiLove.js       2011-05-22 08:41:37 UTC (rev 
88564)
+++ trunk/extensions/WikiLove/wikiLove.js       2011-05-22 08:47:08 UTC (rev 
88565)
@@ -1,7 +1,6 @@
 ( function( $ ) { $.wikiLove = {
 
        $dialog: null, // dialog jQuery object
-       editToken: '', // edit token used for the final AJAX call
        currentTypeId: null, // id of the currently selected type (e.g. 
'barnstar' or 'makeyourown')
        currentSubtypeId: null, // id of the currently selected subtype (e.g. 
'original' or 'special')
        currentTypeOrSubtype: null, // content of the current (sub)type (i.e. 
an object with title, descr, text, etc.)
@@ -213,14 +212,14 @@
         */
        sendEmail: function( subject, text ) {
                $.ajax({
-                       url: mw.config.get( 'wgServer' ) + mw.config.get( 
'wgScriptPath' ) + '/api.php?',
+                       url: mw.util.wikiScript( 'api' ),
                        data: {
                                'action': 'emailuser',
                                'target': wgTitle,
                                'subject': subject,
                                'text': text,
                                'format': 'json',
-                               'token': $.wikiLove.editToken
+                               'token': mw.user.tokens.get( 'editToken' )
                        },
                        dataType: 'json',
                        type: 'POST'
@@ -445,7 +444,7 @@
                                'type': type,
                                'text': wikitext,
                                'subject': subject,
-                               'token': $.wikiLove.editToken
+                               'token': mw.user.tokens.get( 'editToken' )
                        },
                        dataType: 'json',
                        type: 'POST',


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to