Skip to content

Commit

Permalink
refactor(core): ♻️ use SkinComponentUtils to get SpecialPages URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair3149 committed Jan 2, 2025
1 parent d67bcb1 commit dfa0aa4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
9 changes: 2 additions & 7 deletions includes/Components/CitizenComponentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

namespace MediaWiki\Skins\Citizen\Components;

/**
* TODO: Update to new classes when we move to MW 1.43
* - MediaWiki\Html\Html
* - MediaWiki\Linker\Linker
*/
use Html;
use Linker;
use MediaWiki\Html\Html;
use MediaWiki\Linker\Linker;
use MessageLocalizer;

/**
Expand Down
5 changes: 2 additions & 3 deletions includes/Components/CitizenComponentPageHeading.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace MediaWiki\Skins\Citizen\Components;

use MediaWiki\MediaWikiServices;
use MediaWiki\Skin\SkinComponentUtils;
use MediaWiki\Title\Title;
use MediaWiki\User\UserIdentity;
use MessageLocalizer;
use MWTimestamp;
use OutputPage;
use SpecialPage;
use Wikimedia\IPUtils;

/**
Expand Down Expand Up @@ -119,8 +119,7 @@ private function buildUserTagline(): string {

if ( $editCount ) {
$msgEditCount = $localizer->msg( 'usereditcount' )->numParams( sprintf( '%s', number_format( $editCount, 0 ) ) );
// TODO: Replace with SkinComponentUtils on 1.43
$editCountHref = SpecialPage::getTitleFor( 'Contributions', $user )->getLocalURL();
$editCountHref = SkinComponentUtils::makeSpecialUrlSubpage( 'Contributions', $user );
$tagline .= "<span id=\"citizen-tagline-user-editcount\" data-user-editcount=\"$editCount\"><a href=\"$editCountHref\">$msgEditCount</a></span>";
}

Expand Down
5 changes: 2 additions & 3 deletions includes/Components/CitizenComponentSearchBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace MediaWiki\Skins\Citizen\Components;

use ExtensionRegistry;
use MediaWiki\Skin\SkinComponentUtils;
use MessageLocalizer;
use SpecialPage;

/**
* CitizenComponentSearchBox component
Expand Down Expand Up @@ -71,8 +71,7 @@ public function getTemplateData(): array {
'array-keyboard-hint' => $this->getKeyboardHintData(),
'msg-citizen-search-footer' => $this->getFooterMessage(),
'msg-citizen-search-toggle-shortcut' => '[/]',
// TODO: Replace with SkinComponentUtils on 1.43
'html-random-href' => SpecialPage::getTitleFor( 'Randompage' )->getLocalURL()
'html-random-href' => SkinComponentUtils::makeSpecialUrl( 'Randompage' )
];
return $searchBoxData;
}
Expand Down
12 changes: 5 additions & 7 deletions includes/Hooks/SkinHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
namespace MediaWiki\Skins\Citizen\Hooks;

use ExtensionRegistry;
use Html;
use MediaWiki\Html\Html;
use Language;
use MediaWiki\Hook\BeforePageDisplayHook;
use MediaWiki\Hook\SidebarBeforeOutputHook;
use MediaWiki\Hook\SkinBuildSidebarHook;
use MediaWiki\Hook\SkinEditSectionLinksHook;
use MediaWiki\ResourceLoader as RL;
use MediaWiki\Skin\SkinComponentUtils;
use MediaWiki\Skins\Citizen\GetConfigTrait;
use MediaWiki\Skins\Hook\SkinPageReadyConfigHook;
use MediaWiki\Title\Title;
use OutputPage;
use Skin;
use SkinTemplate;
use SpecialPage;

/**
* Hooks to run relating the skin
Expand Down Expand Up @@ -111,8 +111,7 @@ public function onSkinBuildSidebar( $skin, &$bar ): void {
$name = empty( $globalToolsId ) ? 'navigation' : preg_replace( '/^p-/', '', $globalToolsId );
$bar[$name]['specialpages'] = [
'text' => $skin->msg( 'specialpages' ),
// TODO: Replace with SkinComponentUtils on 1.43
'href' => SpecialPage::getTitleFor( 'Specialpages' )->getLocalURL(),
'href' => SkinComponentUtils::makeSpecialUrl( 'Specialpages' ),
'title' => $skin->msg( 'tooltip-t-specialpages' ),
'icon' => 'specialPages',
'id' => 't-specialpages',
Expand All @@ -122,11 +121,10 @@ public function onSkinBuildSidebar( $skin, &$bar ): void {
$isUploadWizardEnabled = ExtensionRegistry::getInstance()->isLoaded( 'Upload Wizard' );
$bar[$name]['upload'] = [
'text' => $skin->msg( 'upload' ),
// TODO: Replace with SkinComponentUtils on 1.43
'href' => SpecialPage::getTitleFor( $isUploadWizardEnabled ?
'href' => SkinComponentUtils::makeSpecialUrl( $isUploadWizardEnabled ?
'UploadWizard' :
'Upload'
)->getLocalURL(),
),
'title' => $skin->msg( 'tooltip-t-upload' ),
'icon' => 'upload',
'id' => 't-upload',
Expand Down

0 comments on commit dfa0aa4

Please sign in to comment.