3 * Contains a class for formatting log legacy entries
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.
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.
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
21 * @author Niklas Laxström
22 * @license GPL-2.0-or-later
27 * This class formats all log entries for log types
28 * which have not been converted to the new system.
29 * This is not about old log entries which store
30 * parameters in a different format - the new
31 * LogFormatter classes have code to support formatting
35 class LegacyLogFormatter
extends LogFormatter
{
37 * Backward compatibility for extension changing the comment from
38 * the LogLine hook. This will be set by the first call on getComment(),
39 * then it might be modified by the hook when calling getActionLinks(),
40 * so that the modified value will be returned when calling getComment()
45 private $comment = null;
48 * Cache for the result of getActionLinks() so that it does not need to
49 * run multiple times depending on the order that getComment() and
50 * getActionLinks() are called.
54 private $revert = null;
56 public function getComment() {
57 if ( $this->comment
=== null ) {
58 $this->comment
= parent
::getComment();
61 // Make sure we execute the LogLine hook so that we immediately return
63 if ( $this->revert
=== null ) {
64 $this->getActionLinks();
67 return $this->comment
;
72 * @return-taint onlysafefor_html
74 protected function getActionMessage() {
75 $entry = $this->entry
;
76 $action = LogPage
::actionText(
80 $this->plaintext ?
null : $this->context
->getSkin(),
81 (array)$entry->getParameters(),
82 !$this->plaintext
// whether to filter [[]] links
85 $performer = $this->getPerformerElement();
86 if ( !$this->irctext
) {
87 $sep = $this->msg( 'word-separator' );
88 $sep = $this->plaintext ?
$sep->text() : $sep->escaped();
89 $action = $performer . $sep . $action;
95 public function getActionLinks() {
96 if ( $this->revert
!== null ) {
100 if ( $this->entry
->isDeleted( LogPage
::DELETED_ACTION
) ) {
102 return $this->revert
;
105 $title = $this->entry
->getTarget();
106 $type = $this->entry
->getType();
107 $subtype = $this->entry
->getSubtype();
109 // Do nothing. The implementation is handled by the hook modifying the
110 // passed-by-ref parameters. This also changes the default value so that
111 // getComment() and getActionLinks() do not call them indefinitely.
114 // This is to populate the $comment member of this instance so that it
115 // can be modified when calling the hook just below.
116 if ( $this->comment
=== null ) {
120 $params = $this->entry
->getParameters();
122 Hooks
::runner()->onLogLine( $type, $subtype, $title, $params, $this->comment
,
123 $this->revert
, $this->entry
->getTimestamp() );
125 return $this->revert
;