Merge "Use mergeMwGlobalArrayValue in AutoLoaderTest::setUp"
[lhc/web/wiklou.git] / includes / logging / MergeLogFormatter.php
1 <?php
2 /**
3 * Formatter for merge 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 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
22 * @since 1.25
23 */
24
25 /**
26 * This class formats merge log entries.
27 *
28 * @since 1.25
29 */
30 class MergeLogFormatter extends LogFormatter {
31 public function getPreloadTitles() {
32 $params = $this->extractParameters();
33
34 return array( Title::newFromText( $params[3] ) );
35 }
36
37 protected function getMessageParameters() {
38 $params = parent::getMessageParameters();
39 $oldname = $this->makePageLink( $this->entry->getTarget(), array( 'redirect' => 'no' ) );
40 $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
41 $params[2] = Message::rawParam( $oldname );
42 $params[3] = Message::rawParam( $newname );
43 $params[4] = $this->context->getLanguage()->timeanddate( $params[4] );
44 return $params;
45 }
46
47 public function getActionLinks() {
48 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
49 || !$this->context->getUser()->isAllowed( 'mergehistory' )
50 ) {
51 return '';
52 }
53
54 // Show unmerge link
55 $params = $this->extractParameters();
56 $revert = Linker::linkKnown(
57 SpecialPage::getTitleFor( 'MergeHistory' ),
58 $this->msg( 'revertmerge' )->escaped(),
59 array(),
60 array(
61 'target' => $params[3],
62 'dest' => $this->entry->getTarget()->getPrefixedDBkey(),
63 'mergepoint' => $params[4],
64 'submitted' => 1 // show the revisions immediately
65 )
66 );
67
68 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
69 }
70 }