MediaWiki  REL1_24
ResourceLoaderUserTokensModule.php
Go to the documentation of this file.
00001 <?php
00027 class ResourceLoaderUserTokensModule extends ResourceLoaderModule {
00028 
00029     /* Protected Members */
00030 
00031     protected $origin = self::ORIGIN_CORE_INDIVIDUAL;
00032 
00033     protected $targets = array( 'desktop', 'mobile' );
00034 
00035     /* Methods */
00036 
00042     protected function contextUserTokens() {
00043         global $wgUser;
00044 
00045         return array(
00046             'editToken' => $wgUser->getEditToken(),
00047             'patrolToken' => $wgUser->getEditToken( 'patrol' ),
00048             'watchToken' => $wgUser->getEditToken( 'watch' ),
00049         );
00050     }
00051 
00056     public function getScript( ResourceLoaderContext $context ) {
00057         return Xml::encodeJsCall( 'mw.user.tokens.set',
00058             array( $this->contextUserTokens() ),
00059             ResourceLoader::inDebugMode()
00060         );
00061     }
00062 
00066     public function supportsURLLoading() {
00067         return false;
00068     }
00069 
00073     public function getGroup() {
00074         return 'private';
00075     }
00076 }