2012-05-25 19:50:48 +00:00
|
|
|
<?php
|
2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor extension hooks
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
2012-07-19 00:11:26 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
2012-05-25 19:50:48 +00:00
|
|
|
|
|
|
|
class VisualEditorHooks {
|
2013-06-11 22:14:44 +00:00
|
|
|
public static function onSetup() {
|
2013-07-31 01:20:37 +00:00
|
|
|
// 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
|
|
|
|
// when additional dependencies are created and pushed into MediaWiki's
|
|
|
|
// core. The most direct effect of this is to avoid confusing any third
|
|
|
|
// parties who attempt to install VisualEditor onto non-alpha wikis, as
|
2014-06-03 20:25:56 +00:00
|
|
|
// 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.
|
2015-03-13 00:51:54 +00:00
|
|
|
wfUseMW( '1.25wmf24' );
|
2013-06-11 22:14:44 +00:00
|
|
|
}
|
|
|
|
|
2015-01-27 05:47:31 +00:00
|
|
|
/**
|
|
|
|
* Function called by extension registration once all extensions have been registered
|
|
|
|
*/
|
|
|
|
public static function onRegistration() {
|
|
|
|
global $wgVisualEditorNamespaces, $wgContentNamespaces;
|
|
|
|
|
|
|
|
$wgVisualEditorNamespaces = array_merge( $wgContentNamespaces, array( NS_USER ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function VisualEditorApiFactory( $main, $name ) {
|
|
|
|
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
|
|
|
|
$class = $name === 'visualeditor' ? 'ApiVisualEditor' : 'ApiVisualEditorEdit';
|
|
|
|
return new $class( $main, $name, $config );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-25 19:50:48 +00:00
|
|
|
/**
|
2013-08-01 19:14:41 +00:00
|
|
|
* Adds VisualEditor JS to the output.
|
2012-06-11 06:54:41 +00:00
|
|
|
*
|
|
|
|
* This is attached to the MediaWiki 'BeforePageDisplay' hook.
|
2012-05-25 19:50:48 +00:00
|
|
|
*
|
2014-09-25 05:06:57 +00:00
|
|
|
* @param OutputPage $output
|
|
|
|
* @param Skin $skin
|
2014-08-13 05:57:21 +00:00
|
|
|
* @return boolean
|
2012-05-25 19:50:48 +00:00
|
|
|
*/
|
2014-09-25 05:06:57 +00:00
|
|
|
public static function onBeforePageDisplay( OutputPage &$output, Skin &$skin ) {
|
Load RL modules in one load.php request, rather than in two stages
This introduces TargetLoader, which manages plugins and RL modules
in a slightly more generic fashion so that Targets themselves don't
have to. This allows us to load all RL modules in one load.php
request, rather than first loading ViewPageTarget which then
loads the other modules.
TargetLoader loads in the bottom queue, so it will be loaded
as part of the main load.php request, but in VPT.init.js we
still have to wait for it with using() because it might not
have arrived yet. This also degrades gracefully on cached pages
where TargetLoader isn't in the bottom queue: it'll be loaded
as a separate request instead, which is suboptimal but no
worse that what we were doing before.
Right now TargetLoader is small enough that it could also be in
the top queue, but in the future we want to add things like
the action=visualeditor API request to it, and mw.Api is
relatively big.
Note: this also makes a breaking change to the plugin API:
plugin callbacks no longer receive the target instance
as a parameter, as they're now executed before the target
has been constructed rather than after. In the long term,
if we want to give plugins access to the target instance,
we could give them the target promise somehow. For now,
I've killed this feature because nothing used it and
the change from a direct object reference to a promise
would have been a breaking change anyway.
Also fixed incorrect documentation index for ve.init.mw.ViewPageTarget.init.
Bug: T53569
Change-Id: Ibfa6abbeaf872ae2aadc6ed9d5beba7473ea441a
2015-02-26 01:22:44 +00:00
|
|
|
$output->addModules( array(
|
|
|
|
'ext.visualEditor.viewPageTarget.init',
|
|
|
|
'ext.visualEditor.targetLoader'
|
|
|
|
) );
|
2013-08-01 19:14:41 +00:00
|
|
|
$output->addModuleStyles( array( 'ext.visualEditor.viewPageTarget.noscript' ) );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-06 19:02:55 +00:00
|
|
|
/**
|
|
|
|
* Convert the content model of messages that are actually JSON to JSON.
|
|
|
|
* This only affects validation and UI when saving and editing, not
|
|
|
|
* loading the content.
|
|
|
|
*
|
|
|
|
* @param Title $title
|
|
|
|
* @param string $model
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function onContentHandlerDefaultModelFor( Title $title, &$model ) {
|
|
|
|
$messages = array(
|
2015-01-16 22:04:10 +00:00
|
|
|
'Visualeditor-cite-tool-definition.json',
|
2015-03-30 01:47:43 +00:00
|
|
|
'Visualeditor-quick-access-characters.json'
|
2014-10-06 19:02:55 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if ( $title->inNamespace( NS_MEDIAWIKI ) && in_array( $title->getText(), $messages ) ) {
|
|
|
|
$model = CONTENT_MODEL_JSON;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-01 19:14:41 +00:00
|
|
|
/**
|
|
|
|
* Changes the Edit tab and adds the VisualEditor tab.
|
|
|
|
*
|
|
|
|
* This is attached to the MediaWiki 'SkinTemplateNavigation' hook.
|
|
|
|
*
|
|
|
|
* @param SkinTemplate $skin
|
|
|
|
* @param array $links Navigation links
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2014-09-25 05:06:57 +00:00
|
|
|
public static function onSkinTemplateNavigation( SkinTemplate &$skin, array &$links ) {
|
2013-08-01 19:14:41 +00:00
|
|
|
// Only do this if the user has VE enabled
|
|
|
|
if (
|
|
|
|
!$skin->getUser()->getOption( 'visualeditor-enable' ) ||
|
|
|
|
$skin->getUser()->getOption( 'visualeditor-betatempdisable' )
|
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-13 08:15:42 +00:00
|
|
|
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
|
|
|
|
|
2013-08-01 19:14:41 +00:00
|
|
|
if ( !isset( $links['views']['edit'] ) ) {
|
|
|
|
// There's no edit link, nothing to do
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
$title = $skin->getRelevantTitle();
|
2014-04-10 18:57:17 +00:00
|
|
|
if ( defined( 'EP_NS' ) && $title->inNamespace( EP_NS ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
2014-08-13 08:15:42 +00:00
|
|
|
$tabMessages = $config->get( 'VisualEditorTabMessages' );
|
2013-08-01 19:14:41 +00:00
|
|
|
// 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
|
|
|
|
// us to splice into the middle of an associative array.
|
|
|
|
$newViews = array();
|
|
|
|
foreach ( $links['views'] as $action => $data ) {
|
|
|
|
if ( $action === 'edit' ) {
|
|
|
|
// Build the VisualEditor tab
|
|
|
|
$existing = $title->exists() || (
|
2014-09-25 05:06:57 +00:00
|
|
|
$title->inNamespace( NS_MEDIAWIKI ) &&
|
2013-08-01 19:14:41 +00:00
|
|
|
$title->getDefaultMessageText() !== false
|
|
|
|
);
|
2014-04-08 23:07:33 +00:00
|
|
|
$action = $existing ? 'edit' : 'create';
|
2013-08-01 19:14:41 +00:00
|
|
|
$veParams = $skin->editUrlOptions();
|
|
|
|
unset( $veParams['action'] ); // Remove action=edit
|
|
|
|
$veParams['veaction'] = 'edit'; // Set veaction=edit
|
2014-08-13 08:15:42 +00:00
|
|
|
$veTabMessage = $tabMessages[$action];
|
2013-08-01 19:14:41 +00:00
|
|
|
$veTabText = $veTabMessage === null ? $data['text'] :
|
2014-09-25 05:06:57 +00:00
|
|
|
$skin->msg( $veTabMessage )->text();
|
2013-08-01 19:14:41 +00:00
|
|
|
$veTab = array(
|
|
|
|
'href' => $title->getLocalURL( $veParams ),
|
|
|
|
'text' => $veTabText,
|
|
|
|
'primary' => true,
|
|
|
|
'class' => '',
|
|
|
|
);
|
|
|
|
|
|
|
|
// Alter the edit tab
|
|
|
|
$editTab = $data;
|
2014-04-08 23:07:33 +00:00
|
|
|
if (
|
|
|
|
$title->inNamespace( NS_FILE ) &&
|
|
|
|
WikiPage::factory( $title ) instanceof WikiFilePage &&
|
|
|
|
!WikiPage::factory( $title )->isLocal()
|
|
|
|
) {
|
2014-08-13 08:15:42 +00:00
|
|
|
$editTabMessage = $tabMessages[$action . 'localdescriptionsource'];
|
2014-04-08 23:07:33 +00:00
|
|
|
} else {
|
2014-08-13 08:15:42 +00:00
|
|
|
$editTabMessage = $tabMessages[$action . 'source'];
|
2014-04-08 23:07:33 +00:00
|
|
|
}
|
|
|
|
|
2013-08-01 19:14:41 +00:00
|
|
|
if ( $editTabMessage !== null ) {
|
2014-09-25 05:06:57 +00:00
|
|
|
$editTab['text'] = $skin->msg( $editTabMessage )->text();
|
2013-08-01 19:14:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Inject the VE tab before or after the edit tab
|
2014-08-13 08:15:42 +00:00
|
|
|
if ( $config->get( 'VisualEditorTabPosition' ) === 'before' ) {
|
2014-04-30 13:01:59 +00:00
|
|
|
$editTab['class'] .= ' collapsible';
|
2013-08-01 19:14:41 +00:00
|
|
|
$newViews['ve-edit'] = $veTab;
|
|
|
|
$newViews['edit'] = $editTab;
|
|
|
|
} else {
|
2014-04-30 13:01:59 +00:00
|
|
|
$veTab['class'] .= ' collapsible';
|
2013-08-01 19:14:41 +00:00
|
|
|
$newViews['edit'] = $editTab;
|
|
|
|
$newViews['ve-edit'] = $veTab;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Just pass through
|
|
|
|
$newViews[$action] = $data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$links['views'] = $newViews;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-16 15:17:44 +00:00
|
|
|
/**
|
|
|
|
* Called when the normal wikitext editor is shown.
|
2014-03-08 17:49:53 +00:00
|
|
|
* Inserts a 'veswitched' hidden field if requested by the client
|
2014-02-16 15:17:44 +00:00
|
|
|
*
|
|
|
|
* @param $editPage EditPage
|
|
|
|
* @param $output OutputPage
|
2014-08-17 19:43:56 +00:00
|
|
|
* @return boolean true
|
2014-02-16 15:17:44 +00:00
|
|
|
*/
|
|
|
|
public static function onEditPageShowEditFormFields( EditPage $editPage, OutputPage $output ) {
|
2014-08-13 05:54:51 +00:00
|
|
|
$request = $output->getRequest();
|
2014-03-08 17:49:53 +00:00
|
|
|
if ( $request->getBool( 'veswitched' ) ) {
|
|
|
|
$output->addHTML( Xml::input( 'veswitched', false, '1', array( 'type' => 'hidden' ) ) );
|
2014-02-16 15:17:44 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an edit is saved
|
|
|
|
* Adds 'visualeditor-switched' tag to the edit if requested
|
|
|
|
*
|
|
|
|
* @param $article WikiPage
|
|
|
|
* @param $user User
|
|
|
|
* @param $content Content
|
|
|
|
* @param $summary string
|
|
|
|
* @param $isMinor boolean
|
|
|
|
* @param $isWatch boolean
|
|
|
|
* @param $section int
|
|
|
|
* @param $flags int
|
2014-03-07 23:44:49 +00:00
|
|
|
* @param $revision Revision|null
|
2014-02-16 15:17:44 +00:00
|
|
|
* @param $status Status
|
|
|
|
* @param $baseRevId int|boolean
|
2014-08-17 19:43:56 +00:00
|
|
|
* @return boolean true
|
2014-02-16 15:17:44 +00:00
|
|
|
*/
|
|
|
|
public static function onPageContentSaveComplete(
|
|
|
|
$article, $user, $content, $summary, $isMinor, $isWatch,
|
|
|
|
$section, $flags, $revision, $status, $baseRevId
|
|
|
|
) {
|
|
|
|
$request = RequestContext::getMain()->getRequest();
|
2014-03-08 17:49:53 +00:00
|
|
|
if ( $request->getBool( 'veswitched' ) && $revision ) {
|
2014-02-16 15:17:44 +00:00
|
|
|
ChangeTags::addTags( 'visualeditor-switched', null, $revision->getId() );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-01 19:14:41 +00:00
|
|
|
/**
|
|
|
|
* Changes the section edit links to add a VE edit link.
|
|
|
|
*
|
2015-02-19 18:09:34 +00:00
|
|
|
* This is attached to the MediaWiki 'SkinEditSectionLinks' hook.
|
2013-08-01 19:14:41 +00:00
|
|
|
*
|
|
|
|
* @param $skin Skin
|
|
|
|
* @param $title Title
|
|
|
|
* @param $section string
|
|
|
|
* @param $tooltip string
|
2015-02-19 18:09:34 +00:00
|
|
|
* @param $result array
|
2013-08-01 19:14:41 +00:00
|
|
|
* @param $lang Language
|
2014-08-17 19:43:56 +00:00
|
|
|
* @return bool true
|
2013-08-01 19:14:41 +00:00
|
|
|
*/
|
2015-02-19 18:09:34 +00:00
|
|
|
public static function onSkinEditSectionLinks( Skin $skin, Title $title, $section,
|
2014-09-25 05:06:57 +00:00
|
|
|
$tooltip, &$result, $lang
|
|
|
|
) {
|
2013-08-01 19:14:41 +00:00
|
|
|
// Only do this if the user has VE enabled
|
2013-09-16 21:12:50 +00:00
|
|
|
// (and we're not in parserTests)
|
2014-04-28 15:07:03 +00:00
|
|
|
// (and we're not on a foreign file description page)
|
2013-08-01 19:14:41 +00:00
|
|
|
if (
|
2013-09-16 21:12:50 +00:00
|
|
|
isset( $GLOBALS[ 'wgVisualEditorInParserTests' ] ) ||
|
2013-08-01 19:14:41 +00:00
|
|
|
!$skin->getUser()->getOption( 'visualeditor-enable' ) ||
|
2014-04-28 15:07:03 +00:00
|
|
|
$skin->getUser()->getOption( 'visualeditor-betatempdisable' ) ||
|
|
|
|
(
|
|
|
|
$title->inNamespace( NS_FILE ) &&
|
|
|
|
WikiPage::factory( $title ) instanceof WikiFilePage &&
|
|
|
|
!WikiPage::factory( $title )->isLocal()
|
|
|
|
)
|
2013-08-01 19:14:41 +00:00
|
|
|
) {
|
2014-09-25 05:06:57 +00:00
|
|
|
return true;
|
2013-08-01 19:14:41 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 08:15:42 +00:00
|
|
|
$config = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
|
|
|
|
$tabMessages = $config->get( 'VisualEditorTabMessages' );
|
|
|
|
$veEditSection = $tabMessages['editsection'] !== null ?
|
|
|
|
$tabMessages['editsection'] : 'editsection';
|
|
|
|
$sourceEditSection = $tabMessages['editsectionsource'] !== null ?
|
|
|
|
$tabMessages['editsectionsource'] : 'editsection';
|
2013-08-01 19:14:41 +00:00
|
|
|
|
2015-02-19 18:09:34 +00:00
|
|
|
$result['editsection']['text'] = $skin->msg( $sourceEditSection )->inLanguage( $lang )->text();
|
|
|
|
|
|
|
|
$veLink = array(
|
|
|
|
'text' => $skin->msg( $veEditSection )->inLanguage( $lang )->text(),
|
|
|
|
'targetTitle' => $title,
|
|
|
|
'attribs' => $result['editsection']['attribs'] + array(
|
|
|
|
'class' => 'mw-editsection-visualeditor'
|
|
|
|
),
|
|
|
|
'query' => array( 'veaction' => 'edit', 'vesection' => $section ),
|
|
|
|
'options' => array( 'noclasses', 'known' )
|
2013-08-01 19:14:41 +00:00
|
|
|
);
|
|
|
|
|
2015-02-19 18:09:34 +00:00
|
|
|
$result['veeditsection'] = $veLink;
|
|
|
|
if ( $config->get( 'VisualEditorTabPosition' ) === 'before' ) {
|
|
|
|
krsort( $result );
|
|
|
|
// TODO: This will probably cause weird ordering if any other extensions added something already.
|
|
|
|
// ... wfArrayInsertBefore?
|
|
|
|
}
|
2013-06-26 17:23:56 +00:00
|
|
|
|
2012-05-25 19:50:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-26 06:31:32 +00:00
|
|
|
/**
|
|
|
|
* Convert a namespace index to the local text for display to the user.
|
|
|
|
*
|
|
|
|
* @param $nsIndex int
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private static function convertNs( $nsIndex ) {
|
|
|
|
global $wgLang;
|
|
|
|
if ( $nsIndex ) {
|
|
|
|
return $wgLang->convertNamespace( $nsIndex );
|
|
|
|
} else {
|
|
|
|
return wfMessage( 'blanknamespace' )->text();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-13 05:57:21 +00:00
|
|
|
public static function onGetPreferences( User $user, array &$preferences ) {
|
2014-08-13 08:15:42 +00:00
|
|
|
global $wgLang;
|
2014-09-20 17:49:37 +00:00
|
|
|
if ( !class_exists( 'BetaFeatures' ) ) {
|
2014-09-16 17:35:57 +00:00
|
|
|
$namespaces = ConfigFactory::getDefaultInstance()
|
|
|
|
->makeConfig( 'visualeditor' )
|
|
|
|
->get( 'VisualEditorNamespaces' );
|
|
|
|
|
2013-09-30 16:18:46 +00:00
|
|
|
$preferences['visualeditor-enable'] = array(
|
|
|
|
'type' => 'toggle',
|
2014-04-26 06:31:32 +00:00
|
|
|
'label-message' => array(
|
|
|
|
'visualeditor-preference-enable',
|
|
|
|
$wgLang->commaList( array_map(
|
|
|
|
array( 'self', 'convertNs' ),
|
2014-09-16 17:35:57 +00:00
|
|
|
$namespaces
|
|
|
|
) ),
|
|
|
|
count( $namespaces )
|
2014-04-26 06:31:32 +00:00
|
|
|
),
|
2014-04-07 09:42:41 +00:00
|
|
|
'section' => 'editing/editor'
|
2013-09-30 16:18:46 +00:00
|
|
|
);
|
|
|
|
}
|
2013-07-24 01:11:56 +00:00
|
|
|
$preferences['visualeditor-betatempdisable'] = array(
|
|
|
|
'type' => 'toggle',
|
|
|
|
'label-message' => 'visualeditor-preference-betatempdisable',
|
2014-04-06 23:53:25 +00:00
|
|
|
'section' => 'editing/editor'
|
2013-07-24 01:11:56 +00:00
|
|
|
);
|
2014-05-10 19:58:02 +00:00
|
|
|
$preferences['visualeditor-hidebetawelcome'] = array(
|
|
|
|
'type' => 'api'
|
|
|
|
);
|
2012-11-05 20:46:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-13 05:57:21 +00:00
|
|
|
public static function onGetBetaPreferences( User $user, array &$preferences ) {
|
2014-08-13 08:15:42 +00:00
|
|
|
$coreConfig = RequestContext::getMain()->getConfig();
|
|
|
|
$iconpath = $coreConfig->get( 'ExtensionAssetsPath' ) . "/VisualEditor";
|
2013-11-08 16:33:53 +00:00
|
|
|
|
2014-08-13 08:15:42 +00:00
|
|
|
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
|
2013-09-30 16:18:46 +00:00
|
|
|
$preferences['visualeditor-enable'] = array(
|
|
|
|
'version' => '1.0',
|
|
|
|
'label-message' => 'visualeditor-preference-core-label',
|
|
|
|
'desc-message' => 'visualeditor-preference-core-description',
|
2014-03-22 20:43:28 +00:00
|
|
|
'screenshot' => array(
|
|
|
|
'ltr' => "$iconpath/betafeatures-icon-VisualEditor-ltr.svg",
|
|
|
|
'rtl' => "$iconpath/betafeatures-icon-VisualEditor-rtl.svg",
|
|
|
|
),
|
2013-10-30 20:57:05 +00:00
|
|
|
'info-message' => 'visualeditor-preference-core-info-link',
|
|
|
|
'discussion-message' => 'visualeditor-preference-core-discussion-link',
|
2013-10-10 12:33:49 +00:00
|
|
|
'requirements' => array(
|
|
|
|
'javascript' => true,
|
2014-08-13 08:15:42 +00:00
|
|
|
'blacklist' => $veConfig->get( 'VisualEditorBrowserBlacklist' ),
|
|
|
|
'skins' => $veConfig->get( 'VisualEditorSupportedSkins' ),
|
2013-10-10 12:33:49 +00:00
|
|
|
)
|
2013-09-30 16:18:46 +00:00
|
|
|
);
|
|
|
|
|
2013-10-21 23:06:10 +00:00
|
|
|
/* Disabling Beta Features option for generic content for now
|
|
|
|
$preferences['visualeditor-enable-mwalienextension'] = array(
|
|
|
|
'version' => '1.0',
|
|
|
|
'label-message' => 'visualeditor-preference-mwalienextension-label',
|
|
|
|
'desc-message' => 'visualeditor-preference-mwalienextension-description',
|
2014-03-22 20:43:28 +00:00
|
|
|
'screenshot' => array(
|
|
|
|
'ltr' => "$iconpath/betafeatures-icon-VisualEditor-alien-ltr.svg",
|
|
|
|
'rtl' => "$iconpath/betafeatures-icon-VisualEditor-alien-rtl.svg",
|
|
|
|
),
|
2013-10-30 20:57:05 +00:00
|
|
|
'info-message' => 'visualeditor-preference-mwalienextension-info-link',
|
|
|
|
'discussion-message' => 'visualeditor-preference-mwalienextension-discussion-link',
|
2013-10-21 23:06:10 +00:00
|
|
|
'requirements' => array(
|
|
|
|
'betafeatures' => array(
|
|
|
|
'visualeditor-enable',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
*/
|
2013-08-12 05:50:04 +00:00
|
|
|
}
|
|
|
|
|
2015-01-29 04:02:37 +00:00
|
|
|
/**
|
|
|
|
* Implements the ListDefinedTags and ChangeTagsListActive hooks, to populate
|
|
|
|
* core Special:Tags with the change tags in use by VisualEditor.
|
|
|
|
*
|
|
|
|
* @param array $tags
|
|
|
|
* @return bool true
|
|
|
|
*/
|
2012-11-22 02:26:29 +00:00
|
|
|
public static function onListDefinedTags( &$tags ) {
|
|
|
|
$tags[] = 'visualeditor';
|
2015-02-18 01:14:34 +00:00
|
|
|
$tags[] = 'visualeditor-needcheck'; // No longer in active use
|
2014-02-16 15:17:44 +00:00
|
|
|
$tags[] = 'visualeditor-switched';
|
2012-11-22 02:26:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-25 19:50:48 +00:00
|
|
|
/**
|
2012-06-11 06:54:41 +00:00
|
|
|
* Adds extra variables to the page config.
|
2012-05-25 19:50:48 +00:00
|
|
|
*/
|
2012-12-06 05:57:53 +00:00
|
|
|
public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) {
|
2013-11-08 16:19:15 +00:00
|
|
|
$pageLanguage = $out->getTitle()->getPageLanguage();
|
|
|
|
|
2012-06-11 06:54:41 +00:00
|
|
|
$vars['wgVisualEditor'] = array(
|
2013-11-08 16:19:15 +00:00
|
|
|
'pageLanguageCode' => $pageLanguage->getHtmlCode(),
|
2014-01-26 22:59:30 +00:00
|
|
|
'pageLanguageDir' => $pageLanguage->getDir(),
|
2014-11-20 17:05:47 +00:00
|
|
|
'usePageImages' => defined( 'PAGE_IMAGES_INSTALLED' ),
|
|
|
|
'usePageDescriptions' => defined( 'WBC_VERSION' ),
|
2013-04-17 16:48:09 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds extra variables to the global config
|
|
|
|
*/
|
|
|
|
public static function onResourceLoaderGetConfigVars( array &$vars ) {
|
2014-08-13 08:15:42 +00:00
|
|
|
$coreConfig = RequestContext::getMain()->getConfig();
|
|
|
|
$defaultUserOptions = $coreConfig->get( 'DefaultUserOptions' );
|
|
|
|
$thumbLimits = $coreConfig->get( 'ThumbLimits' );
|
|
|
|
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
|
2013-06-03 22:23:45 +00:00
|
|
|
|
2013-04-17 16:48:09 +00:00
|
|
|
$vars['wgVisualEditorConfig'] = array(
|
2014-08-13 08:15:42 +00:00
|
|
|
'disableForAnons' => $veConfig->get( 'VisualEditorDisableForAnons' ),
|
|
|
|
'preferenceModules' => $veConfig->get( 'VisualEditorPreferenceModules' ),
|
|
|
|
'namespaces' => $veConfig->get( 'VisualEditorNamespaces' ),
|
2015-01-27 05:47:31 +00:00
|
|
|
'pluginModules' => array_merge(
|
|
|
|
ExtensionRegistry::getInstance()->getAttribute( 'VisualEditorPluginModules' ),
|
|
|
|
$veConfig->get( 'VisualEditorPluginModules' ) // @todo deprecate the global setting
|
|
|
|
),
|
2013-07-26 20:20:10 +00:00
|
|
|
'defaultUserOptions' => array(
|
2014-08-13 08:15:42 +00:00
|
|
|
'defaultthumbsize' => $thumbLimits[ $defaultUserOptions['thumbsize'] ]
|
2013-07-26 20:20:10 +00:00
|
|
|
),
|
2014-08-13 08:15:42 +00:00
|
|
|
'blacklist' => $veConfig->get( 'VisualEditorBrowserBlacklist' ),
|
|
|
|
'skins' => $veConfig->get( 'VisualEditorSupportedSkins' ),
|
|
|
|
'tabPosition' => $veConfig->get( 'VisualEditorTabPosition' ),
|
|
|
|
'tabMessages' => $veConfig->get( 'VisualEditorTabMessages' ),
|
|
|
|
'showBetaWelcome' => $veConfig->get( 'VisualEditorShowBetaWelcome' ),
|
2015-02-13 08:19:49 +00:00
|
|
|
'enableTocWidget' => $veConfig->get( 'VisualEditorEnableTocWidget' ),
|
|
|
|
'svgMaxSize' => $coreConfig->get( 'SVGMaxSize' ),
|
|
|
|
'namespacesWithSubpages' => $coreConfig->get( 'NamespacesWithSubpages' ),
|
2015-03-13 22:15:17 +00:00
|
|
|
'restbaseUrl' => $coreConfig->get( 'VisualEditorRestbaseURL' ),
|
2012-06-11 06:54:41 +00:00
|
|
|
);
|
2012-12-06 05:57:53 +00:00
|
|
|
|
2012-06-01 23:26:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-07-27 23:43:27 +00:00
|
|
|
|
2013-12-05 02:28:59 +00:00
|
|
|
/**
|
2014-07-22 23:49:06 +00:00
|
|
|
* Conditionally register the jquery.uls.data and jquery.i18n modules, in case they've already
|
2015-01-03 17:10:08 +00:00
|
|
|
* been registered by the UniversalLanguageSelector extension or the TemplateData extension.
|
2013-12-05 22:45:44 +00:00
|
|
|
*
|
2013-12-05 02:28:59 +00:00
|
|
|
* @param ResourceLoader $resourceLoader
|
2014-08-17 19:43:56 +00:00
|
|
|
* @return boolean true
|
2013-12-05 02:28:59 +00:00
|
|
|
*/
|
|
|
|
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
|
2014-08-13 08:15:42 +00:00
|
|
|
$resourceModules = $resourceLoader->getConfig()->get( 'ResourceModules' );
|
2015-01-27 05:47:31 +00:00
|
|
|
$veResourceTemplate = array(
|
|
|
|
'localBasePath' => __DIR__,
|
|
|
|
'remoteExtPath' => 'VisualEditor',
|
|
|
|
);
|
2014-02-14 22:31:15 +00:00
|
|
|
$libModules = array(
|
2014-08-13 08:15:42 +00:00
|
|
|
'jquery.uls.data' => $veResourceTemplate + array(
|
2013-12-05 22:45:44 +00:00
|
|
|
'scripts' => array(
|
2014-04-22 02:13:42 +00:00
|
|
|
'lib/ve/lib/jquery.uls/src/jquery.uls.data.js',
|
|
|
|
'lib/ve/lib/jquery.uls/src/jquery.uls.data.utils.js',
|
2013-12-05 22:45:44 +00:00
|
|
|
),
|
2014-06-13 17:52:24 +00:00
|
|
|
'targets' => array( 'desktop', 'mobile' ),
|
2014-02-14 22:31:15 +00:00
|
|
|
),
|
2014-08-13 08:15:42 +00:00
|
|
|
'jquery.i18n' => $veResourceTemplate + array(
|
2013-12-05 22:08:29 +00:00
|
|
|
'scripts' => array(
|
2013-12-19 23:07:19 +00:00
|
|
|
'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.parser.js',
|
|
|
|
'lib/ve/lib/jquery.i18n/src/jquery.i18n.emitter.js',
|
|
|
|
'lib/ve/lib/jquery.i18n/src/jquery.i18n.language.js',
|
2013-12-05 22:08:29 +00:00
|
|
|
),
|
|
|
|
'dependencies' => 'mediawiki.libs.pluralruleparser',
|
|
|
|
'languageScripts' => array(
|
2013-12-19 23:07:19 +00:00
|
|
|
'bs' => 'lib/ve/lib/jquery.i18n/src/languages/bs.js',
|
|
|
|
'dsb' => 'lib/ve/lib/jquery.i18n/src/languages/dsb.js',
|
|
|
|
'fi' => 'lib/ve/lib/jquery.i18n/src/languages/fi.js',
|
|
|
|
'ga' => 'lib/ve/lib/jquery.i18n/src/languages/ga.js',
|
|
|
|
'he' => 'lib/ve/lib/jquery.i18n/src/languages/he.js',
|
|
|
|
'hsb' => 'lib/ve/lib/jquery.i18n/src/languages/hsb.js',
|
|
|
|
'hu' => 'lib/ve/lib/jquery.i18n/src/languages/hu.js',
|
|
|
|
'hy' => 'lib/ve/lib/jquery.i18n/src/languages/hy.js',
|
|
|
|
'la' => 'lib/ve/lib/jquery.i18n/src/languages/la.js',
|
|
|
|
'ml' => 'lib/ve/lib/jquery.i18n/src/languages/ml.js',
|
|
|
|
'os' => 'lib/ve/lib/jquery.i18n/src/languages/os.js',
|
|
|
|
'ru' => 'lib/ve/lib/jquery.i18n/src/languages/ru.js',
|
|
|
|
'sl' => 'lib/ve/lib/jquery.i18n/src/languages/sl.js',
|
|
|
|
'uk' => 'lib/ve/lib/jquery.i18n/src/languages/uk.js',
|
2013-12-05 22:08:29 +00:00
|
|
|
),
|
2014-06-13 17:52:24 +00:00
|
|
|
'targets' => array( 'desktop', 'mobile' ),
|
2014-02-14 22:31:15 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
$addModules = array();
|
|
|
|
|
|
|
|
foreach ( $libModules as $name => $data ) {
|
2015-03-15 23:54:51 +00:00
|
|
|
if ( !isset( $resourceModules[$name] ) && !$resourceLoader->isModuleRegistered( $name ) ) {
|
2014-02-14 22:31:15 +00:00
|
|
|
$addModules[$name] = $data;
|
|
|
|
}
|
2013-12-05 22:08:29 +00:00
|
|
|
}
|
2013-12-09 23:00:09 +00:00
|
|
|
|
2014-02-14 22:31:15 +00:00
|
|
|
$resourceLoader->register( $addModules );
|
2013-12-05 02:28:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-05-30 11:00:36 +00:00
|
|
|
public static function onResourceLoaderTestModules(
|
|
|
|
array &$testModules,
|
|
|
|
ResourceLoader &$resourceLoader
|
|
|
|
) {
|
2012-07-27 23:43:27 +00:00
|
|
|
$testModules['qunit']['ext.visualEditor.test'] = array(
|
2013-09-30 12:11:49 +00:00
|
|
|
'styles' => array(
|
|
|
|
// jsdifflib
|
2013-12-19 23:07:19 +00:00
|
|
|
'lib/ve/lib/jsdifflib/diffview.css',
|
2013-09-30 12:11:49 +00:00
|
|
|
),
|
2012-07-27 23:43:27 +00:00
|
|
|
'scripts' => array(
|
2013-07-03 01:30:10 +00:00
|
|
|
// MW config preload
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/mw-preload.js',
|
2013-09-30 12:11:49 +00:00
|
|
|
// jsdifflib
|
2013-12-19 23:07:19 +00:00
|
|
|
'lib/ve/lib/jsdifflib/diffview.js',
|
|
|
|
'lib/ve/lib/jsdifflib/difflib.js',
|
2012-07-27 23:43:27 +00:00
|
|
|
// QUnit plugin
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ve.qunit.js',
|
2012-07-27 23:43:27 +00:00
|
|
|
// VisualEditor Tests
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ve.test.utils.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/ve.test.utils.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ve.test.js',
|
|
|
|
'lib/ve/tests/ve.Document.test.js',
|
|
|
|
'lib/ve/tests/ve.Node.test.js',
|
|
|
|
'lib/ve/tests/ve.BranchNode.test.js',
|
|
|
|
'lib/ve/tests/ve.LeafNode.test.js',
|
2012-07-27 23:43:27 +00:00
|
|
|
// VisualEditor DataModel Tests
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/dm/ve.dm.example.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.AnnotationSet.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.NodeFactory.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.Node.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.Converter.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.BranchNode.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.LeafNode.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.LinearData.test.js',
|
|
|
|
'lib/ve/tests/dm/nodes/ve.dm.TextNode.test.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/dm/nodes/ve.dm.MWTransclusionNode.test.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/dm/ve.dm.Document.test.js',
|
2014-09-18 23:56:11 +00:00
|
|
|
'modules/ve-mw/tests/dm/ve.dm.Document.test.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/dm/ve.dm.DocumentSynchronizer.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.IndexValueStore.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.InternalList.test.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/dm/ve.dm.InternalList.test.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/dm/ve.dm.Transaction.test.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/dm/ve.dm.Transaction.test.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/dm/ve.dm.TransactionProcessor.test.js',
|
2015-02-07 01:35:34 +00:00
|
|
|
'lib/ve/tests/dm/ve.dm.APIResultsQueue.test.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/dm/ve.dm.Surface.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.SurfaceFragment.test.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/dm/ve.dm.SurfaceFragment.test.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/dm/ve.dm.ModelRegistry.test.js',
|
|
|
|
'lib/ve/tests/dm/ve.dm.MetaList.test.js',
|
|
|
|
'lib/ve/tests/dm/lineardata/ve.dm.FlatLinearData.test.js',
|
|
|
|
'lib/ve/tests/dm/lineardata/ve.dm.ElementLinearData.test.js',
|
|
|
|
'lib/ve/tests/dm/lineardata/ve.dm.MetaLinearData.test.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/dm/ve.dm.mwExample.js',
|
|
|
|
'modules/ve-mw/tests/dm/ve.dm.Converter.test.js',
|
|
|
|
'modules/ve-mw/tests/dm/ve.dm.MWImageModel.test.js',
|
2012-07-27 23:43:27 +00:00
|
|
|
// VisualEditor ContentEditable Tests
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ce/ve.ce.test.js',
|
|
|
|
'lib/ve/tests/ce/ve.ce.Document.test.js',
|
|
|
|
'lib/ve/tests/ce/ve.ce.Surface.test.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/ce/ve.ce.Surface.test.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ce/ve.ce.NodeFactory.test.js',
|
|
|
|
'lib/ve/tests/ce/ve.ce.Node.test.js',
|
|
|
|
'lib/ve/tests/ce/ve.ce.BranchNode.test.js',
|
|
|
|
'lib/ve/tests/ce/ve.ce.ContentBranchNode.test.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/ce/ve.ce.ContentBranchNode.test.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ce/ve.ce.LeafNode.test.js',
|
|
|
|
'lib/ve/tests/ce/nodes/ve.ce.TextNode.test.js',
|
2013-05-14 23:45:42 +00:00
|
|
|
// VisualEditor Actions Tests
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ui/actions/ve.ui.AnnotationAction.test.js',
|
|
|
|
'lib/ve/tests/ui/actions/ve.ui.FormatAction.test.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/ui/actions/ve.ui.FormatAction.test.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ui/actions/ve.ui.IndentationAction.test.js',
|
|
|
|
'lib/ve/tests/ui/actions/ve.ui.ListAction.test.js',
|
2012-12-04 06:56:41 +00:00
|
|
|
// VisualEditor initialization Tests
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/init/ve.init.Platform.test.js',
|
2014-07-11 09:09:29 +00:00
|
|
|
'modules/ve-mw/tests/init/targets/ve.init.mw.ViewPageTarget.test.js',
|
2013-09-06 19:25:21 +00:00
|
|
|
// IME tests
|
2014-10-14 17:46:23 +00:00
|
|
|
// FIXME: these work in VE core but break in VE-MW, so not running most of them for now
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ce/ve.ce.TestRunner.js',
|
|
|
|
'lib/ve/tests/ce/ve.ce.imetests.test.js',
|
2014-10-14 17:46:23 +00:00
|
|
|
//'lib/ve/tests/ce/imetests/backspace-chromium-ubuntu-none.js',
|
|
|
|
//'lib/ve/tests/ce/imetests/backspace-firefox-ubuntu-none.js',
|
2014-11-26 01:03:51 +00:00
|
|
|
//'lib/ve/tests/ce/imetests/backspace-ie-win-none.js',
|
2014-10-14 17:46:23 +00:00
|
|
|
/*
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ce/imetests/input-chrome-win-chinese-traditional-handwriting.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-chrome-win-greek.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-chrome-win-welsh.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-chromium-ubuntu-ibus-chinese-cantonese.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-chromium-ubuntu-ibus-japanese-anthy-' .
|
2014-07-23 00:24:43 +00:00
|
|
|
'-hiraganaonly.js',
|
2014-08-14 21:16:47 +00:00
|
|
|
'lib/ve/tests/ce/imetests/input-chromium-ubuntu-ibus-korean-korean.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-chromium-ubuntu-ibus-malayalam-swanalekha.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-firefox-ubuntu-ibus-chinese-cantonese.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-firefox-ubuntu-ibus-japanese-anthy--hiraganaonly.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-firefox-ubuntu-ibus-korean-korean.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-firefox-ubuntu-ibus-malayalam.swanalekha.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-firefox-win-chinese-traditional-handwriting.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-firefox-win-greek.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-firefox-win-welsh.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-ie-win-chinese-traditional-handwriting.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-ie-win-greek.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-ie-win-korean.js',
|
|
|
|
'lib/ve/tests/ce/imetests/input-ie-win-welsh.js',
|
|
|
|
'lib/ve/tests/ce/imetests/leftarrow-chromium-ubuntu-none.js',
|
|
|
|
'lib/ve/tests/ce/imetests/leftarrow-firefox-ubuntu-none.js',
|
|
|
|
'lib/ve/tests/ce/imetests/leftarrow-ie-win-none.js',
|
2014-10-14 17:46:23 +00:00
|
|
|
*/
|
2012-07-27 23:43:27 +00:00
|
|
|
),
|
|
|
|
'dependencies' => array(
|
2014-08-14 21:16:47 +00:00
|
|
|
'unicodejs',
|
2013-05-14 23:45:42 +00:00
|
|
|
'ext.visualEditor.standalone',
|
2012-07-27 23:43:27 +00:00
|
|
|
'ext.visualEditor.core',
|
2014-02-26 00:50:20 +00:00
|
|
|
'ext.visualEditor.mwcore',
|
|
|
|
'ext.visualEditor.mwformatting',
|
|
|
|
'ext.visualEditor.mwlink',
|
|
|
|
'ext.visualEditor.mwgallery',
|
|
|
|
'ext.visualEditor.mwimage',
|
|
|
|
'ext.visualEditor.mwmeta',
|
|
|
|
'ext.visualEditor.mwreference',
|
|
|
|
'ext.visualEditor.mwtransclusion',
|
2013-04-16 17:31:17 +00:00
|
|
|
'ext.visualEditor.experimental',
|
2013-07-03 22:14:52 +00:00
|
|
|
'ext.visualEditor.viewPageTarget.init',
|
2012-07-27 23:43:27 +00:00
|
|
|
'ext.visualEditor.viewPageTarget',
|
|
|
|
),
|
2013-12-19 20:28:07 +00:00
|
|
|
'localBasePath' => __DIR__,
|
|
|
|
'remoteExtPath' => 'VisualEditor',
|
2012-07-27 23:43:27 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-09-16 21:12:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures that we know whether we're running inside a parser test.
|
|
|
|
*/
|
|
|
|
public static function onParserTestGlobals( array &$settings ) {
|
|
|
|
$settings['wgVisualEditorInParserTests'] = true;
|
|
|
|
}
|
2014-05-22 07:04:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Array $redirectParams Parameters preserved on special page redirects
|
|
|
|
* to wiki pages
|
|
|
|
* @return bool Always true
|
|
|
|
*/
|
|
|
|
public static function onRedirectSpecialArticleRedirectParams( &$redirectParams ) {
|
|
|
|
array_push( $redirectParams, 'veaction', 'vesection' );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2014-06-09 22:58:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the user has specified that they want to edit the page with VE, suppress any redirect.
|
|
|
|
* @param Title $title Title being used for request
|
|
|
|
* @param Article|null $article
|
|
|
|
* @param OutputPage $output
|
|
|
|
* @param User $user
|
|
|
|
* @param WebRequest $request
|
|
|
|
* @param MediaWiki $mediaWiki
|
|
|
|
* @return bool Always true
|
|
|
|
*/
|
|
|
|
public static function onBeforeInitialize(
|
|
|
|
Title $title, $article, OutputPage $output,
|
|
|
|
User $user, WebRequest $request, MediaWiki $mediaWiki
|
|
|
|
) {
|
|
|
|
if ( $request->getVal( 'veaction' ) === 'edit' ) {
|
|
|
|
$request->setVal( 'redirect', 'no' );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-04-17 21:01:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets user preference to enable the VisualEditor account if their new
|
|
|
|
* account's userID is even, if $wgVisualEditorEnableSplitTest is true.
|
|
|
|
*
|
|
|
|
* To be removed once no longer needed.
|
|
|
|
*/
|
|
|
|
public static function onAddNewAccount( $user, $byEmail ) {
|
|
|
|
if (
|
|
|
|
RequestContext::getMain()->getConfig()->get( 'VisualEditorEnableSplitTest' ) &&
|
|
|
|
$user->isLoggedin() &&
|
|
|
|
( ( $user->getId() % 2 ) === 0 )
|
|
|
|
) {
|
2015-04-22 00:32:34 +00:00
|
|
|
$user->setOption( 'visualeditor-enable', 1 );
|
2015-04-17 21:01:11 +00:00
|
|
|
$user->saveSettings();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-05-25 19:50:48 +00:00
|
|
|
}
|