Page MenuHomePhabricator

Timeless skin Your account dropdown username not modifiable
Closed, ResolvedPublic

Description

Hello,

I have maintained Extension:Realnames for the last 7 years. It is used to add the realname to username links and mentions.

In Vector (legacy skin) and MonoBook the PersonalUrls hook allows me to modify the userpage link text to add the realname, making it so the logged in user's realname is displayed in the top right.

In the new official Timeless skin, the username is hardwired in (link to code line) and no hook is provided that can modify it.

I would like it if the line of code could please be changed from:

$dropdownHeader = $userName;
...
$headerMsg = [ 'timeless-loggedinas', $user->getName() ];

to:

$userNameLinkTextBackup = $personalTools['userpage']['links'][0]['text']; // before the re-label
...
$dropdownHeader = $userNameLinkTextBackup;
...
$headerMsg = [ 'timeless-loggedinas', $userNameLinkTextBackup ];

Or perhaps it could use an optional key if present, $userName otherwise. That way, any work I do in the PersonalUrls hook to modify the text of the user link would be carried over into the Timeless skin.

Alternatively, a new hook could be introduced, but it seems kind of niche usage. I also thought I could potentially use BeforePageDisplay hook to modify the HTML, however that doesn't include the top right header HTML. It could be there is another hook that I'm not aware of that gives me access to the HTML of the page after TimelessTemplate::execute, but the bottom of the function is an echo() so it would have to be ob_start() somewhere else then hooked.

Since I'm maintaining an extension for people to install, I'd like to solve this in the general extension case, not with a core hack, now that Timeless is an official skin. To be sure this is not a bug, not a support request, but a feature request on the Timeless skin.

Thanks,
Finlay

Event Timeline

Ofbeaton updated the task description. (Show Details)
Ofbeaton updated the task description. (Show Details)

So the expectation is that the username be pulled from the data array, so that way your extension can just change the display name to something else?

Yes please. This is how it is done in Vector and MonoBook.

I guess to be safe in case the userpage array is not in there... you could do something like this instead:

                $userName = $user->getName();
                // Re-label some messages
		if ( isset( $personalTools['userpage'] ) ) {
                        $userName = $personalTools['userpage']['links'][0]['text'];
			$personalTools['userpage']['links'][0]['text'] = $this->getMsg( 'timeless-userpage' )->text();
		}
		if ( isset( $personalTools['mytalk'] ) ) {
			$personalTools['mytalk']['links'][0]['text'] = $this->getMsg( 'timeless-talkpage' )->text();
		}

		// Labels
		if ( $user->isLoggedIn() ) {
			// Make sure it fits first (numbers slightly made up, may need adjusting)
			$fit = empty( $extraTools ) ? 13 : 9;
			if ( mb_strlen( $userName ) < $fit ) {
				$dropdownHeader = $userName;
			} else {
				$dropdownHeader = $this->getMsg( 'timeless-loggedin' )->text();
			}
			$headerMsg = [ 'timeless-loggedinas', $userName ];

Okay, I gotta figure out how to make the header in general less feckin' dumb in the first place to make this actually likely to... show up, and such, but that sounds good to me. Suppose there's no particular reason not to just do it as is in the meantime, regardless...

(The issue is the space for the username is very small currently and it just replaces it with 'account' if it doesn't fit, which... isn't really ideal. Need better handling in general, as this use case means it'd be likely to be even longer.)

Change 504965 had a related patch set uploaded (by Isarra; owner: Isarra):
[mediawiki/skins/Timeless@master] Preserve standard username label to allow customisation

https://gerrit.wikimedia.org/r/504965

Change 504965 merged by jenkins-bot:
[mediawiki/skins/Timeless@master] Preserve standard username label to allow customisation

https://gerrit.wikimedia.org/r/504965

Isarra claimed this task.

But if this doesn't do what you wanted, please do say so.