From 7dc4b5861589f2cef472195273c41a86083f69d4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 5 Sep 2014 16:12:04 +0200 Subject: [PATCH] Article: Don't hardcode tags on redirect page * Created a ResourceLoader module for redirect page styling. * Fixed a couple of bugs in Article code. Keeping two of the old files for a while because they might still be referenced by something (bug 69277 comment 11). Bug: 69277 Change-Id: I8fa565833545e41d0232101566da8c5ffa850e36 --- includes/content/WikitextContent.php | 1 + includes/page/Article.php | 60 +++++------------- resources/Resources.php | 4 ++ .../images/nextredirect-ltr.png | Bin .../images/nextredirect-rtl.png | Bin .../mediawiki.action/images/redirect-ltr.png | Bin 0 -> 128 bytes .../mediawiki.action/images/redirect-rtl.png | Bin 0 -> 132 bytes .../mediawiki.action.view.redirectPage.css | 53 ++++++++++++++++ resources/src/mediawiki.legacy/oldshared.css | 5 -- 9 files changed, 75 insertions(+), 48 deletions(-) rename skins/common/images/nextredirectltr.png => resources/src/mediawiki.action/images/nextredirect-ltr.png (100%) rename skins/common/images/nextredirectrtl.png => resources/src/mediawiki.action/images/nextredirect-rtl.png (100%) create mode 100644 resources/src/mediawiki.action/images/redirect-ltr.png create mode 100644 resources/src/mediawiki.action/images/redirect-rtl.png create mode 100644 resources/src/mediawiki.action/mediawiki.action.view.redirectPage.css diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php index d23f925d80..3ab6a6dbea 100644 --- a/includes/content/WikitextContent.php +++ b/includes/content/WikitextContent.php @@ -336,6 +336,7 @@ class WikitextContent extends TextContent { Article::getRedirectHeaderHtml( $title->getPageLanguage(), $chain, false ) . $output->getText() ); + $output->addModuleStyles( 'mediawiki.action.view.redirectPage' ); } } } diff --git a/includes/page/Article.php b/includes/page/Article.php index 71350ac783..9772d4f3f6 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1466,10 +1466,11 @@ class Article implements Page { */ public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) { $lang = $this->getTitle()->getPageLanguage(); + $out = $this->getContext()->getOutput(); if ( $appendSubtitle ) { - $out = $this->getContext()->getOutput(); $out->addSubtitle( wfMessage( 'redirectpagesub' )->parse() ); } + $out->addModuleStyles( 'mediawiki.action.view.redirectPage' ); return static::getRedirectHeaderHtml( $lang, $target, $forceKnown ); } @@ -1486,57 +1487,30 @@ class Article implements Page { * @return string Containing HTML with redirect link */ public static function getRedirectHeaderHtml( Language $lang, $target, $forceKnown = false ) { - global $wgStylePath; - if ( !is_array( $target ) ) { $target = array( $target ); } - $imageDir = $lang->getDir(); - - // the loop prepends the arrow image before the link, so the first case needs to be outside - - /** @var $title Title */ - $title = array_shift( $target ); - - if ( $forceKnown ) { - $link = Linker::linkKnown( $title, htmlspecialchars( $title->getFullText() ) ); - } else { - $link = Linker::link( $title, htmlspecialchars( $title->getFullText() ) ); - } - - $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png'; - $alt = $lang->isRTL() ? '←' : '→'; - - // Automatically append redirect=no to each link, since most of them are - // redirect pages themselves. - /** @var Title $rt */ - foreach ( $target as $rt ) { - $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) ); - if ( $forceKnown ) { - $link .= Linker::linkKnown( - $rt, - htmlspecialchars( $rt->getFullText(), - array(), - array( 'redirect' => 'no' ) - ) - ); - } else { - $link .= Linker::link( - $rt, - htmlspecialchars( $rt->getFullText() ), - array(), - array( 'redirect' => 'no' ) - ); - } + $html = '