From 36ed0cd96c478292bacb9a01be47a15cd2e50301 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 8 Nov 2006 07:12:03 +0000 Subject: [PATCH] Reverting 17479/17480, breaks subclassing of Linker methods by skins. See my comment on bug 7405. --- RELEASE-NOTES | 1 - includes/AjaxFunctions.php | 10 +- includes/Article.php | 28 +- includes/CategoryPage.php | 20 +- includes/ChangesList.php | 60 +-- includes/Credits.php | 9 +- includes/DifferenceEngine.php | 27 +- includes/EditPage.php | 15 +- includes/ImageGallery.php | 35 +- includes/ImagePage.php | 60 ++- includes/Linker.php | 525 ++++++++++------------- includes/LogPage.php | 48 ++- includes/OutputPage.php | 25 +- includes/PageHistory.php | 23 +- includes/Pager.php | 13 +- includes/Parser.php | 73 ++-- includes/QueryPage.php | 19 +- includes/Skin.php | 102 +++-- includes/SkinTemplate.php | 4 +- includes/SpecialAllpages.php | 15 +- includes/SpecialAncientpages.php | 4 +- includes/SpecialBrokenRedirects.php | 10 +- includes/SpecialCategories.php | 4 +- includes/SpecialConfirmemail.php | 3 +- includes/SpecialContributions.php | 28 +- includes/SpecialDisambiguations.php | 15 +- includes/SpecialDoubleRedirects.php | 10 +- includes/SpecialImagelist.php | 6 +- includes/SpecialImport.php | 8 +- includes/SpecialIpblocklist.php | 16 +- includes/SpecialListredirects.php | 6 +- includes/SpecialListusers.php | 4 +- includes/SpecialLog.php | 10 +- includes/SpecialMIMEsearch.php | 8 +- includes/SpecialMostcategories.php | 6 +- includes/SpecialMostimages.php | 6 +- includes/SpecialMostlinked.php | 12 +- includes/SpecialMostlinkedcategories.php | 4 +- includes/SpecialMostrevisions.php | 6 +- includes/SpecialNewimages.php | 13 +- includes/SpecialNewpages.php | 11 +- includes/SpecialPopularpages.php | 4 +- includes/SpecialPreferences.php | 3 +- includes/SpecialPrefixindex.php | 10 +- includes/SpecialRecentchanges.php | 21 +- includes/SpecialRecentchangeslinked.php | 7 +- includes/SpecialRevisiondelete.php | 10 +- includes/SpecialSearch.php | 6 +- includes/SpecialShortpages.php | 8 +- includes/SpecialSpecialpages.php | 12 +- includes/SpecialStatistics.php | 5 +- includes/SpecialUncategorizedimages.php | 4 +- includes/SpecialUndelete.php | 23 +- includes/SpecialUnusedcategories.php | 4 +- includes/SpecialUnusedimages.php | 8 +- includes/SpecialUnusedtemplates.php | 6 +- includes/SpecialUnwatchedpages.php | 6 +- includes/SpecialUpload.php | 17 +- includes/SpecialUserlogin.php | 5 +- includes/SpecialWantedcategories.php | 6 +- includes/SpecialWantedpages.php | 15 +- includes/SpecialWatchlist.php | 26 +- includes/SpecialWhatlinkshere.php | 10 +- includes/User.php | 4 +- skins/CologneBlue.php | 42 +- skins/Nostalgia.php | 6 +- skins/Standard.php | 16 +- skins/disabled/HTMLDump.php | 2 +- skins/disabled/MonoBookCBT.php | 4 +- 69 files changed, 851 insertions(+), 741 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e66cafa4fa..8d62530801 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -153,7 +153,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN if they have selected that option in preferences. * (bug 5936) Show an 'm' to the left of the edit summary on diff pages for minor edits. * (bug 7820) Improve error reporting for uploads via URL. -* (bug 7405) Make Linker methods static. == Languages updated == diff --git a/includes/AjaxFunctions.php b/includes/AjaxFunctions.php index 91295bcfde..9f7a332f4b 100644 --- a/includes/AjaxFunctions.php +++ b/includes/AjaxFunctions.php @@ -71,6 +71,8 @@ function code2utf($num){ function wfSajaxSearch( $term ) { global $wgContLang, $wgOut; $limit = 16; + + $l = new Linker; $term = str_replace( ' ', '_', $wgContLang->ucfirst( $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) ) @@ -92,10 +94,10 @@ function wfSajaxSearch( $term ) { $i=0; while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) { $nt = Title::newFromDBkey( $row->page_title ); - $r .= '
  • ' . Linker::makeKnownLinkObj( $nt ) . "
  • \n"; + $r .= '
  • ' . $l->makeKnownLinkObj( $nt ) . "
  • \n"; } if ( $i > $limit ) { - $more = '' . Linker::makeKnownLink( $wgContLang->specialPage( "Allpages" ), + $more = '' . $l->makeKnownLink( $wgContLang->specialPage( "Allpages" ), wfMsg('moredotdotdot'), "namespace=0&from=" . wfUrlEncode ( $term ) ) . ''; @@ -111,10 +113,10 @@ function wfSajaxSearch( $term ) { . wfMsg( 'hideresults' ) . '' . '

    '.wfMsg('search') . '

    '. $subtitle . '

    " . wfMsg( 'articletitles', $term ) . "

    " diff --git a/includes/Article.php b/includes/Article.php index c469888d3f..b2c3b7efd5 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -613,6 +613,7 @@ class Article { global $wgUser, $wgOut, $wgRequest, $wgContLang; global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser; global $wgUseTrackbacks, $wgNamespaceRobotPolicies; + $sk = $wgUser->getSkin(); wfProfileIn( __METHOD__ ); @@ -692,7 +693,8 @@ class Article { // This is an internally redirected page view. // We'll need a backlink to the source page for navigation. if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) { - $redir = Linker::makeKnownLinkObj( $this->mRedirectedFrom, '', 'redirect=no' ); + $sk = $wgUser->getSkin(); + $redir = $sk->makeKnownLinkObj( $this->mRedirectedFrom, '', 'redirect=no' ); $s = wfMsg( 'redirectedfrom', $redir ); $wgOut->setSubtitle( $s ); $wasRedirected = true; @@ -702,7 +704,8 @@ class Article { // If it was reported from a trusted site, supply a backlink. global $wgRedirectSources; if( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) { - $redir = Linker::makeExternalLink( $rdfrom, $rdfrom ); + $sk = $wgUser->getSkin(); + $redir = $sk->makeExternalLink( $rdfrom, $rdfrom ); $s = wfMsg( 'redirectedfrom', $redir ); $wgOut->setSubtitle( $s ); $wasRedirected = true; @@ -784,7 +787,7 @@ class Article { $targetUrl = $rt->escapeLocalURL(); # fixme unused $titleText : $titleText = htmlspecialchars( $rt->getPrefixedText() ); - $link = Linker::makeLinkObj( $rt ); + $link = $sk->makeLinkObj( $rt ); $wgOut->addHTML( '#REDIRECT' . ''.$link.'' ); @@ -826,7 +829,7 @@ class Article { $wgOut->addHTML( "' ); @@ -2253,7 +2256,7 @@ class Article { * @param string $oldid Revision ID of this article revision */ function setOldSubtitle( $oldid=0 ) { - global $wgLang, $wgOut; + global $wgLang, $wgOut, $wgUser; if ( !wfRunHooks( 'DisplayOldSubtitle', array(&$this, &$oldid) ) ) { return; @@ -2263,25 +2266,26 @@ class Article { $current = ( $oldid == $this->mLatest ); $td = $wgLang->timeanddate( $this->mTimestamp, true ); + $sk = $wgUser->getSkin(); $lnk = $current ? wfMsg( 'currentrevisionlink' ) - : $lnk = Linker::makeKnownLinkObj( $this->mTitle, wfMsg( 'currentrevisionlink' ) ); + : $lnk = $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'currentrevisionlink' ) ); $prev = $this->mTitle->getPreviousRevisionID( $oldid ) ; $prevlink = $prev - ? Linker::makeKnownLinkObj( $this->mTitle, wfMsg( 'previousrevision' ), 'direction=prev&oldid='.$oldid ) + ? $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'previousrevision' ), 'direction=prev&oldid='.$oldid ) : wfMsg( 'previousrevision' ); $prevdiff = $prev - ? Linker::makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=prev&oldid='.$oldid ) + ? $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=prev&oldid='.$oldid ) : wfMsg( 'diff' ); $nextlink = $current ? wfMsg( 'nextrevision' ) - : Linker::makeKnownLinkObj( $this->mTitle, wfMsg( 'nextrevision' ), 'direction=next&oldid='.$oldid ); + : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'nextrevision' ), 'direction=next&oldid='.$oldid ); $nextdiff = $current ? wfMsg( 'diff' ) - : Linker::makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=next&oldid='.$oldid ); + : $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'diff' ), 'diff=next&oldid='.$oldid ); - $userlinks = Linker::userLink( $revision->getUser(), $revision->getUserText() ) - . Linker::userToolLinks( $revision->getUser(), $revision->getUserText() ); + $userlinks = $sk->userLink( $revision->getUser(), $revision->getUserText() ) + . $sk->userToolLinks( $revision->getUser(), $revision->getUserText() ); $r = wfMsg( 'old-revision-navigation', $td, $lnk, $prevlink, $nextlink, $userlinks, $prevdiff, $nextdiff ); $wgOut->setSubtitle( $r ); diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index 9709033a8e..277ee1dbf5 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -49,7 +49,8 @@ class CategoryViewer { var $title, $limit, $from, $until, $articles, $articles_start_char, $children, $children_start_char, - $showGallery, $gallery; + $showGallery, $gallery, + $skin; function __construct( $title, $from = '', $until = '' ) { global $wgCategoryPagingLimit; @@ -98,13 +99,21 @@ class CategoryViewer { } } + function getSkin() { + if ( !$this->skin ) { + global $wgUser; + $this->skin = $wgUser->getSkin(); + } + return $this->skin; + } + /** * Add a subcategory to the internal lists */ function addSubcategory( $title, $sortkey, $pageLength ) { global $wgContLang; // Subcategory; strip the 'Category' namespace from the link text. - $this->children[] = Linker::makeKnownLinkObj( + $this->children[] = $this->getSkin()->makeKnownLinkObj( $title, $wgContLang->convertHtml( $title->getText() ) ); $this->children_start_char[] = $this->getSubcategorySortChar( $title, $sortkey ); @@ -150,7 +159,7 @@ class CategoryViewer { */ function addPage( $title, $sortkey, $pageLength ) { global $wgContLang; - $this->articles[] = Linker::makeSizeLinkObj( + $this->articles[] = $this->getSkin()->makeSizeLinkObj( $pageLength, $title, $wgContLang->convert( $title->getPrefixedText() ) ); $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $sortkey ) ); @@ -379,16 +388,17 @@ class CategoryViewer { */ function pagingLinks( $title, $first, $last, $limit, $query = array() ) { global $wgUser, $wgLang; + $sk =& $this->getSkin(); $limitText = $wgLang->formatNum( $limit ); $prevLink = htmlspecialchars( wfMsg( 'prevn', $limitText ) ); if( $first != '' ) { - $prevLink = Linker::makeLinkObj( $title, $prevLink, + $prevLink = $sk->makeLinkObj( $title, $prevLink, wfArrayToCGI( $query + array( 'until' => $first ) ) ); } $nextLink = htmlspecialchars( wfMsg( 'nextn', $limitText ) ); if( $last != '' ) { - $nextLink = Linker::makeLinkObj( $title, $nextLink, + $nextLink = $sk->makeLinkObj( $title, $nextLink, wfArrayToCGI( $query + array( 'from' => $last ) ) ); } diff --git a/includes/ChangesList.php b/includes/ChangesList.php index a0b41309a1..fe3ec1b32d 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -34,7 +34,8 @@ class ChangesList { # /** @todo document */ - function ChangesList() { + function ChangesList( &$skin ) { + $this->skin =& $skin; $this->preCacheMessages(); } @@ -46,9 +47,10 @@ class ChangesList { * @return ChangesList derivative */ function newFromUser( &$user ) { + $sk =& $user->getSkin(); $list = NULL; - if( wfRunHooks( 'FetchChangesList', array( &$user, &$list ) ) ) { - return $user->getOption( 'usenewrc' ) ? new EnhancedChangesList() : new OldChangesList(); + if( wfRunHooks( 'FetchChangesList', array( &$user, &$skin, &$list ) ) ) { + return $user->getOption( 'usenewrc' ) ? new EnhancedChangesList( $sk ) : new OldChangesList( $sk ); } else { return $list; } @@ -110,13 +112,13 @@ class ChangesList { # Diff $s .= '(' . $this->message['diff'] . ') ('; # Hist - $s .= Linker::makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], 'action=history' ) . + $s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], 'action=history' ) . ') . . '; # "[[x]] moved to [[y]]" $msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir'; - $s .= wfMsg( $msg, Linker::makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ), - Linker::makeKnownLinkObj( $rc->getMovedToTitle(), '' ) ); + $s .= wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ), + $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) ); } function insertDateHeader(&$s, $rc_timestamp) { @@ -137,7 +139,7 @@ class ChangesList { function insertLog(&$s, $title, $logtype) { $logname = LogPage::logName( $logtype ); - $s .= '(' . Linker::makeKnownLinkObj($title, $logname ) . ')'; + $s .= '(' . $this->skin->makeKnownLinkObj($title, $logname ) . ')'; } @@ -149,7 +151,7 @@ class ChangesList { $rcidparam = $unpatrolled ? array( 'rcid' => $rc->mAttribs['rc_id'] ) : array(); - $diffLink = Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], + $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], wfArrayToCGI( array( 'curid' => $rc->mAttribs['rc_cur_id'], 'diff' => $rc->mAttribs['rc_this_oldid'], @@ -160,7 +162,7 @@ class ChangesList { $s .= '('.$diffLink.') ('; # History link - $s .= Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['hist'], + $s .= $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['hist'], wfArrayToCGI( array( 'curid' => $rc->mAttribs['rc_cur_id'], 'action' => 'history' ) ) ); @@ -174,7 +176,7 @@ class ChangesList { $params = ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW ) ? 'rcid='.$rc->mAttribs['rc_id'] : ''; - $articlelink = ' '. Linker::makeKnownLinkObj( $rc->getTitle(), '', $params ); + $articlelink = ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params ); if($watched) $articlelink = ''.$articlelink.''; global $wgContLang; $articlelink .= $wgContLang->getDirMark(); @@ -190,15 +192,15 @@ class ChangesList { /** Insert links to user page, user talk page and eventually a blocking link */ function insertUserRelatedLinks(&$s, &$rc) { - $s .= Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); - $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); + $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); + $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] ); } /** insert a formatted comment */ function insertComment(&$s, &$rc) { # Add comment if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) { - $s .= Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); + $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); } } @@ -322,23 +324,23 @@ class EnhancedChangesList extends ChangesList { # Make article link if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $msg = ( $rc_type == RC_MOVE ) ? "1movedto2" : "1movedto2_redir"; - $clink = wfMsg( $msg, Linker::makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ), - Linker::makeKnownLinkObj( $rc->getMovedToTitle(), '' ) ); + $clink = wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ), + $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) ); } elseif( $rc_namespace == NS_SPECIAL ) { list( $specialName, $logtype ) = SpecialPage::resolveAliasWithSubpage( $rc_title ); if ( $specialName == 'Log' ) { # Log updates, etc $logname = LogPage::logName( $logtype ); - $clink = '(' . Linker::makeKnownLinkObj( $rc->getTitle(), $logname ) . ')'; + $clink = '(' . $this->skin->makeKnownLinkObj( $rc->getTitle(), $logname ) . ')'; } else { wfDebug( "Unexpected special page in recentchanges\n" ); $clink = ''; } } elseif( $rc->unpatrolled && $rc_type == RC_NEW ) { # Unpatrolled new page, give rc_id in query - $clink = Linker::makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" ); + $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', "rcid={$rc_id}" ); } else { - $clink = Linker::makeKnownLinkObj( $rc->getTitle(), '' ); + $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' ); } $time = $wgContLang->time( $rc_timestamp, true, true ); @@ -356,31 +358,31 @@ class EnhancedChangesList extends ChangesList { $querycur = $curIdEq."&diff=0&oldid=$rc_this_oldid"; $querydiff = $curIdEq."&diff=$rc_this_oldid&oldid=$rc_last_oldid$rcIdQuery"; $aprops = ' tabindex="'.$baseRC->counter.'"'; - $curLink = Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $querycur, '' ,'', $aprops ); + $curLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['cur'], $querycur, '' ,'', $aprops ); if( $rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { if( $rc_type != RC_NEW ) { $curLink = $this->message['cur']; } $diffLink = $this->message['diff']; } else { - $diffLink = Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $querydiff, '' ,'', $aprops ); + $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], $querydiff, '' ,'', $aprops ); } # Make "last" link if( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $lastLink = $this->message['last']; } else { - $lastLink = Linker::makeKnownLinkObj( $rc->getTitle(), $this->message['last'], + $lastLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['last'], $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery ); } - $rc->userlink = Linker::userLink( $rc_user, $rc_user_text ); + $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text ); $rc->lastlink = $lastLink; $rc->curlink = $curLink; $rc->difflink = $diffLink; - $rc->usertalklink = Linker::userToolLinks( $rc_user, $rc_user_text ); + $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text ); # Put accumulated information into the cache, for later display # Page moves go on their own line @@ -470,13 +472,13 @@ class EnhancedChangesList extends ChangesList { if( $isnew ) { $r .= $this->message['changes']; } else { - $r .= Linker::makeKnownLinkObj( $block[0]->getTitle(), + $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(), $this->message['changes'], $curIdEq."&diff=$currentRevision&oldid=$oldid" ); } $r .= '; '; # History - $r .= Linker::makeKnownLinkObj( $block[0]->getTitle(), + $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(), $this->message['history'], $curIdEq.'&action=history' ); $r .= ')'; } @@ -507,7 +509,7 @@ class EnhancedChangesList extends ChangesList { if( $rc_type == RC_LOG ) { $link = $rcObj->timestamp; } else { - $link = Linker::makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp, $curIdEq.'&'.$o ); + $link = $this->skin->makeKnownLinkObj( $rcObj->getTitle(), $rcObj->timestamp, $curIdEq.'&'.$o ); } $link = ''.$link.''; @@ -518,7 +520,7 @@ class EnhancedChangesList extends ChangesList { $r .= $rcObj->lastlink; $r .= ') . . '.$rcObj->userlink; $r .= $rcObj->usertalklink; - $r .= Linker::commentBlock( $rc_comment, $rcObj->getTitle() ); + $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() ); $r .= "
    \n"; } $r .= "\n"; @@ -614,14 +616,14 @@ class EnhancedChangesList extends ChangesList { $r .= ' ('. $rcObj->difflink .'; '; # Hist - $r .= Linker::makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ); + $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ); # User/talk $r .= ') . . '.$rcObj->userlink . $rcObj->usertalklink; # Comment if( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) { - $r .= Linker::commentBlock( $rc_comment, $rcObj->getTitle() ); + $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() ); } if( $rcObj->numberofWatchingusers > 0 ) { diff --git a/includes/Credits.php b/includes/Credits.php index a31c4f929a..62f0b2566a 100644 --- a/includes/Credits.php +++ b/includes/Credits.php @@ -171,8 +171,9 @@ function getContributorCredits($article, $cnt, $showIfMax) { * */ function creditLink($user_name, $link_text = '') { - global $wgContLang; - return Linker::makeLink($wgContLang->getNsText(NS_USER) . ':' . $user_name, + global $wgUser, $wgContLang; + $skin = $wgUser->getSkin(); + return $skin->makeLink($wgContLang->getNsText(NS_USER) . ':' . $user_name, htmlspecialchars( (empty($link_text)) ? $user_name : $link_text )); } @@ -180,7 +181,9 @@ function creditLink($user_name, $link_text = '') { * */ function creditOthersLink($article) { - return Linker::makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), 'action=credits'); + global $wgUser; + $skin = $wgUser->getSkin(); + return $skin->makeKnownLink($article->mTitle->getPrefixedText(), wfMsg('others'), 'action=credits'); } ?> diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 206dddc60c..72ba3469b5 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -143,12 +143,13 @@ CONTROL; exit; } + $sk = $wgUser->getSkin(); $talk = $wgContLang->getNsText( NS_TALK ); $contribs = wfMsg( 'contribslink' ); if ( $this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback') ) { $username = $this->mNewRev->getUserText(); - $rollback = '   [' . Linker::makeKnownLinkObj( $this->mTitle, wfMsg( 'rollbacklink' ), + $rollback = '   [' . $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'rollbacklink' ), 'action=rollback&from=' . urlencode( $username ) . '&token=' . urlencode( $wgUser->editToken( array( $this->mTitle->getPrefixedText(), $username ) ) ) ) . ']'; @@ -156,17 +157,17 @@ CONTROL; $rollback = ''; } if( $wgUseRCPatrol && $this->mRcidMarkPatrolled != 0 && $wgUser->isAllowed( 'patrol' ) ) { - $patrol = ' [' . Linker::makeKnownLinkObj( $this->mTitle, wfMsg( 'markaspatrolleddiff' ), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}" ) . ']'; + $patrol = ' [' . $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'markaspatrolleddiff' ), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}" ) . ']'; } else { $patrol = ''; } - $prevlink = Linker::makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'previousdiff' ), + $prevlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'previousdiff' ), 'diff=prev&oldid='.$this->mOldid, '', '', 'id="differences-prevlink"' ); if ( $this->mNewRev->isCurrent() ) { $nextlink = ' '; } else { - $nextlink = Linker::makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), + $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), 'diff=next&oldid='.$this->mNewid, '', '', 'id="differences-nextlink"' ); } @@ -184,12 +185,12 @@ CONTROL; } $oldHeader = "{$this->mOldtitle}
    " . - Linker::revUserTools( $this->mOldRev ) . "
    " . - $oldminor . Linker::revComment( $this->mOldRev ) . "
    " . + $sk->revUserTools( $this->mOldRev ) . "
    " . + $oldminor . $sk->revComment( $this->mOldRev ) . "
    " . $prevlink; $newHeader = "{$this->mNewtitle}
    " . - Linker::revUserTools( $this->mNewRev ) . " $rollback
    " . - $newminor . Linker::revComment( $this->mNewRev ) . "
    " . + $sk->revUserTools( $this->mNewRev ) . " $rollback
    " . + $newminor . $sk->revComment( $this->mNewRev ) . "
    " . $nextlink . $patrol; $this->showDiff( $oldHeader, $newHeader ); @@ -217,7 +218,7 @@ CONTROL; * contrast to normal "old revision" display style. */ function showFirstRevision() { - global $wgOut; + global $wgOut, $wgUser; $fname = 'DifferenceEngine::showFirstRevision'; wfProfileIn( $fname ); @@ -248,10 +249,12 @@ CONTROL; # Prepare the header box # - $nextlink = Linker::makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), 'diff=next&oldid='.$this->mNewid, '', '', 'id="differences-nextlink"' ); + $sk = $wgUser->getSkin(); + + $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), 'diff=next&oldid='.$this->mNewid, '', '', 'id="differences-nextlink"' ); $header = "
    {$this->mOldtitle}
    " . - Linker::revUserTools( $this->mNewRev ) . "
    " . - Linker::revComment( $this->mNewRev ) . "
    " . + $sk->revUserTools( $this->mNewRev ) . "
    " . + $sk->revComment( $this->mNewRev ) . "
    " . $nextlink . "
    \n"; $wgOut->addHTML( $header ); diff --git a/includes/EditPage.php b/includes/EditPage.php index 82f875196f..3017005830 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -820,6 +820,8 @@ class EditPage { $fname = 'EditPage::showEditForm'; wfProfileIn( $fname ); + $sk =& $wgUser->getSkin(); + wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ; $wgOut->setRobotpolicy( 'noindex,nofollow' ); @@ -941,7 +943,7 @@ class EditPage { $minor = wfMsgExt('minoredit', array('parseinline')); $watchthis = wfMsgExt('watchthis', array('parseinline')); - $cancel = Linker::makeKnownLink( $this->mTitle->getPrefixedText(), + $cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')) ); $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' )); $edithelp = ''. @@ -1252,9 +1254,13 @@ END * Prepare a list of templates used by this page. Returns HTML. */ function formatTemplates() { + global $wgUser; + $fname = 'EditPage::formatTemplates'; wfProfileIn( $fname ); + $sk =& $wgUser->getSkin(); + $outText = ''; $templates = $this->mArticle->getUsedTemplates(); if ( count( $templates ) > 0 ) { @@ -1270,7 +1276,7 @@ END wfMsgExt( 'templatesused', array( 'parse' ) ) . '
      '; foreach ( $templates as $titleObj ) { - $outText .= '
    • ' . Linker::makeLinkObj( $titleObj ) . '
    • '; + $outText .= '
    • ' . $sk->makeLinkObj( $titleObj ) . '
    • '; } $outText .= '
    '; } @@ -1430,10 +1436,11 @@ END * Produce the stock "please login to edit pages" page */ function userNotLoggedInPage() { - global $wgOut; + global $wgUser, $wgOut; + $skin = $wgUser->getSkin(); $loginTitle = SpecialPage::getTitleFor( 'Userlogin' ); - $loginLink = Linker::makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $this->mTitle->getPrefixedUrl() ); + $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $this->mTitle->getPrefixedUrl() ); $wgOut->setPageTitle( wfMsg( 'whitelistedittitle' ) ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 7e6307eff4..7ff456b666 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -17,6 +17,7 @@ class ImageGallery { var $mImages, $mShowBytes, $mShowFilename; var $mCaption = false; + var $mSkin = false; /** * Is the gallery on a wiki page (i.e. not a special page) @@ -49,6 +50,30 @@ class ImageGallery $this->mCaption = $caption; } + /** + * Instruct the class to use a specific skin for rendering + * + * @param $skin Skin object + */ + function useSkin( $skin ) { + $this->mSkin =& $skin; + } + + /** + * Return the skin that should be used + * + * @return Skin object + */ + function getSkin() { + if( !$this->mSkin ) { + global $wgUser; + $skin =& $wgUser->getSkin(); + } else { + $skin =& $this->mSkin; + } + return $skin; + } + /** * Add an image to the gallery. * @@ -111,6 +136,8 @@ class ImageGallery function toHTML() { global $wgLang, $wgIgnoreImageErrors, $wgGenerateThumbnailOnParse; + $sk = $this->getSkin(); + $s = ''; if( $this->mCaption ) $s .= ''; @@ -130,7 +157,7 @@ class ImageGallery else if( $this->mParsing && wfIsBadImage( $nt->getDBkey() ) ) { # The image is blacklisted, just show it as a text link. $thumbhtml = '
    ' - . Linker::makeKnownLinkObj( $nt, htmlspecialchars( $nt->getText() ) ) . '
    '; + . $sk->makeKnownLinkObj( $nt, htmlspecialchars( $nt->getText() ) ) . ''; } else if( !( $thumb = $img->getThumbnail( 120, 120, $wgGenerateThumbnailOnParse ) ) ) { # Error generating thumbnail. $thumbhtml = '
    ' @@ -139,11 +166,11 @@ class ImageGallery else { $vpad = floor( ( 150 - $thumb->height ) /2 ) - 2; $thumbhtml = '
    ' - . Linker::makeKnownLinkObj( $nt, $thumb->toHtml() ) . '
    '; + . $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '
    '; } //TODO - //$ul = Linker::makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut ); + //$ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut ); if( $this->mShowBytes ) { if( $img->exists() ) { @@ -158,7 +185,7 @@ class ImageGallery } $textlink = $this->mShowFilename ? - Linker::makeKnownLinkObj( $nt, htmlspecialchars( $wgLang->truncate( $nt->getText(), 20, '...' ) ) ) . "
    \n" : + $sk->makeKnownLinkObj( $nt, htmlspecialchars( $wgLang->truncate( $nt->getText(), 20, '...' ) ) ) . "
    \n" : '' ; # ATTENTION: The newline after
    is needed to accommodate htmltidy which diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 5067151b02..86a15008fb 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -181,6 +181,7 @@ class ImagePage extends Article { $max = $wgImageLimits[$sizeSel]; $maxWidth = $max[0]; $maxHeight = $max[1]; + $sk = $wgUser->getSkin(); if ( $this->img->exists() ) { # image @@ -253,9 +254,9 @@ class ImagePage extends Article { if ( $page > 1 ) { $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false ); - $link = Linker::makeLinkObj( $this->mTitle, $label, 'page='. ($page-1) ); + $link = $sk->makeLinkObj( $this->mTitle, $label, 'page='. ($page-1) ); $this->img->selectPage( $page - 1 ); - $thumb1 = Linker::makeThumbLinkObj( $this->img, $link, $label, 'none' ); + $thumb1 = $sk->makeThumbLinkObj( $this->img, $link, $label, 'none' ); } else { $thumb1 = ''; } @@ -263,8 +264,8 @@ class ImagePage extends Article { if ( $page < $count ) { $label = wfMsg( 'imgmultipagenext' ); $this->img->selectPage( $page + 1 ); - $link = Linker::makeLinkObj( $this->mTitle, $label, 'page='. ($page+1) ); - $thumb2 = Linker::makeThumbLinkObj( $this->img, $link, $label, 'none' ); + $link = $sk->makeLinkObj( $this->mTitle, $label, 'page='. ($page+1) ); + $thumb2 = $sk->makeThumbLinkObj( $this->img, $link, $label, 'none' ); } else { $thumb2 = ''; } @@ -333,20 +334,22 @@ END # Image does not exist $title = SpecialPage::getTitleFor( 'Upload' ); - $link = Linker::makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'), + $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'), 'wpDestFile=' . urlencode( $this->img->getName() ) ); $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) ); } } function printSharedImageText() { - global $wgRepositoryBaseUrl, $wgFetchCommonsDescriptions, $wgOut; + global $wgRepositoryBaseUrl, $wgFetchCommonsDescriptions, $wgOut, $wgUser; $url = $wgRepositoryBaseUrl . urlencode($this->mTitle->getDBkey()); $sharedtext = "
    " . wfMsgWikiHtml("sharedupload"); if ($wgRepositoryBaseUrl && !$wgFetchCommonsDescriptions) { + + $sk = $wgUser->getSkin(); $title = SpecialPage::getTitleFor( 'Upload' ); - $link = Linker::makeKnownLinkObj($title, wfMsgHtml('shareduploadwiki-linktext'), + $link = $sk->makeKnownLinkObj($title, wfMsgHtml('shareduploadwiki-linktext'), array( 'wpDestFile' => urlencode( $this->img->getName() ))); $sharedtext .= " " . wfMsgWikiHtml('shareduploadwiki', $link); } @@ -376,16 +379,18 @@ END if( $this->img->fromSharedDirectory ) return; + $sk = $wgUser->getSkin(); + $wgOut->addHtml( '
      ' ); # "Upload a new version of this file" link if( $wgUser->isAllowed( 'reupload' ) ) { - $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) ); + $ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) ); $wgOut->addHtml( "
    • {$ulink}
    • " ); } # External editing link - $elink = Linker::makeKnownLinkObj( $this->mTitle, wfMsg( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' ); + $elink = $sk->makeKnownLinkObj( $this->mTitle, wfMsg( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' ); $wgOut->addHtml( '
    • ' . $elink . '
      ' . wfMsgWikiHtml( 'edit-externally-help' ) . '
    • ' ); $wgOut->addHtml( '
    ' ); @@ -401,13 +406,16 @@ END * If the page we've just displayed is in the "Image" namespace, * we follow it with an upload history of the image and its usage. */ - function imageHistory() { - global $wgOut, $wgUseExternalEditor; + function imageHistory() + { + global $wgUser, $wgOut, $wgUseExternalEditor; + + $sk = $wgUser->getSkin(); $line = $this->img->nextHistoryLine(); if ( $line ) { - $list = new ImageHistoryList(); + $list = new ImageHistoryList( $sk ); $s = $list->beginImageHistoryList() . $list->imageHistoryLine( true, wfTimestamp(TS_MW, $line->img_timestamp), $this->mTitle->getDBkey(), $line->img_user, @@ -434,8 +442,9 @@ END } - function imageLinks() { - global $wgOut; + function imageLinks() + { + global $wgUser, $wgOut; $wgOut->addHTML( '\n" ); @@ -454,9 +463,10 @@ END } $wgOut->addHTML( '

    ' . wfMsg( 'linkstoimage' ) . "

    \n
      " ); + $sk = $wgUser->getSkin(); while ( $s = $dbr->fetchObject( $res ) ) { $name = Title::MakeTitle( $s->page_namespace, $s->page_title ); - $link = Linker::makeKnownLinkObj( $name, "" ); + $link = $sk->makeKnownLinkObj( $name, "" ); $wgOut->addHTML( "
    • {$link}
    • \n" ); } $wgOut->addHTML( "
    \n" ); @@ -689,7 +699,8 @@ END * @package MediaWiki */ class ImageHistoryList { - function ImageHistoryList() { + function ImageHistoryList( &$skin ) { + $this->skin =& $skin; } function beginImageHistoryList() { @@ -715,8 +726,11 @@ class ImageHistoryList { $url = Image::imageUrl( $img ); $rlink = $cur; if ( $wgUser->isAllowed('delete') ) { - $dlink = Linker::makeKnownLinkObj( $wgTitle, $delall, - 'image=' . $wgTitle->getPartialURL() . '&action=delete'); + $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() . + '&action=delete' ); + $style = $this->skin->getInternalLinkAttributes( $link, $delall ); + + $dlink = ''.$delall.''; } else { $dlink = $del; } @@ -724,10 +738,10 @@ class ImageHistoryList { $url = htmlspecialchars( wfImageArchiveUrl( $img ) ); if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) { $token = urlencode( $wgUser->editToken( $img ) ); - $rlink = Linker::makeKnownLinkObj( $wgTitle, + $rlink = $this->skin->makeKnownLinkObj( $wgTitle, wfMsg( 'revertimg' ), 'action=revert&oldimage=' . urlencode( $img ) . "&wpEditToken=$token" ); - $dlink = Linker::makeKnownLinkObj( $wgTitle, + $dlink = $this->skin->makeKnownLinkObj( $wgTitle, $del, 'action=delete&oldimage=' . urlencode( $img ) . "&wpEditToken=$token" ); } else { @@ -739,15 +753,15 @@ class ImageHistoryList { } } - $userlink = Linker::userLink( $user, $usertext ) . Linker::userToolLinks( $user, $usertext ); + $userlink = $this->skin->userLink( $user, $usertext ) . $this->skin->userToolLinks( $user, $usertext ); $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), $wgLang->formatNum( $size ) ); $widthheight = wfMsg( 'widthheight', $width, $height ); - $style = Linker::getInternalLinkAttributes( $url, $datetime ); + $style = $this->skin->getInternalLinkAttributes( $url, $datetime ); $s = "
  • ({$dlink}) ({$rlink}) {$datetime} . . {$userlink} . . {$widthheight} ({$nbytes})"; - $s .= Linker::commentBlock( $description, $wgTitle ); + $s .= $this->skin->commentBlock( $description, $wgTitle ); $s .= "
  • \n"; return $s; } diff --git a/includes/Linker.php b/includes/Linker.php index be482839d5..f492f5733a 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -16,20 +16,18 @@ * @package MediaWiki */ class Linker { + function Linker() {} /** * @deprecated */ - private static function postParseLinkColour( $s = NULL ) { + function postParseLinkColour( $s = NULL ) { return NULL; } - /** - * @todo document - * @static - */ - public static function getExternalLinkAttributes( $link, $text, $class='' ) { + /** @todo document */ + function getExternalLinkAttributes( $link, $text, $class='' ) { $link = htmlspecialchars( $link ); $r = ($class != '') ? " class=\"$class\"" : " class=\"external\""; @@ -38,11 +36,7 @@ class Linker { return $r; } - /** - * @todo document - * @static - */ - protected static function getInterwikiLinkAttributes( $link, $text, $class='' ) { + function getInterwikiLinkAttributes( $link, $text, $class='' ) { global $wgContLang; $same = ($link == $text); @@ -57,12 +51,8 @@ class Linker { return $r; } - /** - * Unfortunately cannot be protected because it is needed by ImagePage.php. - * @todo document - * @static - */ - static function getInternalLinkAttributes( $link, $text, $broken = false ) { + /** @todo document */ + function getInternalLinkAttributes( $link, $text, $broken = false ) { $link = urldecode( $link ); $link = str_replace( '_', ' ', $link ); $link = htmlspecialchars( $link ); @@ -80,13 +70,11 @@ class Linker { } /** - * @param $nt Title object - * @param $text String FIXME - * @param $broken String FIXME, default false - * - * @static + * @param $nt Title object. + * @param $text String: FIXME + * @param $broken Boolean: FIXME, default 'false'. */ - protected static function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) { + function getInternalLinkAttributesObj( &$nt, $text, $broken = false ) { if( $broken == 'stub' ) { $r = ' class="stub"'; } else if ( $broken == 'yes' ) { @@ -102,24 +90,22 @@ class Linker { /** * This function is a shortcut to makeLinkObj(Title::newFromText($title),...). Do not call * it if you already have a title object handy. See makeLinkObj for further documentation. - * - * @param $title String the text of the title - * @param $text String link text - * @param $query String optional query part - * @param $trail String optional trail. Alphabetic characters at the start of this string will + * + * @param $title String: the text of the title + * @param $text String: link text + * @param $query String: optional query part + * @param $trail String: optional trail. Alphabetic characters at the start of this string will * be included in the link text. Other characters will be appended after * the end of the link. - * - * @static */ - public static function makeLink( $title, $text = '', $query = '', $trail = '' ) { + function makeLink( $title, $text = '', $query = '', $trail = '' ) { wfProfileIn( 'Linker::makeLink' ); $nt = Title::newFromText( $title ); if ($nt) { - $result = self::makeLinkObj( $nt, $text, $query, $trail ); + $result = $this->makeLinkObj( Title::newFromText( $title ), $text, $query, $trail ); } else { - wfDebug( "Invalid title passed to Linker::makeLink(): \"$title\"\n" ); - $result = $text == '' ? $title : $text; + wfDebug( 'Invalid title passed to Linker::makeLink(): "'.$title."\"\n" ); + $result = $text == "" ? $title : $text; } wfProfileOut( 'Linker::makeLink' ); @@ -130,21 +116,19 @@ class Linker { * This function is a shortcut to makeKnownLinkObj(Title::newFromText($title),...). Do not call * it if you already have a title object handy. See makeKnownLinkObj for further documentation. * - * @param $title String the text of the title - * @param $text String link text - * @param $query String optional query part - * @param $trail String optional trail. Alphabetic characters at the start of this string will + * @param $title String: the text of the title + * @param $text String: link text + * @param $query String: optional query part + * @param $trail String: optional trail. Alphabetic characters at the start of this string will * be included in the link text. Other characters will be appended after * the end of the link. - * - * @static */ - public static function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') { + function makeKnownLink( $title, $text = '', $query = '', $trail = '', $prefix = '',$aprops = '') { $nt = Title::newFromText( $title ); if ($nt) { - return self::makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail, $prefix, $aprops ); + return $this->makeKnownLinkObj( Title::newFromText( $title ), $text, $query, $trail, $prefix , $aprops ); } else { - wfDebug( "Invalid title passed to Linker::makeKnownLink(): \"$title\"\n" ); + wfDebug( 'Invalid title passed to Linker::makeKnownLink(): "'.$title."\"\n" ); return $text == '' ? $title : $text; } } @@ -153,21 +137,19 @@ class Linker { * This function is a shortcut to makeBrokenLinkObj(Title::newFromText($title),...). Do not call * it if you already have a title object handy. See makeBrokenLinkObj for further documentation. * - * @param $title String The text of the title - * @param $text String Link text - * @param $query String Optional query part - * @param $trail String Optional trail. Alphabetic characters at the start of this string will + * @param string $title The text of the title + * @param string $text Link text + * @param string $query Optional query part + * @param string $trail Optional trail. Alphabetic characters at the start of this string will * be included in the link text. Other characters will be appended after * the end of the link. - * - * @static */ - public static function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) { + function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) { $nt = Title::newFromText( $title ); if ($nt) { - return self::makeBrokenLinkObj( Title::newFromText( $title ), $text, $query, $trail ); + return $this->makeBrokenLinkObj( Title::newFromText( $title ), $text, $query, $trail ); } else { - wfDebug( "Invalid title passed to Linker::makeBrokenLink(): \"$title\"\n" ); + wfDebug( 'Invalid title passed to Linker::makeBrokenLink(): "'.$title."\"\n" ); return $text == '' ? $title : $text; } } @@ -176,21 +158,19 @@ class Linker { * This function is a shortcut to makeStubLinkObj(Title::newFromText($title),...). Do not call * it if you already have a title object handy. See makeStubLinkObj for further documentation. * - * @param $title String the text of the title - * @param $text String link text - * @param $query String optional query part - * @param $trail String optional trail. Alphabetic characters at the start of this string will + * @param $title String: the text of the title + * @param $text String: link text + * @param $query String: optional query part + * @param $trail String: optional trail. Alphabetic characters at the start of this string will * be included in the link text. Other characters will be appended after * the end of the link. - * - * @static */ - public static function makeStubLink( $title, $text = '', $query = '', $trail = '' ) { + function makeStubLink( $title, $text = '', $query = '', $trail = '' ) { $nt = Title::newFromText( $title ); if ($nt) { - return self::makeStubLinkObj( Title::newFromText( $title ), $text, $query, $trail ); + return $this->makeStubLinkObj( Title::newFromText( $title ), $text, $query, $trail ); } else { - wfDebug( "Invalid title passed to Linker::makeStubLink(): \"$title\"\n" ); + wfDebug( 'Invalid title passed to Linker::makeStubLink(): "'.$title."\"\n" ); return $text == '' ? $title : $text; } } @@ -200,22 +180,22 @@ class Linker { * call this lots of times, pre-fill the link cache with a LinkBatch, otherwise each * call to this will result in a DB query. * - * @param $nt Title the title object to make the link from, e.g. from Title::newFromText - * @param $text String link text - * @param $query String optional query part - * @param $trail String optional trail. Alphabetic characters at the start of this string will - * be included in the link text. Other characters will be appended after - * the end of the link. - * @param $prefix String optional prefix. As trail, only before instead of after. - * @static + * @param $nt Title: the title object to make the link from, e.g. from + * Title::newFromText. + * @param $text String: link text + * @param $query String: optional query part + * @param $trail String: optional trail. Alphabetic characters at the start of this string will + * be included in the link text. Other characters will be appended after + * the end of the link. + * @param $prefix String: optional prefix. As trail, only before instead of after. */ - public static function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { + function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) { global $wgUser; $fname = 'Linker::makeLinkObj'; wfProfileIn( $fname ); # Fail gracefully - if ( !is_object($nt) ) { + if ( ! is_object($nt) ) { # throw new MWException(); wfProfileOut( $fname ); return "{$prefix}{$text}{$trail}"; @@ -227,7 +207,7 @@ class Linker { $u = $nt->getFullURL(); $link = $nt->getPrefixedURL(); if ( '' == $text ) { $text = $nt->getPrefixedText(); } - $style = self::getInterwikiLinkAttributes( $link, $text, 'extiw' ); + $style = $this->getInterwikiLinkAttributes( $link, $text, 'extiw' ); $inside = ''; if ( '' != $trail ) { @@ -238,6 +218,7 @@ class Linker { } # Check for anchors, normalize the anchor + $parts = explode( '#', $u, 2 ); if ( count( $parts ) == 2 ) { $anchor = urlencode( Sanitizer::decodeCharReferences( str_replace(' ', '_', $parts[1] ) ) ); @@ -257,13 +238,13 @@ class Linker { return $t; } elseif ( $nt->isAlwaysKnown() ) { # Image links, special page links and self-links with fragements are always known. - $retVal = self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); + $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); } else { wfProfileIn( $fname.'-immediate' ); # Work out link colour immediately $aid = $nt->getArticleID() ; if ( 0 == $aid ) { - $retVal = self::makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix ); + $retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix ); } else { $threshold = $wgUser->getOption('stubthreshold') ; if ( $threshold > 0 ) { @@ -286,9 +267,9 @@ class Linker { $size = 1 ; } if ( $size < $threshold ) { - $retVal = self::makeStubLinkObj( $nt, $text, $query, $trail, $prefix ); + $retVal = $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix ); } else { - $retVal = self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); + $retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); } } wfProfileOut( $fname.'-immediate' ); @@ -301,19 +282,18 @@ class Linker { * Make a link for a title which definitely exists. This is faster than makeLinkObj because * it doesn't have to do a database query. It's also valid for interwiki titles and special * pages. - * - * @param $nt Title object of target page - * @param $text String text to replace the title - * @param $query String link target - * @param $trail String text after link - * @param $prefix String text before link text - * @param $aprops String extra attributes to the a-element - * @param $style String style to apply - * @return String HTML for link - * - * @static + * + * @param $nt Title object of target page + * @param $text String: text to replace the title + * @param $query String: link target + * @param $trail String: text after link + * @param $prefix String: text before link text + * @param $aprops String: extra attributes to the a-element + * @param $style String: style to apply - if empty, use getInternalLinkAttributesObj instead + * @return the a-element */ - public static function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { + function makeKnownLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) { + $fname = 'Linker::makeKnownLinkObj'; wfProfileIn( $fname ); @@ -341,12 +321,12 @@ class Linker { $text = htmlspecialchars( $nt->getPrefixedText() ); } if ( $style == '' ) { - $style = self::getInternalLinkAttributesObj( $nt, $text ); + $style = $this->getInternalLinkAttributesObj( $nt, $text ); } if ( $aprops !== '' ) $aprops = ' ' . $aprops; - list( $inside, $trail ) = self::splitTrail( $trail ); + list( $inside, $trail ) = Linker::splitTrail( $trail ); $r = "{$prefix}{$text}{$inside}{$trail}"; wfProfileOut( $fname ); return $r; @@ -355,18 +335,16 @@ class Linker { /** * Make a red link to the edit page of a given title. * - * @param $title String The text of the title - * @param $text String Link text - * @param $query String Optional query part - * @param $trail String Optional trail. Alphabetic characters at the start of this string will + * @param $title String: The text of the title + * @param $text String: Link text + * @param $query String: Optional query part + * @param $trail String: Optional trail. Alphabetic characters at the start of this string will * be included in the link text. Other characters will be appended after * the end of the link. - * - * @static */ - public static function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { # Fail gracefully - if ( !isset($nt) ) { + if ( ! isset($nt) ) { # throw new MWException(); return "{$prefix}{$text}{$trail}"; } @@ -384,9 +362,9 @@ class Linker { if ( '' == $text ) { $text = htmlspecialchars( $nt->getPrefixedText() ); } - $style = self::getInternalLinkAttributesObj( $nt, $text, 'yes' ); + $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" ); - list( $inside, $trail ) = self::splitTrail( $trail ); + list( $inside, $trail ) = Linker::splitTrail( $trail ); $s = "{$prefix}{$text}{$inside}{$trail}"; wfProfileOut( $fname ); @@ -396,16 +374,14 @@ class Linker { /** * Make a brown link to a short article. * - * @param $title String the text of the title - * @param $text String link text - * @param $query String optional query part - * @param $trail String optional trail. Alphabetic characters at the start of this string will + * @param $title String: the text of the title + * @param $text String: link text + * @param $query String: optional query part + * @param $trail String: optional trail. Alphabetic characters at the start of this string will * be included in the link text. Other characters will be appended after * the end of the link. - * - * @static */ - public static function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { $link = $nt->getPrefixedURL(); $u = $nt->escapeLocalURL( $query ); @@ -413,9 +389,9 @@ class Linker { if ( '' == $text ) { $text = htmlspecialchars( $nt->getPrefixedText() ); } - $style = self::getInternalLinkAttributesObj( $nt, $text, 'stub' ); + $style = $this->getInternalLinkAttributesObj( $nt, $text, 'stub' ); - list( $inside, $trail ) = self::splitTrail( $trail ); + list( $inside, $trail ) = Linker::splitTrail( $trail ); $s = "{$prefix}{$text}{$inside}{$trail}"; return $s; } @@ -423,47 +399,40 @@ class Linker { /** * Generate either a normal exists-style link or a stub link, depending * on the given page size. - * + * * @param $size Integer - * @param $nt Title object + * @param $nt Title object. * @param $text String * @param $query String * @param $trail String * @param $prefix String - * @return String HTML of link - * - * @static + * @return string HTML of link */ - public static function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { global $wgUser; $threshold = intval( $wgUser->getOption( 'stubthreshold' ) ); if( $size < $threshold ) { - return self::makeStubLinkObj( $nt, $text, $query, $trail, $prefix ); + return $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix ); } else { - return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); + return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); } } - /** + /** * Make appropriate markup for a link to the current article. This is currently rendered * as the bold link text. The calling sequence is the same as the other make*LinkObj functions, * despite $query not being used. - * - * @static */ - public static function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { if ( '' == $text ) { $text = htmlspecialchars( $nt->getPrefixedText() ); } - list( $inside, $trail ) = self::splitTrail( $trail ); + list( $inside, $trail ) = Linker::splitTrail( $trail ); return "{$prefix}{$text}{$inside}{$trail}"; } - /** - * @todo document - * @static - */ - public static function fnamePart( $url ) { + /** @todo document */ + function fnamePart( $url ) { $basename = strrchr( $url, '/' ); if ( false === $basename ) { $basename = $url; @@ -473,66 +442,62 @@ class Linker { return htmlspecialchars( $basename ); } - /** - * @deprecated Obsolete alias - */ - private static function makeImage( $url, $alt = '' ) { - return self::makeExternalImage( $url, $alt ); + /** Obsolete alias */ + function makeImage( $url, $alt = '' ) { + return $this->makeExternalImage( $url, $alt ); } - /** - * @todo document - * @static - */ - public static function makeExternalImage( $url, $alt = '' ) { + /** @todo document */ + function makeExternalImage( $url, $alt = '' ) { if ( '' == $alt ) { - $alt = self::fnamePart( $url ); + $alt = $this->fnamePart( $url ); } $s = ''.$alt.''; return $s; } - /** - * @todo document - * @static - */ - public static function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false, - $thumb = false, $manual_thumb = '', $page = null ) { + /** @todo document */ + function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false, + $thumb = false, $manual_thumb = '', $page = null ) + { global $wgContLang, $wgUser, $wgThumbLimits, $wgGenerateThumbnailOnParse; - $img = new Image( $nt ); + $img = new Image( $nt ); - if ( !is_null( $page ) ) { + if ( ! is_null( $page ) ) { $img->selectPage( $page ); } if ( !$img->allowInlineDisplay() && $img->exists() ) { - return self::makeKnownLinkObj( $nt ); + return $this->makeKnownLinkObj( $nt ); } - $url = $img->getViewURL(); + $url = $img->getViewURL(); $error = $prefix = $postfix = ''; wfDebug( "makeImageLinkObj: '$width'x'$height', \"$label\"\n" ); - if ( 'center' == $align ) { + if ( 'center' == $align ) + { $prefix = '
    '; $postfix = '
    '; $align = 'none'; } if ( $thumb || $framed ) { + # Create a thumbnail. Alignment depends on language - # writing direction: right-aligned for left-to-right- + # writing direction, # right aligned for left-to-right- # languages ("Western languages"), left-aligned # for right-to-left-languages ("Semitic languages") # - # If thumbnail width has not been provided, it is set + # If thumbnail width has not been provided, it is set # to the default user option as specified in Language*.php if ( $align == '' ) { $align = $wgContLang->isRTL() ? 'left' : 'right'; } + if ( $width === false ) { $wopt = $wgUser->getOption( 'thumbsize' ); @@ -543,12 +508,14 @@ class Linker { $width = min( $img->getWidth(), $wgThumbLimits[$wopt] ); } - return $prefix.self::makeThumbLinkObj( $img, $label, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix; + return $prefix.$this->makeThumbLinkObj( $img, $label, $alt, $align, $width, $height, $framed, $manual_thumb ).$postfix; } if ( $width && $img->exists() ) { + # Create a resized image, without the additional thumbnail # features + if ( $height == false ) $height = -1; if ( $manual_thumb == '') { @@ -582,7 +549,7 @@ class Linker { if ( $error ) { $s = $error; } elseif ( $url == '' ) { - $s = self::makeBrokenImageLinkObj( $img->getTitle() ); + $s = $this->makeBrokenImageLinkObj( $img->getTitle() ); //$s .= "
    {$alt}
    {$url}
    \n"; } else { $s = '' . @@ -601,10 +568,8 @@ class Linker { /** * Make HTML for a thumbnail including image, border and caption * $img is an Image object - * - * @static */ - public static function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) { + function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) { global $wgStylePath, $wgContLang, $wgGenerateThumbnailOnParse; $thumbUrl = ''; $error = ''; @@ -641,17 +606,19 @@ class Linker { } $oboxwidth = $boxwidth + 2; - if ( $manual_thumb != '' ) { # Use manually specified thumbnail + if ( $manual_thumb != '' ) # Use manually specified thumbnail + { $manual_title = Title::makeTitleSafe( NS_IMAGE, $manual_thumb ); #new Title ( $manual_thumb ) ; if( $manual_title ) { $manual_img = new Image( $manual_title ); $thumbUrl = $manual_img->getViewURL(); - if ( $manual_img->exists() ) { + if ( $manual_img->exists() ) + { $width = $manual_img->getWidth(); $height = $manual_img->getHeight(); - $boxwidth = $width; - $boxheight = $height; - $oboxwidth = $boxwidth + 2; + $boxwidth = $width ; + $boxheight = $height ; + $oboxwidth = $boxwidth + 2 ; } } } @@ -671,7 +638,7 @@ class Linker { $s .= htmlspecialchars( $error ); $zoomicon = ''; } elseif( !$img->exists() ) { - $s .= self::makeBrokenImageLinkObj( $img->getTitle() ); + $s .= $this->makeBrokenImageLinkObj( $img->getTitle() ); $zoomicon = ''; } else { $s .= ''. @@ -693,12 +660,10 @@ class Linker { /** * Pass a title object, not a title string - * - * @static */ - public static function makeBrokenImageLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + function makeBrokenImageLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { # Fail gracefully - if ( !isset($nt) ) { + if ( ! isset($nt) ) { # throw new MWException(); return "{$prefix}{$text}{$trail}"; } @@ -716,34 +681,33 @@ class Linker { if ( '' == $text ) { $text = htmlspecialchars( $nt->getPrefixedText() ); } - $style = self::getInternalLinkAttributesObj( $nt, $text, 'yes' ); - list( $inside, $trail ) = self::splitTrail( $trail ); + $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" ); + list( $inside, $trail ) = Linker::splitTrail( $trail ); $s = "{$prefix}{$text}{$inside}{$trail}"; wfProfileOut( $fname ); return $s; } - /** - * @todo document - * @static - */ - public static function makeMediaLink( $name, /* wtf?! */ $url, $alt = '' ) { + /** @todo document */ + function makeMediaLink( $name, /* wtf?! */ $url, $alt = '' ) { $nt = Title::makeTitleSafe( NS_IMAGE, $name ); - return self::makeMediaLinkObj( $nt, $alt ); + return $this->makeMediaLinkObj( $nt, $alt ); } /** * Create a direct link to a given uploaded file. - * - * @param $title Title object - * @param $text String pre-sanitized HTML - * @return String HTML - * - * @static + * + * @param $title Title object. + * @param $text String: pre-sanitized HTML + * @param $nourl Boolean: Mask absolute URLs, so the parser doesn't + * linkify them (it is currently not context-aware) + * @return string HTML + * + * @public * @todo Handle invalid or missing images better. */ - public static function makeMediaLinkObj( $title, $text = '' ) { + function makeMediaLinkObj( $title, $text = '' ) { if( is_null( $title ) ) { ### HOTFIX. Instead of breaking, return empty string. return $text; @@ -767,24 +731,19 @@ class Linker { } } - /** - * @todo document - * @static - */ - public static function specialLink( $name, $key = '' ) { + /** @todo document */ + function specialLink( $name, $key = '' ) { global $wgContLang; if ( '' == $key ) { $key = strtolower( $name ); } $pn = $wgContLang->ucfirst( $name ); - return self::makeKnownLink( $wgContLang->specialPage( $pn ), wfMsg( $key ) ); + return $this->makeKnownLink( $wgContLang->specialPage( $pn ), + wfMsg( $key ) ); } - /** - * @todo document - * @static - */ - public static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = null ) { - $style = self::getExternalLinkAttributes( $url, $text, 'external ' . $linktype ); + /** @todo document */ + function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = null ) { + $style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype ); global $wgNoFollowLinks, $wgNoFollowNsExceptions; if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) { $style .= ' rel="nofollow"'; @@ -798,47 +757,45 @@ class Linker { /** * Make user link (or user contributions for unregistered users) - * @param $userId Integer user id in database - * @param $userText String user name in database - * @return String HTML fragment - * - * @static + * @param $userId Integer: user id in database. + * @param $userText String: user name in database + * @return string HTML fragment + * @private */ - public static function userLink( $userId, $userText ) { + function userLink( $userId, $userText ) { $encName = htmlspecialchars( $userText ); if( $userId == 0 ) { $contribsPage = SpecialPage::getTitleFor( 'Contributions' ); - return self::makeKnownLinkObj( $contribsPage, + return $this->makeKnownLinkObj( $contribsPage, $encName, 'target=' . urlencode( $userText ) ); } else { $userPage = Title::makeTitle( NS_USER, $userText ); - return self::makeLinkObj( $userPage, $encName ); + return $this->makeLinkObj( $userPage, $encName ); } } /** - * @param $userId Integer user id in database - * @param $userText String user name in database - * @return String HTML fragment with talk and/or block links - * - * @static + * @param $userId Integer: user id in database. + * @param $userText String: user name in database. + * @return string HTML fragment with talk and/or block links + * @private */ - public static function userToolLinks( $userId, $userText ) { + function userToolLinks( $userId, $userText ) { global $wgUser, $wgDisableAnonTalk, $wgSysopUserBans; $talkable = !( $wgDisableAnonTalk && 0 == $userId ); $blockable = ( $wgSysopUserBans || 0 == $userId ); $items = array(); if( $talkable ) { - $items[] = self::userTalkLink( $userId, $userText ); + $items[] = $this->userTalkLink( $userId, $userText ); } if( $userId ) { $contribsPage = SpecialPage::getTitleFor( 'Contributions' ); - $items[] = self::makeKnownLinkObj( $contribsPage, + $items[] = $this->makeKnownLinkObj( $contribsPage, wfMsgHtml( 'contribslink' ), 'target=' . urlencode( $userText ) ); } if( $blockable && $wgUser->isAllowed( 'block' ) ) { - $items[] = self::blockLink( $userId, $userText ); + $items[] = $this->blockLink( $userId, $userText ); } if( $items ) { @@ -849,45 +806,41 @@ class Linker { } /** - * @param $userId Integer user id in database - * @param $userText String user name in database - * @return String HTML fragment with user talk link - * - * @static + * @param $userId Integer: user id in database. + * @param $userText String: user name in database. + * @return string HTML fragment with user talk link + * @private */ - public static function userTalkLink( $userId, $userText ) { + function userTalkLink( $userId, $userText ) { global $wgLang; $talkname = $wgLang->getNsText( NS_TALK ); # use the shorter name $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText ); - $userTalkLink = self::makeLinkObj( $userTalkPage, $talkname ); + $userTalkLink = $this->makeLinkObj( $userTalkPage, $talkname ); return $userTalkLink; } /** - * @param $userId Integer userid - * @param $userText String user name in database + * @param $userId Integer: userid + * @param $userText String: user name in database. * @return string HTML fragment with block link - * - * @static + * @private */ - public static function blockLink( $userId, $userText ) { + function blockLink( $userId, $userText ) { $blockPage = SpecialPage::getTitleFor( 'Blockip' ); - $blockLink = self::makeKnownLinkObj( $blockPage, + $blockLink = $this->makeKnownLinkObj( $blockPage, wfMsgHtml( 'blocklink' ), 'ip=' . urlencode( $userText ) ); return $blockLink; } - + /** * Generate a user link if the current user is allowed to view it - * @param $rev Revision object + * @param $rev Revision object. * @return string HTML - * - * @static */ - public static function revUserLink( $rev ) { + function revUserLink( $rev ) { if( $rev->userCan( Revision::DELETED_USER ) ) { - $link = self::userLink( $rev->getRawUser(), $rev->getRawUserText() ); + $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ); } else { $link = wfMsgHtml( 'rev-deleted-user' ); } @@ -899,16 +852,14 @@ class Linker { /** * Generate a user tool link cluster if the current user is allowed to view it - * @param $rev Revision object + * @param $rev Revision object. * @return string HTML - * - * @static */ - public static function revUserTools( $rev ) { + function revUserTools( $rev ) { if( $rev->userCan( Revision::DELETED_USER ) ) { - $link = self::userLink( $rev->getRawUser(), $rev->getRawUserText() ) . + $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ) . ' ' . - self::userToolLinks( $rev->getRawUser(), $rev->getRawUserText() ); + $this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() ); } else { $link = wfMsgHtml( 'rev-deleted-user' ); } @@ -917,24 +868,22 @@ class Linker { } return $link; } - + /** * This function is called by all recent changes variants, by the page history, * and by the user contributions list. It is responsible for formatting edit * comments. It escapes any HTML in the comment, but adds some CSS to format * auto-generated comments (from section editing) and formats [[wikilinks]]. - * + * * The $title parameter must be a title OBJECT. It is used to generate a * direct link to the section in the autocomment. * @author Erik Moeller - * + * * Note: there's not always a title to pass to this function. * Since you can't set a default parameter for a reference, I've turned it * temporarily to a value pass. Should be adjusted further. --brion - * - * @static */ - public static function formatComment( $comment, $title = NULL ) { + function formatComment($comment, $title = NULL) { $fname = 'Linker::formatComment'; wfProfileIn( $fname ); @@ -964,7 +913,7 @@ class Linker { $section = str_replace( ']]', '', $section ); $sectionTitle = wfClone( $title ); $sectionTitle->mFragment = $section; - $link = self::makeKnownLinkObj( $sectionTitle, wfMsg( 'sectionlink' ) ); + $link = $this->makeKnownLinkObj( $sectionTitle, wfMsg( 'sectionlink' ) ); } $sep='-'; $auto=$link.$auto; @@ -987,7 +936,7 @@ class Linker { if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) { # Media link; trail not supported. $linkRegexp = '/\[\[(.*?)\]\]/'; - $thelink = self::makeMediaLink( $submatch[1], "", $text ); + $thelink = $this->makeMediaLink( $submatch[1], "", $text ); } else { # Other kind of link if( preg_match( $wgContLang->linkTrail(), $match[4], $submatch ) ) { @@ -998,7 +947,7 @@ class Linker { $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/'; if ($match[1][0] == ':') $match[1] = substr($match[1], 1); - $thelink = self::makeLink( $match[1], $text, "", $trail ); + $thelink = $this->makeLink( $match[1], $text, "", $trail ); } $comment = preg_replace( $linkRegexp, wfRegexReplacement( $thelink ), $comment, 1 ); } @@ -1009,36 +958,33 @@ class Linker { /** * Wrap a comment in standard punctuation and formatting if * it's non-empty, otherwise return empty string. - * - * @param $comment String the comment - * @param $title Title object - * @return String - * - * @static + * + * @param $comment String: the comment. + * @param $title Title object. + * + * @return string */ - public static function commentBlock( $comment, $title = NULL ) { + function commentBlock( $comment, $title = NULL ) { // '*' used to be the comment inserted by the software way back // in antiquity in case none was provided, here for backwards // compatability, acc. to brion -ævar if( $comment == '' || $comment == '*' ) { return ''; } else { - $formatted = self::formatComment( $comment, $title ); + $formatted = $this->formatComment( $comment, $title ); return " ($formatted)"; } } - + /** * Wrap and format the given revision's comment block, if the current * user is allowed to view it. - * @param $rev Revision object - * @return String HTML - * - * @static + * @param $rev Revision object. + * @return string HTML */ - public static function revComment( $rev ) { + function revComment( $rev ) { if( $rev->userCan( Revision::DELETED_COMMENT ) ) { - $block = self::commentBlock( $rev->getRawComment(), $rev->getTitle() ); + $block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle() ); } else { $block = " " . wfMsgHtml( 'rev-deleted-comment' ) . ""; @@ -1049,49 +995,35 @@ class Linker { return $block; } - /** - * @todo document - * @static - */ - public static function tocIndent() { + /** @todo document */ + function tocIndent() { return "\n
      "; } - /** - * @todo document - * @static - */ - public static function tocUnindent($level) { + /** @todo document */ + function tocUnindent($level) { return "\n" . str_repeat( "
    \n\n", $level>0 ? $level : 0 ); } /** * parameter level defines if we are on an indentation level - * - * @static */ - public static function tocLine( $anchor, $tocline, $tocnumber, $level ) { + function tocLine( $anchor, $tocline, $tocnumber, $level ) { return "\n
  • ' . $tocnumber . ' ' . $tocline . ''; } - /** - * @todo document - * @static - */ - static function tocLineEnd() { + /** @todo document */ + function tocLineEnd() { return "
  • \n"; } - /** - * @todo document - * @static - */ - static function tocList($toc) { + /** @todo document */ + function tocList($toc) { global $wgJsMimeType; - $title = wfMsgForContent('toc') ; + $title = wfMsgForContent('toc') ; return '
    ' . '

    ' . $title . "

    \n" @@ -1108,33 +1040,29 @@ class Linker { . "\n"; } - /** - * @todo document - * @static - */ - public static function editSectionLinkForOther( $title, $section ) { + /** @todo document */ + function editSectionLinkForOther( $title, $section ) { global $wgContLang; $title = Title::newFromText( $title ); $editurl = '§ion='.$section; - $url = self::makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl ); + $url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl ); return "[".$url."]"; + } /** - * @param $title Title object - * @param $section Integer section number - * @param $hint Link String title, or default if omitted or empty - * - * @static + * @param $title Title object. + * @param $section Integer: section number. + * @param $hint Link String: title, or default if omitted or empty */ - public static function editSectionLink( $nt, $section, $hint='' ) { + function editSectionLink( $nt, $section, $hint='' ) { global $wgContLang; $editurl = '§ion='.$section; $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"'; - $url = self::makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '', $hint ); + $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '', $hint ); return "[".$url."]"; } @@ -1142,10 +1070,10 @@ class Linker { /** * Split a link trail, return the "inside" portion and the remainder of the trail * as a two-element array - * + * * @static */ - public static function splitTrail( $trail ) { + static function splitTrail( $trail ) { static $regex = false; if ( $regex === false ) { global $wgContLang; @@ -1160,5 +1088,6 @@ class Linker { } return array( $inside, $trail ); } + } ?> diff --git a/includes/LogPage.php b/includes/LogPage.php index 46bace0001..d25b8aa4ce 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -130,7 +130,7 @@ class LogPage { /** * @static */ - static function actionText( $type, $action, $title = NULL, $forContent = true, $params = array(), $filterWikilinks=false, $translate=false ) { + function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks=false, $translate=false ) { global $wgLang, $wgContLang, $wgLogActions; $key = "$type/$action"; @@ -138,35 +138,37 @@ class LogPage { if( is_null( $title ) ) { $rv=wfMsg( $wgLogActions[$key] ); } else { - if( $forContent ) { - $titleLink = $title->getPrefixedText(); - } else { + if( $skin ) { + switch( $type ) { case 'move': - $titleLink = Linker::makeLinkObj( $title, $title->getPrefixedText(), 'redirect=no' ); - $params[0] = Linker::makeLinkObj( Title::newFromText( $params[0] ), $params[0] ); + $titleLink = $skin->makeLinkObj( $title, $title->getPrefixedText(), 'redirect=no' ); + $params[0] = $skin->makeLinkObj( Title::newFromText( $params[0] ), $params[0] ); break; case 'block': if( substr( $title->getText(), 0, 1 ) == '#' ) { $titleLink = $title->getText(); } else { - $titleLink = Linker::makeLinkObj( $title, $title->getText() ); - $titleLink .= ' (' . Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Contributions', $title->getDBkey() ), wfMsg( 'contribslink' ) ) . ')'; + $titleLink = $skin->makeLinkObj( $title, $title->getText() ); + $titleLink .= ' (' . $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Contributions', $title->getDBkey() ), wfMsg( 'contribslink' ) ) . ')'; } break; case 'rights': $text = $wgContLang->ucfirst( $title->getText() ); - $titleLink = Linker::makeLinkObj( Title::makeTitle( NS_USER, $text ) ); + $titleLink = $skin->makeLinkObj( Title::makeTitle( NS_USER, $text ) ); break; default: - $titleLink = Linker::makeLinkObj( $title ); + $titleLink = $skin->makeLinkObj( $title ); } + + } else { + $titleLink = $title->getPrefixedText(); } if( $key == 'rights/rights' ) { - if( $forContent ) { - $rightsnone = wfMsgForContent( 'rightsnone' ); - } else { + if ($skin) { $rightsnone = wfMsg( 'rightsnone' ); + } else { + $rightsnone = wfMsgForContent( 'rightsnone' ); } if( !isset( $params[0] ) || trim( $params[0] ) == '' ) $params[0] = $rightsnone; @@ -174,17 +176,17 @@ class LogPage { $params[1] = $rightsnone; } if( count( $params ) == 0 ) { - if ( $forContent ) { - $rv = wfMsgForContent( $wgLogActions[$key], $titleLink ); - } else { + if ( $skin ) { $rv = wfMsg( $wgLogActions[$key], $titleLink ); + } else { + $rv = wfMsgForContent( $wgLogActions[$key], $titleLink ); } } else { array_unshift( $params, $titleLink ); if ( $translate && $key == 'block/block' ) { $params[1] = $wgLang->translateBlockExpiry($params[1]); } - $rv = wfMsgReal( $wgLogActions[$key], $params, true, $forContent ); + $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ); } } } else { @@ -192,8 +194,8 @@ class LogPage { $rv = "$action"; } if( $filterWikilinks ) { - $rv = str_replace( '[[', '', $rv ); - $rv = str_replace( ']]', '', $rv ); + $rv = str_replace( "[[", "", $rv ); + $rv = str_replace( "]]", "", $rv ); } return $rv; } @@ -213,9 +215,9 @@ class LogPage { $this->action = $action; $this->target = $target; $this->comment = $comment; - $this->params = self::makeParamBlob( $params ); + $this->params = LogPage::makeParamBlob( $params ); - $this->actionText = self::actionText( $this->type, $action, $target, true, $params ); + $this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params ); return $this->saveContent(); } @@ -224,7 +226,7 @@ class LogPage { * Create a blob from a parameter array * @static */ - static function makeParamBlob( $params ) { + function makeParamBlob( $params ) { return implode( "\n", $params ); } @@ -232,7 +234,7 @@ class LogPage { * Extract a parameter array from a blob * @static */ - static function extractParams( $blob ) { + function extractParams( $blob ) { if ( $blob === '' ) { return array(); } else { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index dc56282320..a59ff3d357 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -231,7 +231,7 @@ class OutputPage { * Add an array of categories, with names in the keys */ public function addCategoryLinks($categories) { - global $wgContLang; + global $wgUser, $wgContLang; if ( !is_array( $categories ) ) { return; @@ -242,10 +242,11 @@ class OutputPage { $lb->setArray( $arr ); $lb->execute(); + $sk =& $wgUser->getSkin(); foreach ( $categories as $category => $arbitrary ) { $title = Title::makeTitleSafe( NS_CATEGORY, $category ); $text = $wgContLang->convertHtml( $title->getText() ); - $this->mCategoryLinks[] = Linker::makeLinkObj( $title, $text ); + $this->mCategoryLinks[] = $sk->makeLinkObj( $title, $text ); } } @@ -614,6 +615,9 @@ class OutputPage { # Buffer output; final headers may depend on later processing ob_start(); + # Disable temporary placeholders, so that the skin produces HTML + $sk->postParseLinkColour( false ); + $wgRequest->response()->header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" ); $wgRequest->response()->header( 'Content-language: '.$wgContLanguageCode ); @@ -756,7 +760,7 @@ class OutputPage { * @param string $permission key required */ public function permissionRequired( $permission ) { - global $wgGroupPermissions; + global $wgGroupPermissions, $wgUser; $this->setPageTitle( wfMsg( 'badaccess' ) ); $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) ); @@ -770,7 +774,8 @@ class OutputPage { $groupName = User::getGroupName( $key ); $groupPage = User::getGroupPage( $key ); if( $groupPage ) { - $groups[] = '"'.Linker::makeLinkObj( $groupPage, $groupName ).'"'; + $skin =& $wgUser->getSkin(); + $groups[] = '"'.$skin->makeLinkObj( $groupPage, $groupName ).'"'; } else { $groups[] = '"'.$groupName.'"'; } @@ -818,13 +823,15 @@ class OutputPage { return; } + $skin = $wgUser->getSkin(); + $this->setPageTitle( wfMsg( 'loginreqtitle' ) ); $this->setHtmlTitle( wfMsg( 'errorpagetitle' ) ); $this->setRobotPolicy( 'noindex,nofollow' ); $this->setArticleFlag( false ); $loginTitle = SpecialPage::getTitleFor( 'Userlogin' ); - $loginLink = Linker::makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() ); + $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() ); $this->addHtml( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) ); $this->addHtml( "\n" ); @@ -852,8 +859,9 @@ class OutputPage { $this->setArticleRelated( false ); if( $protected ) { + $skin = $wgUser->getSkin(); $this->setPageTitle( wfMsg( 'viewsource' ) ); - $this->setSubtitle( wfMsg( 'viewsourcefor', Linker::makeKnownLinkObj( $wgTitle ) ) ); + $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) ); # Determine if protection is due to the page being a system message # and show an appropriate explanation @@ -957,7 +965,7 @@ class OutputPage { * @param $returnto page title to return to. Default is Main Page. */ public function returnToMain( $auto = true, $returnto = NULL ) { - global $wgOut, $wgRequest; + global $wgUser, $wgOut, $wgRequest; if ( $returnto == NULL ) { $returnto = $wgRequest->getText( 'returnto' ); @@ -976,7 +984,8 @@ class OutputPage { $titleObj = Title::newMainPage(); } - $link = Linker::makeLinkObj( $titleObj, '' ); + $sk = $wgUser->getSkin(); + $link = $sk->makeLinkObj( $titleObj, '' ); $r = wfMsg( 'returnto', $link ); if ( $auto ) { diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 2b174cffef..380bbe2637 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -21,7 +21,7 @@ class PageHistory { const DIR_PREV = 0; const DIR_NEXT = 1; - var $mArticle, $mTitle; + var $mArticle, $mTitle, $mSkin; var $lastdate; var $linesonpage; var $mNotificationTimestamp; @@ -34,9 +34,12 @@ class PageHistory { * @returns nothing */ function PageHistory($article) { + global $wgUser; + $this->mArticle =& $article; $this->mTitle =& $article->mTitle; $this->mNotificationTimestamp = NULL; + $this->mSkin = $wgUser->getSkin(); } /** @@ -68,7 +71,7 @@ class PageHistory { $wgOut->setSyndicated( true ); $logPage = SpecialPage::getTitleFor( 'Log' ); - $logLink = Linker::makeKnownLinkObj( $logPage, wfMsgHtml( 'viewpagelogs' ), 'page=' . $this->mTitle->getPrefixedUrl() ); + $logLink = $this->mSkin->makeKnownLinkObj( $logPage, wfMsgHtml( 'viewpagelogs' ), 'page=' . $this->mTitle->getPrefixedUrl() ); $subtitle = wfMsgHtml( 'revhistory' ) . '
    ' . $logLink; $wgOut->setSubtitle( $subtitle ); @@ -175,8 +178,8 @@ class PageHistory { $arbitrary = $this->diffButtons( $rev, $firstInList, $counter ); $link = $this->revLink( $rev ); - $user = Linker::userLink( $rev->getUser(), $rev->getUserText() ) - . Linker::userToolLinks( $rev->getUser(), $rev->getUserText() ); + $user = $this->mSkin->userLink( $rev->getUser(), $rev->getUserText() ) + . $this->mSkin->userToolLinks( $rev->getUser(), $rev->getUserText() ); $s .= "($curlink) ($lastlink) $arbitrary"; @@ -186,7 +189,7 @@ class PageHistory { // We don't currently handle well changing the top revision's settings $del = wfMsgHtml( 'rev-delundel' ); } else { - $del = Linker::makeKnownLinkObj( $revdel, + $del = $this->mSkin->makeKnownLinkObj( $revdel, wfMsg( 'rev-delundel' ), 'target=' . urlencode( $this->mTitle->getPrefixedDbkey() ) . '&oldid=' . urlencode( $rev->getId() ) ); @@ -200,7 +203,7 @@ class PageHistory { $s .= ' ' . wfElement( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') ); } - $s .= Linker::revComment( $rev ); + $s .= $this->mSkin->revComment( $rev ); if ($notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp)) { $s .= ' ' . wfMsgHtml( 'updatedmarker' ) . ''; } @@ -217,7 +220,7 @@ class PageHistory { global $wgLang; $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true ); if( $rev->userCan( Revision::DELETED_TEXT ) ) { - $link = Linker::makeKnownLinkObj( + $link = $this->mSkin->makeKnownLinkObj( $this->mTitle, $date, "oldid=" . $rev->getId() ); } else { $link = $date; @@ -234,7 +237,7 @@ class PageHistory { if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { return $cur; } else { - return Linker::makeKnownLinkObj( + return $this->mSkin->makeKnownLinkObj( $this->mTitle, $cur, 'diff=' . $this->getLatestID() . "&oldid=" . $rev->getId() ); @@ -249,14 +252,14 @@ class PageHistory { return $last; } elseif ( $next === 'unknown' ) { # Next row probably exists but is unknown, use an oldid=prev link - return Linker::makeKnownLinkObj( + return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last, "diff=" . $rev->getId() . "&oldid=prev" ); } elseif( !$rev->userCan( Revision::DELETED_TEXT ) ) { return $last; } else { - return Linker::makeKnownLinkObj( + return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last, "diff=" . $rev->getId() . "&oldid={$next->rev_id}" diff --git a/includes/Pager.php b/includes/Pager.php index f4b22a3834..b14aa8ca6e 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -225,7 +225,7 @@ abstract class IndexPager implements Pager { if ( $query === null ) { return $text; } else { - return Linker::makeKnownLinkObj( $this->getTitle(), $text, + return $this->getSkin()->makeKnownLinkObj( $this->getTitle(), $text, wfArrayToCGI( $query, $this->getDefaultQuery() ) ); } } @@ -261,6 +261,17 @@ abstract class IndexPager implements Pager { return $GLOBALS['wgTitle']; } + /** + * Get the current skin. This can be overridden if necessary. + */ + function getSkin() { + if ( !isset( $this->mSkin ) ) { + global $wgUser; + $this->mSkin = $wgUser->getSkin(); + } + return $this->mSkin; + } + /** * Get an array of query parameters that should be put into self-links. * By default, all parameters passed in the URL are used, except for a diff --git a/includes/Parser.php b/includes/Parser.php index e83cbcc8bb..336b6f8f32 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1037,8 +1037,9 @@ class Parser substr($m[0], 0, 20 ) . '"' ); } - $url = wfMsg( $urlmsg, $id ); - $la = Linker::getExternalLinkAttributes( $url, "$keyword $id" ); + $url = wfMsg( $urlmsg, $id); + $sk =& $this->mOptions->getSkin(); + $la = $sk->getExternalLinkAttributes( $url, $keyword.$id ); $text = "{$keyword} {$id}"; } return $text; @@ -1257,6 +1258,8 @@ class Parser $fname = 'Parser::replaceExternalLinks'; wfProfileIn( $fname ); + $sk =& $this->mOptions->getSkin(); + $bits = preg_split( EXT_LINK_BRACKETED, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); $s = $this->replaceFreeExternalLinks( array_shift( $bits ) ); @@ -1318,7 +1321,7 @@ class Parser # This means that users can paste URLs directly into the text # Funny characters like ö aren't valid in URLs anyway # This was changed in August 2004 - $s .= Linker::makeExternalLink( $url, $text, false, $linktype, $this->mTitle->getNamespace() ) . $dtrail . $trail; + $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->mTitle->getNamespace() ) . $dtrail . $trail; # Register link in the output object. # Replace unnecessary URL escape codes with the referenced character @@ -1344,6 +1347,8 @@ class Parser $s = array_shift( $bits ); $i = 0; + $sk =& $this->mOptions->getSkin(); + while ( $i < count( $bits ) ){ $protocol = $bits[$i++]; $remainder = $bits[$i++]; @@ -1395,7 +1400,7 @@ class Parser $text = $this->maybeMakeExternalImage( $url ); if ( $text === false ) { # Not an image, make a link - $text = Linker::makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', $this->mTitle->getNamespace() ); + $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', $this->mTitle->getNamespace() ); # Register it in the output object... # Replace unnecessary URL escape codes with their equivalent characters $pasteurized = Parser::replaceUnusualEscapes( $url ); @@ -1450,6 +1455,7 @@ class Parser * @private */ function maybeMakeExternalImage( $url ) { + $sk =& $this->mOptions->getSkin(); $imagesfrom = $this->mOptions->getAllowExternalImagesFrom(); $imagesexception = !empty($imagesfrom); $text = false; @@ -1457,7 +1463,7 @@ class Parser || ( $imagesexception && strpos( $url, $imagesfrom ) === 0 ) ) { if ( preg_match( EXT_IMAGE_REGEX, $url ) ) { # Image found - $text = Linker::makeExternalImage( htmlspecialchars( $url ) ); + $text = $sk->makeExternalImage( htmlspecialchars( $url ) ); } } return $text; @@ -1479,6 +1485,8 @@ class Parser # the % is needed to support urlencoded titles as well if ( !$tc ) { $tc = Title::legalChars() . '#%'; } + $sk =& $this->mOptions->getSkin(); + #split the entire text string on occurences of [[ $a = explode( '[[', ' ' . $s ); #get the first element (all text up to first [[), and remove the space we added @@ -1726,13 +1734,13 @@ class Parser if( ( $nt->getPrefixedText() === $selflink ) && ( $nt->getFragment() === '' ) ) { # Self-links are handled specially; generally de-link and change to bold. - $s .= $prefix . Linker::makeSelfLinkObj( $nt, $text, '', $trail ); + $s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, '', $trail ); continue; } # Special and Media are pseudo-namespaces; no pages actually exist in them if( $ns == NS_MEDIA ) { - $link = Linker::makeMediaLinkObj( $nt, $text ); + $link = $sk->makeMediaLinkObj( $nt, $text ); # Cloak with NOPARSE to avoid replacement in replaceExternalLinks $s .= $prefix . $this->armorLinks( $link ) . $trail; $this->mOutput->addImage( $nt->getDBkey() ); @@ -1807,7 +1815,8 @@ class Parser */ function makeKnownLinkHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { list( $inside, $trail ) = Linker::splitTrail( $trail ); - $link = Linker::makeKnownLinkObj( $nt, $text, $query, $inside, $prefix ); + $sk =& $this->mOptions->getSkin(); + $link = $sk->makeKnownLinkObj( $nt, $text, $query, $inside, $prefix ); return $this->armorLinks( $link ) . $trail; } @@ -3372,6 +3381,9 @@ class Parser $enoughToc = false; } + # We need this to perform operations on the HTML + $sk =& $this->mOptions->getSkin(); + # headline counter $headlineCount = 0; $sectionCount = 0; # headlineCount excluding template sections @@ -3415,7 +3427,7 @@ class Parser $toclevel++; $sublevelCount[$toclevel] = 0; if( $toclevel<$wgMaxTocLevel ) { - $toc .= Linker::tocIndent(); + $toc .= $sk->tocIndent(); } } elseif ( $level < $prevlevel && $toclevel > 1 ) { @@ -3439,13 +3451,13 @@ class Parser } } if( $toclevel<$wgMaxTocLevel ) { - $toc .= Linker::tocUnindent( $prevtoclevel - $toclevel ); + $toc .= $sk->tocUnindent( $prevtoclevel - $toclevel ); } } else { # No change in level, end TOC line if( $toclevel<$wgMaxTocLevel ) { - $toc .= Linker::tocLineEnd(); + $toc .= $sk->tocLineEnd(); } } @@ -3505,7 +3517,7 @@ class Parser $anchor .= '_' . $refcount[$headlineCount]; } if( $enoughToc && ( !isset($wgMaxTocLevel) || $toclevel<$wgMaxTocLevel ) ) { - $toc .= Linker::tocLine($anchor, $tocline, $numbering, $toclevel); + $toc .= $sk->tocLine($anchor, $tocline, $numbering, $toclevel); } # give headline the correct tag @$head[$headlineCount] .= "editSectionLinkForOther($templatetitle, $templatesection); else - $head[$headlineCount] .= Linker::editSectionLink($this->mTitle, $sectionCount+1, $headline_hint); + $head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint); } // Yes, the headline logically goes before the edit section. Why isn't it there // in source? Ask the CSS people. The float gets screwed up if you do that. @@ -3532,9 +3544,9 @@ class Parser if( $enoughToc ) { if( $toclevel<$wgMaxTocLevel ) { - $toc .= Linker::tocUnindent( $toclevel - 1 ); + $toc .= $sk->tocUnindent( $toclevel - 1 ); } - $toc = Linker::tocList( $toc ); + $toc = $sk->tocList( $toc ); } # split up and insert constructed headlines @@ -3549,7 +3561,7 @@ class Parser # Disabled because it broke block formatting # For example, a bullet point in the top line - # $full .= Linker::editSectionLink(0); + # $full .= $sk->editSectionLink(0); } $full .= $block; if( $enoughToc && !$i && $isMain && !$this->mForceTocPosition ) { @@ -3892,7 +3904,7 @@ class Parser /** * Replace link placeholders with actual links, in the buffer - * Placeholders created in Linker::makeLinkObj() + * Placeholders created in Skin::makeLinkObj() * Returns an array of links found, indexed by PDBK: * 0 - broken * 1 - normal link @@ -3909,6 +3921,7 @@ class Parser $pdbks = array(); $colours = array(); + $sk =& $this->mOptions->getSkin(); $linkCache =& LinkCache::singleton(); if ( !empty( $this->mLinkHolders['namespaces'] ) ) { @@ -4089,15 +4102,15 @@ class Parser $linkCache->addBadLinkObj( $title ); $colours[$pdbk] = 0; $this->mOutput->addLink( $title, 0 ); - $wgOutputReplace[$searchkey] = Linker::makeBrokenLinkObj( $title, + $wgOutputReplace[$searchkey] = $sk->makeBrokenLinkObj( $title, $this->mLinkHolders['texts'][$key], $this->mLinkHolders['queries'][$key] ); } elseif ( $colours[$pdbk] == 1 ) { - $wgOutputReplace[$searchkey] = Linker::makeKnownLinkObj( $title, + $wgOutputReplace[$searchkey] = $sk->makeKnownLinkObj( $title, $this->mLinkHolders['texts'][$key], $this->mLinkHolders['queries'][$key] ); } elseif ( $colours[$pdbk] == 2 ) { - $wgOutputReplace[$searchkey] = Linker::makeStubLinkObj( $title, + $wgOutputReplace[$searchkey] = $sk->makeStubLinkObj( $title, $this->mLinkHolders['texts'][$key], $this->mLinkHolders['queries'][$key] ); } @@ -4123,7 +4136,7 @@ class Parser $wgOutputReplace = array(); foreach( $this->mInterwikiLinkHolders['texts'] as $key => $link ) { $title = $this->mInterwikiLinkHolders['titles'][$key]; - $wgOutputReplace[$key] = Linker::makeLinkObj( $title, $link ); + $wgOutputReplace[$key] = $sk->makeLinkObj( $title, $link ); } $text = preg_replace_callback( @@ -4203,6 +4216,7 @@ class Parser $ig->setShowBytes( false ); $ig->setShowFilename( false ); $ig->setParsing(); + $ig->useSkin( $this->mOptions->getSkin() ); if( isset( $params['caption'] ) ) $ig->setCaption( $params['caption'] ); @@ -4331,7 +4345,8 @@ class Parser $alt = Sanitizer::stripAllTags( $alt ); # Linker does the rest - return Linker::makeImageLinkObj( $nt, $caption, $alt, $align, $width, $height, $framed, $thumb, $manual_thumb, $page ); + $sk =& $this->mOptions->getSkin(); + return $sk->makeImageLinkObj( $nt, $caption, $alt, $align, $width, $height, $framed, $thumb, $manual_thumb, $page ); } /** @@ -4667,6 +4682,7 @@ class ParserOptions var $mInterwikiMagic; # Interlanguage links are removed and returned in an array var $mAllowExternalImages; # Allow external images inline var $mAllowExternalImagesFrom; # If not, any exception? + var $mSkin; # Reference to the preferred skin var $mDateFormat; # Date format index var $mEditSection; # Create "edit section" links var $mNumberHeadings; # Automatically number headings @@ -4676,7 +4692,7 @@ class ParserOptions var $mMaxIncludeSize; # Maximum size of template expansions, in bytes var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS - var $mUser; # Stored user object, just used to initialise the date format + var $mUser; # Stored user object, just used to initialise the skin function getUseTeX() { return $this->mUseTeX; } function getUseDynamicDates() { return $this->mUseDynamicDates; } @@ -4691,6 +4707,13 @@ class ParserOptions function getMaxIncludeSize() { return $this->mMaxIncludeSize; } function getRemoveComments() { return $this->mRemoveComments; } + function &getSkin() { + if ( !isset( $this->mSkin ) ) { + $this->mSkin = $this->mUser->getSkin(); + } + return $this->mSkin; + } + function getDateFormat() { if ( !isset( $this->mDateFormat ) ) { $this->mDateFormat = $this->mUser->getDatePreference(); @@ -4708,6 +4731,7 @@ class ParserOptions function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); } function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); } function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); } + function setSkin( $x ) { $this->mSkin = $x; } function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage, $x); } function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize, $x ); } function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments, $x ); } @@ -4748,6 +4772,7 @@ class ParserOptions $this->mInterwikiMagic = $wgInterwikiMagic; $this->mAllowExternalImages = $wgAllowExternalImages; $this->mAllowExternalImagesFrom = $wgAllowExternalImagesFrom; + $this->mSkin = null; # Deferred $this->mDateFormat = null; # Deferred $this->mEditSection = true; $this->mNumberHeadings = $user->getOption( 'numberheadings' ); diff --git a/includes/QueryPage.php b/includes/QueryPage.php index f7b9d1a585..3839aae563 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -156,11 +156,12 @@ class QueryPage { } /** - * Formats the results of the query for display. The result is a single - * row of result data. You should be able to grab SQL results off of it. + * Formats the results of the query for display. The skin is the current + * skin; you can use it for making links. The result is a single row of + * result data. You should be able to grab SQL results off of it. * If the function return "false", the line output will be skipped. */ - function formatResult( $result ) { + function formatResult( $skin, $result ) { return ''; } @@ -274,7 +275,7 @@ class QueryPage { * @param $shownavigation show navigation like "next 200"? */ function doQuery( $offset, $limit, $shownavigation=true ) { - global $wgOut, $wgLang, $wgContLang; + global $wgUser, $wgOut, $wgLang, $wgContLang; $this->offset = $offset; $this->limit = $limit; @@ -320,6 +321,8 @@ class QueryPage { $this->preprocessResults( $dbr, $res ); + $sk = $wgUser->getSkin( ); + if($shownavigation) { $wgOut->addHTML( $this->getPageHeader() ); $top = wfShowingResults( $offset, $num); @@ -340,7 +343,7 @@ class QueryPage { # Only read at most $num rows, because $res may contain the whole 1000 for ( $i = 0; $i < $num && $obj = $dbr->fetchObject( $res ); $i++ ) { - $format = $this->formatResult( $obj ); + $format = $this->formatResult( $sk, $obj ); if ( $format ) { $attr = ( isset ( $obj->usepatrol ) && $obj->usepatrol && $obj->patrolled == 0 ) ? ' class="not-patrolled"' : ''; @@ -351,7 +354,7 @@ class QueryPage { if($this->tryLastResult()) { // flush the very last result $obj = null; - $format = $this->formatResult( $obj ); + $format = $this->formatResult( $sk, $obj ); if( $format ) { $attr = ( isset ( $obj->usepatrol ) && $obj->usepatrol && $obj->patrolled == 0 ) ? ' class="not-patrolled"' : ''; @@ -470,10 +473,10 @@ class QueryPage { */ class PageQueryPage extends QueryPage { - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgContLang; $nt = Title::makeTitle( $result->namespace, $result->title ); - return Linker::makeKnownLinkObj( $nt, htmlspecialchars( $wgContLang->convert( $nt->getPrefixedText() ) ) ); + return $skin->makeKnownLinkObj( $nt, htmlspecialchars( $wgContLang->convert( $nt->getPrefixedText() ) ) ); } } diff --git a/includes/Skin.php b/includes/Skin.php index 87dad8f1c8..0f9ca2ca67 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -70,7 +70,7 @@ class Skin extends Linker { */ static function normalizeKey( $key ) { global $wgDefaultSkin; - $skinNames = self::getSkinNames(); + $skinNames = Skin::getSkinNames(); if( $key == '' ) { // Don't return the default immediately; @@ -110,9 +110,9 @@ class Skin extends Linker { static function &newFromKey( $key ) { global $wgStyleDirectory; - $key = self::normalizeKey( $key ); + $key = Skin::normalizeKey( $key ); - $skinNames = self::getSkinNames(); + $skinNames = Skin::getSkinNames(); $skinName = $skinNames[$key]; # Grab the skin class and initialise it. @@ -579,7 +579,7 @@ END; $t = $embed . implode ( "{$pop} {$sep} {$embed}" , $wgOut->mCategoryLinks ) . $pop; $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escape' ), count( $wgOut->mCategoryLinks ) ); - $s = self::makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg ) + $s = $this->makeLinkObj( Title::newFromText( wfMsgForContent('pagecategorieslink') ), $msg ) . ': ' . $t; # optional 'dmoz-like' category browser. Will be shown under the list @@ -591,7 +591,7 @@ END; $parenttree = $wgTitle->getParentCategoryTree(); # Skin object passed by reference cause it can not be # accessed under the method subfunction drawCategoryBrowser - $tempout = explode("\n", self::drawCategoryBrowser($parenttree, $this) ); + $tempout = explode("\n", Skin::drawCategoryBrowser($parenttree, $this) ); # Clean out bogus first entry and sort them unset($tempout[0]); asort($tempout); @@ -602,14 +602,12 @@ END; return $s; } - /** - * Render the array as a series of links. - * @param $tree Array categories tree returned by Title::getParentCategoryTree - * @param &skin Object skin passed by reference + /** Render the array as a serie of links. + * @param $tree Array: categories tree returned by Title::getParentCategoryTree + * @param &skin Object: skin passed by reference * @return String separated by >, terminate with "\n" - * @static */ - static function drawCategoryBrowser($tree, &$skin) { + function drawCategoryBrowser($tree, &$skin) { $return = ''; foreach ($tree as $element => $parent) { if (empty($parent)) { @@ -617,11 +615,11 @@ END; $return .= "\n"; } else { # grab the others elements - $return .= self::drawCategoryBrowser($parent, $skin) . ' > '; + $return .= Skin::drawCategoryBrowser($parent, $skin) . ' > '; } # add our current element to the list $eltitle = Title::NewFromText($element); - $return .= self::makeLinkObj( $eltitle, $eltitle->getText() ) ; + $return .= $skin->makeLinkObj( $eltitle, $eltitle->getText() ) ; } return $return; } @@ -692,13 +690,13 @@ END; $image = new Image( $wgTitle ); if( $image->exists() ) { $link = htmlspecialchars( $image->getURL() ); - $style = self::getInternalLinkAttributes( $link, $name ); + $style = $this->getInternalLinkAttributes( $link, $name ); $s .= " | {$name}"; } } } if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) { - $s .= ' | ' . self::makeKnownLinkObj( $wgTitle, + $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle, wfMsg( 'currentrev' ) ); } @@ -706,8 +704,8 @@ END; # do not show "You have new messages" text when we are viewing our # own talk page if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) { - $tl = self::makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' ); - $dl = self::makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' ); + $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' ); + $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' ); $s.= ' | '. wfMsg( 'youhavenewmessages', $tl, $dl ) . ''; # disable caching $wgOut->setSquidMaxage(0); @@ -734,7 +732,7 @@ END; $msg = 'viewdeleted'; } return wfMsg( $msg, - self::makeKnownLink( + $this->makeKnownLink( $wgContLang->SpecialPage( 'Undelete/' . $wgTitle->getPrefixedDBkey() ), wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $n ) ) ); } @@ -796,7 +794,7 @@ END; $c++; if ($cmakeLink( $growinglink, htmlspecialchars( $link ) ); if(preg_match('/class="new"/i',$getlink)) { break; } # this is a hack, but it saves time if ($c>1) { $subpages .= ' | '; @@ -823,7 +821,7 @@ END; if( $wgShowIPinHeader && isset( $_COOKIE[ini_get('session.name')] ) ) { $n = wfGetIP(); - $tl = self::makeKnownLinkObj( $wgUser->getTalkPage(), + $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), $wgLang->getNsText( NS_TALK ) ); $s .= $n . ' ('.$tl.')'; @@ -836,24 +834,24 @@ END; $q = ''; } else { $q = "returnto={$rt}"; } - $s .= "\n
    " . self::makeKnownLinkObj( + $s .= "\n
    " . $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Userlogin' ), wfMsg( 'login' ), $q ); } else { $n = $wgUser->getName(); $rt = $wgTitle->getPrefixedURL(); - $tl = self::makeKnownLinkObj( $wgUser->getTalkPage(), + $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), $wgLang->getNsText( NS_TALK ) ); $tl = " ({$tl})"; - $s .= self::makeKnownLinkObj( $wgUser->getUserPage(), + $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(), $n ) . "{$tl}
    " . - self::makeKnownLinkObj( SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ), + $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ), "returnto={$rt}" ) . ' | ' . - self::specialLink( 'preferences' ); + $this->specialLink( 'preferences' ); } - $s .= ' | ' . self::makeKnownLink( wfMsgForContent( 'helppage' ), + $s .= ' | ' . $this->makeKnownLink( wfMsgForContent( 'helppage' ), wfMsg( 'help' ) ); return $s; @@ -887,7 +885,7 @@ END; $sep = " |\n"; $s = $this->mainPageLink() . $sep - . self::specialLink( 'recentchanges' ); + . $this->specialLink( 'recentchanges' ); if ( $wgOut->isArticleRelated() ) { $s .= $sep . $this->editThisPage() @@ -1044,9 +1042,9 @@ END; $out = ''; if( $wgRightsPage ) { - $link = self::makeKnownLink( $wgRightsPage, $wgRightsText ); + $link = $this->makeKnownLink( $wgRightsPage, $wgRightsText ); } elseif( $wgRightsUrl ) { - $link = self::makeExternalLink( $wgRightsUrl, $wgRightsText ); + $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText ); } else { # Give up now return $out; @@ -1150,12 +1148,12 @@ END; function mainPageLink() { $mp = wfMsgForContent( 'mainpage' ); $mptxt = wfMsg( 'mainpage'); - $s = self::makeKnownLink( $mp, $mptxt ); + $s = $this->makeKnownLink( $mp, $mptxt ); return $s; } function copyrightLink() { - $s = self::makeKnownLink( wfMsgForContent( 'copyrightpage' ), + $s = $this->makeKnownLink( wfMsgForContent( 'copyrightpage' ), wfMsg( 'copyrightpagename' ) ); return $s; } @@ -1165,12 +1163,12 @@ END; if ($privacy == '-') { return ''; } else { - return self::makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy); + return $this->makeKnownLink( wfMsgForContent( 'privacypage' ), $privacy); } } function aboutLink() { - $s = self::makeKnownLink( wfMsgForContent( 'aboutpage' ), + $s = $this->makeKnownLink( wfMsgForContent( 'aboutpage' ), wfMsg( 'aboutsite' ) ); return $s; } @@ -1180,7 +1178,7 @@ END; if ($disclaimers == '-') { return ''; } else { - return self::makeKnownLink( wfMsgForContent( 'disclaimerpage' ), + return $this->makeKnownLink( wfMsgForContent( 'disclaimerpage' ), $disclaimers ); } } @@ -1197,7 +1195,7 @@ END; $t = wfMsg( 'viewsource' ); } - $s = self::makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() ); + $s = $this->makeKnownLinkObj( $wgTitle, $t, $this->editUrlOptions() ); } return $s; } @@ -1226,7 +1224,7 @@ END; if ( $wgTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('delete') ) { $t = wfMsg( 'deletethispage' ); - $s = self::makeKnownLinkObj( $wgTitle, $t, 'action=delete' ); + $s = $this->makeKnownLinkObj( $wgTitle, $t, 'action=delete' ); } else { $s = ''; } @@ -1245,7 +1243,7 @@ END; $t = wfMsg( 'protectthispage' ); $q = 'action=protect'; } - $s = self::makeKnownLinkObj( $wgTitle, $t, $q ); + $s = $this->makeKnownLinkObj( $wgTitle, $t, $q ); } else { $s = ''; } @@ -1263,7 +1261,7 @@ END; $t = wfMsg( 'watchthispage' ); $q = 'action=watch'; } - $s = self::makeKnownLinkObj( $wgTitle, $t, $q ); + $s = $this->makeKnownLinkObj( $wgTitle, $t, $q ); } else { $s = wfMsg( 'notanarticle' ); } @@ -1274,7 +1272,7 @@ END; global $wgTitle; if ( $wgTitle->userCanMove() ) { - return self::makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ), + return $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ), wfMsg( 'movethispage' ), 'target=' . $wgTitle->getPrefixedURL() ); } else { // no message if page is protected - would be redundant @@ -1285,14 +1283,14 @@ END; function historyLink() { global $wgTitle; - return self::makeKnownLinkObj( $wgTitle, + return $this->makeKnownLinkObj( $wgTitle, wfMsg( 'history' ), 'action=history' ); } function whatLinksHere() { global $wgTitle; - return self::makeKnownLinkObj( + return $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Whatlinkshere', $wgTitle->getPrefixedDBkey() ), wfMsg( 'whatlinkshere' ) ); } @@ -1300,7 +1298,7 @@ END; function userContribsLink() { global $wgTitle; - return self::makeKnownLinkObj( + return $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Contributions', $wgTitle->getDBkey() ), wfMsg( 'contributions' ) ); } @@ -1319,7 +1317,7 @@ END; function emailUserLink() { global $wgTitle; - return self::makeKnownLinkObj( + return $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Emailuser', $wgTitle->getDBkey() ), wfMsg( 'emailuser' ) ); } @@ -1330,7 +1328,7 @@ END; if ( ! $wgOut->isArticleRelated() ) { return '(' . wfMsg( 'notanarticle' ) . ')'; } else { - return self::makeKnownLinkObj( + return $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Recentchangeslinked', $wgTitle->getPrefixedDBkey() ), wfMsg( 'recentchangeslinked' ) ); } @@ -1367,7 +1365,7 @@ END; $text = $wgContLang->getLanguageName( $nt->getInterwiki() ); if ( '' == $text ) { $text = $l; } - $style = self::getExternalLinkAttributes( $l, $text ); + $style = $this->getExternalLinkAttributes( $l, $text ); $s .= "{$text}"; } if($wgContLang->isRTL()) $s .= ''; @@ -1375,7 +1373,7 @@ END; } function bugReportsLink() { - $s = self::makeKnownLink( wfMsgForContent( 'bugreportspage' ), + $s = $this->makeKnownLink( wfMsgForContent( 'bugreportspage' ), wfMsg( 'bugreports' ) ); return $s; } @@ -1387,18 +1385,18 @@ END; $id = $t1->getArticleID(); if ( 0 == $id ) { - $s = self::makeBrokenLink( $t1->getText() ); + $s = $this->makeBrokenLink( $t1->getText() ); } else { - $s = self::makeKnownLink( $t1->getText() ); + $s = $this->makeKnownLink( $t1->getText() ); } $s .= ', '; $id = $t2->getArticleID(); if ( 0 == $id ) { - $s .= self::makeBrokenLink( $t2->getText() ); + $s .= $this->makeBrokenLink( $t2->getText() ); } else { - $s .= self::makeKnownLink( $t2->getText() ); + $s .= $this->makeKnownLink( $t2->getText() ); } return $s; } @@ -1446,7 +1444,7 @@ END; $text = wfMsg( 'talkpage' ); } - $s = self::makeLinkObj( $link, $text ); + $s = $this->makeLinkObj( $link, $text ); return $s; } @@ -1469,7 +1467,7 @@ END; $title =& $wgTitle->getTalkPage(); } - return self::makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' ); + return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' ); } /* these are used extensively in SkinTemplate, but also some other places */ diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index a0ae8cdaa9..a4238cce74 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -295,12 +295,12 @@ class SkinTemplate extends Skin { $usertalktitle = $usertitle->getTalkPage(); if( !$usertalktitle->equals( $this->mTitle ) ) { $ntl = wfMsg( 'youhavenewmessages', - self::makeKnownLinkObj( + $this->makeKnownLinkObj( $usertalktitle, wfMsgHtml( 'newmessageslink' ), 'redirect=no' ), - self::makeKnownLinkObj( + $this->makeKnownLinkObj( $usertalktitle, wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' diff --git a/includes/SpecialAllpages.php b/includes/SpecialAllpages.php index 43d63dbbcf..e868ec7160 100644 --- a/includes/SpecialAllpages.php +++ b/includes/SpecialAllpages.php @@ -83,7 +83,8 @@ function namespaceForm ( $namespace = NS_MAIN, $from = '' ) { * @param integer $namespace (default NS_MAIN) */ function showToplevel ( $namespace = NS_MAIN, $including = false ) { - global $wgOut; + global $wgOut, $wgUser; + $sk = $wgUser->getSkin(); $fname = "indexShowToplevel"; # TODO: Either make this *much* faster or cache the title index points @@ -184,6 +185,8 @@ function showToplevel ( $namespace = NS_MAIN, $including = false ) { * @param integer $namespace (Default NS_MAIN) */ function showline( $inpoint, $outpoint, $namespace = NS_MAIN ) { + global $wgUser; + $sk = $wgUser->getSkin(); $dbr =& wfGetDB( DB_SLAVE ); $inpointf = htmlspecialchars( str_replace( '_', ' ', $inpoint ) ); @@ -205,10 +208,12 @@ function showline( $inpoint, $outpoint, $namespace = NS_MAIN ) { * @param string $from list all pages from this name (default FALSE) */ function showChunk( $namespace = NS_MAIN, $from, $including = false ) { - global $wgOut, $wgContLang; + global $wgOut, $wgUser, $wgContLang; $fname = 'indexShowChunk'; + $sk = $wgUser->getSkin(); + $fromList = $this->getNamespaceKeyAndText($namespace, $from); if ( !$fromList ) { @@ -241,7 +246,7 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) { $t = Title::makeTitle( $s->page_namespace, $s->page_title ); if( $t ) { $link = ($s->page_is_redirect ? '
    ' : '' ) . - Linker::makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . + $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . ($s->page_is_redirect ? '
    ' : '' ); } else { $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; @@ -268,12 +273,12 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) { $out2 = ''; $out2 .= '
    ' . $nsForm; $out2 .= '' . - Linker::makeKnownLink( $wgContLang->specialPage( "Allpages" ), + $sk->makeKnownLink( $wgContLang->specialPage( "Allpages" ), wfMsgHtml ( 'allpages' ) ); if ( isset($dbr) && $dbr && ($n == $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) { $self = SpecialPage::getTitleFor( 'Allpages' ); $q = 'from=' . $t->getPartialUrl() . ( $namespace ? '&namespace=' . $namespace : '' ); - $out2 .= ' | ' . Linker::makeKnownLinkObj( $self, wfMsgHtml( 'nextpage', $t->getText() ), $q ); + $out2 .= ' | ' . $sk->makeKnownLinkObj( $self, wfMsgHtml( 'nextpage', $t->getText() ), $q ); } $out2 .= "

    "; } diff --git a/includes/SpecialAncientpages.php b/includes/SpecialAncientpages.php index e5b5ab7f72..39a3c8ea17 100644 --- a/includes/SpecialAncientpages.php +++ b/includes/SpecialAncientpages.php @@ -44,12 +44,12 @@ class AncientPagesPage extends QueryPage { return false; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgLang, $wgContLang; $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $result->value ), true ); $title = Title::makeTitle( $result->namespace, $result->title ); - $link = Linker::makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) ); + $link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) ); return wfSpecialList($link, $d); } } diff --git a/includes/SpecialBrokenRedirects.php b/includes/SpecialBrokenRedirects.php index 98af782311..653e13e244 100644 --- a/includes/SpecialBrokenRedirects.php +++ b/includes/SpecialBrokenRedirects.php @@ -45,7 +45,7 @@ class BrokenRedirectsPage extends PageQueryPage { return ''; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgContLang; $fromObj = Title::makeTitle( $result->namespace, $result->title ); @@ -62,12 +62,12 @@ class BrokenRedirectsPage extends PageQueryPage { // $toObj may very easily be false if the $result list is cached if ( !is_object( $toObj ) ) { - return '' . Linker::makeLinkObj( $fromObj ) . ''; + return '' . $skin->makeLinkObj( $fromObj ) . ''; } - $from = Linker::makeKnownLinkObj( $fromObj ,'', 'redirect=no' ); - $edit = Linker::makeBrokenLinkObj( $fromObj , "(".wfMsg("qbedit").")" , 'redirect=no'); - $to = Linker::makeBrokenLinkObj( $toObj ); + $from = $skin->makeKnownLinkObj( $fromObj ,'', 'redirect=no' ); + $edit = $skin->makeBrokenLinkObj( $fromObj , "(".wfMsg("qbedit").")" , 'redirect=no'); + $to = $skin->makeBrokenLinkObj( $toObj ); $arr = $wgContLang->getArrow(); return "$from $edit $arr $to"; diff --git a/includes/SpecialCategories.php b/includes/SpecialCategories.php index 5bcb97e34d..89cff20a05 100644 --- a/includes/SpecialCategories.php +++ b/includes/SpecialCategories.php @@ -44,10 +44,10 @@ class CategoriesPage extends QueryPage { return false; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgLang; $title = Title::makeTitle( NS_CATEGORY, $result->title ); - $plink = Linker::makeLinkObj( $title, $title->getText() ); + $plink = $skin->makeLinkObj( $title, $title->getText() ); $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'), $wgLang->formatNum( $result->count ) ); return wfSpecialList($plink, $nlinks); diff --git a/includes/SpecialConfirmemail.php b/includes/SpecialConfirmemail.php index e428d6ca62..d109eee785 100644 --- a/includes/SpecialConfirmemail.php +++ b/includes/SpecialConfirmemail.php @@ -38,7 +38,8 @@ class EmailConfirmation extends SpecialPage { } else { $title = SpecialPage::getTitleFor( 'Userlogin' ); $self = SpecialPage::getTitleFor( 'Confirmemail' ); - $llink = Linker::makeKnownLinkObj( $title, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $self->getPrefixedUrl() ); + $skin = $wgUser->getSkin(); + $llink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $self->getPrefixedUrl() ); $wgOut->addHtml( wfMsgWikiHtml( 'confirmemail_needlogin', $llink ) ); } } else { diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index d077b76c5d..29198bb1af 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -291,8 +291,9 @@ function wfSpecialContributions( $par = null ) { $wgOut->addHTML( "
      \n" ); + $sk = $wgUser->getSkin(); foreach ( $contribs as $contrib ) - $wgOut->addHTML( ucListEdit( $contrib ) ); + $wgOut->addHTML( ucListEdit( $sk, $contrib ) ); $wgOut->addHTML( "
    \n" ); $wgOut->addHTML( "

    {$prevnextbits}

    \n" ); @@ -305,26 +306,27 @@ function wfSpecialContributions( $par = null ) { function contributionsSub( $nt ) { global $wgSysopUserBans, $wgLang, $wgUser; + $sk = $wgUser->getSkin(); $id = User::idFromName( $nt->getText() ); if ( 0 == $id ) { $ul = $nt->getText(); } else { - $ul = Linker::makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) ); + $ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) ); } $talk = $nt->getTalkPage(); if( $talk ) { # Talk page link - $tools[] = Linker::makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) ); + $tools[] = $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) ); if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && User::isIP( $nt->getText() ) ) ) { # Block link if( $wgUser->isAllowed( 'block' ) ) - $tools[] = Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) ); + $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Blockip', $nt->getDBkey() ), wfMsgHtml( 'blocklink' ) ); # Block log link - $tools[] = Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), htmlspecialchars( LogPage::logName( 'block' ) ), 'type=block&page=' . $nt->getPrefixedUrl() ); + $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), htmlspecialchars( LogPage::logName( 'block' ) ), 'type=block&page=' . $nt->getPrefixedUrl() ); } # Other logs link - $tools[] = Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'log' ), 'user=' . $nt->getPartialUrl() ); + $tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'log' ), 'user=' . $nt->getPartialUrl() ); $ul .= ' (' . implode( ' | ', $tools ) . ')'; } return $ul; @@ -375,7 +377,7 @@ function contributionsForm( $options ) { * * @todo This would probably look a lot nicer in a table. */ -function ucListEdit( $row ) { +function ucListEdit( $sk, $row ) { $fname = 'ucListEdit'; wfProfileIn( $fname ); @@ -390,12 +392,12 @@ function ucListEdit( $row ) { $rev = new Revision( $row ); $page = Title::makeTitle( $row->page_namespace, $row->page_title ); - $link = Linker::makeKnownLinkObj( $page ); + $link = $sk->makeKnownLinkObj( $page ); $difftext = $topmarktext = ''; if( $row->rev_id == $row->page_latest ) { $topmarktext .= '' . $messages['uctop'] . ''; if( !$row->page_is_new ) { - $difftext .= '(' . Linker::makeKnownLinkObj( $page, $messages['diff'], 'diff=0' ) . ')'; + $difftext .= '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=0' ) . ')'; } else { $difftext .= $messages['newarticle']; } @@ -404,20 +406,20 @@ function ucListEdit( $row ) { $extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : ''; $extraRollback .= '&token=' . urlencode( $wgUser->editToken( array( $page->getPrefixedText(), $row->rev_user_text ) ) ); - $topmarktext .= ' ['. Linker::makeKnownLinkObj( $page, + $topmarktext .= ' ['. $sk->makeKnownLinkObj( $page, $messages['rollbacklink'], 'action=rollback&from=' . urlencode( $row->rev_user_text ) . $extraRollback ) .']'; } } if( $rev->userCan( Revision::DELETED_TEXT ) ) { - $difftext = '(' . Linker::makeKnownLinkObj( $page, $messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')'; + $difftext = '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')'; } else { $difftext = '(' . $messages['diff'] . ')'; } - $histlink = '(' . Linker::makeKnownLinkObj( $page, $messages['hist'], 'action=history' ) . ')'; + $histlink='('.$sk->makeKnownLinkObj( $page, $messages['hist'], 'action=history' ) . ')'; - $comment = Linker::revComment( $rev ); + $comment = $sk->revComment( $rev ); $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true ); if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { diff --git a/includes/SpecialDisambiguations.php b/includes/SpecialDisambiguations.php index 622c813ef1..0355c85b72 100644 --- a/includes/SpecialDisambiguations.php +++ b/includes/SpecialDisambiguations.php @@ -23,8 +23,11 @@ class DisambiguationsPage extends PageQueryPage { return Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage'); } - function getPageHeader() { - return '

    '.wfMsg('disambiguationstext', Linker::makeKnownLinkObj($this->getDisambiguationPageObj()))."


    \n"; + function getPageHeader( ) { + global $wgUser; + $sk = $wgUser->getSkin(); + + return '

    '.wfMsg('disambiguationstext', $sk->makeKnownLinkObj($this->getDisambiguationPageObj()))."


    \n"; } function getSQL() { @@ -85,15 +88,15 @@ class DisambiguationsPage extends PageQueryPage { return ''; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgContLang; $title = Title::newFromId( $result->value ); $dp = Title::makeTitle( $result->namespace, $result->title ); - $from = Linker::makeKnownLinkObj( $title,''); - $edit = Linker::makeBrokenLinkObj( $title, "(".wfMsg("qbedit").")" , 'redirect=no'); + $from = $skin->makeKnownLinkObj( $title,''); + $edit = $skin->makeBrokenLinkObj( $title, "(".wfMsg("qbedit").")" , 'redirect=no'); $arr = $wgContLang->getArrow(); - $to = Linker::makeKnownLinkObj( $dp,''); + $to = $skin->makeKnownLinkObj( $dp,''); return "$from $edit $arr $to"; } diff --git a/includes/SpecialDoubleRedirects.php b/includes/SpecialDoubleRedirects.php index 079d7eb4d8..fe42b00a1b 100644 --- a/includes/SpecialDoubleRedirects.php +++ b/includes/SpecialDoubleRedirects.php @@ -61,7 +61,7 @@ class DoubleRedirectsPage extends PageQueryPage { return ''; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgContLang; $fname = 'DoubleRedirectsPage::formatResult'; @@ -83,10 +83,10 @@ class DoubleRedirectsPage extends PageQueryPage { $titleB = Title::makeTitle( $result->nsb, $result->tb ); $titleC = Title::makeTitle( $result->nsc, $result->tc ); - $linkA = Linker::makeKnownLinkObj( $titleA,'', 'redirect=no' ); - $edit = Linker::makeBrokenLinkObj( $titleA, "(".wfMsg("qbedit").")" , 'redirect=no'); - $linkB = Linker::makeKnownLinkObj( $titleB, '', 'redirect=no' ); - $linkC = Linker::makeKnownLinkObj( $titleC ); + $linkA = $skin->makeKnownLinkObj( $titleA,'', 'redirect=no' ); + $edit = $skin->makeBrokenLinkObj( $titleA, "(".wfMsg("qbedit").")" , 'redirect=no'); + $linkB = $skin->makeKnownLinkObj( $titleB, '', 'redirect=no' ); + $linkC = $skin->makeKnownLinkObj( $titleC ); $arr = $wgContLang->getArrow() . $wgContLang->getDirMark(); return( "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}" ); diff --git a/includes/SpecialImagelist.php b/includes/SpecialImagelist.php index bd4939ba4d..54ee83e5f1 100644 --- a/includes/SpecialImagelist.php +++ b/includes/SpecialImagelist.php @@ -112,7 +112,7 @@ class ImageListPager extends TablePager { $name = $this->mCurrentRow->img_name; $ilink = "" . $this->mMessages['imgfile'] . ""; - $desc = Linker::makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ), + $desc = $this->getSkin()->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ), $this->mMessages['imgdesc'] ); return "$desc | $ilink"; case 'img_timestamp': @@ -121,7 +121,7 @@ class ImageListPager extends TablePager { return htmlspecialchars( $value ); case 'img_user_text': if ( $this->mCurrentRow->img_user ) { - $link = Linker::makeLinkObj( Title::makeTitle( NS_USER, $value ), + $link = $this->getSkin()->makeLinkObj( Title::makeTitle( NS_USER, $value ), htmlspecialchars( $value ) ); } else { $link = htmlspecialchars( $value ); @@ -130,7 +130,7 @@ class ImageListPager extends TablePager { case 'img_size': return $wgLang->formatNum( $value ); case 'img_description': - return Linker::commentBlock( $value ); + return $this->getSkin()->commentBlock( $value ); } } diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index 9c04111adc..04deb1bfd3 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -176,14 +176,16 @@ class ImportReporter { } function reportPage( $title, $origTitle, $revisionCount, $successCount ) { - global $wgOut, $wgLang, $wgContLang; - + global $wgOut, $wgUser, $wgLang, $wgContLang; + + $skin = $wgUser->getSkin(); + $this->mPageCount++; $localCount = $wgLang->formatNum( $successCount ); $contentCount = $wgContLang->formatNum( $successCount ); - $wgOut->addHtml( "
  • " . Linker::makeKnownLinkObj( $title ) . + $wgOut->addHtml( "
  • " . $skin->makeKnownLinkObj( $title ) . " " . wfMsgExt( 'import-revision-count', array( 'parsemag', 'escape' ), $localCount ) . "
  • \n" ); diff --git a/includes/SpecialIpblocklist.php b/includes/SpecialIpblocklist.php index 869d672910..85764be909 100644 --- a/includes/SpecialIpblocklist.php +++ b/includes/SpecialIpblocklist.php @@ -234,8 +234,10 @@ class IPUnblockForm { wfProfileIn( __METHOD__ ); - static $msg=null; + static $sk=null, $msg=null; + if( is_null( $sk ) ) + $sk = $wgUser->getSkin(); if( is_null( $msg ) ) { $msg = array(); $keys = array( 'infiniteblock', 'expiringblock', 'contribslink', 'unblocklink', @@ -249,15 +251,15 @@ class IPUnblockForm { # Prepare links to the blocker's user and talk pages $blocker_name = $block->getByName(); - $blocker = Linker::makeLinkObj( Title::makeTitle( NS_USER, $blocker_name ), $blocker_name ); - $blocker .= ' (' . Linker::makeLinkObj( Title::makeTitle( NS_USER_TALK, $blocker_name ), $wgLang->getNsText( NS_TALK ) ) . ')'; + $blocker = $sk->MakeLinkObj( Title::makeTitle( NS_USER, $blocker_name ), $blocker_name ); + $blocker .= ' (' . $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $blocker_name ), $wgLang->getNsText( NS_TALK ) ) . ')'; # Prepare links to the block target's user and contribs. pages (as applicable, don't do it for autoblocks) if( $block->mAuto ) { $target = $block->getRedactedName(); # Hide the IP addresses of auto-blocks; privacy } else { - $target = Linker::makeLinkObj( Title::makeTitle( NS_USER, $block->mAddress ), $block->mAddress ); - $target .= ' (' . Linker::makeKnownLinkObj( SpecialPage::getSafeTitleFor( 'Contributions', $block->mAddress ), $msg['contribslink'] ) . ')'; + $target = $sk->makeLinkObj( Title::makeTitle( NS_USER, $block->mAddress ), $block->mAddress ); + $target .= ' (' . $sk->makeKnownLinkObj( SpecialPage::getSafeTitleFor( 'Contributions', $block->mAddress ), $msg['contribslink'] ) . ')'; } $formattedTime = $wgLang->timeanddate( $block->mTimestamp, true ); @@ -287,9 +289,9 @@ class IPUnblockForm { if ( $wgUser->isAllowed('block') ) { $titleObj = SpecialPage::getTitleFor( "Ipblocklist" ); - $s .= ' (' . Linker::makeKnownLinkObj($titleObj, $msg['unblocklink'], 'action=unblock&id=' . urlencode( $block->mId ) ) . ')'; + $s .= ' (' . $sk->makeKnownLinkObj($titleObj, $msg['unblocklink'], 'action=unblock&id=' . urlencode( $block->mId ) ) . ')'; } - $s .= Linker::commentBlock( $block->mReason ); + $s .= $sk->commentBlock( $block->mReason ); $s .= "\n"; wfProfileOut( __METHOD__ ); return $s; diff --git a/includes/SpecialListredirects.php b/includes/SpecialListredirects.php index cd59d255a2..f717ef72c0 100644 --- a/includes/SpecialListredirects.php +++ b/includes/SpecialListredirects.php @@ -27,13 +27,13 @@ class ListredirectsPage extends QueryPage { return( $sql ); } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgContLang; # Make a link to the redirect itself $rd_title = Title::makeTitle( $result->namespace, $result->title ); $arr = $wgContLang->getArrow() . $wgContLang->getDirMark(); - $rd_link = Linker::makeKnownLinkObj( $rd_title, '', 'redirect=no' ); + $rd_link = $skin->makeKnownLinkObj( $rd_title, '', 'redirect=no' ); # Find out where the redirect leads $revision = Revision::newFromTitle( $rd_title ); @@ -41,7 +41,7 @@ class ListredirectsPage extends QueryPage { # Make a link to the destination page $target = Title::newFromRedirect( $revision->getText() ); if( $target ) { - $targetLink = Linker::makeLinkObj( $target ); + $targetLink = $skin->makeLinkObj( $target ); } else { /** @todo Put in some decent error display here */ $targetLink = '*'; diff --git a/includes/SpecialListusers.php b/includes/SpecialListusers.php index f5446ba0d9..4668d0c7d7 100644 --- a/includes/SpecialListusers.php +++ b/includes/SpecialListusers.php @@ -173,9 +173,9 @@ class ListUsersPage extends QueryPage { return false; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { $userPage = Title::makeTitle( $result->namespace, $result->title ); - $name = Linker::makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ); + $name = $skin->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ); $groups = null; if( !isset( $result->numgroups ) || $result->numgroups > 0 ) { diff --git a/includes/SpecialLog.php b/includes/SpecialLog.php index 2a67763a78..10d1d89cb6 100644 --- a/includes/SpecialLog.php +++ b/includes/SpecialLog.php @@ -218,6 +218,8 @@ class LogViewer { * @param LogReader &$reader where to get our data from */ function LogViewer( &$reader ) { + global $wgUser; + $this->skin =& $wgUser->getSkin(); $this->reader =& $reader; } @@ -314,15 +316,15 @@ class LogViewer { $linkCache->addBadLinkObj( $title ); } - $userLink = Linker::userLink( $s->log_user, $s->user_name ) . Linker::userToolLinks( $s->log_user, $s->user_name ); - $comment = Linker::commentBlock( $s->log_comment ); + $userLink = $this->skin->userLink( $s->log_user, $s->user_name ) . $this->skin->userToolLinks( $s->log_user, $s->user_name ); + $comment = $this->skin->commentBlock( $s->log_comment ); $paramArray = LogPage::extractParams( $s->log_params ); $revert = ''; if ( $s->log_type == 'move' && isset( $paramArray[0] ) ) { $specialTitle = SpecialPage::getTitleFor( 'Movepage' ); $destTitle = Title::newFromText( $paramArray[0] ); if ( $destTitle ) { - $revert = '(' . Linker::makeKnownLinkObj( $specialTitle, wfMsg( 'revertmove' ), + $revert = '(' . $this->skin->makeKnownLinkObj( $specialTitle, wfMsg( 'revertmove' ), 'wpOldTitle=' . urlencode( $destTitle->getPrefixedDBkey() ) . '&wpNewTitle=' . urlencode( $title->getPrefixedDBkey() ) . '&wpReason=' . urlencode( wfMsgForContent( 'revertmove' ) ) . @@ -330,7 +332,7 @@ class LogViewer { } } - $action = LogPage::actionText( $s->log_type, $s->log_action, $title, false, $paramArray, true, true ); + $action = LogPage::actionText( $s->log_type, $s->log_action, $title, $this->skin, $paramArray, true, true ); $out = "
  • $time $userLink $action $comment $revert
  • \n"; return $out; } diff --git a/includes/SpecialMIMEsearch.php b/includes/SpecialMIMEsearch.php index bdd22fc154..cbbe6f936d 100644 --- a/includes/SpecialMIMEsearch.php +++ b/includes/SpecialMIMEsearch.php @@ -59,19 +59,19 @@ class MIMEsearchPage extends QueryPage { "; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgContLang, $wgLang; $nt = Title::makeTitle( $result->namespace, $result->title ); $text = $wgContLang->convert( $nt->getText() ); - $plink = Linker::makeLink( $nt->getPrefixedText(), $text ); + $plink = $skin->makeLink( $nt->getPrefixedText(), $text ); - $download = Linker::makeMediaLink( $nt->getText(), 'fuck me!', wfMsgHtml( 'download' ) ); + $download = $skin->makeMediaLink( $nt->getText(), 'fuck me!', wfMsgHtml( 'download' ) ); $bytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'), $wgLang->formatNum( $result->img_size ) ); $dimensions = wfMsg( 'widthheight', $wgLang->formatNum( $result->img_width ), $wgLang->formatNum( $result->img_height ) ); - $user = Linker::makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text ); + $user = $skin->makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text ); $time = $wgLang->timeanddate( $result->img_timestamp ); return "($download) $plink . . $dimensions . . $bytes . . $user . . $time"; diff --git a/includes/SpecialMostcategories.php b/includes/SpecialMostcategories.php index 503cad413d..c0d662cc41 100644 --- a/includes/SpecialMostcategories.php +++ b/includes/SpecialMostcategories.php @@ -36,18 +36,18 @@ class MostcategoriesPage extends QueryPage { "; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgContLang, $wgLang; $nt = Title::makeTitle( $result->namespace, $result->title ); $text = $wgContLang->convert( $nt->getPrefixedText() ); - $plink = Linker::makeKnownLink( $nt->getPrefixedText(), $text ); + $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text ); $nl = wfMsgExt( 'ncategories', array( 'parsemag', 'escape' ), $wgLang->formatNum( $result->value ) ); - $nlink = Linker::makeKnownLink( $wgContLang->specialPage( 'Categories' ), + $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Categories' ), $nl, 'article=' . $nt->getPrefixedURL() ); return wfSpecialList($plink, $nlink); diff --git a/includes/SpecialMostimages.php b/includes/SpecialMostimages.php index 45ab1473e5..09f7108863 100644 --- a/includes/SpecialMostimages.php +++ b/includes/SpecialMostimages.php @@ -34,17 +34,17 @@ class MostimagesPage extends QueryPage { "; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgLang, $wgContLang; $nt = Title::makeTitle( $result->namespace, $result->title ); $text = $wgContLang->convert( $nt->getPrefixedText() ); - $plink = Linker::makeKnownLink( $nt->getPrefixedText(), $text ); + $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text ); $nl = wfMsgExt( 'nlinks', array( 'parsemag', 'escape'), $wgLang->formatNum ( $result->value ) ); - $nlink = Linker::makeKnownLink( $nt->getPrefixedText() . '#filelinks', $nl ); + $nlink = $skin->makeKnownLink( $nt->getPrefixedText() . '#filelinks', $nl ); return wfSpecialList($plink, $nlink); } diff --git a/includes/SpecialMostlinked.php b/includes/SpecialMostlinked.php index f50120c7c5..6f5f30dbdd 100644 --- a/includes/SpecialMostlinked.php +++ b/includes/SpecialMostlinked.php @@ -58,26 +58,28 @@ class MostlinkedPage extends QueryPage { * Make a link to "what links here" for the specified title * * @param $title Title being queried + * @param $skin Skin to use * @return string */ - function makeWlhLink( &$title, $caption ) { + function makeWlhLink( &$title, $caption, &$skin ) { $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() ); - return Linker::makeKnownLinkObj( $wlh, $caption ); + return $skin->makeKnownLinkObj( $wlh, $caption ); } /** * Make links to the page corresponding to the item, and the "what links here" page for it * + * @param $skin Skin to be used * @param $result Result row * @return string */ - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgLang; $title = Title::makeTitleSafe( $result->namespace, $result->title ); - $link = Linker::makeLinkObj( $title ); + $link = $skin->makeLinkObj( $title ); $wlh = $this->makeWlhLink( $title, wfMsgExt( 'nlinks', array( 'parsemag', 'escape'), - $wgLang->formatNum( $result->value ) ) ); + $wgLang->formatNum( $result->value ) ), $skin ); return wfSpecialList( $link, $wlh ); } } diff --git a/includes/SpecialMostlinkedcategories.php b/includes/SpecialMostlinkedcategories.php index 055cf7c45b..5942b3f4ea 100644 --- a/includes/SpecialMostlinkedcategories.php +++ b/includes/SpecialMostlinkedcategories.php @@ -53,13 +53,13 @@ class MostlinkedCategoriesPage extends QueryPage { $db->dataSeek( $res, 0 ); } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgLang, $wgContLang; $nt = Title::makeTitle( $result->namespace, $result->title ); $text = $wgContLang->convert( $nt->getText() ); - $plink = Linker::makeLinkObj( $nt, htmlspecialchars( $text ) ); + $plink = $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ); $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'), $wgLang->formatNum( $result->value ) ); diff --git a/includes/SpecialMostrevisions.php b/includes/SpecialMostrevisions.php index 906d4b7fdf..676923ae79 100644 --- a/includes/SpecialMostrevisions.php +++ b/includes/SpecialMostrevisions.php @@ -38,17 +38,17 @@ class MostrevisionsPage extends QueryPage { "; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgLang, $wgContLang; $nt = Title::makeTitle( $result->namespace, $result->title ); $text = $wgContLang->convert( $nt->getPrefixedText() ); - $plink = Linker::makeKnownLinkObj( $nt, $text ); + $plink = $skin->makeKnownLinkObj( $nt, $text ); $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape'), $wgLang->formatNum( $result->value ) ); - $nlink = Linker::makeKnownLinkObj( $nt, $nl, 'action=history' ); + $nlink = $skin->makeKnownLinkObj( $nt, $nl, 'action=history' ); return wfSpecialList($plink, $nlink); } diff --git a/includes/SpecialNewimages.php b/includes/SpecialNewimages.php index 7f3144845a..66cf42603c 100644 --- a/includes/SpecialNewimages.php +++ b/includes/SpecialNewimages.php @@ -9,10 +9,11 @@ * */ function wfSpecialNewimages( $par, $specialPage ) { - global $wgOut, $wgLang, $wgContLang, $wgRequest, $wgGroupPermissions; + global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgGroupPermissions; $wpIlMatch = $wgRequest->getText( 'wpIlMatch' ); $dbr =& wfGetDB( DB_SLAVE ); + $sk = $wgUser->getSkin(); $shownav = !$specialPage->including(); $hidebots = $wgRequest->getBool('hidebots',1); @@ -134,7 +135,7 @@ function wfSpecialNewimages( $par, $specialPage ) { $nt = Title::newFromText( $name, NS_IMAGE ); $img = new Image( $nt ); - $ul = Linker::makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut ); + $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut ); $gallery->add( $img, "$ul
    \n".$wgLang->timeanddate( $s->img_timestamp, true )."
    \n" ); @@ -176,18 +177,18 @@ function wfSpecialNewimages( $par, $specialPage ) { } $now = wfTimestampNow(); $date = $wgLang->timeanddate( $now, true ); - $dateLink = Linker::makeKnownLinkObj( $titleObj, wfMsg( 'sp-newimages-showfrom', $date ), 'from='.$now.$botpar.$searchpar ); + $dateLink = $sk->makeKnownLinkObj( $titleObj, wfMsg( 'sp-newimages-showfrom', $date ), 'from='.$now.$botpar.$searchpar ); - $botLink = Linker::makeKnownLinkObj($titleObj, wfMsg( 'showhidebots', ($hidebots ? wfMsg('show') : wfMsg('hide'))),'hidebots='.($hidebots ? '0' : '1').$searchpar); + $botLink = $sk->makeKnownLinkObj($titleObj, wfMsg( 'showhidebots', ($hidebots ? wfMsg('show') : wfMsg('hide'))),'hidebots='.($hidebots ? '0' : '1').$searchpar); $prevLink = wfMsg( 'prevn', $wgLang->formatNum( $limit ) ); if( $firstTimestamp && $firstTimestamp != $latestTimestamp ) { - $prevLink = Linker::makeKnownLinkObj( $titleObj, $prevLink, 'from=' . $firstTimestamp . $botpar . $searchpar ); + $prevLink = $sk->makeKnownLinkObj( $titleObj, $prevLink, 'from=' . $firstTimestamp . $botpar . $searchpar ); } $nextLink = wfMsg( 'nextn', $wgLang->formatNum( $limit ) ); if( $shownImages > $limit && $lastTimestamp ) { - $nextLink = Linker::makeKnownLinkObj( $titleObj, $nextLink, 'until=' . $lastTimestamp.$botpar.$searchpar ); + $nextLink = $sk->makeKnownLinkObj( $titleObj, $nextLink, 'until=' . $lastTimestamp.$botpar.$searchpar ); } $prevnext = '

    ' . $botLink . ' '. wfMsg( 'viewprevnext', $prevLink, $nextLink, $dateLink ) .'

    '; diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index d299a6c0f3..a9a028b144 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -84,20 +84,21 @@ class NewPagesPage extends QueryPage { /** * Format a row, providing the timestamp, links to the page/history, size, user links, and a comment * + * @param $skin Skin to use * @param $result Result row * @return string */ - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgLang, $wgContLang; $dm = $wgContLang->getDirMark(); $title = Title::makeTitleSafe( $result->namespace, $result->title ); $time = $wgLang->timeAndDate( $result->timestamp, true ); - $plink = Linker::makeKnownLinkObj( $title, '', $this->patrollable( $result ) ? 'rcid=' . $result->rcid : '' ); - $hist = Linker::makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' ); + $plink = $skin->makeKnownLinkObj( $title, '', $this->patrollable( $result ) ? 'rcid=' . $result->rcid : '' ); + $hist = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' ); $length = wfMsgHtml( 'nbytes', $wgLang->formatNum( htmlspecialchars( $result->length ) ) ); - $ulink = Linker::userLink( $result->user, $result->user_text ) . Linker::userToolLinks( $result->user, $result->user_text ); - $comment = Linker::commentBlock( $result->comment ); + $ulink = $skin->userLink( $result->user, $result->user_text ) . $skin->userToolLinks( $result->user, $result->user_text ); + $comment = $skin->commentBlock( $result->comment ); return "{$time} {$dm}{$plink} ({$hist}) {$dm}[{$length}] {$dm}{$ulink} {$comment}"; } diff --git a/includes/SpecialPopularpages.php b/includes/SpecialPopularpages.php index 8e12efa46e..77d41437c5 100644 --- a/includes/SpecialPopularpages.php +++ b/includes/SpecialPopularpages.php @@ -35,10 +35,10 @@ class PopularPagesPage extends QueryPage { WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0"; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgLang, $wgContLang; $title = Title::makeTitle( $result->namespace, $result->title ); - $link = Linker::makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) ); + $link = $skin->makeKnownLinkObj( $title, htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) ); $nv = wfMsgExt( 'nviews', array( 'parsemag', 'escape'), $wgLang->formatNum( $result->value ) ); return wfSpecialList($link, $nv); diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 7616a49c0a..ec1a957e4f 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -506,8 +506,9 @@ class PreferencesForm { $disableEmailPrefs = false; } else { $disableEmailPrefs = true; + $skin = $wgUser->getSkin(); $emailauthenticated = wfMsg('emailnotauthenticated').'
    ' . - Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 'Confirmemail' ), + $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Confirmemail' ), wfMsg( 'emailconfirmlink' ) ); } } else { diff --git a/includes/SpecialPrefixindex.php b/includes/SpecialPrefixindex.php index 3f39cbce67..86880d2f04 100644 --- a/includes/SpecialPrefixindex.php +++ b/includes/SpecialPrefixindex.php @@ -56,10 +56,12 @@ class SpecialPrefixindex extends SpecialAllpages { * @param string $from list all pages from this name (default FALSE) */ function showChunk( $namespace = NS_MAIN, $prefix, $including = false, $from = null ) { - global $wgOut, $wgContLang; + global $wgOut, $wgUser, $wgContLang; $fname = 'indexShowChunk'; + $sk = $wgUser->getSkin(); + if (!isset($from)) $from = $prefix; $fromList = $this->getNamespaceKeyAndText($namespace, $from); @@ -100,7 +102,7 @@ function showChunk( $namespace = NS_MAIN, $prefix, $including = false, $from = n $t = Title::makeTitle( $s->page_namespace, $s->page_title ); if( $t ) { $link = ($s->page_is_redirect ? '
    ' : '' ) . - Linker::makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . + $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . ($s->page_is_redirect ? '
    ' : '' ); } else { $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; @@ -127,11 +129,11 @@ function showChunk( $namespace = NS_MAIN, $prefix, $including = false, $from = n $out2 = ''; $out2 .= '
    ' . $nsForm; $out2 .= '' . - Linker::makeKnownLink( $wgContLang->specialPage( $this->name ), + $sk->makeKnownLink( $wgContLang->specialPage( $this->name ), wfMsg ( 'allpages' ) ); if ( isset($dbr) && $dbr && ($n == $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) { $namespaceparam = $namespace ? "&namespace=$namespace" : ""; - $out2 .= " | " . Linker::makeKnownLink( + $out2 .= " | " . $sk->makeKnownLink( $wgContLang->specialPage( $this->name ), wfMsg ( 'nextpage', $s->page_title ), "from=" . wfUrlEncode ( $s->page_title ) . diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 95e9ee5e4a..cfa115f168 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -222,6 +222,7 @@ function wfSpecialRecentchanges( $par, $specialPage ) { } // And now for the content + $sk = $wgUser->getSkin(); $wgOut->setSyndicated( true ); $list = ChangesList::newFromUser( $wgUser ); @@ -420,8 +421,9 @@ function rcDoOutputFeed( $rows, &$feed ) { * */ function rcCountLink( $lim, $d, $page='Recentchanges', $more='' ) { - global $wgLang, $wgContLang; - $s = Linker::makeKnownLink( $wgContLang->specialPage( $page ), + global $wgUser, $wgLang, $wgContLang; + $sk = $wgUser->getSkin(); + $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ), ($lim ? $wgLang->formatNum( "{$lim}" ) : wfMsg( 'recentchangesall' ) ), "{$more}" . ($d ? "days={$d}&" : '') . 'limit='.$lim ); return $s; @@ -431,8 +433,9 @@ function rcCountLink( $lim, $d, $page='Recentchanges', $more='' ) { * */ function rcDaysLink( $lim, $d, $page='Recentchanges', $more='' ) { - global $wgLang, $wgContLang; - $s = Linker::makeKnownLink( $wgContLang->specialPage( $page ), + global $wgUser, $wgLang, $wgContLang; + $sk = $wgUser->getSkin(); + $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ), ($d ? $wgLang->formatNum( "{$d}" ) : wfMsg( 'recentchangesall' ) ), $more.'days='.$d . ($lim ? '&limit='.$lim : '') ); return $s; @@ -475,8 +478,9 @@ function rcDayLimitLinks( $days, $limit, $page='Recentchanges', $more='', $doall * @param $options */ function makeOptionsLink( $title, $override, $options ) { - global $wgContLang; - return Linker::makeKnownLink( $wgContLang->specialPage( 'Recentchanges' ), + global $wgUser, $wgContLang; + $sk = $wgUser->getSkin(); + return $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchanges' ), htmlspecialchars( $title ), wfArrayToCGI( $override, $options ) ); } @@ -617,11 +621,12 @@ function rcFormatDiff( $row ) { } function rcFormatDiffRow( $title, $oldid, $newid, $timestamp, $comment ) { - global $wgFeedDiffCutoff, $wgContLang; + global $wgFeedDiffCutoff, $wgContLang, $wgUser; $fname = 'rcFormatDiff'; wfProfileIn( $fname ); - $completeText = '

    ' . Linker::formatComment( $comment ) . "

    \n"; + $skin = $wgUser->getSkin(); + $completeText = '

    ' . $skin->formatComment( $comment ) . "

    \n"; if( $title->getNamespace() >= 0 ) { if( $oldid ) { diff --git a/includes/SpecialRecentchangeslinked.php b/includes/SpecialRecentchangeslinked.php index 71b625ee49..59a3beb5c7 100644 --- a/includes/SpecialRecentchangeslinked.php +++ b/includes/SpecialRecentchangeslinked.php @@ -23,6 +23,7 @@ function wfSpecialRecentchangeslinked( $par = NULL ) { $hideminor = $wgRequest->getBool( 'hideminor' ) ? 1 : 0; $wgOut->setPagetitle( wfMsg( 'recentchangeslinked' ) ); + $sk = $wgUser->getSkin(); # Validate the title $nt = Title::newFromURL( $target ); @@ -54,11 +55,11 @@ function wfSpecialRecentchangeslinked( $par = NULL ) { $hideminor = ($hideminor ? 1 : 0); if ( $hideminor ) { - $mlink = Linker::makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ), + $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ), wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) . "&days={$days}&limit={$limit}&hideminor=0" ); } else { - $mlink = Linker::makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ), + $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ), wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) . "&days={$days}&limit={$limit}&hideminor=1" ); } @@ -137,7 +138,7 @@ $GROUPBY } $res = $dbr->query( $sql, $fname ); - $wgOut->addHTML("< ".Linker::makeKnownLinkObj($nt, "", "redirect=no" )."
    \n"); + $wgOut->addHTML("< ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."
    \n"); $note = wfMsg( "rcnote", $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) ); $wgOut->addHTML( "
    \n{$note}\n
    " ); diff --git a/includes/SpecialRevisiondelete.php b/includes/SpecialRevisiondelete.php index 544c624025..1ab505dbf1 100644 --- a/includes/SpecialRevisiondelete.php +++ b/includes/SpecialRevisiondelete.php @@ -10,11 +10,12 @@ */ function wfSpecialRevisiondelete( $par = null ) { - global $wgOut, $wgRequest; + global $wgOut, $wgRequest, $wgUser; $target = $wgRequest->getVal( 'target' ); $oldid = $wgRequest->getIntArray( 'oldid' ); + $sk = $wgUser->getSkin(); $page = Title::newFromUrl( $target ); if( is_null( $page ) ) { @@ -48,6 +49,7 @@ class RevisionDeleteForm { $this->revisions = $request->getIntArray( 'oldid', array() ); + $this->skin = $wgUser->getSkin(); $this->checks = array( array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT ), array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ), @@ -120,11 +122,11 @@ class RevisionDeleteForm { $date = $wgContLang->timeanddate( $rev->getTimestamp() ); return "
  • " . - Linker::makeLinkObj( $this->page, $date, 'oldid=' . $rev->getId() ) . + $this->skin->makeLinkObj( $this->page, $date, 'oldid=' . $rev->getId() ) . " " . - Linker::revUserLink( $rev ) . + $this->skin->revUserLink( $rev ) . " " . - Linker::revComment( $rev ) . + $this->skin->revComment( $rev ) . "
  • "; } diff --git a/includes/SpecialSearch.php b/includes/SpecialSearch.php index 2d0ef1ef3e..8c2f8aad4d 100644 --- a/includes/SpecialSearch.php +++ b/includes/SpecialSearch.php @@ -126,7 +126,8 @@ class SpecialSearch { $this->setupPage( $term ); - global $wgOut; + global $wgUser, $wgOut; + $sk = $wgUser->getSkin(); $wgOut->addWikiText( wfMsg( 'searchresulttext' ) ); #if ( !$this->parseQuery() ) { @@ -320,13 +321,14 @@ class SpecialSearch { wfProfileOut( $fname ); return "\n"; } + $sk =& $wgUser->getSkin(); $contextlines = $wgUser->getOption( 'contextlines' ); if ( '' == $contextlines ) { $contextlines = 5; } $contextchars = $wgUser->getOption( 'contextchars' ); if ( '' == $contextchars ) { $contextchars = 50; } - $link = Linker::makeKnownLinkObj( $t ); + $link = $sk->makeKnownLinkObj( $t ); $revision = Revision::newFromTitle( $t ); $text = $revision->getText(); $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'), diff --git a/includes/SpecialShortpages.php b/includes/SpecialShortpages.php index d6bd073d9e..34b3505bbd 100644 --- a/includes/SpecialShortpages.php +++ b/includes/SpecialShortpages.php @@ -60,7 +60,7 @@ class ShortPagesPage extends QueryPage { return false; } - function formatResult( $result ) { + function formatResult( $skin, $result ) { global $wgLang, $wgContLang; $dm = $wgContLang->getDirMark(); @@ -68,10 +68,10 @@ class ShortPagesPage extends QueryPage { if ( !$title ) { return ''; } - $hlink = Linker::makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' ); + $hlink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' ); $plink = $this->isCached() - ? Linker::makeLinkObj( $title ) - : Linker::makeKnownLinkObj( $title ); + ? $skin->makeLinkObj( $title ) + : $skin->makeKnownLinkObj( $title ); $size = wfMsgHtml( 'nbytes', $wgLang->formatNum( htmlspecialchars( $result->value ) ) ); return $title->exists() diff --git a/includes/SpecialSpecialpages.php b/includes/SpecialSpecialpages.php index 67dc858296..6a01cd0829 100644 --- a/includes/SpecialSpecialpages.php +++ b/includes/SpecialSpecialpages.php @@ -9,23 +9,25 @@ * */ function wfSpecialSpecialpages() { - global $wgOut; + global $wgOut, $wgUser; $wgOut->setRobotpolicy( 'index,nofollow' ); + $sk = $wgUser->getSkin(); /** Pages available to all */ - wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading' ); + wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk ); /** Restricted special pages */ - wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading' ); + wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $sk ); } /** * sub function generating the list of pages * @param $pages the list of pages * @param $heading header to be used + * @param $sk skin object ??? */ -function wfSpecialSpecialpages_gen( $pages, $heading ) { +function wfSpecialSpecialpages_gen($pages,$heading,$sk) { global $wgOut, $wgSortSpecialPages; if( count( $pages ) == 0 ) { @@ -49,7 +51,7 @@ function wfSpecialSpecialpages_gen( $pages, $heading ) { /** Now output the HTML */ $wgOut->addHTML( '

    ' . wfMsgHtml( $heading ) . "

    \n
      " ); foreach ( $sortedPages as $desc => $title ) { - $link = Linker::makeKnownLinkObj( $title, $desc ); + $link = $sk->makeKnownLinkObj( $title, $desc ); $wgOut->addHTML( "
    • {$link}
    • \n" ); } $wgOut->addHTML( "
    \n" ); diff --git a/includes/SpecialStatistics.php b/includes/SpecialStatistics.php index 2ab40962e3..4a51efd9b5 100644 --- a/includes/SpecialStatistics.php +++ b/includes/SpecialStatistics.php @@ -82,16 +82,17 @@ function wfSpecialStatistics() { $wgOut->addWikiText( $text ); - global $wgDisableCounters, $wgMiserMode, $wgLang, $wgContLang; + global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang; if( !$wgDisableCounters && !$wgMiserMode ) { $sql = "SELECT page_namespace, page_title, page_counter FROM {$page} WHERE page_is_redirect = 0 AND page_counter > 0 ORDER BY page_counter DESC"; $sql = $dbr->limitResult($sql, 10, 0); $res = $dbr->query( $sql, $fname ); if( $res ) { $wgOut->addHtml( '

    ' . wfMsgHtml( 'statistics-mostpopular' ) . '

    ' ); + $skin =& $wgUser->getSkin(); $wgOut->addHtml( '
      ' ); while( $row = $dbr->fetchObject( $res ) ) { - $link = Linker::makeKnownLinkObj( Title::makeTitleSafe( $row->page_namespace, $row->page_title ) ); + $link = $skin->makeKnownLinkObj( Title::makeTitleSafe( $row->page_namespace, $row->page_title ) ); $dirmark = $wgContLang->getDirMark(); $wgOut->addHtml( '
    1. ' . $link . $dirmark . ' [' . $wgLang->formatNum( $row->page_counter ) . ']
    2. ' ); } diff --git a/includes/SpecialUncategorizedimages.php b/includes/SpecialUncategorizedimages.php index a4c6324612..3815697630 100644 --- a/includes/SpecialUncategorizedimages.php +++ b/includes/SpecialUncategorizedimages.php @@ -37,11 +37,11 @@ class UncategorizedImagesPage extends QueryPage { WHERE cl_from IS NULL AND page_namespace = {$ns} AND page_is_redirect = 0"; } - function formatResult( $row ) { + function formatResult( &$skin, $row ) { global $wgContLang; $title = Title::makeTitleSafe( NS_IMAGE, $row->title ); $label = htmlspecialchars( $wgContLang->convert( $title->getText() ) ); - return Linker::makeKnownLinkObj( $title, $label ); + return $skin->makeKnownLinkObj( $title, $label ); } } diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 26eb15a82b..299cb232ed 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -482,7 +482,7 @@ class UndeleteForm { } /* private */ function showList() { - global $wgLang, $wgContLang, $wgOut; + global $wgLang, $wgContLang, $wgUser, $wgOut; # List undeletable articles $result = PageArchive::listAllPages(); @@ -494,11 +494,12 @@ class UndeleteForm { } $wgOut->addWikiText( wfMsg( "undeletepagetext" ) ); + $sk = $wgUser->getSkin(); $undelete =& SpecialPage::getTitleFor( 'Undelete' ); $wgOut->addHTML( "
    "; $s .= $this->bottomLinks(); - $s .= "\n
    " . self::makeKnownLink( wfMsgForContent( "mainpage" ) ) . " | " + $s .= "\n
    " . $this->makeKnownLink( wfMsgForContent( "mainpage" ) ) . " | " . $this->aboutLink() . " | " . $this->searchForm( wfMsg( "qbfind" ) ); @@ -138,15 +138,15 @@ class SkinCologneBlue extends Skin { } $s = "" . - self::makeKnownLink( wfMsgForContent( "mainpage" ), wfMsg( "mainpage" ) ) + $this->makeKnownLink( wfMsgForContent( "mainpage" ), wfMsg( "mainpage" ) ) . " | " . - self::makeKnownLink( wfMsgForContent( "aboutpage" ), wfMsg( "about" ) ) + $this->makeKnownLink( wfMsgForContent( "aboutpage" ), wfMsg( "about" ) ) . " | " . - self::makeKnownLink( wfMsgForContent( "helppage" ), wfMsg( "help" ) ) + $this->makeKnownLink( wfMsgForContent( "helppage" ), wfMsg( "help" ) ) . " | " . - self::makeKnownLink( wfMsgForContent( "faqpage" ), wfMsg("faq") ) + $this->makeKnownLink( wfMsgForContent( "faqpage" ), wfMsg("faq") ) . " | " . - self::specialLink( "specialpages" ); + $this->specialLink( "specialpages" ); /* show links to different language variants */ $s .= $this->variantLinks(); @@ -154,9 +154,9 @@ class SkinCologneBlue extends Skin { $s .= " | "; if ( $wgUser->isLoggedIn() ) { - $s .= self::makeKnownLink( $lo, wfMsg( "logout" ), $q ); + $s .= $this->makeKnownLink( $lo, wfMsg( "logout" ), $q ); } else { - $s .= self::makeKnownLink( $li, wfMsg( "login" ), $q ); + $s .= $this->makeKnownLink( $li, wfMsg( "login" ), $q ); } return $s; @@ -195,7 +195,7 @@ class SkinCologneBlue extends Skin { $s .= $this->menuHead( "qbedit" ); $s .= "" . $this->editThisPage() . ""; - $s .= $sep . self::makeKnownLink( wfMsgForContent( "edithelppage" ), wfMsg( "edithelp" ) ); + $s .= $sep . $this->makeKnownLink( wfMsgForContent( "edithelppage" ), wfMsg( "edithelp" ) ); if( $wgUser->isLoggedIn() ) { $s .= $sep . $this->moveThisPage(); @@ -244,31 +244,31 @@ class SkinCologneBlue extends Skin { $s .= $this->menuHead( "qbmyoptions" ); if ( $wgUser->isLoggedIn() ) { $name = $wgUser->getName(); - $tl = self::makeKnownLinkObj( $wgUser->getTalkPage(), + $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsg( 'mytalk' ) ); if ( $wgUser->getNewtalk() ) { $tl .= " *"; } - $s .= self::makeKnownLinkObj( $wgUser->getUserPage(), + $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(), wfMsg( "mypage" ) ) . $sep . $tl - . $sep . self::specialLink( "watchlist" ) - . $sep . self::makeKnownLinkObj( SpecialPage::getSafeTitleFor( "Contributions", $wgUser->getName() ), + . $sep . $this->specialLink( "watchlist" ) + . $sep . $this->makeKnownLinkObj( SpecialPage::getSafeTitleFor( "Contributions", $wgUser->getName() ), wfMsg( "mycontris" ) ) - . $sep . self::specialLink( "preferences" ) - . $sep . self::specialLink( "userlogout" ); + . $sep . $this->specialLink( "preferences" ) + . $sep . $this->specialLink( "userlogout" ); } else { - $s .= self::specialLink( "userlogin" ); + $s .= $this->specialLink( "userlogin" ); } $s .= $this->menuHead( "qbspecialpages" ) - . self::specialLink( "newpages" ) - . $sep . self::specialLink( "imagelist" ) - . $sep . self::specialLink( "statistics" ) + . $this->specialLink( "newpages" ) + . $sep . $this->specialLink( "imagelist" ) + . $sep . $this->specialLink( "statistics" ) . $sep . $this->bugReportsLink(); if ( $wgUser->isLoggedIn() && $wgEnableUploads ) { - $s .= $sep . self::specialLink( "upload" ); + $s .= $sep . $this->specialLink( "upload" ); } global $wgSiteSupportPage; if( $wgSiteSupportPage) { @@ -276,7 +276,7 @@ class SkinCologneBlue extends Skin { .wfMsg( "sitesupport" ).""; } - $s .= $sep . self::makeKnownLinkObj( + $s .= $sep . $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Specialpages' ), wfMsg( 'moredotdotdot' ) ); diff --git a/skins/Nostalgia.php b/skins/Nostalgia.php index 7c82e0b8ba..3b19e41e64 100644 --- a/skins/Nostalgia.php +++ b/skins/Nostalgia.php @@ -57,7 +57,7 @@ class SkinNostalgia extends Skin { $sep = " |\n"; $s = $this->mainPageLink() . $sep - . self::specialLink( "recentchanges" ); + . $this->specialLink( "recentchanges" ); if ( $wgOut->isArticle() ) { $s .= $sep . $this->editThisPage() @@ -69,9 +69,9 @@ class SkinNostalgia extends Skin { $s .= $this->extensionTabLinks(); if ( $wgUser->isAnon() ) { - $s .= $sep . self::specialLink( "userlogin" ); + $s .= $sep . $this->specialLink( "userlogin" ); } else { - $s .= $sep . self::specialLink( "userlogout" ); + $s .= $sep . $this->specialLink( "userlogout" ); } $s .= $sep . $this->specialPagesList(); diff --git a/skins/Standard.php b/skins/Standard.php index fb0a8df0f7..517fd19430 100644 --- a/skins/Standard.php +++ b/skins/Standard.php @@ -118,7 +118,7 @@ class SkinStandard extends Skin { $s .= $this->bottomLinks(); $s .= "\n
    " . $this->mainPageLink() . ' | ' . $this->aboutLink() - . ' | ' . self::specialLink( 'recentchanges' ) + . ' | ' . $this->specialLink( 'recentchanges' ) . ' | ' . $this->searchForm() . '
    ' . $this->pageStats() . ''; @@ -164,8 +164,8 @@ class SkinStandard extends Skin { } if( $wgUser->isLoggedIn() ) { - $s.= self::specialLink( 'watchlist' ) ; - $s .= $sep . self::makeKnownLink( $wgContLang->specialPage( 'Contributions' ), + $s.= $this->specialLink( 'watchlist' ) ; + $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( 'Contributions' ), wfMsg( 'mycontris' ), 'target=' . wfUrlencode($wgUser->getName() ) ); } // only show watchlist link if logged in @@ -220,7 +220,7 @@ class SkinStandard extends Skin { $link = $nstext . ':' . $link ; } - $s .= self::makeLink( $link, $text ); + $s .= $this->makeLink( $link, $text ); } elseif( $wgTitle->getNamespace() != NS_SPECIAL ) { # we just throw in a "New page" text to tell the user that he's in edit mode, # and to avoid messing with the separator that is prepended to the next item @@ -231,10 +231,10 @@ class SkinStandard extends Skin { # "Post a comment" link if( ( $wgTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview ) - $s .= '
    ' . self::makeKnownLinkObj( $wgTitle, wfMsg( 'postcomment' ), 'action=edit§ion=new' ); + $s .= '
    ' . $this->makeKnownLinkObj( $wgTitle, wfMsg( 'postcomment' ), 'action=edit§ion=new' ); #if( $tns%2 && $action!='edit' && !$wpPreview) { - #$s.= '
    '.self::makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit§ion=new'); + #$s.= '
    '.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit§ion=new'); #} /* @@ -282,9 +282,9 @@ class SkinStandard extends Skin { } if ( $wgUser->isLoggedIn() && ( $wgEnableUploads || $wgRemoteUploads ) ) { - $s .= self::specialLink( 'upload' ) . $sep; + $s .= $this->specialLink( 'upload' ) . $sep; } - $s .= self::specialLink( 'specialpages' ) + $s .= $this->specialLink( 'specialpages' ) . $sep . $this->bugReportsLink(); global $wgSiteSupportPage; diff --git a/skins/disabled/HTMLDump.php b/skins/disabled/HTMLDump.php index 12cbb58b68..5f739a379d 100644 --- a/skins/disabled/HTMLDump.php +++ b/skins/disabled/HTMLDump.php @@ -80,7 +80,7 @@ class SkinHTMLDump extends SkinTemplate { $hasMembers = $dbr->selectField( 'categorylinks', '1', array( 'cl_to' => $nt->getDBkey() ), __METHOD__ ); if ( $hasMembers ) { - return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); + return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); } } diff --git a/skins/disabled/MonoBookCBT.php b/skins/disabled/MonoBookCBT.php index 24c09c2f25..f5f742d601 100644 --- a/skins/disabled/MonoBookCBT.php +++ b/skins/disabled/MonoBookCBT.php @@ -428,12 +428,12 @@ class SkinMonoBookCBT extends SkinTemplate { $usertalktitle = $usertitle->getTalkPage(); if( !$usertalktitle->equals( $this->mTitle ) ) { $ntl = wfMsg( 'youhavenewmessages', - self::makeKnownLinkObj( + $this->makeKnownLinkObj( $usertalktitle, wfMsgHtml( 'newmessageslink' ), 'redirect=no' ), - self::makeKnownLinkObj( + $this->makeKnownLinkObj( $usertalktitle, wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' -- 2.20.1