Skip to content

Commit

Permalink
fix(core): 🐛 add missing classes
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair3149 committed May 14, 2024
1 parent 8f5ec9b commit b70e760
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions includes/Components/CitizenComponentPageHeading.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class CitizenComponentPageHeading implements CitizenComponent {
/** @var OutputPage */
private $out;

/** @var Language|StubUserLang */
private $pageLang;

/** @var Title */
private $title;

Expand All @@ -35,6 +38,7 @@ class CitizenComponentPageHeading implements CitizenComponent {

/**
* @param MessageLocalizer $localizer
* @param Language|StubUserLang $pageLang
* @param Title $title
* @param OutputPage $out
* @param string $titleData
Expand All @@ -43,12 +47,14 @@ class CitizenComponentPageHeading implements CitizenComponent {
public function __construct(
MessageLocalizer $localizer,
OutputPage $out,
$pageLang,
Title $title,
string $titleData,
UserIdentity $user
) {
$this->localizer = $localizer;
$this->out = $out;
$this->pageLang = $pageLang;
$this->title = $title;
$this->titleData = $titleData;
$this->user = $user;
Expand Down Expand Up @@ -93,9 +99,10 @@ private function buildPageUserObject() {
* @return string|null
*/
private function buildUserTagline() {
$localizer = $this->localizer;

$user = $this->buildPageUserObject();
if ( $user ) {
$skin = $this->skin;
$tagline = '<div id="citizen-tagline-user">';
$editCount = $user->getEditCount();
$regDate = $user->getRegistration();
Expand All @@ -111,14 +118,14 @@ private function buildUserTagline() {
}

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

if ( is_string( $regDate ) ) {
$regDateTs = wfTimestamp( TS_UNIX, $regDate );
$msgRegDate = $skin->msg( 'citizen-tagline-user-regdate', $skin->getLanguage()->userDate( new MWTimestamp( $regDate ), $skin->getUser() ), $user );
$msgRegDate = $localizer->msg( 'citizen-tagline-user-regdate', $this->pageLang->userDate( new MWTimestamp( $regDate ), $this->user ), $user );
$tagline .= "<span id=\"citizen-tagline-user-regdate\" data-user-regdate=\"$regDateTs\">$msgRegDate</span>";
}

Expand All @@ -134,6 +141,7 @@ private function buildUserTagline() {
* @return string
*/
private function getPageHeading(): string {
$titleHtml = $this->titleData;
if ( $this->shouldAddParenthesis() ) {
// Look for the </span> to ensure that it is the last parenthesis of the title
$pattern = '/\s(\(.+\))<\/span>/';
Expand Down
1 change: 1 addition & 0 deletions includes/SkinCitizen.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public function getTemplateData(): array {
'data-page-heading' => new CitizenComponentPageHeading(
$localizer,
$out,
$pageLang,
$title,
$parentData['html-title-heading'],
$user
Expand Down

0 comments on commit b70e760

Please sign in to comment.