Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| SearchResult | |
0.00% |
0 / 9 |
|
0.00% |
0 / 6 |
56 | |
0.00% |
0 / 1 |
| newFromTitle | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| isBrokenTitle | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| isMissingRevision | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getTitle | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getFile | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getTextSnippet | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getTextSnippetField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTitleSnippet | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getTitleSnippetField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRedirectSnippet | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getRedirectSnippetField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRedirectTitle | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getSectionSnippet | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getSectionSnippetField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSectionTitle | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getCategorySnippet | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getCategorySnippetField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTimestamp | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getWordCount | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getByteSize | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getInterwikiPrefix | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getInterwikiNamespaceText | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| isFileMatch | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | * @ingroup Search |
| 6 | */ |
| 7 | |
| 8 | namespace MediaWiki\Search; |
| 9 | |
| 10 | use File; |
| 11 | use MediaWiki\Title\Title; |
| 12 | |
| 13 | /** |
| 14 | * An abstract base class representing a search engine result |
| 15 | * |
| 16 | * @ingroup Search |
| 17 | */ |
| 18 | abstract class SearchResult { |
| 19 | use SearchResultTrait; |
| 20 | |
| 21 | /** |
| 22 | * Return a new SearchResult and initializes it with a title. |
| 23 | * |
| 24 | * @param Title $title |
| 25 | * @param ISearchResultSet|null $parentSet |
| 26 | * @return SearchResult |
| 27 | */ |
| 28 | public static function newFromTitle( $title, ?ISearchResultSet $parentSet = null ): SearchResult { |
| 29 | $result = new RevisionSearchResult( $title ); |
| 30 | if ( $parentSet ) { |
| 31 | $parentSet->augmentResult( $result ); |
| 32 | } |
| 33 | return $result; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Check if this is result points to an invalid title |
| 38 | * |
| 39 | * @return bool |
| 40 | */ |
| 41 | abstract public function isBrokenTitle(); |
| 42 | |
| 43 | /** |
| 44 | * Check if target page is missing, happens when index is out of date |
| 45 | * |
| 46 | * @return bool |
| 47 | */ |
| 48 | abstract public function isMissingRevision(); |
| 49 | |
| 50 | /** |
| 51 | * @return Title|null |
| 52 | */ |
| 53 | abstract public function getTitle(); |
| 54 | |
| 55 | /** |
| 56 | * Get the file for this page, if one exists |
| 57 | * @return File|null |
| 58 | */ |
| 59 | abstract public function getFile(); |
| 60 | |
| 61 | /** |
| 62 | * @param string[] $terms Terms to highlight (this parameter is deprecated and ignored) |
| 63 | * @return string Highlighted text snippet, null (and not '') if not supported |
| 64 | */ |
| 65 | abstract public function getTextSnippet( $terms = [] ); |
| 66 | |
| 67 | /** |
| 68 | * @return string Name of the field containing the text snippet, '' if not supported |
| 69 | */ |
| 70 | public function getTextSnippetField() { |
| 71 | return ''; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * @return string Highlighted title, '' if not supported |
| 76 | */ |
| 77 | abstract public function getTitleSnippet(); |
| 78 | |
| 79 | /** |
| 80 | * @return string Name of the field containing the title snippet, '' if not supported |
| 81 | */ |
| 82 | public function getTitleSnippetField() { |
| 83 | return ''; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @return string Highlighted redirect name (redirect to this page), '' if none or not supported |
| 88 | */ |
| 89 | abstract public function getRedirectSnippet(); |
| 90 | |
| 91 | /** |
| 92 | * @return string Name of the field containing the redirect snippet, '' if not supported |
| 93 | */ |
| 94 | public function getRedirectSnippetField() { |
| 95 | return ''; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * @return Title|null Title object for the redirect to this page, null if none or not supported |
| 100 | */ |
| 101 | abstract public function getRedirectTitle(); |
| 102 | |
| 103 | /** |
| 104 | * @return string Highlighted relevant section name, null if none or not supported |
| 105 | */ |
| 106 | abstract public function getSectionSnippet(); |
| 107 | |
| 108 | /** |
| 109 | * @return string Name of the field containing the section snippet, '' if not supported |
| 110 | */ |
| 111 | public function getSectionSnippetField() { |
| 112 | return ''; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * @return Title|null Title object (pagename+fragment) for the section, |
| 117 | * null if none or not supported |
| 118 | */ |
| 119 | abstract public function getSectionTitle(); |
| 120 | |
| 121 | /** |
| 122 | * @return string Highlighted relevant category name or '' if none or not supported |
| 123 | */ |
| 124 | abstract public function getCategorySnippet(); |
| 125 | |
| 126 | /** |
| 127 | * @return string Name of the field containing the category snippet, '' if not supported |
| 128 | */ |
| 129 | public function getCategorySnippetField() { |
| 130 | return ''; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * @return string Timestamp |
| 135 | */ |
| 136 | abstract public function getTimestamp(); |
| 137 | |
| 138 | /** |
| 139 | * @return int Number of words |
| 140 | */ |
| 141 | abstract public function getWordCount(); |
| 142 | |
| 143 | /** |
| 144 | * @return int Size in bytes |
| 145 | */ |
| 146 | abstract public function getByteSize(); |
| 147 | |
| 148 | /** |
| 149 | * @return string Interwiki prefix of the title (return iw even if title is broken) |
| 150 | */ |
| 151 | abstract public function getInterwikiPrefix(); |
| 152 | |
| 153 | /** |
| 154 | * @return string Interwiki namespace of the title (since we likely can't resolve it locally) |
| 155 | */ |
| 156 | abstract public function getInterwikiNamespaceText(); |
| 157 | |
| 158 | /** |
| 159 | * Did this match file contents (eg: PDF/DJVU)? |
| 160 | * @return bool |
| 161 | */ |
| 162 | abstract public function isFileMatch(); |
| 163 | } |
| 164 | |
| 165 | /** @deprecated class alias since 1.46 */ |
| 166 | class_alias( SearchResult::class, 'SearchResult' ); |