Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1431338
EchoRevertedPresentationModel.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
EchoRevertedPresentationModel.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications\Formatters
;
use
MediaWiki\Extension\Notifications\DiscussionParser
;
use
MediaWiki\Revision\RevisionRecord
;
class
EchoRevertedPresentationModel
extends
EchoEventPresentationModel
{
public
function
getIconType
()
{
return
'revert'
;
}
public
function
canRender
()
{
return
(
bool
)
$this
->
event
->
getTitle
();
}
public
function
getHeaderMessage
()
{
// Messages: notification-header-reverted
$msg
=
parent
::
getHeaderMessage
();
$msg
->
params
(
$this
->
getTruncatedTitleText
(
$this
->
event
->
getTitle
(),
true
)
);
$msg
->
params
(
$this
->
getNumberOfEdits
()
);
return
$msg
;
}
public
function
getBodyMessage
()
{
$summary
=
$this
->
event
->
getExtraParam
(
'summary'
);
if
(
!
$this
->
isAutomaticSummary
(
$summary
)
&&
$this
->
userCan
(
RevisionRecord
::
DELETED_COMMENT
)
)
{
$msg
=
$this
->
msg
(
'notification-body-reverted'
);
$msg
->
plaintextParams
(
$this
->
formatSummary
(
$summary
)
);
return
$msg
;
}
else
{
return
false
;
}
}
/**
* @param string|null $wikitext
* @return string
*/
private
function
formatSummary
(
$wikitext
)
{
if
(
$wikitext
===
null
||
$wikitext
===
''
)
{
return
''
;
}
return
DiscussionParser
::
getTextSnippetFromSummary
(
$wikitext
,
$this
->
language
);
}
public
function
getPrimaryLink
()
{
$url
=
$this
->
event
->
getTitle
()->
getLocalURL
(
[
'oldid'
=>
'prev'
,
'diff'
=>
$this
->
event
->
getExtraParam
(
'revid'
)
]
);
return
[
'url'
=>
$url
,
'label'
=>
$this
->
msg
(
'notification-link-text-view-changes'
,
$this
->
getViewingUserForGender
()
)->
text
()
];
}
public
function
getSecondaryLinks
()
{
$links
=
[
$this
->
getAgentLink
()
];
$title
=
$this
->
event
->
getTitle
();
if
(
$title
->
canHaveTalkPage
()
)
{
$links
[]
=
$this
->
getPageLink
(
$title
->
getTalkPage
(),
''
,
true
);
}
return
$links
;
}
/**
* Return a number that represents if one or multiple edits
* have been reverted for formatting purposes.
* @return int
*/
private
function
getNumberOfEdits
()
{
$method
=
$this
->
event
->
getExtraParam
(
'method'
);
if
(
$method
&&
$method
===
'rollback'
)
{
return
2
;
}
else
{
return
1
;
}
}
/**
* @param string|null $summary
* @return bool
*/
private
function
isAutomaticSummary
(
$summary
)
{
if
(
$summary
===
null
||
$summary
===
''
)
{
return
false
;
}
$autoSummaryMsg
=
$this
->
msg
(
'undo-summary'
)->
inContentLanguage
();
$autoSummaryMsg
->
params
(
$this
->
event
->
getExtraParam
(
'reverted-revision-id'
)
);
$autoSummaryMsg
->
params
(
$this
->
getViewingUserForGender
()
);
$autoSummary
=
$autoSummaryMsg
->
text
();
return
$summary
===
$autoSummary
;
}
protected
function
getSubjectMessageKey
()
{
return
'notification-reverted-email-subject2'
;
}
public
function
getSubjectMessage
()
{
return
parent
::
getSubjectMessage
()->
params
(
$this
->
getNumberOfEdits
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 20:21 (1 d, 1 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d2/e3/aa2e6031f79b2ebbaceaa571992d
Default Alt Text
EchoRevertedPresentationModel.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment