From: Alex Monk Date: Sat, 14 Feb 2015 00:18:12 +0000 (+0000) Subject: Fix hook situation for Skin::doEditSectionLink X-Git-Tag: 1.31.0-rc.0~12364 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/modifier.php?a=commitdiff_plain;h=56c1c43dc5d916e1348596b4e8eb6fca83115688;p=lhc%2Fweb%2Fwiklou.git Fix hook situation for Skin::doEditSectionLink The old hook supplied a way to override the HTML used for the section link, but two extensions both trying to use it was obviously not going to work. Deprecate it in favour of a hook that goes around gathering info to build the initial HTML, then shoves it through the old hook for back-compat. So that WikiEditor can add in extra URL parameters as well as VE adding in it's own link. Bug: T88027 Change-Id: I5a7a23709805625bdefb69cd9379be0c95acd982 --- diff --git a/docs/hooks.txt b/docs/hooks.txt index f47890d8da..78ac2ffdb4 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1060,6 +1060,7 @@ $article: article (object) being viewed $oldid: oldid (int) being viewed 'DoEditSectionLink': Override the HTML generated for section edit links +* Deprecated in favour of SkinEditSectionLinks hook * $skin: Skin object rendering the UI $title: Title object for the title being linked to (may not be the same as the page title, if the section is included from a template) @@ -2423,6 +2424,23 @@ $type: 'normal' or 'history' for old/diff views &$forContent: overridable flag if copyright footer is shown in content language. This parameter is deprecated. +'SkinEditSectionLinks': Modify the section edit links +$skin: Skin object rendering the UI +$title: Title object for the title being linked to (may not be the same as + the page title, if the section is included from a template) +$section: The designation of the section being pointed to, to be included in + the link, like "§ion=$section" +$tooltip: The default tooltip. Escape before using. + By default, this is wrapped in the 'editsectionhint' message. +&$result: Array containing all link detail arrays. Each link detail array should contain + the following keys: + * targetTitle - Target Title object + * text - String for the text + * attribs - Array of attributes + * query - Array of query parameters to add to the URL + * options - Array of options for Linker::link +$lang: The language code to use for the link in the wfMessage function + 'SkinGetPoweredBy': TODO &$text: additional 'powered by' icons in HTML. Note: Modern skin does not use the MediaWiki icon but plain text instead. diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 244a278378..26ee164c21 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -1584,18 +1584,40 @@ abstract class Skin extends ContextSource { $attribs['title'] = wfMessage( 'editsectionhint' )->rawParams( $tooltip ) ->inLanguage( $lang )->text(); } - $link = Linker::link( $nt, wfMessage( 'editsection' )->inLanguage( $lang )->text(), - $attribs, - array( 'action' => 'edit', 'section' => $section ), - array( 'noclasses', 'known' ) + + $links = array( + 'editsection' => array( + 'text' => wfMessage( 'editsection' )->inLanguage( $lang )->text(), + 'targetTitle' => $nt, + 'attribs' => $attribs, + 'query' => array( 'action' => 'edit', 'section' => $section ), + 'options' => array( 'noclasses', 'known' ) + ) + ); + + Hooks::run( 'SkinEditSectionLinks', array( $this, $nt, $section, $tooltip, &$links, $lang ) ); + + $result = '['; + + $linksHtml = array(); + foreach ( $links as $k => $linkDetails ) { + $linksHtml[] = Linker::link( + $linkDetails['targetTitle'], + $linkDetails['text'], + $linkDetails['attribs'], + $linkDetails['query'], + $linkDetails['options'] + ); + } + + $result .= implode( + '' + . wfMessage( 'pipe-separator' )->inLanguage( $lang )->text() + . '', + $linksHtml ); - # Add the brackets and the span and run the hook. - $result = '' - . '[' - . $link - . ']' - . ''; + $result .= ']'; Hooks::run( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result, $lang ) ); return $result;