Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1432573
OnWikiList.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
OnWikiList.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications
;
use
MediaWiki\Content\TextContent
;
use
MediaWiki\MediaWikiServices
;
use
MediaWiki\Title\Title
;
/**
* Implements ContainmentList interface for sourcing a list of items from a wiki
* page. Uses the page's latest revision ID as cache key.
*/
class
OnWikiList
implements
ContainmentList
{
/**
* @var Title|null A title object representing the page to source the list from,
* or null if the page does not exist.
*/
protected
$title
;
/**
* @param int $titleNs An NS_* constant representing the mediawiki namespace of the page
* @param string $titleString String portion of the wiki page title
*/
public
function
__construct
(
$titleNs
,
$titleString
)
{
$title
=
Title
::
newFromText
(
$titleString
,
$titleNs
);
if
(
$title
!==
null
&&
$title
->
getArticleID
()
)
{
$this
->
title
=
$title
;
}
}
/**
* @inheritDoc
*/
public
function
getValues
()
{
if
(
!
$this
->
title
)
{
return
[];
}
$article
=
MediaWikiServices
::
getInstance
()->
getWikiPageFactory
()->
newFromTitle
(
$this
->
title
);
if
(
!
$article
->
exists
()
)
{
return
[];
}
$content
=
$article
->
getContent
();
$text
=
(
$content
instanceof
TextContent
)
?
$content
->
getText
()
:
null
;
if
(
$text
===
null
)
{
return
[];
}
return
array_filter
(
array_map
(
'trim'
,
explode
(
"
\n
"
,
$text
)
)
);
}
/**
* @inheritDoc
*/
public
function
getCacheKey
()
{
if
(
!
$this
->
title
)
{
return
''
;
}
return
(
string
)
$this
->
title
->
getLatestRevID
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 22:00 (1 d, 5 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ea/de/4e620acfd69b900e264183c0f9d2
Default Alt Text
OnWikiList.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment