MediaWiki REL1_40
PageLangLogFormatter.php
Go to the documentation of this file.
1<?php
27
34 protected function getMessageParameters() {
35 // Get the user language for displaying language names
36 $userLang = $this->context->getLanguage()->getCode();
37 $params = parent::getMessageParameters();
38
39 // Get the language codes from log
40 $oldLang = $params[3];
41 $kOld = strrpos( $oldLang, '[' );
42 if ( $kOld ) {
43 $oldLang = substr( $oldLang, 0, $kOld );
44 }
45
46 $newLang = $params[4];
47 $kNew = strrpos( $newLang, '[' );
48 if ( $kNew ) {
49 $newLang = substr( $newLang, 0, $kNew );
50 }
51
52 // Convert language codes to names in user language
53 $languageNameUtils = MediaWikiServices::getInstance()->getLanguageNameUtils();
54 $logOld = $languageNameUtils->getLanguageName( $oldLang, $userLang )
55 . ' (' . $oldLang . ')';
56 $logNew = $languageNameUtils->getLanguageName( $newLang, $userLang )
57 . ' (' . $newLang . ')';
58
59 // Add the default message to languages if required
60 $params[3] = !$kOld ? $logOld : $logOld . ' [' . $this->msg( 'default' ) . ']';
61 $params[4] = !$kNew ? $logNew : $logNew . ' [' . $this->msg( 'default' ) . ']';
62 return $params;
63 }
64}
Implements the default log formatting.
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Service locator for MediaWiki core services.
This class formats language change log entries.
getMessageParameters()
Formats parameters intended for action message from array of all parameters.