Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| WMLiquidThreadsLogFormatter | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
72 | |
0.00% |
0 / 1 |
| getActionMessage | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
72 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\WikimediaMessages\LogFormatter; |
| 4 | |
| 5 | use MediaWiki\Logging\LogFormatter; |
| 6 | use Wikimedia\StringUtils\StringUtils; |
| 7 | |
| 8 | /** |
| 9 | * A snapshot of the log formatter from the LiquidThreads |
| 10 | * extension. |
| 11 | * |
| 12 | * @see https://phabricator.wikimedia.org/T89426 |
| 13 | */ |
| 14 | class WMLiquidThreadsLogFormatter extends LogFormatter { |
| 15 | /** @inheritDoc */ |
| 16 | protected function getActionMessage() { |
| 17 | $action = $this->entry->getSubtype(); |
| 18 | $title = $this->entry->getTarget(); |
| 19 | $parameters = $this->entry->getParameters(); |
| 20 | |
| 21 | $msg = "lqt-log-action-$action"; |
| 22 | |
| 23 | switch ( $action ) { |
| 24 | case 'merge': |
| 25 | if ( $parameters[0] ) { |
| 26 | $msg = 'lqt-log-action-merge-across'; |
| 27 | } else { |
| 28 | $msg = 'lqt-log-action-merge-down'; |
| 29 | } |
| 30 | break; |
| 31 | case 'move': |
| 32 | // In LiquidThreads, this adds a link to SpecialMoveThread for user who have |
| 33 | // the rights. That is removed here, since SpecialMoveThread is unavailable. |
| 34 | $parameters[] = ''; |
| 35 | break; |
| 36 | default: |
| 37 | // Give grep a chance to find the usages: |
| 38 | // lqt-log-action-move, lqt-log-action-split, lqt-log-action-subjectedit, |
| 39 | // lqt-log-action-resort, lqt-log-action-signatureedit |
| 40 | $msg = "lqt-log-action-$action"; |
| 41 | break; |
| 42 | } |
| 43 | |
| 44 | array_unshift( $parameters, $title->getPrefixedText() ); |
| 45 | $html = wfMessage( $msg, $parameters ); |
| 46 | |
| 47 | if ( $this->plaintext ) { |
| 48 | $html = StringUtils::delimiterReplace( '<', '>', '', $html->inContentLanguage()->parse() ); |
| 49 | } else { |
| 50 | $html = $html->parse(); |
| 51 | } |
| 52 | |
| 53 | if ( !$this->irctext ) { |
| 54 | $performer = $this->getPerformerElement(); |
| 55 | $sep = $this->msg( 'word-separator' ); |
| 56 | $sep = $this->plaintext ? $sep->text() : $sep->escaped(); |
| 57 | $html = $performer . $sep . $html; |
| 58 | } |
| 59 | |
| 60 | return $html; |
| 61 | } |
| 62 | } |