Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7431717
EchoFlyoutFormatter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
EchoFlyoutFormatter.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications\Formatters
;
use
MediaWiki\Html\Html
;
use
MediaWiki\Utils\MWTimestamp
;
/**
* A formatter for the notification flyout popup
*
* Ideally we wouldn't need this, and we'd just pass the
* presentation model to the client, but we need to continue
* sending HTML for backwards compatibility.
*/
class
EchoFlyoutFormatter
extends
EchoEventFormatter
{
/** @inheritDoc */
protected
function
formatModel
(
EchoEventPresentationModel
$model
)
{
$icon
=
Html
::
element
(
'img'
,
[
'class'
=>
'mw-echo-icon'
,
'src'
=>
$this
->
getIconUrl
(
$model
),
]
);
$html
=
Html
::
rawElement
(
'div'
,
[
'class'
=>
'mw-echo-title'
],
$model
->
getHeaderMessage
()->
parse
()
)
.
"
\n
"
;
$body
=
$model
->
getBodyMessage
();
if
(
$body
)
{
$html
.=
Html
::
rawElement
(
'div'
,
[
'class'
=>
'mw-echo-payload'
],
$body
->
parse
()
)
.
"
\n
"
;
}
$ts
=
$this
->
language
->
getHumanTimestamp
(
new
MWTimestamp
(
$model
->
getTimestamp
()
),
null
,
$this
->
user
);
$footerItems
=
[
$ts
];
$secondaryLinks
=
array_filter
(
$model
->
getSecondaryLinks
()
);
foreach
(
$secondaryLinks
as
$link
)
{
$footerItems
[]
=
Html
::
element
(
'a'
,
[
'href'
=>
$link
[
'url'
]
],
$link
[
'label'
]
);
}
$html
.=
Html
::
rawElement
(
'div'
,
[
'class'
=>
'mw-echo-notification-footer'
],
$this
->
language
->
pipeList
(
$footerItems
)
)
.
"
\n
"
;
// Add the primary link afterwards, if it has one
$primaryLink
=
$model
->
getPrimaryLinkWithMarkAsRead
();
if
(
$primaryLink
!==
false
)
{
$html
.=
Html
::
element
(
'a'
,
[
'class'
=>
'mw-echo-notification-primary-link'
,
'href'
=>
$primaryLink
[
'url'
]
],
$primaryLink
[
'label'
]
)
.
"
\n
"
;
}
return
Html
::
rawElement
(
'div'
,
[
'class'
=>
'mw-echo-state'
],
$icon
.
Html
::
rawElement
(
'div'
,
[
'class'
=>
'mw-echo-content'
],
$html
)
);
}
private
function
getIconUrl
(
EchoEventPresentationModel
$model
):
string
{
return
EchoIcon
::
getUrl
(
$model
->
getIconType
(),
$this
->
language
->
getDir
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 11:04 (7 h, 1 s)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
be/b7/5b4d0bc2e512d6f0b18d0bf488b0
Default Alt Text
EchoFlyoutFormatter.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment