MediaWiki
master
ParserOutputSearchDataExtractor.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Search
;
4
5
use
MediaWiki\Parser\ParserOutput
;
6
use
MediaWiki\Parser\ParserOutputLinkTypes
;
7
use
MediaWiki\Title\Title
;
8
29
class
ParserOutputSearchDataExtractor
{
30
37
public
function
getCategories
(
ParserOutput
$parserOutput ) {
38
$categories = [];
39
40
foreach
(
41
$parserOutput->
getLinkList
( ParserOutputLinkTypes::CATEGORY )
42
as [
'link'
=> $link ]
43
) {
44
$categories[] = $link->getText();
45
}
46
47
return
$categories;
48
}
49
56
public
function
getExternalLinks
(
ParserOutput
$parserOutput ) {
57
return
array_keys( $parserOutput->
getExternalLinks
() );
58
}
59
67
public
function
getOutgoingLinks
(
ParserOutput
$parserOutput ) {
68
$outgoingLinks = [];
69
70
foreach
(
71
$parserOutput->
getLinkList
( ParserOutputLinkTypes::LOCAL )
72
as [
'link'
=> $link ]
73
) {
74
// XXX should use a TitleFormatter
75
// XXX why is this a DBkey when all of the others are text?
76
$outgoingLinks[] =
77
Title::newFromLinkTarget( $link )->getPrefixedDBkey();
78
}
79
80
return
$outgoingLinks;
81
}
82
89
public
function
getTemplates
(
ParserOutput
$parserOutput ) {
90
$templates = [];
91
92
foreach
(
93
$parserOutput->
getLinkList
( ParserOutputLinkTypes::TEMPLATE )
94
as [
'link'
=> $link ]
95
) {
96
// XXX should use a TitleFormatter
97
$templates[] =
98
Title::newFromLinkTarget( $link )->getPrefixedText();
99
}
100
101
return
$templates;
102
}
103
104
}
MediaWiki\Parser\ParserOutputLinkTypes
Definition
ParserOutputLinkTypes.php:38
MediaWiki\Parser\ParserOutput
ParserOutput is a rendering of a Content object or a message.
Definition
ParserOutput.php:93
MediaWiki\Parser\ParserOutput\getLinkList
getLinkList(string $linkType)
Get a list of links of the given type.
Definition
ParserOutput.php:790
MediaWiki\Parser\ParserOutput\getExternalLinks
& getExternalLinks()
Definition
ParserOutput.php:936
MediaWiki\Search\ParserOutputSearchDataExtractor
Extracts data from ParserOutput for indexing in the search engine.
Definition
ParserOutputSearchDataExtractor.php:29
MediaWiki\Search\ParserOutputSearchDataExtractor\getExternalLinks
getExternalLinks(ParserOutput $parserOutput)
Get a list of external links from ParserOutput, as an array of strings.
Definition
ParserOutputSearchDataExtractor.php:56
MediaWiki\Search\ParserOutputSearchDataExtractor\getCategories
getCategories(ParserOutput $parserOutput)
Get a list of categories, as an array with title text strings.
Definition
ParserOutputSearchDataExtractor.php:37
MediaWiki\Search\ParserOutputSearchDataExtractor\getOutgoingLinks
getOutgoingLinks(ParserOutput $parserOutput)
Get a list of outgoing wiki links (including interwiki links), as an array of prefixed title strings.
Definition
ParserOutputSearchDataExtractor.php:67
MediaWiki\Search\ParserOutputSearchDataExtractor\getTemplates
getTemplates(ParserOutput $parserOutput)
Get a list of templates used in the ParserOutput content, as prefixed title strings.
Definition
ParserOutputSearchDataExtractor.php:89
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:78
MediaWiki\Search
includes
search
ParserOutputSearchDataExtractor.php
Generated on Fri Dec 13 2024 09:25:43 for MediaWiki by
1.10.0