From 38ca12aa82343574c319ccc0ac1b0783188618f0 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 7 Jun 2009 15:02:12 +0000 Subject: [PATCH] * replace some use of deprecated makeKnownLinkObj() by link() in core * use array type parameter instead of string to escapeLocalUrl(), getFullURL() and getFullUrl() for readability * add FIXME in Parser.php and LogEventsList.php where I didn't know how to replace makeKnownLinkObj by link() * return type for private method Skin::editUrlOptions() changed from string to array * some code readability improvements Linking this to r51559 for CodeReview as there is some discussion there, and these changes are very similar. Todo: core special pages --- includes/LogEventsList.php | 115 ++++++++++++++++----- includes/OutputPage.php | 21 +++- includes/PageHistory.php | 68 ++++++++++--- includes/PatrolLog.php | 16 ++- includes/Preferences.php | 9 +- includes/Skin.php | 180 +++++++++++++++++++++++++-------- includes/SkinTemplate.php | 33 ++++-- includes/WatchlistEditor.php | 29 +++++- includes/parser/Parser.php | 1 + skins/CologneBlue.php | 49 +++++++-- skins/Standard.php | 14 ++- skins/disabled/MonoBookCBT.php | 33 ++++-- 12 files changed, 436 insertions(+), 132 deletions(-) diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index 9cc3c13f26..3739304d11 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -109,6 +109,7 @@ class LogEventsList { $hiddens = ''; // keep track for "go" button foreach( $filter as $type => $val ) { $hideVal = 1 - intval($val); + // FIXME: use link() here. Needs changes in getDefaultQuery() $link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal], wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() ) ); @@ -242,33 +243,55 @@ class LogEventsList { } else if( self::typeAction($row,'move','move','move') && !empty($paramArray[0]) ) { $destTitle = Title::newFromText( $paramArray[0] ); if( $destTitle ) { - $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ), + $revert = '(' . $this->skin->link( + SpecialPage::getTitleFor( 'Movepage' ), $this->message['revertmove'], - 'wpOldTitle=' . urlencode( $destTitle->getPrefixedDBkey() ) . - '&wpNewTitle=' . urlencode( $title->getPrefixedDBkey() ) . - '&wpReason=' . urlencode( wfMsgForContent( 'revertmove' ) ) . - '&wpMovetalk=0' ) . ')'; + array(), + array( + 'wpOldTitle' => $destTitle->getPrefixedDBkey(), + 'wpNewTitle' => $title->getPrefixedDBkey(), + 'wpReason' => wfMsgForContent( 'revertmove' ), + 'wpMovetalk' => 0 + ), + array( 'known', 'noclasses' ) + ) . ')'; } // Show undelete link } else if( self::typeAction($row,array('delete','suppress'),'delete','deletedhistory') ) { - if( !$wgUser->isAllowed( 'undelete' ) ) + if( !$wgUser->isAllowed( 'undelete' ) ) { $viewdeleted = $this->message['undeleteviewlink']; - else + } else { $viewdeleted = $this->message['undeletelink']; - $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Undelete' ), - $viewdeleted, 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')'; + } + + $revert = '(' . $this->skin->link( + SpecialPage::getTitleFor( 'Undelete' ), + $viewdeleted, + array(), + array( 'target' => $title->getPrefixedDBkey() ), + array( 'known', 'noclasses' ) + ) . ')'; // Show unblock/change block link } else if( self::typeAction($row,array('block','suppress'),array('block','reblock'),'block') ) { $revert = '(' . - $this->skin->link( SpecialPage::getTitleFor( 'Ipblocklist' ), + $this->skin->link( + SpecialPage::getTitleFor( 'Ipblocklist' ), $this->message['unblocklink'], array(), - array( 'action' => 'unblock', 'ip' => $row->log_title ), - 'known' ) - . $this->message['pipe-separator'] . - $this->skin->link( SpecialPage::getTitleFor( 'Blockip', $row->log_title ), + array( + 'action' => 'unblock', + 'ip' => $row->log_title + ), + 'known' + ) . + $this->message['pipe-separator'] . + $this->skin->link( + SpecialPage::getTitleFor( 'Blockip', $row->log_title ), $this->message['change-blocklink'], - array(), array(), 'known' ) . + array(), + array(), + 'known' + ) . ')'; // Show change protection link } else if( self::typeAction( $row, 'protect', array( 'modify', 'protect', 'unprotect' ) ) ) { @@ -276,7 +299,11 @@ class LogEventsList { $this->skin->link( $title, $this->message['hist'], array(), - array( 'action' => 'history', 'offset' => $row->log_timestamp ) ); + array( + 'action' => 'history', + 'offset' => $row->log_timestamp + ) + ); if( $wgUser->isAllowed( 'protect' ) ) { $revert .= $this->message['pipe-separator'] . $this->skin->link( $title, @@ -289,9 +316,17 @@ class LogEventsList { // Show unmerge link } else if( self::typeAction($row,'merge','merge','mergehistory') ) { $merge = SpecialPage::getTitleFor( 'Mergehistory' ); - $revert = '(' . $this->skin->makeKnownLinkObj( $merge, $this->message['revertmerge'], - wfArrayToCGI( array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(), - 'mergepoint' => $paramArray[1] ) ) ) . ')'; + $revert = '(' . $this->skin->link( + $merge, + $this->message['revertmerge'], + array(), + array( + 'target' => $paramArray[0], + 'dest' => $title->getPrefixedDBkey(), + 'mergepoint' => $paramArray[1] + ), + array( 'known', 'noclasses' ) + ) . ')'; // If an edit was hidden from a page give a review link to the history } else if( self::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) { if( count($paramArray) >= 2 ) { @@ -300,16 +335,33 @@ class LogEventsList { $key = $paramArray[0]; // $paramArray[1] is a CSV of the IDs $Ids = explode( ',', $paramArray[1] ); - $query = urlencode($paramArray[1]); + $query = $paramArray[1]; $revert = array(); // Diff link for single rev deletions if( ( $key === 'oldid' || $key == 'revision' ) && count($Ids) == 1 ) { - $revert[] = $this->skin->makeKnownLinkObj( $title, $this->message['diff'], - 'diff='.intval($Ids[0])."&unhide=1" ); + $revert[] = $this->skin->link( + $title, + $this->message['diff'], + array(), + array( + 'diff' => intval( $Ids[0] ), + 'unhide' => 1 + ), + array( 'known', 'noclasses' ) + ); } // View/modify link... - $revert[] = $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'], - 'target='.$title->getPrefixedUrl()."&type=$key&ids=$query" ); + $revert[] = $this->skin->link( + $revdel, + $this->message['revdel-restore'], + array(), + array( + 'target' => $title->getPrefixedUrl(), + 'type' => $key, + 'ids' => $query + ), + array( 'known', 'noclasses' ) + ); // Pipe links $revert = '(' . implode(' | ',$revert) . ')'; } @@ -319,10 +371,19 @@ class LogEventsList { $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); // $paramArray[1] is a CSV of the IDs $Ids = explode( ',', $paramArray[0] ); - $query = urlencode($paramArray[0]); + $query = $paramArray[0]; // Link to each hidden object ID, $paramArray[1] is the url param - $revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'], - 'target='.$title->getPrefixedUrl()."&type=logging&ids=$query" ) . ')'; + $revert = '(' . $this->skin->link( + $revdel, + $this->message['revdel-restore'], + array(), + array( + 'target' => $title->getPrefixedUrl(), + 'type' => 'logging', + 'ids' => $query + ), + array( 'known', 'noclasses' ) + ) . ')'; } // Self-created users } else if( self::typeAction($row,'newusers','create2') ) { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 3d860f700a..37b1b441c6 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1254,7 +1254,13 @@ class OutputPage { $this->setArticleFlag( false ); $loginTitle = SpecialPage::getTitleFor( 'Userlogin' ); - $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $this->getTitle()->getPrefixedUrl() ); + $loginLink = $skin->link( + $loginTitle, + wfMsgHtml( 'loginreqlink' ), + array(), + array( 'returnto' => $this->getTitle()->getPrefixedUrl() ), + array( 'known', 'noclasses' ) + ); $this->addHTML( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) ); $this->addHTML( "\n" ); @@ -1336,7 +1342,18 @@ class OutputPage { // Permissions error if( $source ) { $this->setPageTitle( wfMsg( 'viewsource' ) ); - $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $this->getTitle() ) ) ); + $this->setSubtitle( + wfMsg( + 'viewsourcefor', + $skin->link( + $this->getTitle(), + null, + array(), + array(), + array( 'known', 'noclasses' ) + ) + ) + ); } else { $this->setPageTitle( wfMsg( 'badaccess' ) ); } diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 923d47c070..47bd5bb0fd 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -90,8 +90,13 @@ class PageHistory { $wgOut->addScriptFile( 'history.js' ); $logPage = SpecialPage::getTitleFor( 'Log' ); - $logLink = $this->mSkin->makeKnownLinkObj( $logPage, wfMsgHtml( 'viewpagelogs' ), - 'page=' . $this->mTitle->getPrefixedUrl() ); + $logLink = $this->mSkin->link( + $logPage, + wfMsgHtml( 'viewpagelogs' ), + array(), + array( 'page' => $this->mTitle->getPrefixedUrl() ), + array( 'known', 'noclasses' ) + ); $wgOut->setSubtitle( $logLink ); $feedType = $wgRequest->getVal( 'feed' ); @@ -379,7 +384,13 @@ class PageHistory { $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true ); $date = htmlspecialchars( $date ); if( !$rev->isDeleted( Revision::DELETED_TEXT ) ) { - $link = $this->mSkin->makeKnownLinkObj( $this->mTitle, $date, "oldid=" . $rev->getId() ); + $link = $this->mSkin->link( + $this->mTitle, + $date, + array(), + array( 'oldid' => $rev->getId() ), + array( 'known', 'noclasses' ) + ); } else { $link = "$date"; } @@ -397,8 +408,16 @@ class PageHistory { if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { return $cur; } else { - return $this->mSkin->makeKnownLinkObj( $this->mTitle, $cur, - 'diff=' . $this->mTitle->getLatestRevID() . "&oldid=" . $rev->getId() ); + return $this->mSkin->link( + $this->mTitle, + $cur, + array(), + array( + 'diff' => $this->mTitle->getLatestRevID(), + 'oldid' => $rev->getId() + ), + array( 'known', 'noclasses' ) + ); } } @@ -418,13 +437,29 @@ class PageHistory { return $last; } elseif( $next === 'unknown' ) { # Next row probably exists but is unknown, use an oldid=prev link - return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last, - "diff=" . $prevRev->getId() . "&oldid=prev" ); + return $this->mSkin->link( + $this->mTitle, + $last, + array(), + array( + 'diff' => $prevRev->getId(), + 'oldid' => 'prev' + ), + array( 'known', 'noclasses' ) + ); } elseif( !$prevRev->userCan(Revision::DELETED_TEXT) || !$nextRev->userCan(Revision::DELETED_TEXT) ) { return $last; } else { - return $this->mSkin->makeKnownLinkObj( $this->mTitle, $last, - "diff=" . $prevRev->getId() . "&oldid={$next->rev_id}" ); + return $this->mSkin->link( + $this->mTitle, + $last, + array(), + array( + 'diff' => $prevRev->getId(), + 'oldid' => $next->rev_id + ), + array( 'known', 'noclasses' ) + ); } } @@ -506,10 +541,11 @@ class PageHistory { } $feed = new $wgFeedClasses[$type]( - $this->mTitle->getPrefixedText() . ' - ' . - wfMsgForContent( 'history-feed-title' ), - wfMsgForContent( 'history-feed-description' ), - $this->mTitle->getFullUrl( 'action=history' ) ); + $this->mTitle->getPrefixedText() . ' - ' . + wfMsgForContent( 'history-feed-title' ), + wfMsgForContent( 'history-feed-description' ), + $this->mTitle->getFullUrl( array( 'action' => 'history' ) ) + ); // Get a limit on number of feed entries. Provide a sane default // of 10 if none is defined (but limit to $wgFeedLimit max) @@ -573,14 +609,16 @@ class PageHistory { return new FeedItem( $title, $text, - $this->mTitle->getFullUrl( 'diff=' . $rev->getId() . '&oldid=prev' ), + $this->mTitle->getFullUrl( array( + 'diff' => $rev->getId(), + 'oldid' => 'prev' + ) ), $rev->getTimestamp(), $rev->getUserText(), $this->mTitle->getTalkPage()->getFullUrl() ); } } - /** * @ingroup Pager */ diff --git a/includes/PatrolLog.php b/includes/PatrolLog.php index 61512ded5b..117ed4e6b9 100644 --- a/includes/PatrolLog.php +++ b/includes/PatrolLog.php @@ -45,10 +45,18 @@ class PatrolLog { $link = $skin->link( $title ); if( $title->exists() ) { # Generate a diff link - $bits[] = 'oldid=' . urlencode( $cur ); - $bits[] = 'diff=prev'; - $bits = implode( '&', $bits ); - $diff = $skin->makeKnownLinkObj( $title, htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ), $bits ); + $query = array( + 'oldid' => $cur, + 'diff' => 'prev' + ); + + $diff = $skin->link( + $title, + htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ), + array(), + $query, + array( 'known', 'noclasses' ) + ); } else { # Don't bother with a diff link, it's useless $diff = htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ); diff --git a/includes/Preferences.php b/includes/Preferences.php index 5f64f27aef..f54cf05e94 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -310,8 +310,13 @@ class Preferences { global $wgUser; // wgUser is okay here, it's for display $skin = $wgUser->getSkin(); $emailauthenticated = wfMsgHtml('emailnotauthenticated').'
' . - $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Confirmemail' ), - wfMsg( 'emailconfirmlink' ) ) . '
'; + $skin->link( + SpecialPage::getTitleFor( 'Confirmemail' ), + wfMsg( 'emailconfirmlink' ), + array(), + array(), + array( 'known', 'noclasses' ) + ) . '
'; } } else { $disableEmailPrefs = true; diff --git a/includes/Skin.php b/includes/Skin.php index 1e3a9fb117..53a99e188c 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -992,16 +992,34 @@ END; } } if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) { - $s[] .= $this->makeKnownLinkObj( $this->mTitle, - wfMsg( 'currentrev' ) ); + $s[] .= $this->link( + $this->mTitle, + wfMsg( 'currentrev' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); } if ( $wgUser->getNewtalk() ) { # do not show "You have new messages" text when we are viewing our # own talk page if( !$this->mTitle->equals( $wgUser->getTalkPage() ) ) { - $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' ); - $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' ); + $tl = $this->link( + $wgUser->getTalkPage(), + wfMsgHtml( 'newmessageslink' ), + array(), + array( 'redirect' => 'no' ), + array( 'known', 'noclasses' ) + ); + + $dl = $this->link( + $wgUser->getTalkPage(), + wfMsgHtml( 'newmessagesdifflink' ), + array(), + array( 'diff' => 'cur' ), + array( 'known', 'noclasses' ) + ); $s[] = ''. wfMsg( 'youhavenewmessages', $tl, $dl ) . ''; # disable caching $wgOut->setSquidMaxage( 0 ); @@ -1030,10 +1048,16 @@ END; } else { $msg = 'viewdeleted'; } - return wfMsg( $msg, - $this->makeKnownLinkObj( + return wfMsg( + $msg, + $this->link( SpecialPage::getTitleFor( 'Undelete', $this->mTitle->getPrefixedDBkey() ), - wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ) ) ); + wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ), + array(), + array(), + array( 'known', 'noclasses' ) + ) + ); } } return ''; @@ -1094,7 +1118,13 @@ END; $display .= $link; $linkObj = Title::newFromText( $growinglink ); if( is_object( $linkObj ) && $linkObj->exists() ){ - $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) ); + $getlink = $this->link( + $linkObj, + htmlspecialchars( $display ), + array(), + array(), + array( 'known', 'noclasses' ) + ); $c++; if( $c > 1 ) { $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' ); @@ -1503,7 +1533,13 @@ END; } function mainPageLink() { - $s = $this->makeKnownLinkObj( Title::newMainPage(), wfMsg( 'mainpage' ) ); + $s = $this->link( + Title::newMainPage(), + wfMsg( 'mainpage' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); return $s; } @@ -1553,7 +1589,13 @@ END; $t = wfMsg( 'viewsource' ); } - $s = $this->makeKnownLinkObj( $this->mTitle, $t, $this->editUrlOptions() ); + $s = $this->link( + $this->mTitle, + $t, + array(), + $this->editUrlOptions(), + array( 'known', 'noclasses' ) + ); } return $s; } @@ -1562,17 +1604,19 @@ END; * Return URL options for the 'edit page' link. * This may include an 'oldid' specifier, if the current page view is such. * - * @return string + * @return array * @private */ function editUrlOptions() { global $wgArticle; + $options = array( 'action' => 'edit' ); + if( $this->mRevisionId && ! $wgArticle->isCurrent() ) { - return 'action=edit&oldid=' . intval( $this->mRevisionId ); - } else { - return 'action=edit'; + $options['oldid'] = intval( $this->mRevisionId ); } + + return $options; } function deleteThisPage() { @@ -1582,7 +1626,13 @@ END; if ( $this->mTitle->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) { $t = wfMsg( 'deletethispage' ); - $s = $this->makeKnownLinkObj( $this->mTitle, $t, 'action=delete' ); + $s = $this->link( + $this->mTitle, + $t, + array(), + array( 'action' => 'delete' ), + array( 'known', 'noclasses' ) + ); } else { $s = ''; } @@ -1595,13 +1645,20 @@ END; $diff = $wgRequest->getVal( 'diff' ); if ( $this->mTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) { if ( $this->mTitle->isProtected() ) { - $t = wfMsg( 'unprotectthispage' ); - $q = 'action=unprotect'; + $text = wfMsg( 'unprotectthispage' ); + $query = array( 'action' => 'unprotect' ); } else { - $t = wfMsg( 'protectthispage' ); - $q = 'action=protect'; + $text = wfMsg( 'protectthispage' ); + $query = array( 'action' => 'protect' ); } - $s = $this->makeKnownLinkObj( $this->mTitle, $t, $q ); + + $s = $this->link( + $this->mTitle, + $text, + array(), + $query, + array( 'known', 'noclasses' ) + ); } else { $s = ''; } @@ -1614,15 +1671,22 @@ END; if ( $wgOut->isArticleRelated() ) { if ( $this->mTitle->userIsWatching() ) { - $t = wfMsg( 'unwatchthispage' ); - $q = 'action=unwatch'; - $id = 'mw-unwatch-link' . $this->mWatchLinkNum; + $text = wfMsg( 'unwatchthispage' ); + $query = array( 'action' => 'unwatch' ); + $id = array( 'mw-unwatch-link' => $this->mWatchLinkNum ); } else { - $t = wfMsg( 'watchthispage' ); - $q = 'action=watch'; - $id = 'mw-watch-link' . $this->mWatchLinkNum; + $text = wfMsg( 'watchthispage' ); + $query = array( 'action' => 'watch' ); + $id = array( 'mw-watch-link' => $this->mWatchLinkNum ); } - $s = $this->makeKnownLinkObj( $this->mTitle, $t, $q, '', '', " id=\"$id\"" ); + + $s = $this->link( + $this->mTitle, + $text, + array( 'id' => $id ), + $query, + array( 'known', 'noclasses' ) + ); } else { $s = wfMsg( 'notanarticle' ); } @@ -1631,8 +1695,13 @@ END; function moveThisPage() { if ( $this->mTitle->quickUserCan( 'move' ) ) { - return $this->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ), - wfMsg( 'movethispage' ), 'target=' . $this->mTitle->getPrefixedURL() ); + return $this->link( + SpecialPage::getTitleFor( 'Movepage' ), + wfMsg( 'movethispage' ), + array(), + array( 'target' => $this->mTitle->getPrefixedURL() ), + array( 'known', 'noclasses' ) + ); } else { // no message if page is protected - would be redundant return ''; @@ -1640,20 +1709,32 @@ END; } function historyLink() { - return $this->link( $this->mTitle, wfMsgHtml( 'history' ), - array( 'rel' => 'archives' ), array( 'action' => 'history' ) ); + return $this->link( + $this->mTitle, + wfMsgHtml( 'history' ), + array( 'rel' => 'archives' ), + array( 'action' => 'history' ) + ); } function whatLinksHere() { - return $this->makeKnownLinkObj( + return $this->link( SpecialPage::getTitleFor( 'Whatlinkshere', $this->mTitle->getPrefixedDBkey() ), - wfMsgHtml( 'whatlinkshere' ) ); + wfMsgHtml( 'whatlinkshere' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); } function userContribsLink() { - return $this->makeKnownLinkObj( + return $this->link( SpecialPage::getTitleFor( 'Contributions', $this->mTitle->getDBkey() ), - wfMsgHtml( 'contributions' ) ); + wfMsgHtml( 'contributions' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); } function showEmailUser( $id ) { @@ -1664,9 +1745,13 @@ END; } function emailUserLink() { - return $this->makeKnownLinkObj( + return $this->link( SpecialPage::getTitleFor( 'Emailuser', $this->mTitle->getDBkey() ), - wfMsg( 'emailuser' ) ); + wfMsg( 'emailuser' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); } function watchPageLinksLink() { @@ -1674,9 +1759,13 @@ END; if ( ! $wgOut->isArticleRelated() ) { return '(' . wfMsg( 'notanarticle' ) . ')'; } else { - return $this->makeKnownLinkObj( + return $this->link( SpecialPage::getTitleFor( 'Recentchangeslinked', $this->mTitle->getPrefixedDBkey() ), - wfMsg( 'recentchangeslinked-toolbox' ) ); + wfMsg( 'recentchangeslinked-toolbox' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); } } @@ -1777,7 +1866,7 @@ END; } # __NEWSECTIONLINK___ changes behaviour here - # If it's present, the link points to this page, otherwise + # If it is present, the link points to this page, otherwise # it points to the talk page if( $this->mTitle->isTalkPage() ) { $title = $this->mTitle; @@ -1787,7 +1876,16 @@ END; $title = $this->mTitle->getTalkPage(); } - return $this->makeKnownLinkObj( $title, wfMsg( 'postcomment' ), 'action=edit§ion=new' ); + return $this->link( + $title, + wfMsg( 'postcomment' ), + array(), + array( + 'action' => 'edit', + 'section' => 'new' + ), + array( 'known', 'noclasses' ) + ); } /* these are used extensively in SkinTemplate, but also some other places */ diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index dcbedd8816..42e4f3ab9b 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -290,23 +290,34 @@ class SkinTemplate extends Skin { } else { $tpl->set( 'jsvarurl', false ); } + $newtalks = $wgUser->getNewMessageLinks(); if( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) { $usertitle = $this->mUser->getUserPage(); $usertalktitle = $usertitle->getTalkPage(); + if( !$usertalktitle->equals( $this->mTitle ) ) { - $ntl = wfMsg( 'youhavenewmessages', - $this->makeKnownLinkObj( - $usertalktitle, - wfMsgHtml( 'newmessageslink' ), - 'redirect=no' - ), - $this->makeKnownLinkObj( - $usertalktitle, - wfMsgHtml( 'newmessagesdifflink' ), - 'diff=cur' - ) + $newmessageslink = $this->link( + $usertalktitle, + wfMsgHtml( 'newmessageslink' ), + array(), + array( 'redirect' => 'no' ), + array( 'known', 'noclasses' ) + ); + + $newmessagesdifflink = $this->link( + $usertalktitle, + wfMsgHtml( 'newmessagesdifflink' ), + array(), + array( 'diff' => 'cur' ), + array( 'known', 'noclasses' ) + ); + + $ntl = wfMsg( + 'youhavenewmessages', + $newmessageslink, + $newmessagesdifflink ); # Disable Cache $out->setSquidMaxage( 0 ); diff --git a/includes/WatchlistEditor.php b/includes/WatchlistEditor.php index 9744aab93f..e9e79ee1df 100644 --- a/includes/WatchlistEditor.php +++ b/includes/WatchlistEditor.php @@ -340,7 +340,7 @@ class WatchlistEditor { if( ( $count = $this->showItemCount( $output, $user ) ) > 0 ) { $self = SpecialPage::getTitleFor( 'Watchlist' ); $form = Xml::openElement( 'form', array( 'method' => 'post', - 'action' => $self->getLocalUrl( 'action=edit' ) ) ); + 'action' => $self->getLocalUrl( array( 'action' => 'edit' ) ) ) ); $form .= Xml::hidden( 'token', $wgUser->editToken( 'watchlistedit' ) ); $form .= "
\n" . wfMsgHtml( 'watchlistedit-normal-legend' ) . ""; $form .= wfMsgExt( 'watchlistedit-normal-explain', 'parse' ); @@ -414,10 +414,22 @@ class WatchlistEditor { $link = '' . $link . ''; $tools[] = $skin->link( $title->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) ); if( $title->exists() ) { - $tools[] = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'history_short' ), 'action=history' ); + $tools[] = $skin->link( + $title, + wfMsgHtml( 'history_short' ), + array(), + array( 'action' => 'history' ), + array( 'known', 'noclasses' ) + ); } if( $title->getNamespace() == NS_USER && !$title->isSubpage() ) { - $tools[] = $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Contributions', $title->getText() ), wfMsgHtml( 'contributions' ) ); + $tools[] = $skin->link( + SpecialPage::getTitleFor( 'Contributions', $title->getText() ), + wfMsgHtml( 'contributions' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); } return "
  • " . Xml::check( 'titles[]', false, array( 'value' => $title->getPrefixedText() ) ) @@ -435,7 +447,7 @@ class WatchlistEditor { $this->showItemCount( $output, $user ); $self = SpecialPage::getTitleFor( 'Watchlist' ); $form = Xml::openElement( 'form', array( 'method' => 'post', - 'action' => $self->getLocalUrl( 'action=raw' ) ) ); + 'action' => $self->getLocalUrl( array( 'action' => 'raw' ) ) ) ); $form .= Xml::hidden( 'token', $wgUser->editToken( 'watchlistedit' ) ); $form .= '
    ' . wfMsgHtml( 'watchlistedit-raw-legend' ) . ''; $form .= wfMsgExt( 'watchlistedit-raw-explain', 'parse' ); @@ -487,7 +499,14 @@ class WatchlistEditor { $tools = array(); $modes = array( 'view' => false, 'edit' => 'edit', 'raw' => 'raw' ); foreach( $modes as $mode => $subpage ) { - $tools[] = $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Watchlist', $subpage ), wfMsgHtml( "watchlisttools-{$mode}" ) ); + // can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw' + $tools[] = $skin->link( + SpecialPage::getTitleFor( 'Watchlist', $subpage ), + wfMsgHtml( "watchlisttools-{$mode}" ), + array(), + array(), + array( 'known', 'noclasses' ) + ); } return $wgLang->pipeList( $tools ); } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index e9c33c619a..3b93067c46 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1793,6 +1793,7 @@ class Parser function makeKnownLinkHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { list( $inside, $trail ) = Linker::splitTrail( $trail ); $sk = $this->mOptions->getSkin(); + // FIXME: use link() instead of deprecated makeKnownLinkObj() $link = $sk->makeKnownLinkObj( $nt, $text, $query, $inside, $prefix ); return $this->armorLinks( $link ) . $trail; } diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index 458d695ecc..bc4a4c535f 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -79,7 +79,13 @@ class SkinCologneBlue extends Skin { $s .= $this->bottomLinks(); $s .= $wgLang->pipeList( array( - "\n
    " . $this->makeKnownLinkObj( Title::newMainPage() ), + "\n
    " . $this->link( + Title::newMainPage(), + null, + array(), + array(), + array( 'known', 'noclasses' ) + ), $this->aboutLink(), $this->searchForm( wfMsg( 'qbfind' ) ) ) ); @@ -242,20 +248,35 @@ class SkinCologneBlue extends Skin { $s .= $this->menuHead( 'qbmyoptions' ); if ( $wgUser->isLoggedIn() ) { $name = $wgUser->getName(); - $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), - wfMsg( 'mytalk' ) ); + $tl = $this->link( + $wgUser->getTalkPage(), + wfMsg( 'mytalk' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); if ( $wgUser->getNewtalk() ) { $tl .= " *"; } - $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(), - wfMsg( 'mypage' ) ) + $s .= $this->link( + $wgUser->getUserPage(), + wfMsg( 'mypage' ), + array(), + array(), + array( 'known', 'noclasses' ) + ) . $sep . $tl . $sep . $this->specialLink( 'watchlist' ) - . $sep . $this->makeKnownLinkObj( SpecialPage::getSafeTitleFor( 'Contributions', $wgUser->getName() ), - wfMsg( 'mycontris' ) ) - . $sep . $this->specialLink( 'preferences' ) - . $sep . $this->specialLink( 'userlogout' ); + . $sep . $this->link( + SpecialPage::getSafeTitleFor( 'Contributions', $wgUser->getName() ), + wfMsg( 'mycontris' ), + array(), + array(), + array( 'known', 'noclasses' ) + ) + . $sep . $this->specialLink( 'preferences' ) + . $sep . $this->specialLink( 'userlogout' ); } else { $s .= $this->specialLink( 'userlogin' ); } @@ -267,15 +288,21 @@ class SkinCologneBlue extends Skin { if ( $wgUser->isLoggedIn() && $wgEnableUploads ) { $s .= $sep . $this->specialLink( 'upload' ); } + global $wgSiteSupportPage; + if( $wgSiteSupportPage ) { $s .= $sep . '' . wfMsg( 'sitesupport' ) . ''; } - $s .= $sep . $this->makeKnownLinkObj( + $s .= $sep . $this->link( SpecialPage::getTitleFor( 'Specialpages' ), - wfMsg( 'moredotdotdot' ) ); + wfMsg( 'moredotdotdot' ), + array(), + array(), + array( 'known', 'noclasses' ) + ); $s .= $sep . "\n\n"; return $s; diff --git a/skins/Standard.php b/skins/Standard.php index 69da703e48..83a44d6e5f 100644 --- a/skins/Standard.php +++ b/skins/Standard.php @@ -221,13 +221,21 @@ class SkinStandard extends Skin { # and to avoid messing with the separator that is prepended to the next item $s .= '' . wfMsg( 'newpage' ) . ''; } - } # "Post a comment" link if( ( $this->mTitle->isTalkPage() || $wgOut->showNewSectionLink() ) && $action != 'edit' && !$wpPreview ) - $s .= '
    ' . $this->makeKnownLinkObj( $this->mTitle, wfMsg( 'postcomment' ), 'action=edit§ion=new' ); - + $s .= '
    ' . $this->link( + $this->mTitle, + wfMsg( 'postcomment' ), + array(), + array( + 'action' => 'edit', + 'section' => 'new' + ), + array( 'known', 'noclasses' ) + ); + #if( $tns%2 && $action!='edit' && !$wpPreview) { #$s.= '
    '.$this->makeKnownLink($wgTitle->getPrefixedText(),wfMsg('postcomment'),'action=edit§ion=new'); #} diff --git a/skins/disabled/MonoBookCBT.php b/skins/disabled/MonoBookCBT.php index 0d693a8618..9f8098c917 100644 --- a/skins/disabled/MonoBookCBT.php +++ b/skins/disabled/MonoBookCBT.php @@ -426,19 +426,30 @@ class SkinMonoBookCBT extends SkinTemplate { if (count($newtalks) == 1 && $newtalks[0]["wiki"] === $wgDBname) { $usertitle = $this->getUserPageTitle(); $usertalktitle = $usertitle->getTalkPage(); + if( !$usertalktitle->equals( $this->mTitle ) ) { - $ntl = wfMsg( 'youhavenewmessages', - $this->makeKnownLinkObj( - $usertalktitle, - wfMsgHtml( 'newmessageslink' ), - 'redirect=no' - ), - $this->makeKnownLinkObj( - $usertalktitle, - wfMsgHtml( 'newmessagesdifflink' ), - 'diff=cur' - ) + $newmessageslink = $this->link( + $usertalktitle, + wfMsgHtml( 'newmessageslink' ), + array(), + array( 'redirect' => 'no' ), + array( 'known', 'noclasses' ) + ); + + $newmessagesdifflink = $this->link( + $usertalktitle, + wfMsgHtml( 'newmessagesdifflink' ), + array(), + array( 'diff' => 'cur' ), + array( 'known', 'noclasses' ) ); + + $ntl = wfMsg( + 'youhavenewmessages', + $newmessageslink, + $newmessagesdifflink + ); + # Disable Cache $this->mOut->setSquidMaxage(0); } -- 2.20.1