MediaWiki
REL1_37
ParserOutputSearchDataExtractor.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Search
;
4
5
use
Category
;
6
use
ParserOutput
;
7
use
Title
;
8
29
class
ParserOutputSearchDataExtractor
{
30
37
public
function
getCategories
(
ParserOutput
$parserOutput ) {
38
$categories = [];
39
40
foreach
( $parserOutput->
getCategoryLinks
() as $key ) {
41
$name = Category::newFromName( $key )->getName();
42
$categories[] = str_replace(
'_'
,
' '
, $name );
43
}
44
45
return
$categories;
46
}
47
54
public
function
getExternalLinks
(
ParserOutput
$parserOutput ) {
55
return
array_keys( $parserOutput->
getExternalLinks
() );
56
}
57
65
public
function
getOutgoingLinks
(
ParserOutput
$parserOutput ) {
66
$outgoingLinks = [];
67
68
foreach
( $parserOutput->
getLinks
() as $linkedNamespace => $namespaceLinks ) {
69
foreach
( array_keys( $namespaceLinks ) as $linkedDbKey ) {
70
$outgoingLinks[] =
71
Title::makeTitle( $linkedNamespace, $linkedDbKey )->getPrefixedDBkey();
72
}
73
}
74
75
return
$outgoingLinks;
76
}
77
84
public
function
getTemplates
(
ParserOutput
$parserOutput ) {
85
$templates = [];
86
87
foreach
( $parserOutput->
getTemplates
() as $tNS => $templatesInNS ) {
88
foreach
( array_keys( $templatesInNS ) as $tDbKey ) {
89
$templateTitle = Title::makeTitle( $tNS, $tDbKey );
90
$templates[] = $templateTitle->getPrefixedText();
91
}
92
}
93
94
return
$templates;
95
}
96
97
}
Category
Category objects are immutable, strictly speaking.
Definition
Category.php:33
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:54
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:65
MediaWiki\Search\ParserOutputSearchDataExtractor\getTemplates
getTemplates(ParserOutput $parserOutput)
Get a list of templates used in the ParserOutput content, as prefixed title strings.
Definition
ParserOutputSearchDataExtractor.php:84
ParserOutput
Definition
ParserOutput.php:31
ParserOutput\getCategoryLinks
getCategoryLinks()
Definition
ParserOutput.php:578
ParserOutput\getExternalLinks
& getExternalLinks()
Definition
ParserOutput.php:630
ParserOutput\getLinks
& getLinks()
Definition
ParserOutput.php:602
ParserOutput\getTemplates
& getTemplates()
Definition
ParserOutput.php:614
Title
Represents a title within MediaWiki.
Definition
Title.php:48
MediaWiki\Search
includes
search
ParserOutputSearchDataExtractor.php
Generated on Fri Apr 5 2024 23:40:50 for MediaWiki by
1.9.8