2012-06-21 20:39:27 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Resource loader module for certain VisualEditor messages.
|
|
|
|
*
|
|
|
|
* @file
|
2012-07-19 00:11:26 +00:00
|
|
|
* @ingroup Extensions
|
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
2012-06-21 20:39:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2012-12-04 06:56:41 +00:00
|
|
|
* Module for special messages VisualEditor needs to have parsed server side.
|
2012-06-21 20:39:27 +00:00
|
|
|
*/
|
|
|
|
class VisualEditorMessagesModule extends ResourceLoaderModule {
|
|
|
|
|
|
|
|
/* Protected Members */
|
|
|
|
|
2012-12-04 06:56:41 +00:00
|
|
|
protected $origin = self::ORIGIN_USER_SITEWIDE;
|
2012-06-21 20:39:27 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
public function getScript( ResourceLoaderContext $context ) {
|
2012-12-04 06:56:41 +00:00
|
|
|
$parsedMesssages = array();
|
2012-12-04 19:13:59 +00:00
|
|
|
foreach ( $this->getMessages() as $msgKey ) {
|
2012-12-04 06:56:41 +00:00
|
|
|
$parsedMesssages[$msgKey] = wfMessage( $msgKey )->parse();
|
|
|
|
}
|
|
|
|
return 've.init.target.addParsedMessages(' . FormatJson::encode( $parsedMesssages ) . ');';
|
2012-06-21 20:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getMessages() {
|
2012-12-04 06:56:41 +00:00
|
|
|
// We don't actually enable the client-side message system for these messages.
|
|
|
|
// But registering them in this standardised method to make use of the getMsgBlobMtime
|
|
|
|
// utility for make cache invalidation work out-of-the-box.
|
2012-08-17 19:30:33 +00:00
|
|
|
return array( 'minoredit', 'watchthis' );
|
2012-06-21 20:39:27 +00:00
|
|
|
}
|
2012-07-20 23:59:59 +00:00
|
|
|
|
2012-06-21 20:39:27 +00:00
|
|
|
public function getDependencies() {
|
|
|
|
return array( 'ext.visualEditor.base' );
|
|
|
|
}
|
2012-12-04 06:56:41 +00:00
|
|
|
|
|
|
|
public function getModifiedTime( ResourceLoaderContext $context ) {
|
|
|
|
return max(
|
|
|
|
$this->getMsgBlobMtime( $context->getLanguage() ),
|
|
|
|
// Also invalidate this module if this file changes (i.e. when messages were
|
|
|
|
// added or removed, or when the javascript invocation in getScript is changes).
|
|
|
|
file_exists( __FILE__ ) ? filemtime( __FILE__ ) : 1 // use 1 because 0 = now, would invalidate continously
|
|
|
|
);
|
|
|
|
}
|
2012-06-21 20:39:27 +00:00
|
|
|
}
|