MediaWiki REL1_40
SkinComponentLastModified.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Skin;
4
5use Language;
8use User;
9
12 private $language;
14 private $localizer;
16 private $revisionTimestamp;
18 private $user;
19
24 public function __construct( SkinComponentRegistryContext $skinContext, $revisionTimestamp = null ) {
25 $this->revisionTimestamp = $revisionTimestamp;
26 $this->localizer = $skinContext->getMessageLocalizer();
27 $this->user = $skinContext->getUser();
28 $this->language = $skinContext->getLanguage();
29 }
30
36 public function getTemplateData(): array {
37 $localizer = $this->localizer;
38 $user = $this->user;
39 $language = $this->language;
40 $timestamp = $this->revisionTimestamp;
41
42 if ( $timestamp ) {
43 $d = $language->userDate( $timestamp, $user );
44 $t = $language->userTime( $timestamp, $user );
45 $s = ' ' . $localizer->msg( 'lastmodifiedat', $d, $t )->parse();
46 } else {
47 $s = '';
48 $d = null;
49 $t = null;
50 }
51
52 $isLagged = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->laggedReplicaUsed();
53 if ( $isLagged ) {
54 $s .= ' <strong>' .
55 $localizer->msg( 'laggedreplicamode' )->parse() .
56 '</strong>';
57 }
58
59 return [
60 'is-replica' => $isLagged,
61 'text' => $s,
62 'date' => $d,
63 'time' => $t,
64 'timestamp' => $timestamp,
65 ];
66 }
67}
Base class for language-specific code.
Definition Language.php:56
userDate( $ts, UserIdentity $user, array $options=[])
Get the formatted date for the given timestamp and formatted for the given user.
userTime( $ts, UserIdentity $user, array $options=[])
Get the formatted time for the given timestamp and formatted for the given user.
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
__construct(SkinComponentRegistryContext $skinContext, $revisionTimestamp=null)
getTemplateData()
Get the timestamp of the latest revision, formatted in user language.
internal since 1.36
Definition User.php:71
Interface for localizing messages in MediaWiki.
msg( $key,... $params)
This is the method for getting translated interface messages.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...