MediaWiki REL1_33
ParserOutputSearchDataExtractor.php
Go to the documentation of this file.
1<?php
2
4
5use Category;
7use Title;
8
30
37 public function getCategories( ParserOutput $parserOutput ) {
38 $categories = [];
39
40 foreach ( $parserOutput->getCategoryLinks() as $key ) {
41 $categories[] = Category::newFromName( $key )->getTitle()->getText();
42 }
43
44 return $categories;
45 }
46
53 public function getExternalLinks( ParserOutput $parserOutput ) {
54 return array_keys( $parserOutput->getExternalLinks() );
55 }
56
64 public function getOutgoingLinks( ParserOutput $parserOutput ) {
65 $outgoingLinks = [];
66
67 foreach ( $parserOutput->getLinks() as $linkedNamespace => $namespaceLinks ) {
68 foreach ( array_keys( $namespaceLinks ) as $linkedDbKey ) {
69 $outgoingLinks[] =
70 Title::makeTitle( $linkedNamespace, $linkedDbKey )->getPrefixedDBkey();
71 }
72 }
73
74 return $outgoingLinks;
75 }
76
83 public function getTemplates( ParserOutput $parserOutput ) {
84 $templates = [];
85
86 foreach ( $parserOutput->getTemplates() as $tNS => $templatesInNS ) {
87 foreach ( array_keys( $templatesInNS ) as $tDbKey ) {
88 $templateTitle = Title::makeTitle( $tNS, $tDbKey );
89 $templates[] = $templateTitle->getPrefixedText();
90 }
91 }
92
93 return $templates;
94 }
95
96}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Category objects are immutable, strictly speaking.
Definition Category.php:31
static newFromName( $name)
Factory function.
Definition Category.php:126
Extracts data from ParserOutput for indexing in the search engine.
getExternalLinks(ParserOutput $parserOutput)
Get a list of external links from ParserOutput, as an array of strings.
getCategories(ParserOutput $parserOutput)
Get a list of categories, as an array with title text strings.
getOutgoingLinks(ParserOutput $parserOutput)
Get a list of outgoing wiki links (including interwiki links), as an array of prefixed title strings.
getTemplates(ParserOutput $parserOutput)
Get a list of templates used in the ParserOutput content, as prefixed title strings.
Represents a title within MediaWiki.
Definition Title.php:40