Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/191658
Change subject: Use new SkinEditSectionLinks hook instead of DoEditSectionLink
......................................................................
Use new SkinEditSectionLinks hook instead of DoEditSectionLink
So we don't overwrite stuff I'm doing in WikiEditor.
Depends on I5a7a2370
Bug: T88027
Change-Id: I83122694525fe124df914209e281c560ba9d12b7
---
M VisualEditor.hooks.php
M VisualEditor.php
2 files changed, 19 insertions(+), 32 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/58/191658/1
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 60834e9..128b60e3 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -17,7 +17,7 @@
// parties who attempt to install VisualEditor onto non-alpha
wikis, as
// 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.
- wfUseMW( '1.25wmf16' );
+ wfUseMW( '1.25wmf19' );
}
/**
@@ -209,17 +209,17 @@
/**
* Changes the section edit links to add a VE edit link.
*
- * This is attached to the MediaWiki 'DoEditSectionLink' hook.
+ * This is attached to the MediaWiki 'SkinEditSectionLinks' hook.
*
* @param $skin Skin
* @param $title Title
* @param $section string
* @param $tooltip string
- * @param $result string HTML
+ * @param $result array
* @param $lang Language
* @return bool true
*/
- public static function onDoEditSectionLink( Skin $skin, Title $title,
$section,
+ public static function onSkinEditSectionLinks( Skin $skin, Title
$title, $section,
$tooltip, &$result, $lang
) {
// Only do this if the user has VE enabled
@@ -245,35 +245,22 @@
$sourceEditSection = $tabMessages['editsectionsource'] !== null
?
$tabMessages['editsectionsource'] : 'editsection';
- // Code mostly duplicated from Skin::doEditSectionLink() :(
- $attribs = array();
- if ( !is_null( $tooltip ) ) {
- # Bug 25462: undo double-escaping.
- $tooltip = Sanitizer::decodeCharReferences( $tooltip );
- $attribs['title'] = $skin->msg( 'editsectionhint'
)->rawParams( $tooltip )
- ->inLanguage( $lang )->text();
- }
- $veLink = Linker::link( $title, $skin->msg( $veEditSection
)->inLanguage( $lang )->text(),
- $attribs + array( 'class' =>
'mw-editsection-visualeditor' ),
- array( 'veaction' => 'edit', 'vesection' => $section ),
- array( 'noclasses', 'known' )
- );
- $sourceLink = Linker::link( $title, $skin->msg(
$sourceEditSection )->inLanguage( $lang )->text(),
- $attribs,
- array( 'action' => 'edit', 'section' => $section ),
- array( 'noclasses', 'known' )
+ $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' )
);
- $veFirst = $config->get( 'VisualEditorTabPosition' ) ===
'before';
- $result = '<span class="mw-editsection">'
- . '<span class="mw-editsection-bracket">[</span>'
- . ( $veFirst ? $veLink : $sourceLink )
- . '<span class="mw-editsection-divider">'
- . $skin->msg( 'pipe-separator' )->inLanguage( $lang
)->text()
- . '</span>'
- . ( $veFirst ? $sourceLink : $veLink )
- . '<span class="mw-editsection-bracket">]</span>'
- . '</span>';
+ $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?
+ }
return true;
}
diff --git a/VisualEditor.php b/VisualEditor.php
index 46b3f30..7043b19 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -65,7 +65,7 @@
// Register Hooks
$wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onBeforePageDisplay';
$wgHooks['ContentHandlerDefaultModelFor'][] =
'VisualEditorHooks::onContentHandlerDefaultModelFor';
-$wgHooks['DoEditSectionLink'][] = 'VisualEditorHooks::onDoEditSectionLink';
+$wgHooks['SkinEditSectionLinks'][] =
'VisualEditorHooks::onSkinEditSectionLinks';
$wgHooks['GetBetaFeaturePreferences'][] =
'VisualEditorHooks::onGetBetaPreferences';
$wgHooks['GetPreferences'][] = 'VisualEditorHooks::onGetPreferences';
$wgHooks['ListDefinedTags'][] = 'VisualEditorHooks::onListDefinedTags';
--
To view, visit https://gerrit.wikimedia.org/r/191658
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I83122694525fe124df914209e281c560ba9d12b7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits