Merge "Make button text black for non-Vector buttons:"
[lhc/web/wiklou.git] / includes / logging / MoveLogFormatter.php
1 <?php
2 /**
3 * Formatter for move log entries.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @author Niklas Laxström
22 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
23 * @since 1.22
24 */
25
26 /**
27 * This class formats move log entries.
28 *
29 * @since 1.19
30 */
31 class MoveLogFormatter extends LogFormatter {
32 public function getPreloadTitles() {
33 $params = $this->extractParameters();
34 return array( Title::newFromText( $params[3] ) );
35 }
36
37 protected function getMessageKey() {
38 $key = parent::getMessageKey();
39 $params = $this->getMessageParameters();
40 if ( isset( $params[4] ) && $params[4] === '1' ) {
41 $key .= '-noredirect';
42 }
43 return $key;
44 }
45
46 protected function getMessageParameters() {
47 $params = parent::getMessageParameters();
48 $oldname = $this->makePageLink( $this->entry->getTarget(), array( 'redirect' => 'no' ) );
49 $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
50 $params[2] = Message::rawParam( $oldname );
51 $params[3] = Message::rawParam( $newname );
52 return $params;
53 }
54
55 public function getActionLinks() {
56 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
57 || $this->entry->getSubtype() !== 'move'
58 || !$this->context->getUser()->isAllowed( 'move' ) )
59 {
60 return '';
61 }
62
63 $params = $this->extractParameters();
64 $destTitle = Title::newFromText( $params[3] );
65 if ( !$destTitle ) {
66 return '';
67 }
68
69 $revert = Linker::linkKnown(
70 SpecialPage::getTitleFor( 'Movepage' ),
71 $this->msg( 'revertmove' )->escaped(),
72 array(),
73 array(
74 'wpOldTitle' => $destTitle->getPrefixedDBkey(),
75 'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(),
76 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(),
77 'wpMovetalk' => 0
78 )
79 );
80 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
81 }
82 }