summaryrefslogtreecommitdiff
path: root/extensions/Renameuser/RenameuserLogFormatter.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
committerPierre Schmitz <pierre@archlinux.de>2013-08-12 09:28:15 +0200
commit08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch)
tree577a29fb579188d16003a209ce2a2e9c5b0aa2bd /extensions/Renameuser/RenameuserLogFormatter.php
parentcacc939b34e315b85e2d72997811eb6677996cc1 (diff)
Update to MediaWiki 1.21.1
Diffstat (limited to 'extensions/Renameuser/RenameuserLogFormatter.php')
-rw-r--r--extensions/Renameuser/RenameuserLogFormatter.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/extensions/Renameuser/RenameuserLogFormatter.php b/extensions/Renameuser/RenameuserLogFormatter.php
new file mode 100644
index 00000000..c7c4678d
--- /dev/null
+++ b/extensions/Renameuser/RenameuserLogFormatter.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * LogFormatter for renameuser/renameuser logs
+ */
+
+class RenameuserLogFormatter extends LogFormatter {
+
+ protected function getMessageParameters() {
+ $params = parent::getMessageParameters();
+ /* Current format:
+ * 1,2,3: normal logformatter params
+ * 4: old username
+ * (legaciest doesn't have this at all, all in comment)
+ * (legacier uses this as new name and stores old name in target)
+ * 5: new username
+ * 6: number of edits the user had at the time
+ * (not available except in newest log entries)
+ * Note that the arrays are zero-indexed, while message parameters
+ * start from 1, so substract one to get array entries below.
+ */
+
+ if ( !isset( $params[3] ) ) {
+ // The oldest format
+ return $params;
+ } elseif ( !isset( $params[4] ) ) {
+ // See comments above
+ $params[4] = $params[3];
+ $params[3] = $this->entry->getTarget()->getText();
+ }
+
+ // Nice link to old user page
+ $title = Title::makeTitleSafe( NS_USER, $params[3] );
+ $link = $this->myPageLink( $title, $params[3] );
+ $params[3] = Message::rawParam( $link );
+
+ // Nice link to new user page
+ $title = Title::makeTitleSafe( NS_USER, $params[4] );
+ $link = $this->myPageLink( $title, $params[4] );
+ $params[4] = Message::rawParam( $link );
+
+ return $params;
+ }
+
+ protected function myPageLink( Title $title = null, $text ) {
+ if ( !$this->plaintext ) {
+ $text = htmlspecialchars( $text );
+ $link = Linker::link( $title, $text );
+ } else {
+ if ( !$title instanceof Title ) {
+ $link = "[[User:$text]]";
+ } else {
+ $link = '[[' . $title->getPrefixedText() . ']]';
+ }
+ }
+ return $link;
+ }
+
+ public function getMessageKey() {
+ $key = parent::getMessageKey();
+ $params = $this->extractParameters();
+
+ // Very old log format, everything in comment
+ if ( !isset( $params[3] ) ) {
+ return "$key-legaciest";
+ } elseif ( !isset( $params[5] ) ) {
+ return "$key-legacier";
+ }
+
+ return $key;
+ }
+}