Merge "Use Config instead of globals"

This commit is contained in:
jenkins-bot 2014-08-15 22:55:02 +00:00 committed by Gerrit Code Review
commit 14e4a915d7
5 changed files with 112 additions and 92 deletions

View file

@ -10,33 +10,38 @@
class ApiVisualEditor extends ApiBase { class ApiVisualEditor extends ApiBase {
/**
* @var Config
*/
protected $veConfig;
public function __construct( ApiMain $main, $name, Config $config ) {
parent::__construct( $main, $name );
$this->veConfig = $config;
}
/** /**
* Parsoid HTTP proxy configuration for MWHttpRequest * Parsoid HTTP proxy configuration for MWHttpRequest
*/ */
protected function getProxyConf() { protected function getProxyConf() {
global $wgVisualEditorParsoidHTTPProxy; $parsoidHTTPProxy = $this->veConfig->get( 'VisualEditorParsoidHTTPProxy' );
if ( $wgVisualEditorParsoidHTTPProxy ) { if ( $parsoidHTTPProxy ) {
return array( 'proxy' => $wgVisualEditorParsoidHTTPProxy ); return array( 'proxy' => $parsoidHTTPProxy );
} else { } else {
return array( 'noProxy' => true ); return array( 'noProxy' => true );
} }
} }
protected function requestParsoid( $method, $title, $params ) { protected function requestParsoid( $method, $title, $params ) {
global $wgVisualEditorParsoidURL, $url = $this->veConfig->get( 'VisualEditorParsoidURL' ) . '/' .
$wgVisualEditorParsoidPrefix, $this->veConfig->get( 'VisualEditorParsoidPrefix' ) . '/' .
$wgVisualEditorParsoidTimeout,
$wgVisualEditorParsoidForwardCookies;
$url = $wgVisualEditorParsoidURL . '/' .
$wgVisualEditorParsoidPrefix . '/' .
urlencode( $title->getPrefixedDBkey() ); urlencode( $title->getPrefixedDBkey() );
$data = array_merge( $data = array_merge(
$this->getProxyConf(), $this->getProxyConf(),
array( array(
'method' => $method, 'method' => $method,
'timeout' => $wgVisualEditorParsoidTimeout, 'timeout' => $this->veConfig->get( 'VisualEditorParsoidTimeout' ),
) )
); );
@ -48,7 +53,9 @@ class ApiVisualEditor extends ApiBase {
$req = MWHttpRequest::factory( $url, $data ); $req = MWHttpRequest::factory( $url, $data );
// Forward cookies, but only if configured to do so and if there are read restrictions // Forward cookies, but only if configured to do so and if there are read restrictions
if ( $wgVisualEditorParsoidForwardCookies && !User::isEveryoneAllowed( 'read' ) ) { if ( $this->veConfig->get( 'VisualEditorParsoidForwardCookies' )
&& !User::isEveryoneAllowed( 'read' )
) {
$req->setHeader( 'Cookie', $this->getRequest()->getHeader( 'Cookie' ) ); $req->setHeader( 'Cookie', $this->getRequest()->getHeader( 'Cookie' ) );
} }
$status = $req->execute(); $status = $req->execute();
@ -83,11 +90,6 @@ class ApiVisualEditor extends ApiBase {
} }
protected function getHTML( $title, $parserParams ) { protected function getHTML( $title, $parserParams ) {
global $wgVisualEditorParsoidURL,
$wgVisualEditorParsoidPrefix,
$wgVisualEditorParsoidTimeout,
$wgVisualEditorParsoidForwardCookies;
$restoring = false; $restoring = false;
if ( $title->exists() ) { if ( $title->exists() ) {
@ -132,14 +134,14 @@ class ApiVisualEditor extends ApiBase {
} }
protected function storeInSerializationCache( $title, $oldid, $html ) { protected function storeInSerializationCache( $title, $oldid, $html ) {
global $wgMemc, $wgVisualEditorSerializationCacheTimeout; global $wgMemc;
$content = $this->postHTML( $title, $html, array( 'oldid' => $oldid ) ); $content = $this->postHTML( $title, $html, array( 'oldid' => $oldid ) );
if ( $content === false ) { if ( $content === false ) {
return false; return false;
} }
$hash = md5( $content ); $hash = md5( $content );
$key = wfMemcKey( 'visualeditor', 'serialization', $hash ); $key = wfMemcKey( 'visualeditor', 'serialization', $hash );
$wgMemc->set( $key, $content, $wgVisualEditorSerializationCacheTimeout ); $wgMemc->set( $key, $content, $this->veConfig->get( 'VisualEditorSerializationCacheTimeout' ) );
return $hash; return $hash;
} }
@ -282,8 +284,6 @@ class ApiVisualEditor extends ApiBase {
} }
public function execute() { public function execute() {
global $wgVisualEditorNamespaces;
$user = $this->getUser(); $user = $this->getUser();
$params = $this->extractRequestParams(); $params = $this->extractRequestParams();
@ -291,7 +291,7 @@ class ApiVisualEditor extends ApiBase {
if ( !$page ) { if ( !$page ) {
$this->dieUsageMsg( 'invalidtitle', $params['page'] ); $this->dieUsageMsg( 'invalidtitle', $params['page'] );
} }
if ( !in_array( $page->getNamespace(), $wgVisualEditorNamespaces ) ) { if ( !in_array( $page->getNamespace(), $this->veConfig->get( 'VisualEditorNamespaces' ) ) ) {
$this->dieUsage( "VisualEditor is not enabled in namespace " . $this->dieUsage( "VisualEditor is not enabled in namespace " .
$page->getNamespace(), 'novenamespace' ); $page->getNamespace(), 'novenamespace' );
} }

View file

@ -10,6 +10,10 @@
class ApiVisualEditorEdit extends ApiVisualEditor { class ApiVisualEditorEdit extends ApiVisualEditor {
public function __construct( ApiMain $main, $name, Config $config ) {
parent::__construct( $main, $name, $config );
}
protected function saveWikitext( $title, $wikitext, $params ) { protected function saveWikitext( $title, $wikitext, $params ) {
$apiParams = array( $apiParams = array(
'action' => 'edit', 'action' => 'edit',
@ -53,15 +57,13 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
} }
public function execute() { public function execute() {
global $wgVisualEditorNamespaces, $wgVisualEditorUseChangeTagging;
$user = $this->getUser(); $user = $this->getUser();
$params = $this->extractRequestParams(); $params = $this->extractRequestParams();
$page = Title::newFromText( $params['page'] ); $page = Title::newFromText( $params['page'] );
if ( !$page ) { if ( !$page ) {
$this->dieUsageMsg( 'invalidtitle', $params['page'] ); $this->dieUsageMsg( 'invalidtitle', $params['page'] );
} }
if ( !in_array( $page->getNamespace(), $wgVisualEditorNamespaces ) ) { if ( !in_array( $page->getNamespace(), $this->veConfig->get( 'VisualEditorNamespaces' ) ) ) {
$this->dieUsage( "VisualEditor is not enabled in namespace " . $this->dieUsage( "VisualEditor is not enabled in namespace " .
$page->getNamespace(), 'novenamespace' ); $page->getNamespace(), 'novenamespace' );
} }
@ -100,7 +102,9 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
// Success // Success
} else { } else {
if ( isset( $saveresult['edit']['newrevid'] ) && $wgVisualEditorUseChangeTagging ) { if ( isset( $saveresult['edit']['newrevid'] )
&& $this->veConfig->get( 'VisualEditorUseChangeTagging' )
) {
ChangeTags::addTags( 'visualeditor', null, ChangeTags::addTags( 'visualeditor', null,
intval( $saveresult['edit']['newrevid'] ), intval( $saveresult['edit']['newrevid'] ),
null null

View file

@ -10,9 +10,6 @@
class VisualEditorHooks { class VisualEditorHooks {
public static function onSetup() { public static function onSetup() {
global $wgResourceModules,
$wgVisualEditorTabMessages;
// This prevents VisualEditor from being run in environments that don't // This prevents VisualEditor from being run in environments that don't
// have the dependent code in core; this should be updated as a part of // have the dependent code in core; this should be updated as a part of
// when additional dependencies are created and pushed into MediaWiki's // when additional dependencies are created and pushed into MediaWiki's
@ -20,14 +17,18 @@ class VisualEditorHooks {
// parties who attempt to install VisualEditor onto non-alpha wikis, as // parties who attempt to install VisualEditor onto non-alpha wikis, as
// this should have no impact on deploying to Wikimedia's wiki cluster; // this should have no impact on deploying to Wikimedia's wiki cluster;
// is fine for release tarballs because 1.22wmf11 < 1.22alpha < 1.22.0. // is fine for release tarballs because 1.22wmf11 < 1.22alpha < 1.22.0.
wfUseMW( '1.24wmf6' ); wfUseMW( '1.24wmf17' );
$coreConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
$resourceModules = $coreConfig->get( 'ResourceModules' );
// Add tab messages to the init init module // Add tab messages to the init init module
foreach ( $wgVisualEditorTabMessages as $msg ) { foreach ( $veConfig->get( 'VisualEditorTabMessages' ) as $msg ) {
if ( $msg !== null ) { if ( $msg !== null ) {
$wgResourceModules['ext.visualEditor.viewPageTarget.init']['messages'][] = $msg; $resourceModules['ext.visualEditor.viewPageTarget.init']['messages'][] = $msg;
} }
} }
$coreConfig->set( 'ResourceModules', $resourceModules );
} }
/** /**
@ -63,7 +64,8 @@ class VisualEditorHooks {
return true; return true;
} }
global $wgVisualEditorTabMessages, $wgVisualEditorTabPosition; $config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
if ( !isset( $links['views']['edit'] ) ) { if ( !isset( $links['views']['edit'] ) ) {
// There's no edit link, nothing to do // There's no edit link, nothing to do
return true; return true;
@ -72,6 +74,7 @@ class VisualEditorHooks {
if ( defined( 'EP_NS' ) && $title->inNamespace( EP_NS ) ) { if ( defined( 'EP_NS' ) && $title->inNamespace( EP_NS ) ) {
return true; return true;
} }
$tabMessages = $config->get( 'VisualEditorTabMessages' );
// Rebuild the $links['views'] array and inject the VisualEditor tab before or after // Rebuild the $links['views'] array and inject the VisualEditor tab before or after
// the edit tab as appropriate. We have to rebuild the array because PHP doesn't allow // the edit tab as appropriate. We have to rebuild the array because PHP doesn't allow
// us to splice into the middle of an associative array. // us to splice into the middle of an associative array.
@ -87,7 +90,7 @@ class VisualEditorHooks {
$veParams = $skin->editUrlOptions(); $veParams = $skin->editUrlOptions();
unset( $veParams['action'] ); // Remove action=edit unset( $veParams['action'] ); // Remove action=edit
$veParams['veaction'] = 'edit'; // Set veaction=edit $veParams['veaction'] = 'edit'; // Set veaction=edit
$veTabMessage = $wgVisualEditorTabMessages[$action]; $veTabMessage = $tabMessages[$action];
$veTabText = $veTabMessage === null ? $data['text'] : $veTabText = $veTabMessage === null ? $data['text'] :
wfMessage( $veTabMessage )->setContext( $skin->getContext() )->text(); wfMessage( $veTabMessage )->setContext( $skin->getContext() )->text();
$veTab = array( $veTab = array(
@ -104,9 +107,9 @@ class VisualEditorHooks {
WikiPage::factory( $title ) instanceof WikiFilePage && WikiPage::factory( $title ) instanceof WikiFilePage &&
!WikiPage::factory( $title )->isLocal() !WikiPage::factory( $title )->isLocal()
) { ) {
$editTabMessage = $wgVisualEditorTabMessages[$action . 'localdescriptionsource']; $editTabMessage = $tabMessages[$action . 'localdescriptionsource'];
} else { } else {
$editTabMessage = $wgVisualEditorTabMessages[$action . 'source']; $editTabMessage = $tabMessages[$action . 'source'];
} }
if ( $editTabMessage !== null ) { if ( $editTabMessage !== null ) {
@ -114,7 +117,7 @@ class VisualEditorHooks {
} }
// Inject the VE tab before or after the edit tab // Inject the VE tab before or after the edit tab
if ( $wgVisualEditorTabPosition === 'before' ) { if ( $config->get( 'VisualEditorTabPosition' ) === 'before' ) {
$editTab['class'] .= ' collapsible'; $editTab['class'] .= ' collapsible';
$newViews['ve-edit'] = $veTab; $newViews['ve-edit'] = $veTab;
$newViews['edit'] = $editTab; $newViews['edit'] = $editTab;
@ -206,11 +209,12 @@ class VisualEditorHooks {
return; return;
} }
global $wgVisualEditorTabMessages, $wgVisualEditorTabPosition; $config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
$veEditSection = $wgVisualEditorTabMessages['editsection'] !== null ? $tabMessages = $config->get( 'VisualEditorTabMessages' );
$wgVisualEditorTabMessages['editsection'] : 'editsection'; $veEditSection = $tabMessages['editsection'] !== null ?
$sourceEditSection = $wgVisualEditorTabMessages['editsectionsource'] !== null ? $tabMessages['editsection'] : 'editsection';
$wgVisualEditorTabMessages['editsectionsource'] : 'editsection'; $sourceEditSection = $tabMessages['editsectionsource'] !== null ?
$tabMessages['editsectionsource'] : 'editsection';
// Code mostly duplicated from Skin::doEditSectionLink() :( // Code mostly duplicated from Skin::doEditSectionLink() :(
$attribs = array(); $attribs = array();
@ -231,7 +235,7 @@ class VisualEditorHooks {
array( 'noclasses', 'known' ) array( 'noclasses', 'known' )
); );
$veFirst = $wgVisualEditorTabPosition === 'before'; $veFirst = $config->get( 'VisualEditorTabPosition' ) === 'before';
$result = '<span class="mw-editsection">' $result = '<span class="mw-editsection">'
. '<span class="mw-editsection-bracket">[</span>' . '<span class="mw-editsection-bracket">[</span>'
. ( $veFirst ? $veLink : $sourceLink ) . ( $veFirst ? $veLink : $sourceLink )
@ -261,7 +265,8 @@ class VisualEditorHooks {
} }
public static function onGetPreferences( User $user, array &$preferences ) { public static function onGetPreferences( User $user, array &$preferences ) {
global $wgLang, $wgVisualEditorNamespaces; global $wgLang;
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
if ( !array_key_exists( 'visualeditor-enable', $preferences ) ) { if ( !array_key_exists( 'visualeditor-enable', $preferences ) ) {
$preferences['visualeditor-enable'] = array( $preferences['visualeditor-enable'] = array(
'type' => 'toggle', 'type' => 'toggle',
@ -269,7 +274,7 @@ class VisualEditorHooks {
'visualeditor-preference-enable', 'visualeditor-preference-enable',
$wgLang->commaList( array_map( $wgLang->commaList( array_map(
array( 'self', 'convertNs' ), array( 'self', 'convertNs' ),
$wgVisualEditorNamespaces $config->get( 'VisualEditorNamespaces' )
) ) ) )
), ),
'section' => 'editing/editor' 'section' => 'editing/editor'
@ -287,10 +292,10 @@ class VisualEditorHooks {
} }
public static function onGetBetaPreferences( User $user, array &$preferences ) { public static function onGetBetaPreferences( User $user, array &$preferences ) {
global $wgExtensionAssetsPath, $wgVisualEditorSupportedSkins, $wgVisualEditorBrowserBlacklist; $coreConfig = RequestContext::getMain()->getConfig();
$iconpath = $coreConfig->get( 'ExtensionAssetsPath' ) . "/VisualEditor";
$iconpath = $wgExtensionAssetsPath . "/VisualEditor";
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
$preferences['visualeditor-enable'] = array( $preferences['visualeditor-enable'] = array(
'version' => '1.0', 'version' => '1.0',
'label-message' => 'visualeditor-preference-core-label', 'label-message' => 'visualeditor-preference-core-label',
@ -303,8 +308,8 @@ class VisualEditorHooks {
'discussion-message' => 'visualeditor-preference-core-discussion-link', 'discussion-message' => 'visualeditor-preference-core-discussion-link',
'requirements' => array( 'requirements' => array(
'javascript' => true, 'javascript' => true,
'blacklist' => $wgVisualEditorBrowserBlacklist, 'blacklist' => $veConfig->get( 'VisualEditorBrowserBlacklist' ),
'skins' => $wgVisualEditorSupportedSkins, 'skins' => $veConfig->get( 'VisualEditorSupportedSkins' ),
) )
); );
@ -356,20 +361,18 @@ class VisualEditorHooks {
* Adds extra variables to the page config. * Adds extra variables to the page config.
*/ */
public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) { public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) {
global $wgStylePath, $wgSVGMaxSize, $wgNamespacesWithSubpages;
$pageLanguage = $out->getTitle()->getPageLanguage(); $pageLanguage = $out->getTitle()->getPageLanguage();
$vars['wgVisualEditor'] = array( $vars['wgVisualEditor'] = array(
'isPageWatched' => $out->getUser()->isWatched( $out->getTitle() ), 'isPageWatched' => $out->getUser()->isWatched( $out->getTitle() ),
// Same as in Linker.php // Same as in Linker.php
'magnifyClipIconURL' => $wgStylePath . 'magnifyClipIconURL' => $out->getConfig()->get( 'StylePath' ) .
'/common/images/magnify-clip' . '/common/images/magnify-clip' .
( $pageLanguage->isRTL() ? '-rtl' : '' ) . '.png', ( $pageLanguage->isRTL() ? '-rtl' : '' ) . '.png',
'pageLanguageCode' => $pageLanguage->getHtmlCode(), 'pageLanguageCode' => $pageLanguage->getHtmlCode(),
'pageLanguageDir' => $pageLanguage->getDir(), 'pageLanguageDir' => $pageLanguage->getDir(),
'svgMaxSize' => $wgSVGMaxSize, 'svgMaxSize' => $out->getConfig()->get( 'SVGMaxSize' ),
'namespacesWithSubpages' => $wgNamespacesWithSubpages 'namespacesWithSubpages' => $out->getConfig()->get( 'NamespacesWithSubpages' )
); );
return true; return true;
@ -379,40 +382,32 @@ class VisualEditorHooks {
* Adds extra variables to the global config * Adds extra variables to the global config
*/ */
public static function onResourceLoaderGetConfigVars( array &$vars ) { public static function onResourceLoaderGetConfigVars( array &$vars ) {
global $wgDefaultUserOptions, $coreConfig = RequestContext::getMain()->getConfig();
$wgThumbLimits, $defaultUserOptions = $coreConfig->get( 'DefaultUserOptions' );
$wgVisualEditorDisableForAnons, $thumbLimits = $coreConfig->get( 'ThumbLimits' );
$wgVisualEditorNamespaces, $veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
$wgVisualEditorPluginModules,
$wgVisualEditorTabPosition,
$wgVisualEditorTabMessages,
$wgVisualEditorBrowserBlacklist,
$wgVisualEditorSupportedSkins,
$wgVisualEditorShowBetaWelcome,
$wgVisualEditorEnableTocWidget,
$wgVisualEditorPreferenceModules;
$vars['wgVisualEditorConfig'] = array( $vars['wgVisualEditorConfig'] = array(
'disableForAnons' => $wgVisualEditorDisableForAnons, 'disableForAnons' => $veConfig->get( 'VisualEditorDisableForAnons' ),
'preferenceModules' => $wgVisualEditorPreferenceModules, 'preferenceModules' => $veConfig->get( 'VisualEditorPreferenceModules' ),
'namespaces' => $wgVisualEditorNamespaces, 'namespaces' => $veConfig->get( 'VisualEditorNamespaces' ),
'pluginModules' => $wgVisualEditorPluginModules, 'pluginModules' => $veConfig->get( 'VisualEditorPluginModules' ),
'defaultUserOptions' => array( 'defaultUserOptions' => array(
'betatempdisable' => $wgDefaultUserOptions['visualeditor-betatempdisable'], 'betatempdisable' => $defaultUserOptions['visualeditor-betatempdisable'],
'enable' => $wgDefaultUserOptions['visualeditor-enable'], 'enable' => $defaultUserOptions['visualeditor-enable'],
'defaultthumbsize' => $wgThumbLimits[ $wgDefaultUserOptions['thumbsize'] ] 'defaultthumbsize' => $thumbLimits[ $defaultUserOptions['thumbsize'] ]
), ),
'blacklist' => $wgVisualEditorBrowserBlacklist, 'blacklist' => $veConfig->get( 'VisualEditorBrowserBlacklist' ),
'skins' => $wgVisualEditorSupportedSkins, 'skins' => $veConfig->get( 'VisualEditorSupportedSkins' ),
'tabPosition' => $wgVisualEditorTabPosition, 'tabPosition' => $veConfig->get( 'VisualEditorTabPosition' ),
'tabMessages' => $wgVisualEditorTabMessages, 'tabMessages' => $veConfig->get( 'VisualEditorTabMessages' ),
'showBetaWelcome' => $wgVisualEditorShowBetaWelcome, 'showBetaWelcome' => $veConfig->get( 'VisualEditorShowBetaWelcome' ),
'enableTocWidget' => $wgVisualEditorEnableTocWidget 'enableTocWidget' => $veConfig->get( 'VisualEditorEnableTocWidget' )
); );
foreach ( $wgVisualEditorPreferenceModules as $pref => $module ) { foreach ( $veConfig->get( 'VisualEditorPreferenceModules' ) as $pref => $module ) {
$vars['wgVisualEditorConfig']['defaultUserOptions'][$pref] = $vars['wgVisualEditorConfig']['defaultUserOptions'][$pref] =
$wgDefaultUserOptions[$pref]; $defaultUserOptions[$pref];
} }
return true; return true;
@ -426,17 +421,18 @@ class VisualEditorHooks {
* @returns boolean true * @returns boolean true
*/ */
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) { public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
global $wgResourceModules, $wgVisualEditorResourceTemplate; $resourceModules = $resourceLoader->getConfig()->get( 'ResourceModules' );
$veResourceTemplate = ConfigFactory::getDefaultInstance()
->makeConfig( 'visualeditor')->get( 'VisualEditorResourceTemplate' );
$libModules = array( $libModules = array(
'jquery.uls.data' => $wgVisualEditorResourceTemplate + array( 'jquery.uls.data' => $veResourceTemplate + array(
'scripts' => array( 'scripts' => array(
'lib/ve/lib/jquery.uls/src/jquery.uls.data.js', 'lib/ve/lib/jquery.uls/src/jquery.uls.data.js',
'lib/ve/lib/jquery.uls/src/jquery.uls.data.utils.js', 'lib/ve/lib/jquery.uls/src/jquery.uls.data.utils.js',
), ),
'targets' => array( 'desktop', 'mobile' ), 'targets' => array( 'desktop', 'mobile' ),
), ),
'jquery.i18n' => $wgVisualEditorResourceTemplate + array( 'jquery.i18n' => $veResourceTemplate + array(
'scripts' => array( 'scripts' => array(
'lib/ve/lib/jquery.i18n/src/jquery.i18n.js', 'lib/ve/lib/jquery.i18n/src/jquery.i18n.js',
'lib/ve/lib/jquery.i18n/src/jquery.i18n.messagestore.js', 'lib/ve/lib/jquery.i18n/src/jquery.i18n.messagestore.js',
@ -468,7 +464,7 @@ class VisualEditorHooks {
$addModules = array(); $addModules = array();
foreach ( $libModules as $name => $data ) { foreach ( $libModules as $name => $data ) {
if ( !isset( $wgResourceModules[$name] ) && !$resourceLoader->getModule( $name ) ) { if ( !isset( $resourceModules[$name] ) && !$resourceLoader->getModule( $name ) ) {
$addModules[$name] = $data; $addModules[$name] = $data;
} }
} }

View file

@ -48,8 +48,28 @@ $wgMessagesDirs['VisualEditor'] = array(
); );
// Register API modules // Register API modules
$wgAPIModules['visualeditor'] = 'ApiVisualEditor'; $wgAPIModules['visualeditor'] = array(
$wgAPIModules['visualeditoredit'] = 'ApiVisualEditorEdit'; 'class' => 'ApiVisualEditor',
'factory' => 'wfVisualEditorApiFactory',
);
$wgAPIModules['visualeditoredit'] = array(
'class' => 'ApiVisualEditorEdit',
'factory' => 'wfVisualEditorApiFactory',
);
/**
* @param ApiMain $main
* @param string $name
* @return ApiVisualEditor|ApiVisualEditorEdit
*/
function wfVisualEditorApiFactory( $main, $name ) {
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
$class = $name === 'visualeditor' ? 'ApiVisualEditor' : 'ApiVisualEditorEdit';
return new $class( $main, $name, $config );
}
// Register Config instance
$wgConfigRegistry['visualeditor'] = 'GlobalVarConfig::newInstance';
// Register Hooks // Register Hooks
$wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onBeforePageDisplay'; $wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onBeforePageDisplay';

View file

@ -87,11 +87,11 @@ class VisualEditorDataModule extends ResourceLoaderModule {
); );
// Copyright warning (based on EditPage::getCopyrightWarning) // Copyright warning (based on EditPage::getCopyrightWarning)
global $wgRightsText; $rightsText = $this->config->get( 'RightsText' );
if ( $wgRightsText ) { if ( $rightsText ) {
$copywarnMsg = array( 'copyrightwarning', $copywarnMsg = array( 'copyrightwarning',
'[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]', '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]',
$wgRightsText ); $rightsText );
} else { } else {
$copywarnMsg = array( 'copyrightwarning2', $copywarnMsg = array( 'copyrightwarning2',
'[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]' ); '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]' );