SamanthaNguyen has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/405553 )
Change subject: DNM: Convert manually constructed links to use LinkRenderer ...................................................................... DNM: Convert manually constructed links to use LinkRenderer This converts manually constructed links to use the LinkRenderer service. There's still lots of manually constructed HTML left, but this at least takes care of a small portion. The only manually constructed links left are actually 'fake' or pseudo-links, which are links using inline javascript to perform an action. These probably need to be migrated to proper buttons as well as have their JS moved to a proper JS file, which will be taken care of in another patch. There is also a few i18n messages which contain manually constructed links. This will be cleaned up in another follow-up patch as well. Change-Id: I913b5463813a23c8b4f5f697096a95af754e8518 --- M SystemGifts/SpecialRemoveMasterSystemGift.php M SystemGifts/SpecialSystemGiftManager.php M SystemGifts/SpecialSystemGiftManagerLogo.php M SystemGifts/SpecialViewSystemGift.php M SystemGifts/SpecialViewSystemGifts.php M SystemGifts/TopAwards.php M UserActivity/UserActivity.body.php M UserActivity/UserActivityClass.php M UserBoard/SpecialUserBoard.php M UserBoard/UserBoardClass.php M UserGifts/SpecialGiftManager.php M UserGifts/SpecialGiftManagerLogo.php M UserGifts/SpecialGiveGift.php M UserGifts/SpecialRemoveGift.php M UserGifts/SpecialRemoveMasterGift.php M UserGifts/SpecialViewGift.php M UserGifts/SpecialViewGifts.php M UserProfile/SpecialEditProfile.php M UserProfile/SpecialRemoveAvatar.php M UserProfile/SpecialUpdateProfile.php M UserProfile/UserProfilePage.php M UserRelationship/SpecialViewRelationships.php M UserStats/GenerateTopUsersReport.php M UserStats/TopFansByStat.php M UserStats/TopFansRecent.php M UserStats/TopUsers.php M UserStats/TopUsersTag.php M UserWelcome/UserWelcomeClass.php 28 files changed, 905 insertions(+), 414 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SocialProfile refs/changes/53/405553/1 diff --git a/SystemGifts/SpecialRemoveMasterSystemGift.php b/SystemGifts/SpecialRemoveMasterSystemGift.php index 16d8358..01de27a 100644 --- a/SystemGifts/SpecialRemoveMasterSystemGift.php +++ b/SystemGifts/SpecialRemoveMasterSystemGift.php @@ -44,6 +44,7 @@ $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // make sure user has the correct permissions $this->checkPermissions(); @@ -98,10 +99,12 @@ $out->setPageTitle( $this->msg( 'ga-remove-success-title', $gift['gift_name'] )->plain() ); - $output = '<div class="back-links"> - <a href="' . htmlspecialchars( SpecialPage::getTitleFor( 'SystemGiftManager' )->getFullURL() ) . '">' . - $this->msg( 'ga-viewlist' )->plain() . '</a> - </div> + $output = '<div class="back-links">' . + $linkRenderer->makeLink( + SpecialPage::getTitleFor( 'SystemGiftManager' )->getFullURL(), + $this->msg( 'ga-viewlist' )->plain() + ) . + '</div> <div class="ga-container">' . $this->msg( 'ga-remove-success-message', $gift['gift_name'] )->plain() . '<div class="visualClear"></div> @@ -122,6 +125,7 @@ function displayForm() { global $wgUploadPath; + $linkRenderer = $this->getLinkRenderer(); $gift = SystemGifts::getGift( $this->gift_id ); $giftImage = '<img src="' . $wgUploadPath . '/awards/' . @@ -130,10 +134,12 @@ $this->getOutput()->setPageTitle( $this->msg( 'ga-remove-title', $gift['gift_name'] )->plain() ); - $output = '<div class="back-links"> - <a href="' . htmlspecialchars( SpecialPage::getTitleFor( 'SystemGiftManager' )->getFullURL() ) . '">' . - $this->msg( 'ga-viewlist' )->plain() . '</a> - </div> + $output = '<div class="back-links">' . + $linkRenderer->makeLink( + SpecialPage::getTitleFor( 'SystemGiftManager' )->getFullURL(), + $this->msg( 'ga-viewlist' )->plain() + ) . + '</div> <form action="" method="post" enctype="multipart/form-data" name="form1"> <div class="ga-remove-message">' . $this->msg( 'ga-delete-message', $gift['gift_name'] ) . diff --git a/SystemGifts/SpecialSystemGiftManager.php b/SystemGifts/SpecialSystemGiftManager.php index 9b55419..dda55bd 100644 --- a/SystemGifts/SpecialSystemGiftManager.php +++ b/SystemGifts/SpecialSystemGiftManager.php @@ -29,6 +29,7 @@ $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // make sure user has the correct permissions $this->checkPermissions(); @@ -87,9 +88,12 @@ $out->addHTML( $this->displayForm( $gift_id ) ); } else { $out->addHTML( - '<div><b><a href="' . - htmlspecialchars( $this->getPageTitle()->getFullURL( 'method=edit' ) ) . '">' . - $this->msg( 'ga-addnew' )->plain() . '</a></b></div>' + '<div><b>' . + $linkRenderer->makeLink( + $this->getPageTitle()->getFullURL( 'method=edit' ), + $this->msg( 'ga-addnew' )->plain() + ) . + '</b></div>' ); $out->addHTML( $this->displayGiftList() ); } @@ -108,21 +112,25 @@ $per_page = 50; $gifts = SystemGifts::getGiftList( $per_page, $page ); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); if ( $gifts ) { foreach ( $gifts as $gift ) { $deleteLink = ''; if ( $user->isAllowed( 'awardsmanage' ) ) { $removePage = SpecialPage::getTitleFor( 'RemoveMasterSystemGift' ); - $deleteLink = '<a class="ga-remove-link" href="' . - htmlspecialchars( $removePage->getFullURL( "gift_id={$gift['id']}" ) ) . - '">' . $this->msg( 'delete' )->plain() . '</a>'; + $deleteLink = $linkRenderer->makeLink( + $removePage->getFullURL( "gift_id={$gift['id']}" ), + $this->msg( 'delete' )->plain() + ); } - $output .= '<div class="Item"> - <a href="' . htmlspecialchars( $this->getPageTitle()->getFullURL( 'id=' . $gift['id'] ) ) . '">' . - $gift['gift_name'] . '</a> ' . - $deleteLink . '</div>' . "\n"; + $output .= '<div class="Item">' . + $linkRenderer->makeLink( + $this->getPageTitle()->getFullURL( 'id=' . $gift['id'] ), + $gift['gift_name'] + ) . + $deleteLink . '</div>' . "\n"; } } @@ -132,8 +140,14 @@ function displayForm( $gift_id ) { global $wgUploadPath; - $form = '<div><b><a href="' . htmlspecialchars( $this->getPageTitle()->getFullURL() ) . - '">' . $this->msg( 'ga-viewlist' )->plain() . '</a></b></div>'; + $linkRenderer = $this->getLinkRenderer(); + + $form = '<div><b>' . + $linkRenderer->makeLink( + $this->getPageTitle()->getFullURL(), + $this->msg( 'ga-viewlist' )->plain() + ) . + '</b></div>'; if ( $gift_id ) { $gift = SystemGifts::getGift( $gift_id ); @@ -181,9 +195,11 @@ <td class="view-form" valign="top">' . $this->msg( 'ga-giftimage' )->plain() . '</td> <td class="view-container">' . $gift_image . - '<a href="' . htmlspecialchars( $sgml->getFullURL( 'gift_id=' . $gift_id ) ) . '">' . - $this->msg( 'ga-img' )->plain() . '</a> - </td> + $linkRenderer->makeLink( + $sgml->getFullURL( 'gift_id=' . $gift_id ), + $this->msg( 'ga-img' )->plain() + ) . + '</td> </tr>'; } diff --git a/SystemGifts/SpecialSystemGiftManagerLogo.php b/SystemGifts/SpecialSystemGiftManagerLogo.php index 88fd631..3825aaa 100644 --- a/SystemGifts/SpecialSystemGiftManagerLogo.php +++ b/SystemGifts/SpecialSystemGiftManagerLogo.php @@ -494,6 +494,7 @@ function showSuccess( $status ) { global $wgUploadPath; + $linkRenderer = $this->getLinkRenderer(); $ext = 'jpg'; $output = '<h2>' . $this->msg( 'ga-uploadsuccess' )->plain() . '</h2>'; @@ -532,12 +533,21 @@ </tr>'; $systemGiftManager = SpecialPage::getTitleFor( 'SystemGiftManager' ); - $output .= $this->getLanguage()->pipeList( array( - '<tr><td><a href="' . htmlspecialchars( $systemGiftManager->getFullURL() ) . '">' . - $this->msg( 'ga-back-gift-list' )->plain() . '</a> ', - ' <a href="' . htmlspecialchars( $systemGiftManager->getFullURL( 'id=' . $this->gift_id ) ) . '">' . - $this->msg( 'ga-back-edit-gift' )->plain() . '</a></td></tr>' - ) ); + + $output .= '<tr><td>'; + $output .= $this->getLanguage()->pipeList( [ + $linkRenderer->makeLink( + $systemGiftManager->getFullURL(), + $this->msg( 'ga-back-gift-list' )->plain() + ) . ' ', + ' ' . + $linkRenderer->makeLink( + $systemGiftManager->getFullURL( 'id=' . $this->gift_id ), + $this->msg( 'ga-back-edit-gift' )->plain() + ) + ] ); + $output .= '</td></tr>'; + $output .= '</table>'; $this->getOutput()->addHTML( $output ); } diff --git a/SystemGifts/SpecialViewSystemGift.php b/SystemGifts/SpecialViewSystemGift.php index 05d763d..ece6ec4 100644 --- a/SystemGifts/SpecialViewSystemGift.php +++ b/SystemGifts/SpecialViewSystemGift.php @@ -25,6 +25,7 @@ $out = $this->getOutput(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // Set the page title, robot policies, etc. $this->setHeaders(); @@ -120,9 +121,10 @@ $avatar = new wAvatar( $userToId, 'ml' ); $userNameLink = Title::makeTitle( NS_USER, $row->sg_user_name ); - $output .= '<a href="' . htmlspecialchars( $userNameLink->getFullURL() ) . "\"> - {$avatar->getAvatarURL()} - </a>"; + $output .= $linkRenderer->makeLink( + $userNameLink->getFullURL(), + $avatar->getAvatarURL() + ); } $output .= '<div class="visualClear"></div> diff --git a/SystemGifts/SpecialViewSystemGifts.php b/SystemGifts/SpecialViewSystemGifts.php index 1e524c1..82260ce 100644 --- a/SystemGifts/SpecialViewSystemGifts.php +++ b/SystemGifts/SpecialViewSystemGifts.php @@ -32,11 +32,10 @@ public function execute( $par ) { global $wgUploadPath; - $linkRenderer = $this->getLinkRenderer(); - $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // Set the page title, robot policies, etc. $this->setHeaders(); @@ -119,11 +118,12 @@ SystemGifts::getGiftImage( $gift['gift_id'], 'ml' ) . '" border="0" alt="" />'; - $output .= "<div class=\"ga-item\"> - {$gift_image} - <a href=\"" . - htmlspecialchars( $view_system_gift_link->getFullURL( 'gift_id=' . $gift['id'] ) ) . - "\">{$gift['gift_name']}</a>"; + $output .= '<div class=\"ga-item\">' . + $gift_image . + $linkRenderer->makeLink( + $view_system_gift_link->getFullURL( 'gift_id=' . $gift['id'] ), + $gift['gift_name'] + ); if ( $gift['status'] == 1 ) { if ( $user_name == $user->getName() ) { diff --git a/SystemGifts/TopAwards.php b/SystemGifts/TopAwards.php index e733b4e..cc5903c 100644 --- a/SystemGifts/TopAwards.php +++ b/SystemGifts/TopAwards.php @@ -25,6 +25,7 @@ global $wgUserStatsPointValues; $out = $this->getOutput(); + $linkRenderer = $this->getLinkRenderer(); // Variables $gift_name_check = ''; @@ -146,8 +147,12 @@ if ( $nav_x == $category_number ) { $output .= "<p><b>{$msg}</b></p>"; } else { - $output .= '<p><a href="' . htmlspecialchars( $this->getPageTitle()->getFullURL( - "category={$nav_x}" ) ) . "\">{$msg}</a></p>"; + $output .= '<p>' . + $linkRenderer->makeLink( + $this->getPageTitle()->getFullURL( "category={$nav_x}" ), + $msg + ) . + '</p>'; } $nav_x++; } diff --git a/UserActivity/UserActivity.body.php b/UserActivity/UserActivity.body.php index 72c56f2..803bf7c 100644 --- a/UserActivity/UserActivity.body.php +++ b/UserActivity/UserActivity.body.php @@ -36,6 +36,7 @@ $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // Add CSS $out->addModuleStyles( 'ext.socialprofile.useractivity.css' ); @@ -125,9 +126,12 @@ } $link_image = $line[2]; - $output .= '<a href="' . htmlspecialchars( $pageTitle->getFullURL( "item_type={$filter}" ) ) . - "\"><img src=\"{$wgExtensionAssetsPath}/SocialProfile/images/" . - UserActivity::getTypeIcon( $link_image ) . "\"/>{$link_text}</a>"; + $output .= $linkRenderer->makeLink( + $pageTitle->getFullURL( "item_type={$filter}" ), + "<img src=\"{$wgExtensionAssetsPath}/SocialProfile/images/" . + UserActivity::getTypeIcon( $link_image ) . "\"/>" + . $link_text + ); } } diff --git a/UserActivity/UserActivityClass.php b/UserActivity/UserActivityClass.php index 06f7c86..12f4f20 100644 --- a/UserActivity/UserActivityClass.php +++ b/UserActivity/UserActivityClass.php @@ -1,4 +1,7 @@ <?php + +use MediaWiki\MediaWikiServices; + /** * UserActivity class */ @@ -405,6 +408,7 @@ */ private function setGiftsRec() { $dbr = wfGetDB( DB_REPLICA ); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $where = array(); @@ -460,15 +464,26 @@ $view_gift_link = SpecialPage::getTitleFor( 'ViewGift' ); $html = wfMessage( 'useractivity-gift', - '<b><a href="' . htmlspecialchars( $user_title->getFullURL() ) . "\">{$row->ug_user_name_to}</a></b>", - '<a href="' . htmlspecialchars( $user_title_from->getFullURL() ) . "\">{$user_title_from->getText()}</a>" + '<b>' . + $linkRenderer->makeLink( + $user_title->getFullURL(), + $row->ug_user_name_to + ) . + '</b>', + $linkRenderer->makeLink( + $user_title_from->getFullURL(), + $user_title_from->getText() + ) )->text() . - "<div class=\"item\"> - <a href=\"" . htmlspecialchars( $view_gift_link->getFullURL( 'gift_id=' . $row->ug_id ) ) . "\" rel=\"nofollow\"> - {$gift_image} - {$row->gift_name} - </a> - </div>"; + "<div class=\"item\">" . + $linkRenderer->makeLink( + $view_gift_link->getFullURL( 'gift_id=' . $row->ug_id ), + $gift_image . $row->gift_name, + [ + 'rel' => 'nofollow' + ] + ) . + "</div>"; $unixTS = wfTimestamp( TS_UNIX, $row->ug_date ); @@ -502,6 +517,7 @@ global $wgUploadPath; $dbr = wfGetDB( DB_REPLICA ); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $where = array(); @@ -554,15 +570,23 @@ $html = wfMessage( 'useractivity-award', - '<b><a href="' . htmlspecialchars( $user_title->getFullURL() ) . "\">{$row->sg_user_name}</a></b>", + '<b>' . + $linkRenderer->makeLink( + $user_title->getFullURL(), + $row->sg_user_name + ) . + '</b>', $row->sg_user_name )->text() . - '<div class="item"> - <a href="' . htmlspecialchars( $system_gift_link->getFullURL( 'gift_id=' . $row->sg_id ) ) . "\" rel=\"nofollow\"> - {$system_gift_image} - {$row->gift_name} - </a> - </div>"; + '<div class="item">' . + $linkRenderer->makeLink( + $system_gift_link->getFullURL( 'gift_id=' . $row->sg_id ), + $system_gift_image . $row->gift_name, + [ + 'rel' => 'nofollow' + ] + ) . + '</div>'; $unixTS = wfTimestamp( TS_UNIX, $row->sg_date ); @@ -779,6 +803,7 @@ global $wgLang; $dbr = wfGetDB( DB_REPLICA ); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $where = array(); @@ -829,7 +854,12 @@ $this->activityLines[] = array( 'type' => 'system_message', 'timestamp' => $unixTS, - 'data' => ' ' . '<b><a href="' . htmlspecialchars( $user_title->getFullURL() ) . "\">{$user_name_short}</a></b> {$row->um_message}" + 'data' => ' ' . '<b>' . + $linkRenderer->makeLink( + $user_title->getFullURL(), + $user_name_short + ) . + "</b> {$row->um_message}" ); $this->items[] = array( @@ -859,6 +889,7 @@ } $dbr = wfGetDB( DB_REPLICA ); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $where = array(); @@ -927,8 +958,13 @@ $user_title = Title::makeTitle( NS_USER, $row->us_user_name ); $user_name_short = $wgLang->truncate( $row->us_user_name, 15 ); - $page_link = '<a href="' . SportsTeams::getNetworkURL( $row->us_sport_id, $row->us_team_id ) . - "\" rel=\"nofollow\">{$network_name}</a>"; + $page_link = $linkRenderer->makeLink( + SportsTeams::getNetworkURL( $row->us_sport_id, $row->us_team_id ), + $network_name, + [ + 'rel' => 'nofollow' + ] + ); $network_image = SportsTeams::getLogo( $row->us_sport_id, $row->us_team_id, 's' ); $html = wfMessage( @@ -938,12 +974,15 @@ $page_link, htmlspecialchars( $user_title->getFullURL() ) )->text() . - '<div class="item"> - <a href="' . SportsTeams::getNetworkURL( $row->us_sport_id, $row->us_team_id ) . "\" rel=\"nofollow\"> - {$network_image} - \"{$row->us_text}\" - </a> - </div>"; + '<div class="item">' . + $linkRenderer->makeLink( + SportsTeams::getNetworkURL( $row->us_sport_id, $row->us_team_id ), + $network_image . $row->us_text, + [ + 'rel' => 'nofollow' + ] + ) . + '</div>'; $this->activityLines[] = array( 'type' => 'network_update', @@ -1078,6 +1117,8 @@ function simplifyPageActivity( $type, $has_page = true ) { global $wgLang; + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + if ( !isset( $this->items_grouped[$type] ) || !is_array( $this->items_grouped[$type] ) ) { return ''; } @@ -1110,7 +1151,10 @@ if ( $has_page && !isset( $this->displayed[$type][$page_name] ) ) { $this->displayed[$type][$page_name] = 1; - $pages .= ' <a href="' . htmlspecialchars( $page_title->getFullURL() ) . "\">{$page_name}</a>"; + $pages .= $linkRenderer->makeLink( + $page_title->getFullURL(), + $page_name + ); if ( $count_users == 1 && $count_actions > 1 ) { $pages .= wfMessage( 'word-separator' )->text(); $pages .= wfMessage( 'parentheses', wfMessage( @@ -1148,7 +1192,10 @@ $pages .= ', '; } if ( $page_title2 instanceof Title ) { - $pages .= ' <a href="' . htmlspecialchars( $page_title2->getFullURL() ) . "\">{$page_name2}</a>"; + $pages .= $linkRenderer->makeLink( + $page_title2->getFullURL(), + $page_name2 + ); } if ( $count_actions2 > 1 ) { $pages .= ' (' . wfMessage( @@ -1177,7 +1224,15 @@ $user_name_short = $wgLang->truncate( $user_name, 15 ); $safeTitle = htmlspecialchars( $user_title->getText() ); - $users .= ' <b><a href="' . htmlspecialchars( $user_title->getFullURL() ) . "\" title=\"{$safeTitle}\">{$user_name_short}</a></b>"; + $users .= '<b>'; + $users .= $linkRenderer->makeLink( + $user_title->getFullURL(), + $user_name_short, + [ + 'title' => $safeTitle + ] + ); + $users .= '</b>'; } if ( $pages || $has_page == false ) { $this->activityLines[] = array( diff --git a/UserBoard/SpecialUserBoard.php b/UserBoard/SpecialUserBoard.php index 98b7125..cbe152e 100644 --- a/UserBoard/SpecialUserBoard.php +++ b/UserBoard/SpecialUserBoard.php @@ -45,7 +45,6 @@ $out = $this->getOutput(); $request = $this->getRequest(); $currentUser = $this->getUser(); - $linkRenderer = $this->getLinkRenderer(); // Set the page title, robot policies, etc. @@ -142,8 +141,10 @@ } $output = '<div class="user-board-top-links">'; - $output .= '<a href="' . htmlspecialchars( $user->getFullURL() ) . '">< ' . - $this->msg( 'userboard_backprofile', $user_name )->parse() . '</a>'; + $output .= $linkRenderer->makeLink( + $user->getFullURL(), + '< ' . $this->msg( 'userboard_backprofile', $user_name )->parse() + ); $output .= '</div>'; $board_to_board = ''; // Prevent E_NOTICE @@ -156,8 +157,10 @@ $end = $start + ( count( $ub_messages ) ) - 1; if ( $currentUser->getName() != $user_name ) { - $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL( $currentUser->getName(), $user_name ) . '">' . - $this->msg( 'userboard_boardtoboard' )->plain() . '</a>'; + $board_to_board = $linkRenderer->makeLink( + UserBoard::getUserBoardToBoardURL( $currentUser->getName(), $user_name ), + $this->msg( 'userboard_boardtoboard' )->plain() + ); } if ( $total ) { @@ -296,13 +299,20 @@ $delete_link = ''; if ( $currentUser->getName() != $ub_message['user_name_from'] ) { - $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL( $user_name, $ub_message['user_name_from'] ) . '">' . - $this->msg( 'userboard_boardtoboard' )->plain() . '</a>'; - $board_link = '<a href="' . UserBoard::getUserBoardURL( $ub_message['user_name_from'] ) . '">' . - $this->msg( 'userboard_sendmessage', $ub_message['user_name_from'] )->parse() . '</a>'; + $board_to_board = $linkRenderer->makeLink( + UserBoard::getUserBoardToBoardURL( $user_name, $ub_message['user_name_from'] ), + $this->msg( 'userboard_boardtoboard' )->plain() + ); + $board_link = $linkRenderer->makeLink( + UserBoard::getUserBoardURL( $ub_message['user_name_from'] ), + $this->msg( 'userboard_sendmessage', $ub_message['user_name_from'] )->parse() + ); + } else { - $board_link = '<a href="' . UserBoard::getUserBoardURL( $ub_message['user_name_from'] ) . '">' . - $this->msg( 'userboard_myboard' )->plain() . '</a>'; + $board_link = $linkRenderer->makeLink( + UserBoard::getUserBoardURL( $ub_message['user_name_from'] ), + $this->msg( 'userboard_myboard' )->plain() + ); } // If the user owns this private message or they are allowed to @@ -330,16 +340,29 @@ $userPageURL = htmlspecialchars( $user->getFullURL() ); $senderTitle = htmlspecialchars( $ub_message['user_name_from'] ); $output .= "<div class=\"user-board-message\"> - <div class=\"user-board-message-from\"> - <a href=\"{$userPageURL}\" title=\"{$senderTitle}\">{$ub_message['user_name_from']} </a> {$ub_message_type_label} - </div> + <div class=\"user-board-message-from\">" . + $linkRenderer->makeLink( + $userPageURL, + $ub_message['user_name_from'], + [ + 'title' => $senderTitle + ] + ) . + $ub_message_type_label . + "</div> <div class=\"user-board-message-time\">" . $this->msg( 'userboard_posted_ago', $b->getTimeAgo( $ub_message['timestamp'] ) )->parse() . "</div> <div class=\"user-board-message-content\"> - <div class=\"user-board-message-image\"> - <a href=\"{$userPageURL}\" title=\"{$senderTitle}\">{$avatar->getAvatarURL()}</a> - </div> + <div class=\"user-board-message-image\">" . + $linkRenderer->makeLink( + $userPageURL, + $avatar->getAvatarURL(), + [ + 'title' => $senderTitle + ] + ) . + "</div> <div class=\"user-board-message-body\"> {$ub_message_text} </div> diff --git a/UserBoard/UserBoardClass.php b/UserBoard/UserBoardClass.php index 8c0044c..d7d2b9d 100644 --- a/UserBoard/UserBoardClass.php +++ b/UserBoard/UserBoardClass.php @@ -1,6 +1,7 @@ <?php use MediaWiki\Logger\LoggerFactory; +use MediaWiki\MediaWikiServices; /** * Functions for managing user board data @@ -386,6 +387,7 @@ public function displayMessages( $user_id, $user_id_2 = 0, $count = 10, $page = 0 ) { global $wgUser, $wgTitle; + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $output = ''; // Prevent E_NOTICE $messages = $this->getUserBoardMessages( $user_id, $user_id_2, $count, $page ); @@ -400,10 +402,14 @@ $delete_link = ''; if ( $wgUser->getName() != $message['user_name_from'] ) { - $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL( $message['user_name'], $message['user_name_from'] ) . '">' . - wfMessage( 'userboard_board-to-board' )->plain() . '</a>'; - $board_link = '<a href="' . UserBoard::getUserBoardURL( $message['user_name_from'] ) . '">' . - wfMessage( 'userboard_sendmessage', $message['user_name_from'] )->parse() . '</a>'; + $board_to_board = $linkRenderer->makeLink( + UserBoard::getUserBoardToBoardURL( $message['user_name'], $message['user_name_from'] ), + wfMessage( 'userboard_board-to-board' )->plain() + ); + $board_link = $linkRenderer->makeLink( + UserBoard::getUserBoardURL( $message['user_name_from'] ), + wfMessage( 'userboard_sendmessage', $message['user_name_from'] )->parse() + ); } if ( $wgUser->getName() == $message['user_name'] || $wgUser->isAllowed( 'userboard-delete' ) ) { $delete_link = "<span class=\"user-board-red\"> @@ -421,16 +427,29 @@ $sender = htmlspecialchars( $user->getFullURL() ); $senderTitle = htmlspecialchars( $message['user_name_from'] ); $output .= "<div class=\"user-board-message\"> - <div class=\"user-board-message-from\"> - <a href=\"{$sender}\" title=\"{$senderTitle}\">{$message['user_name_from']}</a> {$message_type_label} - </div> + <div class=\"user-board-message-from\">" . + $linkRenderer->makeLink( + $sender, + $message['user_name_from'], + [ + 'title' => $senderTitle + ] + ) . + $message_type_label . + "</div> <div class=\"user-board-message-time\">" . wfMessage( 'userboard_posted_ago', $this->getTimeAgo( $message['timestamp'] ) )->parse() . "</div> <div class=\"user-board-message-content\"> - <div class=\"user-board-message-image\"> - <a href=\"{$sender}\" title=\"{$senderTitle}\">{$avatar->getAvatarURL()}</a> - </div> + <div class=\"user-board-message-image\">" . + $linkRenderer->makeLink( + $sender, + $avatar->getAvatarURL(), + [ + 'title' => $senderTitle + ] + ) . + "</div> <div class=\"user-board-message-body\"> {$message_text} </div> diff --git a/UserGifts/SpecialGiftManager.php b/UserGifts/SpecialGiftManager.php index 5cfec7f..8217097 100644 --- a/UserGifts/SpecialGiftManager.php +++ b/UserGifts/SpecialGiftManager.php @@ -35,6 +35,7 @@ $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // Make sure that the user is logged in and that they can use this // special page @@ -98,10 +99,12 @@ // "add a gift" link to them if ( $this->canUserCreateGift() ) { $out->addHTML( - '<div><b><a href="' . - htmlspecialchars( $this->getPageTitle()->getFullURL( 'method=edit' ) ) . - '">' . $this->msg( 'giftmanager-addgift' )->plain() . - '</a></b></div>' + '<div><b>' . + $linkRenderer->makeLink( + $this->getPageTitle()->getFullURL( 'method=edit' ), + $this->msg( 'giftmanager-addgift' )->plain() + ) . + '</b></div>' ); } $out->addHTML( $this->displayGiftList() ); @@ -192,6 +195,8 @@ * @return string HTML */ function displayGiftList() { + $linkRenderer = $this->getLinkRenderer(); + $output = ''; // Prevent E_NOTICE $page = 0; /** @@ -202,20 +207,27 @@ */ $per_page = 1000; $gifts = Gifts::getManagedGiftList( $per_page, $page ); + if ( $gifts ) { foreach ( $gifts as $gift ) { $deleteLink = ''; if ( $this->canUserDelete() ) { - $deleteLink = '<a href="' . - htmlspecialchars( SpecialPage::getTitleFor( 'RemoveMasterGift' )->getFullURL( "gift_id={$gift['id']}" ) ) . - '" style="font-size:10px; color:red;">' . - $this->msg( 'delete' )->plain() . '</a>'; + $deleteLink = $linkRenderer->makeLink( + SpecialPage::getTitleFor( 'RemoveMasterGift' )->getFullURL( "gift_id={$gift['id']}" ), + $this->msg( 'delete' )->plain(), + [ + 'style' => 'font-size: 10px; color: red;' + ] + ); } - $output .= '<div class="Item"> - <a href="' . htmlspecialchars( $this->getPageTitle()->getFullURL( "id={$gift['id']}" ) ) . '">' . - $gift['gift_name'] . '</a> ' . - $deleteLink . "</div>\n"; + $output .= '<div class="Item">' . + $linkRenderer->makeLink( + $this->getPageTitle()->getFullURL( "id={$gift['id']}" ), + $gift['gift_name'] + ) . + $deleteLink . + "</div>\n"; } } return '<div id="views">' . $output . '</div>'; @@ -223,13 +235,18 @@ function displayForm( $gift_id ) { $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); if ( !$gift_id && !$this->canUserCreateGift() ) { return $this->displayGiftList(); } - $form = '<div><b><a href="' . htmlspecialchars( $this->getPageTitle()->getFullURL() ) . - '">' . $this->msg( 'giftmanager-view' )->plain() . '</a></b></div>'; + $form = '<div><b>' . + $linkRenderer->makeLink( + $this->getPageTitle()->getFullURL(), + $this->msg( 'giftmanager-view' )->plain() + ) . + '</b></div>'; if ( $gift_id ) { $gift = Gifts::getGift( $gift_id ); @@ -263,9 +280,13 @@ <td class="view-form">' . $this->msg( 'g-created-by', $gift['creator_user_name'] )->parse() . '</td> - <td><a href="' . htmlspecialchars( $creator->getFullURL() ) . '">' . - $gift['creator_user_name'] . '</a></td> - </tr>'; + <td>' . + $linkRenderer->makeLink( + $creator->getFullURL(), + $gift['creator_user_name'] + ) . + '</td>' . + '</tr>'; } // If the user isn't in the gift admin group, they can only create @@ -304,10 +325,12 @@ $form .= '<tr> <td width="200" class="view-form" valign="top">' . $this->msg( 'giftmanager-giftimage' )->plain() . '</td> <td width="695">' . $gift_image . - '<p> - <a href="' . htmlspecialchars( $gml->getFullURL( 'gift_id=' . $gift_id ) ) . '">' . - $this->msg( 'giftmanager-image' )->plain() . '</a> - </td> + '<p>' . + $linkRenderer->makeLink( + $gml->getFullURL( 'gift_id=' . $gift_id ), + $this->msg( 'giftmanager-image' )->plain() + ) . + '</td> </tr>'; } diff --git a/UserGifts/SpecialGiftManagerLogo.php b/UserGifts/SpecialGiftManagerLogo.php index 6b23ac9..75332a0 100644 --- a/UserGifts/SpecialGiftManagerLogo.php +++ b/UserGifts/SpecialGiftManagerLogo.php @@ -516,6 +516,8 @@ */ function showSuccess( $status ) { global $wgUploadPath; + + $linkRenderer = $this->getLinkRenderer(); $ext = 'jpg'; @@ -543,13 +545,21 @@ $output .= '<tr><td><input type="button" onclick="javascript:history.go(-1)" value="' . $this->msg( 'g-go-back' )->plain() . '"></td></tr>'; $giftManager = SpecialPage::getTitleFor( 'GiftManager' ); - $output .= $this->getLanguage()->pipeList( array( - '<tr><td><a href="' . htmlspecialchars( $giftManager->getFullURL() ) . '">' . - $this->msg( 'g-back-gift-list' )->plain() . '</a> ', - ' <a href="' . htmlspecialchars( $giftManager->getFullURL( 'id=' . $this->gift_id ) ) . - '">' . $this->msg( 'g-back-edit-gift' )->plain() . '</a></td></tr>' - ) ); + + $output .= '<tr><td>'; + $output .= $this->getLanguage()->pipeList( [ + $linkRenderer->makeLink( + $giftManager->getFullURL(), + $this->msg( 'g-back-gift-list' )->plain() . ' ' + ), + ' ' . $linkRenderer->makeLink( + $giftManager->getFullURL( 'id=' . $this->gift_id ), + $this->msg( 'g-back-edit-gift' )->plain() + ) + ] ); + $output .= '</td></tr>'; $output .= '</table>'; + $this->getOutput()->addHTML( $output ); } diff --git a/UserGifts/SpecialGiveGift.php b/UserGifts/SpecialGiveGift.php index 9eaee05..aa0a7a2 100644 --- a/UserGifts/SpecialGiveGift.php +++ b/UserGifts/SpecialGiveGift.php @@ -48,6 +48,7 @@ $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); $output = ''; // Prevent E_NOTICE @@ -137,17 +138,20 @@ $out->setPageTitle( $this->msg( 'g-sent-title', $this->user_name_to )->parse() ); - $output .= '<div class="back-links"> - <a href="' . htmlspecialchars( $userTitle->getFullURL() ) . '">' . - $this->msg( 'g-back-link', $this->user_name_to )->parse() . - '</a> - </div> - <div class="g-message">' . + $output .= '<div class="back-links">' . + $output .= $linkRenderer->makeLink( + $userTitle->getFullURL(), + $this->msg( 'g-back-link', $this->user_name_to )->parse() + ); + $output .= '</div>'; + + $output .= '<div class="g-message">' . $this->msg( 'g-sent-message', $this->user_name_to )->parse() . '</div> <div class="g-container">' . $gift_image . '<div class="g-title">' . $sent_gift['name'] . '</div>'; + if ( $sent_gift['message'] ) { $output .= '<div class="g-user-message">' . $sent_gift['message'] . @@ -323,9 +327,8 @@ function displayFormAll() { global $wgGiveGiftPerRow, $wgUploadPath; - $linkRenderer = $this->getLinkRenderer(); - $out = $this->getOutput(); + $linkRenderer = $this->getLinkRenderer(); $user = Title::makeTitle( NS_USER, $this->user_name_to ); @@ -347,12 +350,14 @@ if ( $gifts ) { $out->setPageTitle( $this->msg( 'g-give-all-title', $this->user_name_to )->parse() ); - $output .= '<div class="back-links"> - <a href="' . htmlspecialchars( $user->getFullURL() ) . '">' . - $this->msg( 'g-back-link', $this->user_name_to )->parse() . - '</a> - </div> - <div class="g-message">' . + $output .= '<div class="back-links">'; + $output .= $linkRenderer->makeLink( + $user->getFullURL(), + $this->msg( 'g-back-link', $this->user_name_to )->parse() + ); + $output .= '</div>'; + + $output .= '<div class="g-message">' . $this->msg( 'g-give-all', $this->user_name_to )->parse() . '</div> <form action="" method="post" enctype="multipart/form-data" name="gift">'; diff --git a/UserGifts/SpecialRemoveGift.php b/UserGifts/SpecialRemoveGift.php index 60f3705..23a1814 100644 --- a/UserGifts/SpecialRemoveGift.php +++ b/UserGifts/SpecialRemoveGift.php @@ -29,6 +29,7 @@ $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // Set the page title, robot policies, etc. $this->setHeaders(); @@ -70,10 +71,12 @@ $out->setPageTitle( $this->msg( 'g-remove-success-title', $gift['name'] )->parse() ); - $out = '<div class="back-links"> - <a href="' . htmlspecialchars( $user->getUserPage()->getFullURL() ) . '">' . - $this->msg( 'g-back-link', $gift['user_name_to'] )->parse() . '</a> - </div> + $out = '<div class="back-links">' . + $linkRenderer->makeLink( + $user->getUserPage()->getFullURL(), + $this->msg( 'g-back-link', $gift['user_name_to'] )->parse() + ) . + '</div> <div class="g-container">' . $gift_image . $this->msg( 'g-remove-success-message', $gift['name'] )->parse() . '<div class="visualClear"></div> @@ -99,6 +102,8 @@ global $wgUploadPath; $currentUser = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); + $rel = new UserGifts( $currentUser->getName() ); $gift = $rel->getUserGift( $this->gift_id ); $user = Title::makeTitle( NS_USER, $gift['user_name_from'] ); @@ -108,11 +113,14 @@ $this->getOutput()->setPageTitle( $this->msg( 'g-remove-title', $gift['name'] )->parse() ); - $output = '<div class="back-links"> - <a href="' . htmlspecialchars( $currentUser->getUserPage()->getFullURL() ) . '">' . - $this->msg( 'g-back-link', $gift['user_name_to'] )->parse() . '</a> - </div> - <form action="" method="post" enctype="multipart/form-data" name="form1"> + $output .= '<div class="back-links">'; + $output .= $linkRenderer->makeLink( + $currentUser->getUserPage()->getFullURL(), + $this->msg( 'g-back-link', $gift['user_name_to'] )->parse() + ); + $output .= '</div>'; + + $output .= '<form action="" method="post" enctype="multipart/form-data" name="form1"> <div class="g-remove-message">' . $this->msg( 'g-remove-message', $gift['name'] )->parse() . '</div> diff --git a/UserGifts/SpecialRemoveMasterGift.php b/UserGifts/SpecialRemoveMasterGift.php index d0cda78..0518dfa 100644 --- a/UserGifts/SpecialRemoveMasterGift.php +++ b/UserGifts/SpecialRemoveMasterGift.php @@ -65,6 +65,7 @@ public function execute( $par ) { $out = $this->getOutput(); $request = $this->getRequest(); + $linkRenderer = $this->getLinkRenderer(); // user needs to be logged in to access $this->requireLogin(); @@ -117,11 +118,14 @@ $out->setPageTitle( $this->msg( 'g-remove-success-title', $gift['gift_name'] )->parse() ); - $output = '<div class="back-links"> - <a href="' . htmlspecialchars( SpecialPage::getTitleFor( 'GiftManager' )->getFullURL() ) . '">' . - $this->msg( 'g-viewgiftlist' )->plain() . '</a> - </div> - <div class="g-container">' . + $output = '<div class="back-links">'; + $output .= $linkRenderer->makeLink( + SpecialPage::getTitleFor( 'GiftManager' )->getFullURL(), + $this->msg( 'g-viewgiftlist' )->plain() + ); + $output .= '</div>'; + + $output .= '<div class="g-container">' . $this->msg( 'g-remove-success-message', $gift['gift_name'] )->parse() . '<div class="visualClear"></div> </div>'; @@ -141,6 +145,8 @@ function displayForm() { global $wgUploadPath; + $linkRenderer = $this->getLinkRenderer(); + $gift = Gifts::getGift( $this->gift_id ); $gift_image = '<img src="' . $wgUploadPath . '/awards/' . @@ -149,11 +155,14 @@ $this->getOutput()->setPageTitle( $this->msg( 'g-remove-title', $gift['gift_name'] )->parse() ); - $output = '<div class="back-links"> - <a href="' . htmlspecialchars( SpecialPage::getTitleFor( 'GiftManager' )->getFullURL() ) . '">' . - $this->msg( 'g-viewgiftlist' )->plain() . '</a> - </div> - <form action="" method="post" enctype="multipart/form-data" name="form1"> + $output .= '<div class="back-links">'; + $output .= $linkRenderer->makeLink( + SpecialPage::getTitleFor( 'GiftManager' )->getFullURL(), + $this->msg( 'g-viewgiftlist' )->plain() + ); + $output .= '</div>'; + + $output .= '<form action="" method="post" enctype="multipart/form-data" name="form1"> <div class="g-remove-message">' . $this->msg( 'g-delete-message', $gift['gift_name'] )->parse() . '</div> diff --git a/UserGifts/SpecialViewGift.php b/UserGifts/SpecialViewGift.php index ee1663f..7c44d9f 100644 --- a/UserGifts/SpecialViewGift.php +++ b/UserGifts/SpecialViewGift.php @@ -28,6 +28,7 @@ $out = $this->getOutput(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // Set the page title, robot policies, etc. $this->setHeaders(); @@ -79,10 +80,12 @@ $gift['name'] )->parse() ); - $output = '<div class="back-links"> - <a href="' . htmlspecialchars( Title::makeTitle( NS_USER, $gift['user_name_to'] )->getFullURL() ) . '">' - . $this->msg( 'g-back-link', $gift['user_name_to'] )->parse() . '</a> - </div>'; + $output = '<div class="back-links">'; + $output .= $linkRenderer->makeLink( + Title::makeTitle( NS_USER, $gift['user_name_to'] )->getFullURL(), + $this->msg( 'g-back-link', $gift['user_name_to'] )->parse() + ); + $output .= '</div>'; $sender = Title::makeTitle( NS_USER, $gift['user_name_from'] ); $removeGiftLink = SpecialPage::getTitleFor( 'RemoveGift' ); @@ -109,13 +112,18 @@ } $output .= '<div class="visualClear"></div> <div class="g-describe">' . $gift['description'] . '</div> - <div class="g-actions"> - <a href="' . htmlspecialchars( $giveGiftLink->getFullURL( 'gift_id=' . $gift['gift_id'] ) ) . '">' . - $this->msg( 'g-to-another' )->plain() . '</a>'; + <div class="g-actions">' . + $linkRenderer->makeLink( + $giveGiftLink->getFullURL( 'gift_id=' . $gift['gift_id'] ), + $this->msg( 'g-to-another' )->plain() + ); + if ( $gift['user_name_to'] == $user->getName() ) { $output .= $this->msg( 'pipe-separator' )->escaped(); - $output .= '<a href="' . htmlspecialchars( $removeGiftLink->getFullURL( 'gift_id=' . $gift['id'] ) ) . '">' . - $this->msg( 'g-remove-gift' )->plain() . '</a>'; + $output .= $linkRenderer->makeLink( + $removeGiftLink->getFullURL( 'gift_id=' . $gift['id'] ), + $this->msg( 'g-remove-gift' )->plain() + ); } $output .= '</div> </div>'; @@ -133,9 +141,10 @@ $avatar = new wAvatar( $userToId, 'ml' ); $userNameLink = Title::makeTitle( NS_USER, $row->ug_user_name_to ); - $output .= '<a href="' . htmlspecialchars( $userNameLink->getFullURL() ) . "\"> - {$avatar->getAvatarURL()} - </a>"; + $output .= $linkRenderer->makeLink( + $userNameLink->getFullURL(), + $avatar->getAvatarURL() + ); } $output .= '<div class="visualClear"></div> diff --git a/UserGifts/SpecialViewGifts.php b/UserGifts/SpecialViewGifts.php index e82651c..35858d4 100644 --- a/UserGifts/SpecialViewGifts.php +++ b/UserGifts/SpecialViewGifts.php @@ -42,11 +42,10 @@ public function execute( $par ) { global $wgUploadPath; - $linkRenderer = $this->getLinkRenderer(); - $out = $this->getOutput(); $request = $this->getRequest(); $currentUser = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // Set the page title, robot policies, etc. $this->setHeaders(); @@ -107,12 +106,14 @@ */ $out->setPageTitle( $this->msg( 'g-list-title', $rel->user_name )->parse() ); - $output = '<div class="back-links"> - <a href="' . $user->getFullURL() . '">' . - $this->msg( 'g-back-link', $rel->user_name )->parse() . - '</a> - </div> - <div class="g-count">' . + $output = '<div class="back-links">'; + $output .= $linkRenderer->makeLink( + $user->getFullURL(), + $this->msg( 'g-back-link', $rel->user_name )->parse() + ); + $output .= '</div>'; + + $output .= '<div class="g-count">' . $this->msg( 'g-count', $rel->user_name, $total )->parse() . '</div>'; @@ -140,14 +141,17 @@ Gifts::getGiftImage( $gift['gift_id'], 'l' ) . '" border="0" alt="" />'; - $output .= '<div class="g-item"> - <a href="' . htmlspecialchars( $viewGiftLink->getFullURL( 'gift_id=' . $gift['id'] ) ) . '">' . - $gift_image . - '</a> - <div class="g-title"> - <a href="' . htmlspecialchars( $viewGiftLink->getFullURL( 'gift_id=' . $gift['id'] ) ) . '">' . - $gift_name_display . - '</a>'; + $output .= '<div class="g-item">' . + $linkRenderer->makeLink( + $viewGiftLink->getFullURL( 'gift_id=' . $gift['id'] ), + $gift_image + ) . + '<div class="g-title">' . + $linkRenderer->makeLink( + $viewGiftLink->getFullURL( 'gift_id=' . $gift['id'] ), + $gift_name_display + ); + if ( $gift['status'] == 1 ) { if ( $user_name == $currentUser->getName() ) { $rel->clearUserGiftStatus( $gift['id'] ); @@ -162,16 +166,20 @@ $output .= '<div class="g-from">' . $this->msg( 'g-from', htmlspecialchars( $user_from->getFullURL() ), $gift['user_name_from'] )->text() . '</div> - <div class="g-actions"> - <a href="' . htmlspecialchars( $giveGiftLink->getFullURL( 'gift_id=' . $gift['gift_id'] ) ) . '">' . - $this->msg( 'g-to-another' )->plain() . - '</a>'; + <div class="g-actions">' . + $linkRenderer->makeLink( + $giveGiftLink->getFullURL( 'gift_id=' . $gift['gift_id'] ), + $this->msg( 'g-to-another' )->plain() + ); + if ( $rel->user_name == $currentUser->getName() ) { $output .= ' '; $output .= $this->msg( 'pipe-separator' )->escaped(); $output .= ' '; - $output .= '<a href="' . htmlspecialchars( $removeGiftLink->getFullURL( 'gift_id=' . $gift['id'] ) ) . '">' . - $this->msg( 'g-remove-gift' )->plain() . '</a>'; + $output .= $linkRenderer->makeLink( + $removeGiftLink->getFullURL( 'gift_id=' . $gift['id'] ), + $this->msg( 'g-remove-gift' )->plain() + ); } $output .= '</div> <div class="visualClear"></div>'; diff --git a/UserProfile/SpecialEditProfile.php b/UserProfile/SpecialEditProfile.php index a10e7bc..a9f2ec1 100644 --- a/UserProfile/SpecialEditProfile.php +++ b/UserProfile/SpecialEditProfile.php @@ -158,6 +158,8 @@ } function displayBasicForm( $tar ) { + $linkRenderer = $this->getLinkRenderer(); + $dbr = wfGetDB( DB_REPLICA ); $s = $dbr->selectRow( 'user_profile', @@ -223,9 +225,10 @@ <p class="profile-update-unit"><input type="text" size="25" name="email" id="email" value="' . $email . '"/>'; if ( !$tar->mEmailAuthenticated ) { $confirm = SpecialPage::getTitleFor( 'Confirmemail' ); - $form .= " <a href=\"{$confirm->getFullURL()}\">" . - $this->msg( 'confirmemail' )->plain() . - '</a>'; + $form .= $linkRenderer->makeLink( + $confirm->getFullURL(), + $this->msg( 'confirmemail' )->plain() + ); } $form .= '</p> <div class="visualClear"></div>'; diff --git a/UserProfile/SpecialRemoveAvatar.php b/UserProfile/SpecialRemoveAvatar.php index 5312cb7..9b93644 100644 --- a/UserProfile/SpecialRemoveAvatar.php +++ b/UserProfile/SpecialRemoveAvatar.php @@ -52,6 +52,7 @@ $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); $userIsPrivileged = $user->isAllowed( 'avatarremove' ); @@ -100,9 +101,12 @@ // No point in showing this message to mortals, they can't // remove others' avatars anyway $out->addHTML( - '<div><a href="' . htmlspecialchars( $this->getPageTitle()->getFullURL() ) . '">' . - $this->msg( 'avatarupload-removeanother' )->plain() . - '</a></div>' + '<div>' . + $linkRenderer->makeLink( + $this->getPageTitle()->getFullURL(), + $this->msg( 'avatarupload-removeanother' )->plain() + ) . + '</div>' ); } } else { diff --git a/UserProfile/SpecialUpdateProfile.php b/UserProfile/SpecialUpdateProfile.php index 57dad49..d27f8e1 100644 --- a/UserProfile/SpecialUpdateProfile.php +++ b/UserProfile/SpecialUpdateProfile.php @@ -455,6 +455,8 @@ * @param User $user */ function displayBasicForm( $user ) { + $linkRenderer = $this->getLinkRenderer(); + $dbr = wfGetDB( DB_REPLICA ); $s = $dbr->selectRow( 'user_profile', array( @@ -522,7 +524,10 @@ <p class="profile-update-unit"><input type="text" size="25" name="email" id="email" value="' . $email . '"/>'; if ( !$user->mEmailAuthenticated ) { $confirm = SpecialPage::getTitleFor( 'Confirmemail' ); - $form .= " <a href=\"{$confirm->getFullURL()}\">" . $this->msg( 'confirmemail' )->plain() . '</a>'; + $form .= $linkRenderer->makeLink( + $confirm->getFullURL(), + $this->msg( 'confirmemail' )->plain() + ); } $form .= '</p> <div class="visualClear">' . $this->renderEye( 'up_email' ) . '</div>'; diff --git a/UserProfile/UserProfilePage.php b/UserProfile/UserProfilePage.php index a0886b2..93db3cc 100644 --- a/UserProfile/UserProfilePage.php +++ b/UserProfile/UserProfilePage.php @@ -434,6 +434,8 @@ $output = ''; + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + // Safe titles $quiz_title = SpecialPage::getTitleFor( 'QuizGameHome' ); $pic_game_title = SpecialPage::getTitleFor( 'PictureGameHome' ); @@ -499,21 +501,26 @@ $ns = ( defined( 'NS_POLL' ) ? NS_POLL : 300 ); $poll_title = Title::makeTitle( $ns, $item['title'] ); $casual_game_title = wfMessage( 'casual-game-poll' )->escaped(); - $output .= '<a href="' . htmlspecialchars( $poll_title->getFullURL() ) . - "\" rel=\"nofollow\"> - {$poll_title->getText()} - </a> - <span class=\"item-small\">{$casual_game_title}</span>"; + $output .= $linkRenderer->makeLink( + $poll_title->getFullURL() . '\\', + $poll_title->getText(), + [ + 'rel' => 'nofollow' + ] + ); + $output .= "<span class=\"item-small\">{$casual_game_title}</span>"; } if ( $item['type'] == 'Quiz' ) { $casual_game_title = wfMessage( 'casual-game-quiz' )->escaped(); - $output .= '<a href="' . - htmlspecialchars( $quiz_title->getFullURL( 'questionGameAction=renderPermalink&permalinkID=' . $item['id'] ) ) . - "\" rel=\"nofollow\"> - {$item['text']} - </a> - <span class=\"item-small\">{$casual_game_title}</span>"; + $output .= $linkRenderer->makeLink( + $quiz_title->getFullURL( 'questionGameAction=renderPermalink&permalinkID=' . $item['id'] ) . '\\', + $item['text'], + [ + 'rel' => 'nofollow' + ] + ); + $output .="<span class=\"item-small\">{$casual_game_title}</span>"; } if ( $item['type'] == 'Picture Game' ) { @@ -532,15 +539,14 @@ } $casual_game_title = wfMessage( 'casual-game-picture-game' )->escaped(); - - $output .= '<a href="' . - htmlspecialchars( $pic_game_title->getFullURL( 'picGameAction=renderPermalink&id=' . $item['id'] ) ) . - "\" rel=\"nofollow\"> - {$image_1} - {$image_2} - {$item['title']} - </a> - <span class=\"item-small\">{$casual_game_title}</span>"; + $output .= $linkRenderer->makeLink( + $pic_game_title->getFullURL( 'picGameAction=renderPermalink&id=' . $item['id'] ), + $image_1 . $item['title'], + [ + 'rel' => 'nofollow' + ] + ); + $output .= "<span class=\"item-small\">{$casual_game_title}</span>"; } } @@ -592,6 +598,7 @@ $context = $this->getContext(); $user = $context->getUser(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); if ( $wgUserProfileDisplay['personal'] == false ) { return ''; @@ -735,8 +742,10 @@ <div class="user-section-actions"> <div class="action-right">'; if ( $user->getName() == $user_name ) { - $output .= '<a href="' . htmlspecialchars( $edit_info_link->getFullURL() ) . '">' . - wfMessage( 'user-edit-this' )->escaped() . '</a>'; + $output .= $linkRenderer->makeLink( + $edit_info_link->getFullURL(), + wfMessage( 'user-edit-this' )->escaped() + ); } $output .= '</div> <div class="visualClear"></div> @@ -752,11 +761,12 @@ wfMessage( 'user-personal-info-title' )->escaped() . '</div> <div class="user-section-actions"> - <div class="action-right"> - <a href="' . htmlspecialchars( $edit_info_link->getFullURL() ) . '">' . - wfMessage( 'user-edit-this' )->escaped() . - '</a> - </div> + <div class="action-right">' . + $linkRenderer->makeLink( + $edit_info_link->getFullURL(), + wfMessage( 'user-edit-this' )->escaped() + ) . + '</div> <div class="visualClear"></div> </div> </div> @@ -780,6 +790,7 @@ $context = $this->getContext(); $user = $context->getUser(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); if ( $wgUserProfileDisplay['custom'] == false ) { return ''; @@ -816,8 +827,10 @@ <div class="user-section-actions"> <div class="action-right">'; if ( $user->getName() == $user_name ) { - $output .= '<a href="' . htmlspecialchars( $edit_info_link->getFullURL() ) . '/custom">' . - wfMessage( 'user-edit-this' )->escaped() . '</a>'; + $output .= $linkRenderer->makeLink( + $edit_info_link->getFullURL() . '/custom', + wfMessage( 'user-edit-this' )->escaped() + ); } $output .= '</div> <div class="visualClear"></div> @@ -833,11 +846,12 @@ wfMessage( 'custom-info-title' )->escaped() . '</div> <div class="user-section-actions"> - <div class="action-right"> - <a href="' . htmlspecialchars( $edit_info_link->getFullURL() ) . '/custom">' . - wfMessage( 'user-edit-this' )->escaped() . - '</a> - </div> + <div class="action-right">' . + $linkRenderer->makeLink( + $edit_info_link->getFullURL() . '/custom', + wfMessage( 'user-edit-this' )->escaped() + ) . + '</div> <div class="visualClear"></div> </div> </div> @@ -862,6 +876,7 @@ $context = $this->getContext(); $user = $context->getUser(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); if ( $wgUserProfileDisplay['interests'] == false ) { return ''; @@ -912,8 +927,10 @@ <div class="user-section-actions"> <div class="action-right">'; if ( $user->getName() == $user_name ) { - $output .= '<a href="' . htmlspecialchars( $edit_info_link->getFullURL() ) . '/personal">' . - wfMessage( 'user-edit-this' )->escaped() . '</a>'; + $output .= $linkRenderer->makeLink( + $edit_info_link->getFullURL(), + wfMessage( 'user-edit-this' )->escaped() + ); } $output .= '</div> <div class="visualClear"></div> @@ -929,11 +946,13 @@ wfMessage( 'other-info-title' )->escaped() . '</div> <div class="user-section-actions"> - <div class="action-right"> - <a href="' . htmlspecialchars( $edit_info_link->getFullURL() ) . '/personal">' . - wfMessage( 'user-edit-this' )->escaped() . - '</a> - </div> + <div class="action-right">' . + $linkRenderer->makeLink( + $edit_info_link->getFullURL() . '/personal', + wfMessage( 'user-edit-this' )->escaped() + ) + . + '</div> <div class="visualClear"></div> </div> </div> @@ -959,6 +978,7 @@ $context = $this->getContext(); $userContext = $context->getUser(); $language = $context->getLanguage(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $stats = new UserStats( $user_id, $user_name ); $stats_data = $stats->getUserStats(); @@ -1015,10 +1035,15 @@ } else { $toggleMessage = wfMessage( 'user-type-toggle-new' )->escaped(); } - $output .= '<div id="profile-toggle-button"> - <a href="' . htmlspecialchars( $toggle_title->getFullURL() ) . '" rel="nofollow">' . - $toggleMessage . '</a> - </div>'; + $output .= '<div id="profile-toggle-button">'; + $output .= $linkRenderer->makeLink( + $toggle_title->getFullURL(), + $toggleMessage, + [ + 'rel' => 'nofollow' + ] + ); + $output .= '</div>'; } $output .= '<div id="profile-image">' . $avatar->getAvatarURL() . @@ -1033,17 +1058,25 @@ // Show the user's level and the amount of points they have if // UserLevels has been configured if ( $wgUserLevels ) { - $output .= '<div id="points-level"> - <a href="' . htmlspecialchars( $level_link->getFullURL() ) . '">' . - wfMessage( - 'user-profile-points', - $language->formatNum( $stats_data['points'] ) - )->escaped() . - '</a> - </div> - <div id="honorific-level"> - <a href="' . htmlspecialchars( $level_link->getFullURL() ) . '" rel="nofollow">(' . $user_level->getLevelName() . ')</a> - </div>'; + $output .= '<div id="points-level">'; + $output .= $linkRenderer->makeLink( + $level_link->getFullURL(), + wfMessage( + 'user-profile-points', + $language->formatNum( $stats_data['points'] ) + )->escaped() + ); + $output .= '</div>'; + + $output .= '<div id="honorific-level">'; + $output .= $linkRenderer->makeLink( + $level_link->getFullURL(), + $user_level->getLevelName(), + [ + 'rel' => 'nofollow' + ] + ); + $output .= '</div>'; } $output .= '<div class="visualClear"></div> </div> @@ -1051,43 +1084,75 @@ $profileLinks = []; if ( $this->isOwner() ) { - $profileLinks['user-edit-profile'] = - '<a href="' . htmlspecialchars( $update_profile->getFullURL() ) . '">' . wfMessage( 'user-edit-profile' )->escaped() . '</a>'; - $profileLinks['user-upload-avatar'] = - '<a href="' . htmlspecialchars( $upload_avatar->getFullURL() ) . '">' . wfMessage( 'user-upload-avatar' )->escaped() . '</a>'; - $profileLinks['user-watchlist'] = - '<a href="' . htmlspecialchars( $watchlist->getFullURL() ) . '">' . wfMessage( 'user-watchlist' )->escaped() . '</a>'; + $profileLinks['user-edit-profile'] = $linkRenderer->makeLink( + $update_profile->getFullURL(), + wfMessage( 'user-edit-profile' )->escaped() + ); + $profileLinks['user-upload-avatar'] = $linkRenderer->makeLink( + $upload_avatar->getFullURL(), + wfMessage( 'user-upload-avatar' )->escaped() + ); + $profileLinks['user-watchlist'] = $linkRenderer->makeLink( + $watchlist->getFullURL(), + wfMessage( 'user-watchlist' )->escaped() + ); } elseif ( $userContext->isLoggedIn() ) { if ( $relationship == false ) { - $profileLinks['user-add-friend'] = - '<a href="' . htmlspecialchars( $add_relationship->getFullURL( 'user=' . $user_safe . '&rel_type=1' ) ) . '" rel="nofollow">' . wfMessage( 'user-add-friend' )->escaped() . '</a>'; - - $profileLinks['user-add-foe'] = - '<a href="' . htmlspecialchars( $add_relationship->getFullURL( 'user=' . $user_safe . '&rel_type=2' ) ) . '" rel="nofollow">' . wfMessage( 'user-add-foe' )->escaped() . '</a>'; + $profileLinks['user-add-friend'] = $linkRenderer->makeLink( + $add_relationship->getFullURL( 'user=' . $user_safe . '&rel_type=1' ), + wfMessage( 'user-add-friend' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); + $profileLinks['user-add-foe'] = $linkRenderer->makeLink( + $add_relationship->getFullURL( 'user=' . $user_safe . '&rel_type=2' ), + wfMessage( 'user-add-foe' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); } else { if ( $relationship == 1 ) { - $profileLinks['user-remove-friend'] = - '<a href="' . htmlspecialchars( $remove_relationship->getFullURL( 'user=' . $user_safe ) ) . '">' . wfMessage( 'user-remove-friend' )->escaped() . '</a>'; + $profileLinks['user-remove-friend'] = $linkRenderer->makeLink( + $remove_relationship->getFullURL( 'user=' . $user_safe ), + wfMessage( 'user-remove-friend' )->escaped() + ); } if ( $relationship == 2 ) { - $profileLinks['user-remove-foe'] = - '<a href="' . htmlspecialchars( $remove_relationship->getFullURL( 'user=' . $user_safe ) ) . '">' . wfMessage( 'user-remove-foe' )->escaped() . '</a>'; + $profileLinks['user-remove-foe'] = $linkRenderer->makeLink( + $remove_relationship->getFullURL( 'user=' . $user_safe ), + wfMessage( 'user-remove-foe' )->escaped() + ); } } global $wgUserBoard; if ( $wgUserBoard ) { - $profileLinks['user-send-message'] = - '<a href="' . htmlspecialchars( $send_message->getFullURL( 'user=' . $userContext->getName() . '&conv=' . $user_safe ) ) . '" rel="nofollow">' . - wfMessage( 'user-send-message' )->escaped() . '</a>'; + $profileLinks['user-send-message'] = $linkRenderer->makeLink( + $send_message->getFullURL( 'user=' . $userContext->getName() . '&conv=' . $user_safe ), + wfMessage( 'user-send-message' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); } - $profileLinks['user-send-gift'] = - '<a href="' . htmlspecialchars( $give_gift->getFullURL( 'user=' . $user_safe ) ) . '" rel="nofollow">' . - wfMessage( 'user-send-gift' )->escaped() . '</a>'; + $profileLinks['user-send-gift'] = $linkRenderer->makeLink( + $give_gift->getFullURL( 'user=' . $user_safe ), + wfMessage( 'user-send-gift' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); } - $profileLinks['user-contributions'] = - '<a href="' . htmlspecialchars( $contributions->getFullURL() ) . '" rel="nofollow">' . wfMessage( 'user-contributions' )->escaped() . '</a>'; + $profileLinks['user-contributions'] = $linkRenderer->makeLink( + $contributions->getFullURL(), + wfMessage( 'user-contributions' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); // Links to User:user_name from User_profile: if ( @@ -1096,9 +1161,13 @@ $this->profile_data['user_page_type'] == 0 ) { - $profileLinks['user-page-link'] = - '<a href="' . htmlspecialchars( $user_page->getFullURL() ) . '" rel="nofollow">' . - wfMessage( 'user-page-link' )->escaped() . '</a>'; + $profileLinks['user-page-link'] = $linkRenderer->makeLink( + $user_page->getFullURL(), + wfMessage( 'user-page-link' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); } // Links to User:user_name from User_profile: @@ -1108,9 +1177,13 @@ $this->profile_data['user_page_type'] == 0 ) { - $profileLinks['user-social-profile-link'] = - '<a href="' . htmlspecialchars( $user_social_profile->getFullURL() ) . '" rel="nofollow">' . - wfMessage( 'user-social-profile-link' )->escaped() . '</a>'; + $profileLinks['user-social-profile-link'] = $linkRenderer->makeLink( + $user_social_profile->getFullURL(), + wfMessage( 'user-social-profile-link' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); } if ( @@ -1120,9 +1193,13 @@ ) ) { - $profileLinks['user-wiki-link'] = - '<a href="' . htmlspecialchars( $user_wiki->getFullURL() ) . '" rel="nofollow">' . - wfMessage( 'user-wiki-link' )->escaped() . '</a>'; + $profileLinks['user-wiki-link'] = $linkRenderer->makeLink( + $user_wiki->getFullURL(), + wfMessage( 'user-wiki-link' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); } // Provide a hook point for adding links to the profile header @@ -1148,6 +1225,7 @@ function getProfileImage( $user_name ) { $context = $this->getContext(); $user = $context->getUser(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $avatar = new wAvatar( $this->user_id, 'l' ); $avatarTitle = SpecialPage::getTitleFor( 'UploadAvatar' ); @@ -1159,10 +1237,14 @@ } else { $caption = 'new image'; } - $output .= '<a href="' . htmlspecialchars( $avatarTitle->getFullURL() ) . '" rel="nofollow">' . - $avatar->getAvatarURL() . '<br /> - (' . $caption . ') - </a>'; + $output .= $linkRenderer->makeLink( + $avatarTitle->getFullURL(), + $avatar->getAvatarURL() . '<br> + (' . $caption . ')', + [ + 'rel' => 'unfollow' + ] + ); } else { $output .= $avatar->getAvatarURL(); } @@ -1185,6 +1267,7 @@ $context = $this->getContext(); $language = $context->getLanguage(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); // If not enabled in site settings, don't display if ( $rel_type == 1 ) { @@ -1239,8 +1322,13 @@ <div class="user-section-actions"> <div class="action-right">'; if ( intval( $relationship_count ) > 4 ) { - $output .= '<a href="' . htmlspecialchars( $view_all_title->getFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type ) ) . - '" rel="nofollow">' . wfMessage( 'user-view-all' )->escaped() . '</a>'; + $output .= $linkRenderer->makeLink( + $view_all_title->getFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type ), + wfMessage( 'user-view-all' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); } $output .= '</div> <div class="action-left">'; @@ -1263,11 +1351,14 @@ // Chop down username that gets displayed $user_name = $language->truncate( $friend['user_name'], 9, '..' ); - $output .= "<a href=\"" . htmlspecialchars( $user->getFullURL() ) . - "\" title=\"" . htmlspecialchars( $friend['user_name'] ) . "\" rel=\"nofollow\"> - {$avatar->getAvatarURL()}<br /> - {$user_name} - </a>"; + $output .= $linkRenderer->makeLink( + $user->getFullURL() . '\\', + $avatar->getAvatarURL() . '<br>' . $user_name, + [ + 'rel' => 'nofollow', + 'title' => htmlspecialchars( $friend['user_name'] ) + ] + ); if ( $x == count( $friends ) || $x != 1 && $x % $per_row == 0 ) { $output .= '<div class="visualClear"></div>'; @@ -1296,6 +1387,8 @@ } $output = ''; + + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $limit = 8; $rel = new UserActivity( $user_name, 'user', $limit ); @@ -1335,8 +1428,13 @@ $user_title_2 = Title::makeTitle( NS_USER, $item['comment'] ); if ( $user_title_2 ) { - $user_link_2 = '<a href="' . htmlspecialchars( $user_title_2->getFullURL() ) . - '" rel="nofollow">' . $item['comment'] . '</a>'; + $user_link_2 = $linkRenderer->makeLink( + $user_title_2->getFullURL(), + $item['comment'], + [ + 'rel' => 'nofollow' + ] + ); } $comment_url = ''; @@ -1344,8 +1442,13 @@ $comment_url = "#comment-{$item['id']}"; } - $page_link = '<b><a href="' . htmlspecialchars( $title->getFullURL() ) . - "{$comment_url}\">" . $title->getPrefixedText() . '</a></b> '; + $page_link = '<b>'; + $page_link .= $linkRenderer->makeLink( + $title->getFullURL() . $comment_url . '\\', + $title->getPrefixedText() + ); + $page_link .= '</b>'; + $b = new UserBoard(); // Easier than porting the time-related functions here $item_time = '<span class="item-small">' . wfMessage( 'user-time-ago', $b->getTimeAgo( $item['timestamp'] ) )->escaped() . @@ -1386,24 +1489,30 @@ Gifts::getGiftImage( $item['namespace'], 'm' ) . '" border="0" alt="" />'; $item_html .= wfMessage( 'user-recent-activity-gift-sent' )->escaped() . " {$user_link_2} {$item_time} - <div class=\"item\"> - <a href=\"" . htmlspecialchars( $viewGift->getFullURL( "gift_id={$item['id']}" ) ) . "\" rel=\"nofollow\"> - {$gift_image} - {$item['pagetitle']} - </a> - </div>"; + <div class=\"item\">" . + $linkRenderer->makeLink( + $viewGift->getFullURL( "gift_id={$item['id']}" ), + $gift_image . $item['pagetitle'], + [ + 'rel' => 'nofollow' + ] + ) . + "</div>"; break; case 'gift-rec': $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $item['namespace'], 'm' ) . '" border="0" alt="" />'; $item_html .= wfMessage( 'user-recent-activity-gift-rec' )->escaped() . " {$user_link_2} {$item_time}</span> - <div class=\"item\"> - <a href=\"" . htmlspecialchars( $viewGift->getFullURL( "gift_id={$item['id']}" ) ) . "\" rel=\"nofollow\"> - {$gift_image} - {$item['pagetitle']} - </a> - </div>"; + <div class=\"item\">" . + $linkRenderer->makeLink( + $viewGift->getFullURL( "gift_id={$item['id']}" ), + $gift_image . $item['pagetitle'], + [ + 'rel' => 'nofollow' + ] + ) . + "</div>"; break; case 'system_gift': $gift_image = "<img src=\"{$wgUploadPath}/awards/" . @@ -1411,12 +1520,15 @@ '" border="0" alt="" />'; $viewSystemGift = SpecialPage::getTitleFor( 'ViewSystemGift' ); $item_html .= wfMessage( 'user-recent-system-gift' )->escaped() . " {$item_time} - <div class=\"user-home-item-gift\"> - <a href=\"" . htmlspecialchars( $viewSystemGift->getFullURL( "gift_id={$item['id']}" ) ) . "\" rel=\"nofollow\"> - {$gift_image} - {$item['pagetitle']} - </a> - </div>"; + <div class=\"user-home-item-gift\">" . + $linkRenderer->makeLink( + $viewSystemGift->getFullURL( "gift_id={$item['id']}" ) . '\\', + $gift_image . $item['pagetitle'], + [ + 'rel' => 'nofollow' + ] + ) . + "</div>"; break; case 'friend': $item_html .= wfMessage( 'user-recent-activity-friend' )->escaped() . @@ -1431,19 +1543,31 @@ break; case 'user_message': $item_html .= wfMessage( 'user-recent-activity-user-message' )->escaped() . - " <b><a href=\"" . UserBoard::getUserBoardURL( $user_title_2->getText() ) . - "\" rel=\"nofollow\">{$item['comment']}</a></b> {$item_time} - <div class=\"item\"> + "<b>" . + $linkRenderer->makeLink( + UserBoard::getUserBoardURL( $user_title_2->getText() ), + $item['comment'], + [ + 'rel' => 'nofollow' + ] + ) . + "</b>{$item_time} + <div class=\"item\"> \"{$item['namespace']}\" - </div>"; + </div>"; break; case 'network_update': $network_image = SportsTeams::getLogo( $item['sport_id'], $item['team_id'], 's' ); $item_html .= wfMessage( 'user-recent-activity-network-update' )->escaped() . - '<div class="item"> - <a href="' . SportsTeams::getNetworkURL( $item['sport_id'], $item['team_id'] ) . - "\" rel=\"nofollow\">{$network_image} \"{$item['comment']}\"</a> - </div>"; + '<div class="item">' . + $linkRenderer->makeLink( + SportsTeams::getNetworkURL( $item['sport_id'], $item['team_id'] ), + $network_image . $item['comment'], + [ + 'rel' => 'nofollow' + ] + ) . + '</div>'; break; } @@ -1515,8 +1639,13 @@ <div class="user-section-actions"> <div class="action-right">'; if ( $gift_count > 4 ) { - $output .= '<a href="' . htmlspecialchars( $gift_link->getFullURL( 'user=' . $user_safe ) ) . '" rel="nofollow">' . - wfMessage( 'user-view-all' )->escaped() . '</a>'; + $output .= $linkRenderer->makeLink( + $gift_link->getFullURL( 'user=' . $user_safe ), + wfMessage( 'user-view-all' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); } $output .= '</div> <div class="action-left">'; @@ -1550,8 +1679,13 @@ if ( $gift['status'] == 1 ) { $class = 'class="user-page-new"'; } - $output .= '<a href="' . htmlspecialchars( $gift_link->getFullURL( 'gift_id=' . $gift['id'] ) ) . '" ' . - $class . " rel=\"nofollow\">{$gift_image}</a>"; + $output .= $linkRenderer->makeLink( + $gift_link->getFullURL( 'gift_id=' . $gift['id'] ) . '" ' . $class, + $gift_image, + [ + 'rel' => 'nofollow' + ] + ); if ( $x == count( $gifts ) || $x != 1 && $x % $per_row == 0 ) { $output .= '<div class="visualClear"></div>'; } @@ -1570,6 +1704,7 @@ $context = $this->getContext(); $user = $context->getUser(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $logger = LoggerFactory::getInstance( 'SocialProfile' ); // If not enabled in site settings, don't display @@ -1614,8 +1749,13 @@ <div class="user-section-actions"> <div class="action-right">'; if ( $system_gift_count > 4 ) { - $output .= '<a href="' . htmlspecialchars( $system_gift_link->getFullURL( 'user=' . $user_name ) ) . '" rel="nofollow">' . - wfMessage( 'user-view-all' )->escaped() . '</a>'; + $output .= $linkRenderer->makeLink( + $system_gift_link->getFullURL( 'user=' . $user_name ), + wfMessage( 'user-view-all' )->escaped(), + [ + 'rel' => 'nofollow' + ] + ); } $output .= '</div> <div class="action-left">'; @@ -1647,10 +1787,13 @@ if ( $gift['status'] == 1 ) { $class = 'class="user-page-new"'; } - $output .= '<a href="' . htmlspecialchars( $gift_link->getFullURL( 'gift_id=' . $gift['id'] ) ) . - '" ' . $class . " rel=\"nofollow\"> - {$gift_image} - </a>"; + $output .= $linkRenderer->makeLink( + $gift_link->getFullURL( 'gift_id=' . $gift['id'] ) . '" ' . $class, + $gift_image, + [ + 'rel' => 'nofollow' + ] + ); if ( $x == count( $system_gifts ) || $x != 1 && $x % $per_row == 0 ) { $output .= '<div class="visualClear"></div>'; @@ -1676,6 +1819,7 @@ $context = $this->getContext(); $out = $context->getOutput(); $user = $context->getUser(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); // Anonymous users cannot have user boards if ( $user_id == 0 ) { @@ -1715,16 +1859,20 @@ <div class="action-right">'; if ( $user->getName() == $user_name ) { if ( $friends ) { - $output .= '<a href="' . UserBoard::getBoardBlastURL() . '">' . - wfMessage( 'user-send-board-blast' )->escaped() . '</a>'; + $output .= $linkRenderer->makeLink( + UserBoard::getBoardBlastURL(), + wfMessage( 'user-send-board-blast' )->escaped() + ); } if ( $total > 10 ) { $output .= wfMessage( 'pipe-separator' )->escaped(); } } if ( $total > 10 ) { - $output .= '<a href="' . UserBoard::getUserBoardURL( $user_name ) . '">' . - wfMessage( 'user-view-all' )->escaped() . '</a>'; + $output .= $linkRenderer->makeLink( + UserBoard::getUserBoardURL( $user_name ), + wfMessage( 'user-view-all' )->escaped() + ); } $output .= '</div> <div class="action-left">'; @@ -1789,6 +1937,7 @@ $context = $this->getContext(); $out = $context->getOutput(); $user = $context->getUser(); + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); if ( !$wgEnableUserBoxes || $wgUserProfileDisplay['userboxes'] == false ) { return ''; @@ -1838,12 +1987,13 @@ // If there are more than ten fanboxes, display a "View all" link // instead of listing them all on the profile page if ( $fanbox_count > 10 ) { - $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $output .= $linkRenderer->makeLink( $fanbox_link, wfMessage( 'user-view-all' )->plain(), - array(), - array( 'user' => $user_name ) + [], + [ + 'user' => $user_name + ] ); } $output .= '</div> @@ -1921,9 +2071,17 @@ // Output fanboxes $output .= "<div class=\"fanbox-item\"> <div class=\"individual-fanbox\" id=\"individualFanbox" . $fanbox['fantag_id'] . "\"> - <div class=\"show-message-container-profile\" id=\"show-message-container" . $fanbox['fantag_id'] . "\"> - <a class=\"perma\" style=\"font-size:8px; color:" . $fanbox['fantag_right_textcolor'] . "\" href=\"" . htmlspecialchars( $fantag_title->getFullURL() ) . "\" title=\"" . htmlspecialchars( $fanbox['fantag_title'] ) . "\">" . wfMessage( 'fanbox-perma' )->plain() . "</a> - <table class=\"fanBoxTableProfile\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> + <div class=\"show-message-container-profile\" id=\"show-message-container" . $fanbox['fantag_id'] . "\">" . + $linkRenderer->makeLink( + $fantag_title->getFullURL(), + wfMessage( 'fanbox-perma' )->plain(), + [ + 'class' => 'perma', + 'style' => 'font-size:8px; color:' . $fanbox['fantag_right_textcolor'], + 'title' => $fanbox['fantag_title'] + ] + ) . + "<table class=\"fanBoxTableProfile\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <td id=\"fanBoxLeftSideOutputProfile\" style=\"color:" . $fanbox['fantag_left_textcolor'] . "; font-size:$leftfontsize\" bgcolor=\"" . $fanbox['fantag_left_bgcolor'] . "\">" . $fantag_leftside . "</td> <td id=\"fanBoxRightSideOutputProfile\" style=\"color:" . $fanbox['fantag_right_textcolor'] . "; font-size:$rightfontsize\" bgcolor=\"" . $fanbox['fantag_right_bgcolor'] . "\">" . $right_text . "</td> diff --git a/UserRelationship/SpecialViewRelationships.php b/UserRelationship/SpecialViewRelationships.php index bdde9a3..d82049d 100644 --- a/UserRelationship/SpecialViewRelationships.php +++ b/UserRelationship/SpecialViewRelationships.php @@ -131,17 +131,20 @@ $total = $friend_count; $rem = $this->msg( 'ur-remove-relationship-friend' )->plain(); - $output .= '<div class="back-links"> - <a href="' . htmlspecialchars( $back_link->getFullURL() ) . '">' . - $this->msg( 'ur-backlink', $rel->user_name )->parse() . - '</a> - </div> - <div class="relationship-count">' . + $output .= '<div class="back-links">'; + $output .= $linkRenderer->makeLink( + $back_link->getFullURL(), + $this->msg( 'ur-backlink', $rel->user_name )->parse() + ); + $output .= '</div>'; + + $output .= '<div class="relationship-count">' . $this->msg( 'ur-relationship-count-friends', $rel->user_name, $total )->text() . '</div>'; + } else { $out->setPageTitle( $this->msg( 'ur-title-foe', $rel->user_name )->parse() ); @@ -149,12 +152,14 @@ $rem = $this->msg( 'ur-remove-relationship-foe' )->plain(); - $output .= '<div class="back-links"> - <a href="' . htmlspecialchars( $back_link->getFullURL() ) . '">' . - $this->msg( 'ur-backlink', $rel->user_name )->parse() . - '</a> - </div> - <div class="relationship-count">' + $output .= '<div class="back-links">'; + $output .= $linkRenderer->makeLink( + $back_link->getFullURL(), + $this->msg( 'ur-backlink', $rel->user_name )->parse() + ); + $output .= '</div>'; + + $output .= '<div class="relationship-count">' . $this->msg( 'ur-relationship-count-foes', $rel->user_name, @@ -192,12 +197,18 @@ $user_name_display = $relationship['user_name']; } - $output .= "<div class=\"relationship-item\"> - <a href=\"{$userPageURL}\">{$avatar_img}</a> - <div class=\"relationship-info\"> - <div class=\"relationship-name\"> - <a href=\"{$userPageURL}\">{$user_name_display}</a> - </div> + $output .= "<div class=\"relationship-item\">" . + $linkRenderer->makeLink( + $userPageURL, + $avatar_img + ) . + "<div class=\"relationship-info\"> + <div class=\"relationship-name\">" . + $linkRenderer->makeLink( + $userPageURL, + $user_name_display + ) . + "</div> <div class=\"relationship-actions\">"; if ( $indivRelationship == false ) { diff --git a/UserStats/GenerateTopUsersReport.php b/UserStats/GenerateTopUsersReport.php index a9aee31..72ed5a3 100644 --- a/UserStats/GenerateTopUsersReport.php +++ b/UserStats/GenerateTopUsersReport.php @@ -39,6 +39,7 @@ $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); // Check for the correct permission $this->checkPermissions(); @@ -216,9 +217,12 @@ )->inContentLanguage()->parse() . "\n\n"; $output .= "<div class=\"top-fan-row\"> - <span class=\"top-fan-num\">{$user['rank']}</span><span class=\"top-fan\"> <a href='" . - $userTitle->getFullURL() . "' >" . $user['user_name'] . "</a> - </span>"; + <span class=\"top-fan-num\">{$user['rank']}</span><span class=\"top-fan\">" . + $linkRenderer->makeLink( + $userTitle->getFullURL(), + $user['user_name'] + ) . + "</span>"; $output .= '<span class="top-fan-points">' . $this->msg( 'user-stats-report-points', diff --git a/UserStats/TopFansByStat.php b/UserStats/TopFansByStat.php index 0907e3f..5b228e2 100644 --- a/UserStats/TopFansByStat.php +++ b/UserStats/TopFansByStat.php @@ -28,10 +28,10 @@ global $wgMemc; global $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly; - $linkRenderer = $this->getLinkRenderer(); $lang = $this->getLanguage(); $out = $this->getOutput(); $request = $this->getRequest(); + $linkRenderer = $this->getLinkRenderer(); $logger = LoggerFactory::getInstance( 'SocialProfile' ); // Set the page title, robot policies, etc. @@ -130,17 +130,30 @@ $recent_title = SpecialPage::getTitleFor( 'TopUsersRecent' ); $output = '<div class="top-fan-nav"> - <h1>' . $this->msg( 'top-fans-by-points-nav-header' )->plain() . '</h1> - <p><a href="' . htmlspecialchars( $top_title->getFullURL() ) . '">' . - $this->msg( 'top-fans-total-points-link' )->plain() . '</a></p>'; + <h1>' . $this->msg( 'top-fans-by-points-nav-header' )->plain() . '</h1>'; + + $output .= '<p>'; + $output .= $linkRenderer->makeLink( + $top_title->getFullURL(), + $this->msg( 'top-fans-total-points-link' )->plain() + ); + $output .= '</p>'; if ( $wgUserStatsTrackWeekly ) { - $output .= '<p><a href="' . htmlspecialchars( $recent_title->getFullURL( 'period=monthly' ) ) . '">' . - $this->msg( 'top-fans-monthly-points-link' )->plain() . '</a><p>'; + $output .= '<p>'; + $output .= $linkRenderer->makeLink( + $recent_title->getFullURL( 'period=monthly' ), + $this->msg( 'top-fans-monthly-points-link' )->plain() + ); + $output .= '<p>'; } if ( $wgUserStatsTrackMonthly ) { - $output .= '<p><a href="' . htmlspecialchars( $recent_title->getFullURL( 'period=weekly' ) ) . '">' . - $this->msg( 'top-fans-weekly-points-link' )->plain() . '</a></p>'; + $output .= '<p>'; + $output .= $linkRenderer->makeLink( + $recent_title->getFullURL( 'period=weekly' ), + $this->msg( 'top-fans-weekly-points-link' )->plain() + ); + $output .= '</p'; } // Build nav of stats by category based on MediaWiki:Topfans-by-category diff --git a/UserStats/TopFansRecent.php b/UserStats/TopFansRecent.php index 65edfd4..de8ea81 100644 --- a/UserStats/TopFansRecent.php +++ b/UserStats/TopFansRecent.php @@ -31,10 +31,10 @@ public function execute( $par ) { global $wgMemc; - $linkRenderer = $this->getLinkRenderer(); $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); + $linkRenderer = $this->getLinkRenderer(); $logger = LoggerFactory::getInstance( 'SocialProfile' ); // Set the page title, robot policies, etc. @@ -132,17 +132,29 @@ $output = '<div class="top-fan-nav"> <h1>' . $this->msg( 'top-fans-by-points-nav-header' )->plain() . '</h1> - <p><a href="' . htmlspecialchars( $top_title->getFullURL() ) . '">' . - $this->msg( 'top-fans-total-points-link' )->plain() . '</a></p>'; + <p>' . + $linkRenderer->makeLink( + $top_title->getFullURL(), + $this->msg( 'top-fans-total-points-link' )->plain() + ) . + '</p>'; if ( $period == 'weekly' ) { - $output .= '<p><a href="' . htmlspecialchars( $recent_title->getFullURL( 'period=monthly' ) ) . '">' . - $this->msg( 'top-fans-monthly-points-link' )->plain() . '</a><p> + $output .= '<p>' . + $linkRenderer->makeLink( + $recent_title->getFullURL( 'period=monthly' ), + $this->msg( 'top-fans-monthly-points-link' )->plain() + ) . + '<p> <p><b>' . $this->msg( 'top-fans-weekly-points-link' )->plain() . '</b></p>'; } else { $output .= '<p><b>' . $this->msg( 'top-fans-monthly-points-link' )->plain() . '</b><p> - <p><a href="' . htmlspecialchars( $recent_title->getFullURL( 'period=weekly' ) ) . '">' . - $this->msg( 'top-fans-weekly-points-link' )->plain() . '</a></p>'; + <p>' . + $linkRenderer->makeLink( + $recent_title->getFullURL( 'period=weekly' ), + $this->msg( 'top-fans-weekly-points-link' )->plain() + ) . + '</p>'; } // Build nav of stats by category based on MediaWiki:Topfans-by-category diff --git a/UserStats/TopUsers.php b/UserStats/TopUsers.php index 9138d7c..24ca7e9 100644 --- a/UserStats/TopUsers.php +++ b/UserStats/TopUsers.php @@ -19,8 +19,8 @@ public function execute( $par ) { global $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels; - $linkRenderer = $this->getLinkRenderer(); $out = $this->getOutput(); + $linkRenderer = $this->getLinkRenderer(); $logger = LoggerFactory::getInstance( 'SocialProfile' ); // Load CSS @@ -100,13 +100,21 @@ <p><b>' . $this->msg( 'top-fans-total-points-link' )->plain() . '</b></p>'; if ( $wgUserStatsTrackWeekly ) { - $output .= '<p><a href="' . htmlspecialchars( $recent_title->getFullURL( 'period=monthly' ) ) . '">' . - $this->msg( 'top-fans-monthly-points-link' )->plain() . '</a></p>'; + $output .= '<p>'; + $output .= $linkRenderer->makeLink( + $recent_title->getFullURL( 'period=monthly' ), + $this->msg( 'top-fans-monthly-points-link' )->plain() + ); + $output .= '</p>'; } if ( $wgUserStatsTrackMonthly ) { - $output .= '<p><a href="' . htmlspecialchars( $recent_title->getFullURL( 'period=weekly' ) ) . '">' . - $this->msg( 'top-fans-weekly-points-link' )->plain() . '</a></p>'; + $output .= '<p>'; + $output .= $linkRenderer->makeLink( + $recent_title->getFullURL( 'period=weekly' ), + $this->msg( 'top-fans-weekly-points-link' )->plain() + ); + $output .= '</p>'; } // Build nav of stats by category based on MediaWiki:Topfans-by-category diff --git a/UserStats/TopUsersTag.php b/UserStats/TopUsersTag.php index 1119679..eec79ae 100644 --- a/UserStats/TopUsersTag.php +++ b/UserStats/TopUsersTag.php @@ -32,6 +32,8 @@ * @return string HTML */ function getTopUsersForTag( $input, $args, $parser ) { + $linkRenderer = $parser->getLinkRenderer(); + // Don't allow showing OVER 9000...I mean, over 50 users, duh. // Performance and all that stuff. if ( @@ -56,7 +58,6 @@ $x = 1; $topfans = ''; - $linkRenderer = MediaWiki\MediaWikiServices::getInstance()->getLinkRenderer(); foreach ( $fans as $fan ) { $avatar = new wAvatar( $fan['user_id'], 'm' ); $user = Title::makeTitle( NS_USER, $fan['user_name'] ); @@ -67,9 +68,12 @@ ); $safeUserURL = htmlspecialchars( $user->getFullURL() ); $topfans .= "<div class=\"top-fan\"> - <span class=\"top-fan-number\">{$x}.</span> - <a href=\"{$safeUserURL}\">{$avatar->getAvatarURL()}</a> - <span class=\"top-fans-user\">{$userLink}</span> + <span class=\"top-fan-number\">{$x}.</span>" . + $linkRenderer->makeLink( + $safeUserURL, + $avatar->getAvatarURL() + ) . + "<span class=\"top-fans-user\">{$userLink}</span> <span class=\"top-fans-points\">" . wfMessage( 'top-fans-points-tag' )->numParams( $fan['points'] )->parse() . '</span> </div>'; diff --git a/UserWelcome/UserWelcomeClass.php b/UserWelcome/UserWelcomeClass.php index 902f93b..89e203b 100644 --- a/UserWelcome/UserWelcomeClass.php +++ b/UserWelcome/UserWelcomeClass.php @@ -11,6 +11,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later */ +use MediaWiki\MediaWikiServices; + class UserWelcome { /** * Register <welcomeUser /> tag with the parser @@ -35,6 +37,8 @@ function getWelcome() { global $wgUser, $wgLang; + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + // Get stats and user level $stats = new UserStats( $wgUser->getID(), $wgUser->getName() ); $stats_data = $stats->getUserStats(); @@ -50,17 +54,29 @@ // Profile top images/points $output = '<div class="mp-welcome-logged-in"> <h2>' . wfMessage( 'mp-welcome-logged-in', $wgUser->getName() )->parse() . '</h2> - <div class="mp-welcome-image"> - <a href="' . htmlspecialchars( $wgUser->getUserPage()->getFullURL() ) . '" rel="nofollow">' . - $avatar->getAvatarURL() . '</a>'; + <div class="mp-welcome-image">' . + $linkRenderer->makeLink( + $wgUser->getUserPage()->getFullURL(), + $avatar->getAvatarURL(), + [ + 'rel' => 'nofollow' + ] + ); + if ( $avatar->isDefault() ) { $uploadOrEditMsg = 'mp-welcome-upload'; } else { $uploadOrEditMsg = 'edit'; } - $output .= '<div><a href="' . htmlspecialchars( $avatar_link->getFullURL() ) . '" rel="nofollow">' . - wfMessage( $uploadOrEditMsg )->plain() . - '</a></div>'; + $output .= '<div>' . + $linkRenderer->makeLink( + $avatar_link->getFullURL(), + wfMessage( $uploadOrEditMsg )->plain(), + [ + 'rel' => 'nofollow' + ] + ) . + '</div>'; $output .= '</div>'; global $wgUserLevels; @@ -72,8 +88,12 @@ 'mp-welcome-points', $wgLang->formatNum( $stats_data['points'] ) )->parse() . '</div> - <div class="honorific-level"><a href="' . htmlspecialchars( $level_link->getFullURL() ) . - '">(' . $user_level->getLevelName() . ')</a></div> + <div class="honorific-level">' . + $linkRenderer->makeLink( + $level_link->getFullURL(), + '(' . $user_level->getLevelName() . ')' + ) . + '</div> </div> <div class="visualClear"></div> <div class="needed-points"> @@ -117,6 +137,8 @@ function getRelationshipRequestLink() { global $wgUser, $wgExtensionAssetsPath; + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $friend_request_count = UserRelationship::getOpenRequestCount( $wgUser->getID(), 1 ); $foe_request_count = UserRelationship::getOpenRequestCount( $wgUser->getID(), 2 ); $relationship_request_link = SpecialPage::getTitleFor( 'ViewRelationshipRequests' ); @@ -126,16 +148,30 @@ if ( $friend_request_count > 0 ) { $output .= '<p> <img src="' . $wgExtensionAssetsPath . '/SocialProfile/images/addedFriendIcon.png" alt="" border="0" /> - <span class="profile-on"><a href="' . htmlspecialchars( $relationship_request_link->getFullURL() ) . '" rel="nofollow">' - . wfMessage( 'mp-request-new-friend', $friend_request_count )->parse() . '</a></span> + <span class="profile-on">' . + $linkRenderer->makeLink( + $relationship_request_link->getFullURL(), + wfMessage( 'mp-request-new-friend', $friend_request_count )->parse(), + [ + 'rel' => 'nofollow' + ] + ) . + '</span> </p>'; } if ( $foe_request_count > 0 ) { $output .= '<p> <img src="' . $wgExtensionAssetsPath . '/SocialProfile/images/addedFoeIcon.png" alt="" border="0" /> - <span class="profile-on"><a href="' . htmlspecialchars( $relationship_request_link->getFullURL() ) . '" rel="nofollow">' - . wfMessage( 'mp-request-new-foe', $foe_request_count )->parse() . '</a></span> + <span class="profile-on">' . + $linkRenderer->makeLink( + $relationship_request_link->getFullURL(), + wfMessage( 'mp-request-new-foe', $foe_request_count )->parse(), + [ + 'rel' => 'nofollow' + ] + ) . + '</span> </p>'; } @@ -145,6 +181,8 @@ function getNewGiftLink() { global $wgUser, $wgExtensionAssetsPath; + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $gift_count = UserGifts::getNewGiftCount( $wgUser->getID() ); $gifts_title = SpecialPage::getTitleFor( 'ViewGifts' ); $output = ''; @@ -152,9 +190,12 @@ if ( $gift_count > 0 ) { $output .= '<p> <img src="' . $wgExtensionAssetsPath . '/SocialProfile/images/icon_package_get.gif" alt="" border="0" /> - <span class="profile-on"><a href="' . htmlspecialchars( $gifts_title->getFullURL() ) . '" rel="nofollow">' - . wfMessage( 'mp-request-new-gift', $gift_count )->parse() . - '</a></span> + <span class="profile-on">' . + $linkRenderer->makeLink( + $gifts_title->getFullURL(), + wfMessage( 'mp-request-new-gift', $gift_count )->parse() + ) . + '</span> </p>'; } @@ -164,6 +205,8 @@ function getNewSystemGiftLink() { global $wgUser, $wgExtensionAssetsPath; + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $gift_count = UserSystemGifts::getNewSystemGiftCount( $wgUser->getID() ); $gifts_title = SpecialPage::getTitleFor( 'ViewSystemGifts' ); $output = ''; @@ -171,9 +214,15 @@ if ( $gift_count > 0 ) { $output .= '<p> <img src="' . $wgExtensionAssetsPath . '/SocialProfile/images/awardIcon.png" alt="" border="0" /> - <span class="profile-on"><a href="' . htmlspecialchars( $gifts_title->getFullURL() ) . '" rel="nofollow">' - . wfMessage( 'mp-request-new-award', $gift_count )->parse() . - '</a></span> + <span class="profile-on">' . + $linkRenderer->makeLink( + $gifts_title->getFullURL(), + wfMessage( 'mp-request-new-award', $gift_count )->parse(), + [ + 'rel' => 'nofollow' + ] + ) . + '</span> </p>'; } @@ -183,6 +232,8 @@ function getNewMessagesLink() { global $wgUser, $wgExtensionAssetsPath; + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $new_messages = UserBoard::getNewMessageCount( $wgUser->getID() ); $output = ''; @@ -190,9 +241,15 @@ $board_link = SpecialPage::getTitleFor( 'UserBoard' ); $output .= '<p> <img src="' . $wgExtensionAssetsPath . '/SocialProfile/images/emailIcon.gif" alt="" border="" /> - <span class="profile-on"><a href="' . htmlspecialchars( $board_link->getFullURL() ) . '" rel="nofollow">' - . wfMessage( 'mp-request-new-message' )->plain() . - '</a></span> + <span class="profile-on">' . + $linkRenderer->makeLink( + $board_link->getFullURL(), + wfMessage( 'mp-request-new-message' )->plain(), + [ + 'rel' => 'nofollow' + ] + ) . + '</span> </p>'; } -- To view, visit https://gerrit.wikimedia.org/r/405553 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I913b5463813a23c8b4f5f697096a95af754e8518 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SocialProfile Gerrit-Branch: master Gerrit-Owner: SamanthaNguyen <samanthanguyen1...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits