Index: trunk/phase3/resources/Resources.php |
— | — | @@ -8,8 +8,9 @@ |
9 | 9 | 'noscript' => array( 'class' => 'ResourceLoaderNoscriptModule' ), |
10 | 10 | 'startup' => array( 'class' => 'ResourceLoaderStartUpModule' ), |
11 | 11 | 'user' => array( 'class' => 'ResourceLoaderUserModule' ), |
| 12 | + 'user.groups' => array( 'class' => 'ResourceLoaderUserGroupsModule' ), |
12 | 13 | 'user.options' => array( 'class' => 'ResourceLoaderUserOptionsModule' ), |
13 | | - 'user.groups' => array( 'class' => 'ResourceLoaderUserGroupsModule' ), |
| 14 | + 'user.tokens' => array( 'class' => 'ResourceLoaderUserTokensModule' ), |
14 | 15 | |
15 | 16 | /* Skins */ |
16 | 17 | |
Index: trunk/phase3/resources/mediawiki/mediawiki.user.js |
— | — | @@ -17,6 +17,8 @@ |
18 | 18 | |
19 | 19 | this.options = new mw.Map(); |
20 | 20 | |
| 21 | + this.tokens = new mw.Map(); |
| 22 | + |
21 | 23 | /* Public Methods */ |
22 | 24 | |
23 | 25 | /** |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -620,6 +620,7 @@ |
621 | 621 | 'ResourceLoaderUserGroupsModule' => 'includes/resourceloader/ResourceLoaderUserGroupsModule.php', |
622 | 622 | 'ResourceLoaderUserModule' => 'includes/resourceloader/ResourceLoaderUserModule.php', |
623 | 623 | 'ResourceLoaderUserOptionsModule' => 'includes/resourceloader/ResourceLoaderUserOptionsModule.php', |
| 624 | + 'ResourceLoaderUserTokensModule' => 'includes/resourceloader/ResourceLoaderUserTokensModule.php', |
624 | 625 | 'ResourceLoaderWikiModule' => 'includes/resourceloader/ResourceLoaderWikiModule.php', |
625 | 626 | |
626 | 627 | # includes/revisiondelete |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2615,7 +2615,7 @@ |
2616 | 2616 | // Legacy Scripts |
2617 | 2617 | $scripts .= "\n" . $this->mScripts; |
2618 | 2618 | |
2619 | | - $userScripts = array( 'user.options' ); |
| 2619 | + $userScripts = array( 'user.options', 'user.tokens' ); |
2620 | 2620 | |
2621 | 2621 | // Add site JS if enabled |
2622 | 2622 | if ( $wgUseSiteJs ) { |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php |
— | — | @@ -0,0 +1,62 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License along |
| 15 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | + * http://www.gnu.org/copyleft/gpl.html |
| 18 | + * |
| 19 | + * @file |
| 20 | + * @author Krinkle |
| 21 | + */ |
| 22 | + |
| 23 | +/** |
| 24 | + * Module for user tokens |
| 25 | + */ |
| 26 | +class ResourceLoaderUserTokensModule extends ResourceLoaderModule { |
| 27 | + |
| 28 | + /* Protected Members */ |
| 29 | + |
| 30 | + protected $origin = self::ORIGIN_CORE_INDIVIDUAL; |
| 31 | + |
| 32 | + /* Methods */ |
| 33 | + |
| 34 | + /** |
| 35 | + * Fetch the tokens for the current user. |
| 36 | + * |
| 37 | + * @param $context ResourceLoaderContext: Context object |
| 38 | + * @return Array: List of tokens keyed by token type |
| 39 | + */ |
| 40 | + protected function contextUserTokens( ResourceLoaderContext $context ) { |
| 41 | + global $wgUser; |
| 42 | + |
| 43 | + return array( |
| 44 | + 'editToken' => $wgUser->edittoken(), |
| 45 | + ); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @param $context ResourceLoaderContext |
| 50 | + * @return string |
| 51 | + */ |
| 52 | + public function getScript( ResourceLoaderContext $context ) { |
| 53 | + return Xml::encodeJsCall( 'mw.user.tokens.set', |
| 54 | + array( $this->contextUserTokens( $context ) ) ); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * @return string |
| 59 | + */ |
| 60 | + public function getGroup() { |
| 61 | + return 'private'; |
| 62 | + } |
| 63 | +} |
Property changes on: trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 64 | + native |