/**
* @defgroup Watchlist Users watchlist handling
*/
-use MediaWiki\Linker\LinkTarget;
/**
* Implements Special:EditWatchlist
* @ingroup Watchlist
*/
+use MediaWiki\Linker\LinkRenderer;
+use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
/**
protected function outputSubtitle() {
$out = $this->getOutput();
$out->addSubtitle( $this->msg( 'watchlistfor2', $this->getUser()->getName() )
- ->rawParams( SpecialEditWatchlist::buildTools( null ) ) );
+ ->rawParams(
+ self::buildTools(
+ $this->getLanguage(),
+ $this->getLinkRenderer()
+ )
+ )
+ );
}
/**
* @param string $output
*/
private function showTitles( $titles, &$output ) {
- $talk = $this->msg( 'talkpagelinktext' )->escaped();
+ $talk = $this->msg( 'talkpagelinktext' )->text();
// Do a batch existence check
$batch = new LinkBatch();
if ( count( $titles ) >= 100 ) {
// Print out the list
$output .= "<ul>\n";
+ $linkRenderer = $this->getLinkRenderer();
foreach ( $titles as $title ) {
if ( !$title instanceof Title ) {
$title = Title::newFromText( $title );
if ( $title instanceof Title ) {
$output .= '<li>' .
- Linker::link( $title ) . ' ' .
+ $linkRenderer->makeLink( $title ) . ' ' .
$this->msg( 'parentheses' )->rawParams(
- Linker::link( $title->getTalkPage(), $talk )
+ $linkRenderer->makeLink( $title->getTalkPage(), $talk )
)->escaped() .
"</li>\n";
}
* @return string
*/
private function buildRemoveLine( $title ) {
- $link = Linker::link( $title );
+ $linkRenderer = $this->getLinkRenderer();
+ $link = $linkRenderer->makeLink( $title );
- $tools['talk'] = Linker::link(
+ $tools['talk'] = $linkRenderer->makeLink(
$title->getTalkPage(),
- $this->msg( 'talkpagelinktext' )->escaped()
+ $this->msg( 'talkpagelinktext' )->text()
);
if ( $title->exists() ) {
- $tools['history'] = Linker::linkKnown(
+ $tools['history'] = $linkRenderer->makeKnownLink(
$title,
- $this->msg( 'history_short' )->escaped(),
+ $this->msg( 'history_short' )->text(),
[],
[ 'action' => 'history' ]
);
}
if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
- $tools['contributions'] = Linker::linkKnown(
+ $tools['contributions'] = $linkRenderer->makeKnownLink(
SpecialPage::getTitleFor( 'Contributions', $title->getText() ),
- $this->msg( 'contributions' )->escaped()
+ $this->msg( 'contributions' )->text()
);
}
* Build a set of links for convenient navigation
* between watchlist viewing and editing modes
*
- * @param null $unused
+ * @param Language $lang
+ * @param LinkRenderer|null $linkRenderer
* @return string
*/
- public static function buildTools( $unused ) {
- global $wgLang;
+ public static function buildTools( $lang, LinkRenderer $linkRenderer = null ) {
+ if ( !$lang instanceof Language ) {
+ // back-compat where the first parameter was $unused
+ global $wgLang;
+ $lang = $wgLang;
+ }
+ if ( !$linkRenderer ) {
+ $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+ }
$tools = [];
$modes = [
foreach ( $modes as $mode => $arr ) {
// can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw'
- $tools[] = Linker::linkKnown(
+ $tools[] = $linkRenderer->makeKnownLink(
SpecialPage::getTitleFor( $arr[0], $arr[1] ),
- wfMessage( "watchlisttools-{$mode}" )->escaped()
+ wfMessage( "watchlisttools-{$mode}" )->text()
);
}
return Html::rawElement(
'span',
[ 'class' => 'mw-watchlist-toollinks' ],
- wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $tools ) )->escaped()
+ wfMessage( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped()
);
}
}