Index: trunk/extensions/SolrStore/SolrStore.i18n.php |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | $messages['en'] = array( |
13 | 13 | 'solrstore-desc' => 'Search semantic properties with the power of a fulltext search engine', |
14 | 14 | 'solrsearch' => 'SolrSearch', |
| 15 | + 'solrstore-error' => 'Error: Please Check your Query', |
15 | 16 | 'solrstore-searchFieldSets' => 'SolrSearch', |
16 | 17 | 'solrstore-searchFieldSets-select' => 'Please select a SearchSet', |
17 | 18 | 'solrstore-searchFieldSets-title' => 'SolrSearch: SearchSet select', |
— | — | @@ -23,6 +24,7 @@ |
24 | 25 | $messages['qqq'] = array( |
25 | 26 | 'solrstore-desc' => '{{desc}}', |
26 | 27 | 'solrsearch' => "The title of the Special:SolrSearch page as appearing in Special:SpecialPages. Should probably be the same as message ''solrstore-searchFieldSets''", |
| 28 | + 'solrstore-error' => 'Currently we have just One Error Message, "Error: Please Check your Query"', |
27 | 29 | 'solrstore-searchFieldSets' => 'The pagetitle (heading) of the Special:SolrSearch page', |
28 | 30 | 'solrstore-searchFieldSets-select' => 'A SearchSet is a predefined search form for a field based search.', |
29 | 31 | 'solrstore-searchFieldSets-title' => 'The title of the Special:SolrSearch page. A SearchSet is a predefined search form for a field based search.', |
— | — | @@ -43,10 +45,12 @@ |
44 | 46 | |
45 | 47 | /** German (Deutsch) |
46 | 48 | * @author Kghbln |
| 49 | + * @author SBachenberg |
47 | 50 | */ |
48 | 51 | $messages['de'] = array( |
49 | 52 | 'solrstore-desc' => 'Ermöglicht die Suche nach semantischen Attributen mit einer Volltextsuchmaschine', |
50 | 53 | 'solrsearch' => 'SolrSuche', |
| 54 | + 'solrstore-error' => 'Fehler: Bitte überprüfen Sie ihre Suchanfrage', |
51 | 55 | 'solrstore-searchFieldSets' => 'SolrSuche', |
52 | 56 | 'solrstore-searchFieldSets-select' => 'Bitte wähle ein SearchSet aus', |
53 | 57 | 'solrstore-searchFieldSets-title' => 'SolrSearch: SearchSet Auswahl', |
Index: trunk/extensions/SolrStore/SpecialSolrSearch.php |
— | — | @@ -1,564 +1,553 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * File holding the SpecialSolrSearch class |
5 | | - * |
| 4 | + * SolrStore: The SolrStore Extesion is Semantic Mediawiki Searchprovieder based on Apache Solr. |
| 5 | + * |
6 | 6 | * This is the SpecialPage, displaying the SearchSets and Results |
7 | | - * |
8 | | - * @ingroup SolrStore |
9 | | - * @file |
| 7 | + * |
| 8 | + * @defgroup SolrStore |
10 | 9 | * @author Simon Bachenberg |
11 | 10 | */ |
12 | | - |
13 | | -/** |
14 | | - * TODO: Insert class description |
15 | | - * |
16 | | - * @ingroup SolrStore |
17 | | - */ |
18 | 11 | class SpecialSolrSearch extends SpecialPage { |
19 | 12 | |
20 | | - /** |
21 | | - * Set up basic search parameters from the request and user settings. |
22 | | - * Typically you'll pass $wgRequest and $wgUser. |
23 | | - * |
24 | | - * @param $request WebRequest |
25 | | - * @param $user User |
26 | | - */ |
27 | | - public function __construct() { |
28 | | - parent::__construct( 'SolrSearch' ); |
29 | | - global $wgRequest, $wgUser, $wgOut, $wgSolrFields; |
30 | | - $user = $wgUser; |
31 | | - $request = $wgRequest; |
32 | | - list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, 'searchlimit' ); |
| 13 | + /** |
| 14 | + * Set up basic search parameters from the request and user settings. |
| 15 | + * Typically you'll pass $wgRequest and $wgUser. |
| 16 | + * |
| 17 | + * @param $request WebRequest |
| 18 | + * @param $user User |
| 19 | + */ |
| 20 | + public function __construct() { |
| 21 | + parent::__construct("SolrSearch"); |
| 22 | + global $wgRequest, $wgUser, $wgOut, $wgSolrFields; |
| 23 | + $user = $wgUser; |
| 24 | + $request = $wgRequest; |
| 25 | + list( $this->limit, $this->offset ) = $request->getLimitOffset(20, 'searchlimit'); |
33 | 26 | |
34 | | - $this->sk = $user->getSkin(); |
35 | | - $this->didYouMeanHtml = ''; # html of did you mean... link |
36 | | - } |
| 27 | + $this->sk = $user->getSkin(); |
| 28 | + $this->didYouMeanHtml = ''; # html of did you mean... link |
| 29 | + } |
37 | 30 | |
38 | | - function execute( $par ) { |
39 | | - global $wgRequest, $wgUser, $wgOut, $wgSolrFields; |
| 31 | + function execute($par) { |
| 32 | + global $wgRequest, $wgUser, $wgOut, $wgSolrFields; |
40 | 33 | |
41 | | - $this->setHeaders(); |
42 | | - $SpecialSolrSearch = new SpecialSolrSearch( $wgRequest, $wgUser ); |
| 34 | + $this->setHeaders(); |
| 35 | + $SpecialSolrSearch = new SpecialSolrSearch($wgRequest, $wgUser); |
43 | 36 | |
44 | | - foreach ( $wgSolrFields as $set ) { |
45 | | - if ( $par == $set->getName() ) { |
46 | | - $fieldSet = $set; |
47 | | - } |
48 | | - } |
| 37 | + # Get request data from, e.g. |
| 38 | + $param = $wgRequest->getText('param'); |
49 | 39 | |
50 | | - // Strip underscores from title parameter; most of the time we'll want |
51 | | - // text form here. But don't strip underscores from actual text params! |
52 | | - $titleParam = str_replace( '_', ' ', $par ); |
53 | | - // Fetch the search term |
54 | | -// $search = str_replace("\n", " ", $wgRequest->getText('solrsearch', $titleParam)); |
| 40 | + foreach ($wgSolrFields as $set) { |
| 41 | + if ($par == $set->getName()) { |
| 42 | + $fieldSet = $set; |
| 43 | + } |
| 44 | + } |
| 45 | + # Do stuff |
| 46 | + # ... |
| 47 | + // Strip underscores from title parameter; most of the time we'll want |
| 48 | + // text form here. But don't strip underscores from actual text params! |
| 49 | + $titleParam = str_replace('_', ' ', $par); |
| 50 | + // Fetch the search term |
| 51 | +// $search = str_replace("\n", " ", $wgRequest->getText('solrsearch', $titleParam)); |
55 | 52 | |
56 | | - if ( !isset( $fieldSet ) ) { |
57 | | - $SpecialSolrSearch->showFieldSets(); |
58 | | - } else { |
59 | | - $lable = $fieldSet->getLable(); |
60 | | - $firstTimeHere = true; |
61 | | - foreach ( $fieldSet->getFields() as $field ) { |
62 | | - if ( $firstTimeHere ) { |
63 | | - $newLable['solr' . trim( $field )] = trim( $lable[0] ); |
64 | | - $firstTimeHere = false; |
65 | | - } else { |
66 | | - $newLable['solr' . trim( $field )] = trim( next( $lable ) ); |
67 | | - } |
| 53 | + if (!isset($fieldSet)) { |
| 54 | + $SpecialSolrSearch->showFieldSets(); |
| 55 | + } else { |
| 56 | + $lable = $fieldSet->getLable(); |
| 57 | + $firstTimeHere = true; |
| 58 | + foreach ($fieldSet->getFields() as $field) { |
| 59 | + if ($firstTimeHere) { |
| 60 | + $newLable ['solr' . trim($field)] = trim($lable[0]); |
| 61 | + $firstTimeHere = false; |
| 62 | + } else { |
| 63 | + $newLable ['solr' . trim($field)] = trim(next($lable)); |
| 64 | + } |
68 | 65 | |
69 | | - $newFields['solr' . trim( $field )] = $wgRequest->getText( 'solr' . trim( $field ) ); |
70 | | - } |
71 | | - $fieldSet->setFields( $newFields ); |
72 | | - $fieldSet->setLable( $newLable ); |
| 66 | + $newFields ['solr' . trim($field)] = $wgRequest->getText('solr' . trim($field)); |
| 67 | + } |
| 68 | + $fieldSet->setFields($newFields); |
| 69 | + $fieldSet->setLable($newLable); |
73 | 70 | |
74 | | - $SpecialSolrSearch->showResults( $fieldSet ); |
75 | | - } |
76 | | - } |
| 71 | + $SpecialSolrSearch->showResults($fieldSet); |
| 72 | + } |
| 73 | + } |
77 | 74 | |
78 | | - /** |
79 | | - * @param $fieldSet String |
80 | | - */ |
81 | | - public function showFieldSets() { |
82 | | - global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang, $wgScript, $wgSolrFields; |
83 | | - wfProfileIn( __METHOD__ ); |
| 75 | + /** |
| 76 | + * @param $fieldSet String |
| 77 | + */ |
| 78 | + public function showFieldSets() { |
| 79 | + global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang, $wgScript, $wgSolrFields; |
| 80 | + wfProfileIn(__METHOD__); |
84 | 81 | |
85 | | - $sk = $wgUser->getSkin(); |
| 82 | + $sk = $wgUser->getSkin(); |
86 | 83 | |
87 | | - $wgOut->setPageTitle( wfMsg( 'solrstore-searchFieldSets' ) ); |
88 | | - $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'solrstore-searchFieldSets-title', 'SolrSearch: Select FieldSet' ) ) ); |
89 | 84 | |
90 | | - $wgOut->setArticleRelated( false ); |
91 | | - $wgOut->addHTML( '<div class="solrsearch-fieldset">' ); |
92 | | - $wgOut->addHTML( wfMsg( 'solrstore-searchFieldSets-select' ) ); |
93 | | - $wgOut->addHTML( '<ul>' ); |
| 85 | + $wgOut->setPageTitle(wfMsg('searchFieldSets')); |
| 86 | + $wgOut->setHTMLTitle(wfMsg('pagetitle', wfMsg('searchFieldSets-title', 'SolrSearch: Select FieldSet'))); |
94 | 87 | |
95 | | - // TODO: If no SearchSets exist, provide a shot Manual how to create some! |
96 | | - foreach ( $wgSolrFields as $set ) { |
97 | | - $name = $set->getName(); |
98 | | - $wgOut->addHTML( "<li><a href=\"$wgScript/Special:SolrSearch/$name\">$name</a></li>" ); |
99 | | - } |
100 | | - $wgOut->addHTML( '</ul>' ); |
101 | | - $wgOut->addHTML( '</div>' ); |
| 88 | + $wgOut->setArticleRelated(false); |
| 89 | + $wgOut->addHtml('<div class="solrsearch-fieldset">'); |
| 90 | + $wgOut->addHtml(wfMsg('searchFieldSets-select')); |
| 91 | + $wgOut->addHtml('<ul>'); |
102 | 92 | |
103 | | - wfProfileOut( __METHOD__ ); |
104 | | - } |
| 93 | + //TODO: If no SearchSets exist, provide a shot Manual how to create some! |
| 94 | + foreach ($wgSolrFields as $set) { |
| 95 | + $name = $set->getName(); |
| 96 | + $wgOut->addHtml("<li><a href=\"$wgScript/Special:SolrSearch/$name\">$name</a></li>"); |
| 97 | + } |
| 98 | + $wgOut->addHtml('</ul>'); |
| 99 | + $wgOut->addHtml("</div>"); |
105 | 100 | |
106 | | - /** |
107 | | - * @param $fieldSet String |
108 | | - */ |
109 | | - public function showResults( $fieldSet ) { |
110 | | - global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang, $wgScript; |
111 | | - wfProfileIn( __METHOD__ ); |
| 101 | + wfProfileOut(__METHOD__); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * @param $fieldSet String |
| 106 | + */ |
| 107 | + public function showResults($fieldSet) { |
| 108 | + global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang, $wgScript; |
| 109 | + wfProfileIn(__METHOD__); |
112 | 110 | |
113 | | - $sk = $wgUser->getSkin(); |
| 111 | + $sk = $wgUser->getSkin(); |
114 | 112 | |
115 | | - $this->searchEngine = SearchEngine::create(); |
116 | | - $search = & $this->searchEngine; |
117 | | - $search->setLimitOffset( $this->limit, $this->offset ); |
| 113 | + $this->searchEngine = SearchEngine::create(); |
| 114 | + $search = & $this->searchEngine; |
| 115 | + $search->setLimitOffset($this->limit, $this->offset); |
118 | 116 | |
119 | | - $this->setupPage( $fieldSet ); |
| 117 | + $this->setupPage($fieldSet); |
120 | 118 | |
121 | | - $t = Title::newFromText( $fieldSet->getName() ); |
| 119 | + $t = Title::newFromText($fieldSet->getName()); |
122 | 120 | |
123 | | - // Do we have title matches? |
124 | | - $fields = $fieldSet->getFields(); |
| 121 | + //DO we have Title matches |
| 122 | + $fields = $fieldSet->getFields(); |
125 | 123 | |
126 | | - // Build Solr query string from the fields |
127 | | - if ( isset( $fields['solrsearch'] ) ) { |
128 | | - $query = $fields['solrsearch']; |
129 | | - } else { |
130 | | - $query = ''; |
131 | | - } |
| 124 | + //BUILD SOLR QUERY STRING FROM DA FIELDS |
| 125 | + if (isset($fields['solrsearch'])) { |
| 126 | + $query = $fields['solrsearch']; |
| 127 | + } else { |
| 128 | + $query = ''; |
| 129 | + } |
132 | 130 | |
133 | | - foreach ( $fields as $key => $value ) { |
134 | | - if ( $key != 'solrsearch' && !empty( $value ) ) { |
135 | | - $query = trim( $query ) . ' ' . trim( substr( $key, 4 ) ) . ':' . '(' . ( $value ) . ')'; |
136 | | - } |
137 | | - } |
138 | 131 | |
139 | | - if ( !empty( $query ) ) { |
140 | | - $query .= $fieldSet->getQuery(); |
141 | | - } |
| 132 | + foreach ($fields as $key => $value) { |
| 133 | + if ($key != 'solrsearch' && !empty($value)) { |
| 134 | + $query = trim($query).' '.trim(substr($key, 4)) . ':' . '(' . ($value) . ')'; |
| 135 | + } |
| 136 | + } |
142 | 137 | |
143 | | - $titleMatches = $search->searchTitle( $query ); |
| 138 | + if (!empty($query)) { |
| 139 | + $query .=$fieldSet->getQuery(); |
| 140 | + } |
| 141 | + // TODO: More Exception Handling for Format Exceptions |
| 142 | + try { |
| 143 | + $titleMatches = $search->searchTitle($query); |
144 | 144 | |
145 | | - if ( !( $titleMatches instanceof SearchResultTooMany ) ) { |
146 | | - $textMatches = $search->searchText( $query ); |
147 | | - } |
| 145 | + if (!($titleMatches instanceof SearchResultTooMany)) |
| 146 | + $textMatches = $search->searchText($query); |
148 | 147 | |
149 | | - // did you mean... suggestions |
150 | | - if ( $textMatches && $textMatches->hasSuggestion() ) { |
151 | | - $st = SpecialPage::getTitleFor( 'SolrSearch' ); |
| 148 | + // did you mean... suggestions |
| 149 | + if ($textMatches && $textMatches->hasSuggestion()) { |
| 150 | + $st = SpecialPage::getTitleFor('SolrSearch'); |
152 | 151 | |
153 | | - # mirror Go/Search behaviour of original request .. |
154 | | - $didYouMeanParams = array( 'solrsearch' => $textMatches->getSuggestionQuery() ); |
| 152 | + # mirror Go/Search behaviour of original request .. |
| 153 | + $didYouMeanParams = array('solrsearch' => $textMatches->getSuggestionQuery()); |
155 | 154 | |
156 | | - $stParams = $didYouMeanParams; |
| 155 | + $stParams = $didYouMeanParams; |
157 | 156 | |
158 | | - $suggestionSnippet = $textMatches->getSuggestionSnippet(); |
| 157 | + $suggestionSnippet = $textMatches->getSuggestionSnippet(); |
159 | 158 | |
160 | | - if ( $suggestionSnippet == '' ) { |
161 | | - $suggestionSnippet = null; |
162 | | - } |
| 159 | + if ($suggestionSnippet == '') |
| 160 | + $suggestionSnippet = null; |
163 | 161 | |
164 | | - $suggestLink = $sk->linkKnown( |
165 | | - $st, $suggestionSnippet, array(), $stParams |
166 | | - ); |
| 162 | + $suggestLink = $sk->linkKnown( |
| 163 | + $st, $suggestionSnippet, array(), $stParams |
| 164 | + ); |
167 | 165 | |
168 | | - $this->didYouMeanHtml = '<div class="searchdidyoumean">' . |
169 | | - wfMsg( 'search-suggest', $suggestLink ) . '</div>'; |
170 | | - } |
| 166 | + $this->didYouMeanHtml = '<div class="searchdidyoumean">' |
| 167 | + . wfMsg('search-suggest', $suggestLink) |
| 168 | + . '</div>'; |
| 169 | + } |
| 170 | + |
| 171 | + } catch ( Exception $exc ) { |
| 172 | + #Todo: Catch different Exceptions not just one for all |
| 173 | + $textMatches = false; |
| 174 | + $titleMatches = false; |
| 175 | + $wgOut -> addHTML ( '<p class="solr-error">' . wfMsg ( 'solrstore-error' ) . '<p\>' ); |
| 176 | + } |
| 177 | + // start rendering the page |
| 178 | + $wgOut->addHtml( |
| 179 | + Xml::openElement( |
| 180 | + 'form', array( |
| 181 | + 'id' => 'solrsearch', |
| 182 | + 'method' => 'get', |
| 183 | + 'action' => $wgScript |
| 184 | + ) |
| 185 | + ) |
| 186 | + ); |
| 187 | + $wgOut->addHtml( |
| 188 | + Xml::openElement('table', array('id' => 'mw-search-top-table', 'border' => 0, 'cellpadding' => 0, 'cellspacing' => 0)) . |
| 189 | + Xml::openElement('tr') . |
| 190 | + Xml::openElement('td') . "\n" . |
| 191 | + $this->shortDialog($fieldSet) . |
| 192 | + Xml::closeElement('td') . |
| 193 | + Xml::closeElement('tr') . |
| 194 | + Xml::closeElement('table') |
| 195 | + ); |
171 | 196 | |
172 | | - // start rendering the page |
173 | | - $wgOut->addHTML( |
174 | | - Xml::openElement( |
175 | | - 'form', |
176 | | - array( |
177 | | - 'id' => 'solrsearch', |
178 | | - 'method' => 'get', |
179 | | - 'action' => $wgScript |
180 | | - ) |
181 | | - ) |
182 | | - ); |
183 | | - $wgOut->addHTML( |
184 | | - Xml::openElement( 'table', array( 'id' => 'mw-search-top-table', 'border' => 0, 'cellpadding' => 0, 'cellspacing' => 0 ) ) . |
185 | | - Xml::openElement( 'tr' ) . |
186 | | - Xml::openElement( 'td' ) . "\n" . |
187 | | - $this->shortDialog( $fieldSet ) . |
188 | | - Xml::closeElement( 'td' ) . |
189 | | - Xml::closeElement( 'tr' ) . |
190 | | - Xml::closeElement( 'table' ) |
191 | | - ); |
| 197 | + // Sometimes the search engine knows there are too many hits |
| 198 | + if ($titleMatches instanceof SearchResultTooMany) { |
| 199 | + $wgOut->addWikiText('==' . wfMsg('toomanymatches') . "==\n"); |
| 200 | + wfProfileOut(__METHOD__); |
| 201 | + return; |
| 202 | + } |
192 | 203 | |
193 | | - // Sometimes the search engine knows there are too many hits |
194 | | - if ( $titleMatches instanceof SearchResultTooMany ) { |
195 | | - $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" ); |
196 | | - wfProfileOut( __METHOD__ ); |
197 | | - return; |
198 | | - } |
| 204 | + $filePrefix = $wgContLang->getFormattedNsText(NS_FILE) . ':'; |
| 205 | + if (trim($query) === '' || $filePrefix === trim($query)) { |
| 206 | + $wgOut->addHTML($this->formHeader($query, 0, 0)); |
| 207 | + $wgOut->addHTML('</form>'); |
| 208 | + // Empty query -- straight view of search form |
| 209 | + wfProfileOut(__METHOD__); |
| 210 | + return; |
| 211 | + } |
| 212 | + // Get number of results |
| 213 | + $titleMatchesNum = $titleMatches ? $titleMatches->numRows() : 0; |
| 214 | + $textMatchesNum = $textMatches ? $textMatches->numRows() : 0; |
| 215 | + // Total initial query matches (possible false positives) |
| 216 | + $num = $titleMatchesNum + $textMatchesNum; |
199 | 217 | |
200 | | - $filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':'; |
201 | | - if ( trim( $query ) === '' || $filePrefix === trim( $query ) ) { |
202 | | - $wgOut->addHTML( $this->formHeader( $query, 0, 0 ) ); |
203 | | - $wgOut->addHTML( '</form>' ); |
204 | | - // Empty query -- straight view of search form |
205 | | - wfProfileOut( __METHOD__ ); |
206 | | - return; |
207 | | - } |
208 | | - // Get number of results |
209 | | - $titleMatchesNum = $titleMatches ? $titleMatches->numRows() : 0; |
210 | | - $textMatchesNum = $textMatches ? $textMatches->numRows() : 0; |
211 | | - // Total initial query matches (possible false positives) |
212 | | - $num = $titleMatchesNum + $textMatchesNum; |
| 218 | + // Get total actual results (after second filtering, if any) |
| 219 | + $numTitleMatches = $titleMatches && !is_null($titleMatches->getTotalHits()) ? |
| 220 | + $titleMatches->getTotalHits() : $titleMatchesNum; |
| 221 | + $numTextMatches = $textMatches && !is_null($textMatches->getTotalHits()) ? |
| 222 | + $textMatches->getTotalHits() : $textMatchesNum; |
213 | 223 | |
214 | | - // Get total actual results (after second filtering, if any) |
215 | | - $numTitleMatches = $titleMatches && !is_null( $titleMatches->getTotalHits() ) ? |
216 | | - $titleMatches->getTotalHits() : $titleMatchesNum; |
217 | | - $numTextMatches = $textMatches && !is_null( $textMatches->getTotalHits() ) ? |
218 | | - $textMatches->getTotalHits() : $textMatchesNum; |
| 224 | + // get total number of results if backend can calculate it |
| 225 | + $totalRes = 0; |
| 226 | + if ($titleMatches && !is_null($titleMatches->getTotalHits())) |
| 227 | + $totalRes += $titleMatches->getTotalHits(); |
| 228 | + if ($textMatches && !is_null($textMatches->getTotalHits())) |
| 229 | + $totalRes += $textMatches->getTotalHits(); |
| 230 | + // show number of results and current offset |
| 231 | + $wgOut->addHTML($this->formHeader($query, $num, $totalRes)); |
219 | 232 | |
220 | | - // get total number of results if backend can calculate it |
221 | | - $totalRes = 0; |
222 | | - if ( $titleMatches && !is_null( $titleMatches->getTotalHits() ) ) |
223 | | - $totalRes += $titleMatches->getTotalHits(); |
224 | | - if ( $textMatches && !is_null( $textMatches->getTotalHits() ) ) |
225 | | - $totalRes += $textMatches->getTotalHits(); |
226 | | - // show number of results and current offset |
227 | | - $wgOut->addHTML( $this->formHeader( $query, $num, $totalRes ) ); |
| 233 | + $wgOut->addHtml(Xml::closeElement('form')); |
| 234 | + $wgOut->addHtml("<div class='searchresults'>"); |
228 | 235 | |
229 | | - $wgOut->addHTML( Xml::closeElement( 'form' ) ); |
230 | | - $wgOut->addHTML( "<div class='searchresults'>" ); |
| 236 | + // prev/next links |
| 237 | + if ($num || $this->offset) { |
| 238 | + // Show the create link ahead |
| 239 | + $this->showCreateLink($t); |
| 240 | + $prevnext = wfViewPrevNext($this->offset, $this->limit, SpecialPage::getTitleFor('SolrSearch'), wfArrayToCGI(array('solrsearch' => $query)), max($titleMatchesNum, $textMatchesNum) < $this->limit |
| 241 | + ); |
| 242 | + //$wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" ); |
| 243 | + wfRunHooks('SpecialSolrSearchResults', array($fieldSet, &$titleMatches, &$textMatches)); |
| 244 | + } else { |
| 245 | + wfRunHooks('SpecialSolrSearchNoResults', array($fieldSet)); |
| 246 | + } |
231 | 247 | |
232 | | - // prev/next links |
233 | | - if ( $num || $this->offset ) { |
234 | | - // Show the create link ahead |
235 | | - $this->showCreateLink( $t ); |
236 | | - $prevnext = wfViewPrevNext( |
237 | | - $this->offset, |
238 | | - $this->limit, |
239 | | - SpecialPage::getTitleFor( 'SolrSearch' ), |
240 | | - wfArrayToCGI( array( 'solrsearch' => $query ) ), |
241 | | - max( $titleMatchesNum, $textMatchesNum ) < $this->limit |
242 | | - ); |
243 | | - // $wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" ); |
244 | | - wfRunHooks( 'SpecialSolrSearchResults', array( $fieldSet, &$titleMatches, &$textMatches ) ); |
245 | | - } else { |
246 | | - wfRunHooks( 'SpecialSolrSearchNoResults', array( $fieldSet ) ); |
247 | | - } |
| 248 | + if ($titleMatches) { |
| 249 | + if ($numTitleMatches > 0) { |
| 250 | + $wgOut->wrapWikiMsg("==$1==\n", 'titlematches'); |
| 251 | + $wgOut->addHTML($this->showMatches($titleMatches)); |
| 252 | + } |
| 253 | + $titleMatches->free(); |
| 254 | + } |
| 255 | + if ($textMatches) { |
| 256 | + // output appropriate heading |
| 257 | + if ($numTextMatches > 0 && $numTitleMatches > 0) { |
| 258 | + // if no title matches the heading is redundant |
| 259 | + $wgOut->wrapWikiMsg("==$1==\n", 'textmatches'); |
| 260 | + } elseif ($totalRes == 0) { |
| 261 | + # Don't show the 'no text matches' if we received title matches |
| 262 | + # $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' ); |
| 263 | + } |
248 | 264 | |
249 | | - if ( $titleMatches ) { |
250 | | - if ( $numTitleMatches > 0 ) { |
251 | | - $wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' ); |
252 | | - $wgOut->addHTML( $this->showMatches( $titleMatches ) ); |
253 | | - } |
254 | | - $titleMatches->free(); |
255 | | - } |
256 | | - if ( $textMatches ) { |
257 | | - // output appropriate heading |
258 | | - if ( $numTextMatches > 0 && $numTitleMatches > 0 ) { |
259 | | - // if no title matches the heading is redundant |
260 | | - $wgOut->wrapWikiMsg( "==$1==\n", 'textmatches' ); |
261 | | - } elseif ( $totalRes == 0 ) { |
262 | | - # Don't show the 'no text matches' if we received title matches |
263 | | - # $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' ); |
264 | | - } |
| 265 | + // show results |
| 266 | + if ($numTextMatches > 0) { |
| 267 | + $wgOut->addHTML($this->showMatches($textMatches)); |
| 268 | + } |
265 | 269 | |
266 | | - // show results |
267 | | - if ( $numTextMatches > 0 ) { |
268 | | - $wgOut->addHTML( $this->showMatches( $textMatches ) ); |
269 | | - } |
| 270 | + $textMatches->free(); |
| 271 | + } |
270 | 272 | |
271 | | - $textMatches->free(); |
272 | | - } |
| 273 | + $wgOut->addHtml("</div>"); |
273 | 274 | |
274 | | - $wgOut->addHTML( '</div>' ); |
| 275 | + if ($num || $this->offset) { |
| 276 | + $wgOut->addHTML("<p class='mw-search-pager-bottom'>{$prevnext}</p>\n"); |
| 277 | + } |
| 278 | + wfProfileOut(__METHOD__); |
| 279 | + } |
275 | 280 | |
276 | | - if ( $num || $this->offset ) { |
277 | | - $wgOut->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" ); |
278 | | - } |
279 | | - wfProfileOut( __METHOD__ ); |
280 | | - } |
| 281 | + protected function showCreateLink($t) { |
| 282 | + global $wgOut; |
281 | 283 | |
282 | | - protected function showCreateLink( $t ) { |
283 | | - global $wgOut; |
| 284 | + // show direct page/create link if applicable |
| 285 | + $messageName = null; |
| 286 | + if (!is_null($t)) { |
| 287 | + if ($t->isKnown()) { |
| 288 | + $messageName = 'searchmenu-exists'; |
| 289 | + } elseif ($t->userCan('create')) { |
| 290 | + $messageName = 'searchmenu-new'; |
| 291 | + } else { |
| 292 | + $messageName = 'searchmenu-new-nocreate'; |
| 293 | + } |
| 294 | + } |
| 295 | + if ($messageName) { |
| 296 | + $wgOut->wrapWikiMsg("<p class=\"mw-search-createlink\">\n$1</p>", array($messageName, wfEscapeWikiText($t->getPrefixedText()))); |
| 297 | + } else { |
| 298 | + // preserve the paragraph for margins etc... |
| 299 | + $wgOut->addHtml('<p></p>'); |
| 300 | + } |
| 301 | + } |
284 | 302 | |
285 | | - // show direct page/create link if applicable |
286 | | - $messageName = null; |
287 | | - if ( !is_null( $t ) ) { |
288 | | - if ( $t->isKnown() ) { |
289 | | - $messageName = 'searchmenu-exists'; |
290 | | - } elseif ( $t->userCan( 'create' ) ) { |
291 | | - $messageName = 'searchmenu-new'; |
292 | | - } else { |
293 | | - $messageName = 'searchmenu-new-nocreate'; |
294 | | - } |
295 | | - } |
296 | | - if ( $messageName ) { |
297 | | - $wgOut->wrapWikiMsg( "<p class=\"mw-search-createlink\">\n$1</p>", |
298 | | - array( $messageName, wfEscapeWikiText( $t->getPrefixedText() ) ) ); |
299 | | - } else { |
300 | | - // preserve the paragraph for margins etc... |
301 | | - $wgOut->addHtml( '<p></p>' ); |
302 | | - } |
303 | | - } |
| 303 | + /** |
| 304 | + * |
| 305 | + */ |
| 306 | + protected function setupPage($fieldSet) { |
| 307 | + global $wgOut; |
304 | 308 | |
305 | | - /** |
306 | | - * |
307 | | - */ |
308 | | - protected function setupPage( $fieldSet ) { |
309 | | - global $wgOut; |
| 309 | + if (!empty($fieldSet)) { |
| 310 | + $wgOut->setPageTitle(wfMsg('searchresults')); |
| 311 | + $wgOut->setHTMLTitle(wfMsg('pagetitle', wfMsg('searchresults-title', $fieldSet->getName()))); |
| 312 | + } |
| 313 | + $wgOut->setArticleRelated(false); |
| 314 | + $wgOut->setRobotPolicy('noindex,nofollow'); |
| 315 | + // add javascript specific to special:search |
| 316 | + $wgOut->addModules('mediawiki.legacy.search'); |
| 317 | + $wgOut->addModules('mediawiki.special.search'); |
| 318 | + } |
310 | 319 | |
311 | | - if ( !empty( $fieldSet ) ) { |
312 | | - $wgOut->setPageTitle( wfMsg( 'searchresults' ) ); |
313 | | - $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'searchresults-title', $fieldSet->getName() ) ) ); |
314 | | - } |
315 | | - $wgOut->setArticleRelated( false ); |
316 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
317 | | - // add JavaScript specific to Special:Search |
318 | | - $wgOut->addModules( 'mediawiki.legacy.search' ); |
319 | | - $wgOut->addModules( 'mediawiki.special.search' ); |
320 | | - } |
| 320 | + /** |
| 321 | + * Show whole set of results |
| 322 | + * |
| 323 | + * @param $matches SearchResultSet |
| 324 | + */ |
| 325 | + protected function showMatches(&$matches) { |
| 326 | + global $wgContLang; |
| 327 | + wfProfileIn(__METHOD__); |
321 | 328 | |
322 | | - /** |
323 | | - * Show whole set of results |
324 | | - * |
325 | | - * @param $matches SearchResultSet |
326 | | - */ |
327 | | - protected function showMatches( &$matches ) { |
328 | | - global $wgContLang; |
329 | | - wfProfileIn( __METHOD__ ); |
| 329 | + $fieldSets = $wgContLang->convertForSearchResult($matches->termMatches()); |
330 | 330 | |
331 | | - $fieldSets = $wgContLang->convertForSearchResult( $matches->termMatches() ); |
| 331 | + $out = ""; |
| 332 | + $infoLine = $matches->getInfo(); |
| 333 | + if (!is_null($infoLine)) { |
| 334 | + $out .= "\n<!-- {$infoLine} -->\n"; |
| 335 | + } |
| 336 | + $out .= "<ul class='mw-search-results'>\n"; |
| 337 | + $xxx = 0; |
| 338 | + while ($result = $matches->next()) { |
| 339 | + $out .= $this->showHit($result, $fieldSets); |
| 340 | + } |
| 341 | + $out .= "</ul>\n"; |
332 | 342 | |
333 | | - $out = ''; |
334 | | - $infoLine = $matches->getInfo(); |
335 | | - if ( !is_null( $infoLine ) ) { |
336 | | - $out .= "\n<!-- {$infoLine} -->\n"; |
337 | | - } |
338 | | - $out .= "<ul class='mw-search-results'>\n"; |
339 | | - while ( $result = $matches->next() ) { |
340 | | - $out .= $this->showHit( $result, $fieldSets ); |
341 | | - } |
342 | | - $out .= "</ul>\n"; |
| 343 | + // convert the whole thing to desired language variant |
| 344 | + $out = $wgContLang->convert($out); |
| 345 | + wfProfileOut(__METHOD__); |
| 346 | + return $out; |
| 347 | + } |
343 | 348 | |
344 | | - // convert the whole thing to desired language variant |
345 | | - $out = $wgContLang->convert( $out ); |
346 | | - wfProfileOut( __METHOD__ ); |
347 | | - return $out; |
348 | | - } |
| 349 | + /** |
| 350 | + * Format a single hit result |
| 351 | + * |
| 352 | + * @param $result SearchResult |
| 353 | + * @param $fieldSets Array: terms to highlight |
| 354 | + */ |
| 355 | + protected function showHit($result, $fieldSets) { |
| 356 | + global $wgLang, $wgUser; |
| 357 | + wfProfileIn(__METHOD__); |
349 | 358 | |
350 | | - /** |
351 | | - * Format a single hit result |
352 | | - * |
353 | | - * @param $result SearchResult |
354 | | - * @param $fieldSets Array: terms to highlight |
355 | | - */ |
356 | | - protected function showHit( $result, $fieldSets ) { |
357 | | - global $wgLang, $wgUser; |
358 | | - wfProfileIn( __METHOD__ ); |
| 359 | + if ($result->isBrokenTitle()) { |
| 360 | + wfProfileOut(__METHOD__); |
| 361 | + return "<!-- Broken link in search result -->\n"; |
| 362 | + } |
359 | 363 | |
360 | | - if ( $result->isBrokenTitle() ) { |
361 | | - wfProfileOut( __METHOD__ ); |
362 | | - return "<!-- Broken link in search result -->\n"; |
363 | | - } |
| 364 | + $sk = $wgUser->getSkin(); |
| 365 | + $t = $result->getTitle(); |
364 | 366 | |
365 | | - $sk = $wgUser->getSkin(); |
366 | | - $t = $result->getTitle(); |
| 367 | + $titleSnippet = $result->getTitleSnippet($fieldSets); |
367 | 368 | |
368 | | - $titleSnippet = $result->getTitleSnippet( $fieldSets ); |
| 369 | + if ($titleSnippet == '') |
| 370 | + $titleSnippet = null; |
369 | 371 | |
370 | | - if ( $titleSnippet == '' ) { |
371 | | - $titleSnippet = null; |
372 | | - } |
| 372 | + $link_t = clone $t; |
373 | 373 | |
374 | | - $link_t = clone $t; |
| 374 | + wfRunHooks('ShowSearchHitTitle', array(&$link_t, &$titleSnippet, $result, $fieldSets, $this)); |
375 | 375 | |
376 | | - wfRunHooks( 'ShowSearchHitTitle', array( &$link_t, &$titleSnippet, $result, $fieldSets, $this ) ); |
| 376 | + $link = $this->sk->linkKnown( |
| 377 | + $link_t, $titleSnippet |
| 378 | + ); |
| 379 | + // FÜLLEN |
| 380 | + //If page content is not readable, just return the title. |
| 381 | + //This is not quite safe, but better than showing excerpts from non-readable pages |
| 382 | + //Note that hiding the entry entirely would screw up paging. |
| 383 | + // ---- HIER |
| 384 | + if (!$t->userCanRead()) { |
| 385 | + wfProfileOut(__METHOD__); |
| 386 | + return "<li>{$link}</li>\n"; |
| 387 | + } |
| 388 | + //return "<li>{$link}</li>\n"; |
| 389 | + // If the page doesn't *exist*... our search index is out of date. |
| 390 | + // The least confusing at this point is to drop the result. |
| 391 | + // You may get less results, but... oh well. :P |
| 392 | + // ---- HIER |
| 393 | + if ($result->isMissingRevision()) { |
| 394 | + wfProfileOut(__METHOD__); |
| 395 | + return "<!-- missing page " . htmlspecialchars($t->getPrefixedText()) . "-->\n"; |
| 396 | + } |
377 | 397 | |
378 | | - $link = $this->sk->linkKnown( |
379 | | - $link_t, $titleSnippet |
380 | | - ); |
381 | | - // FÜLLEN |
382 | | - // If page content is not readable, just return the title. |
383 | | - // This is not quite safe, but better than showing excerpts from non-readable pages |
384 | | - // Note that hiding the entry entirely would screw up paging. |
385 | | - // ---- HIER |
386 | | - if ( !$t->userCanRead() ) { |
387 | | - wfProfileOut( __METHOD__ ); |
388 | | - return "<li>{$link}</li>\n"; |
389 | | - } |
390 | | - // return "<li>{$link}</li>\n"; |
391 | | - // If the page doesn't *exist*... our search index is out of date. |
392 | | - // The least confusing at this point is to drop the result. |
393 | | - // You may get less results, but... oh well. :P |
394 | | - // ---- HIER |
395 | | - if ( $result->isMissingRevision() ) { |
396 | | - wfProfileOut( __METHOD__ ); |
397 | | - return "<!-- missing page " . htmlspecialchars( $t->getPrefixedText() ) . "-->\n"; |
398 | | - } |
| 398 | + // format redirects / relevant sections |
| 399 | + $redirectTitle = $result->getRedirectTitle(); |
| 400 | + $redirectText = $result->getRedirectSnippet($fieldSets); |
| 401 | + $sectionTitle = $result->getSectionTitle(); |
| 402 | + $sectionText = $result->getSectionSnippet($fieldSets); |
| 403 | + $redirect = ''; |
399 | 404 | |
400 | | - // format redirects / relevant sections |
401 | | - $redirectTitle = $result->getRedirectTitle(); |
402 | | - $redirectText = $result->getRedirectSnippet( $fieldSets ); |
403 | | - $sectionTitle = $result->getSectionTitle(); |
404 | | - $sectionText = $result->getSectionSnippet( $fieldSets ); |
405 | | - $redirect = ''; |
| 405 | + if (!is_null($redirectTitle)) { |
| 406 | + if ($redirectText == '') |
| 407 | + $redirectText = null; |
406 | 408 | |
407 | | - if ( !is_null( $redirectTitle ) ) { |
408 | | - if ( $redirectText == '' ) { |
409 | | - $redirectText = null; |
410 | | - } |
| 409 | + $redirect = "<span class='searchalttitle'>" . |
| 410 | + wfMsg('search-redirect', $this->sk->linkKnown($redirectTitle, $redirectText)) . |
| 411 | + "</span>"; |
| 412 | + } |
411 | 413 | |
412 | | - $redirect = '<span class="searchalttitle">' . |
413 | | - wfMsg( 'search-redirect', $this->sk->linkKnown( $redirectTitle, $redirectText ) ) . |
414 | | - '</span>'; |
415 | | - } |
| 414 | + $section = ''; |
416 | 415 | |
417 | | - $section = ''; |
418 | 416 | |
| 417 | + if (!is_null($sectionTitle)) { |
| 418 | + if ($sectionText == '') |
| 419 | + $sectionText = null; |
419 | 420 | |
420 | | - if ( !is_null( $sectionTitle ) ) { |
421 | | - if ( $sectionText == '' ) { |
422 | | - $sectionText = null; |
423 | | - } |
| 421 | + $section = "<span class='searchalttitle'>" . |
| 422 | + wfMsg('search-section', $this->sk->linkKnown($sectionTitle, $sectionText)) . |
| 423 | + "</span>"; |
| 424 | + } |
424 | 425 | |
425 | | - $section = '<span class="searchalttitle">' . |
426 | | - wfMsg( 'search-section', $this->sk->linkKnown( $sectionTitle, $sectionText ) ) . |
427 | | - '</span>'; |
428 | | - } |
| 426 | + // format text extract |
| 427 | + $extract = "<div class='searchresult'>" . $result->getTextSnippet($fieldSets) . "</div>"; |
429 | 428 | |
430 | | - // format text extract |
431 | | - $extract = '<div class="searchresult">' . $result->getTextSnippet( $fieldSets ) . '</div>'; |
| 429 | + // format score |
| 430 | + if (is_null($result->getScore())) { |
| 431 | + // Search engine doesn't report scoring info |
| 432 | + $score = ''; |
| 433 | + } else { |
| 434 | + $percent = sprintf('%2.1f', $result->getScore() * 100); |
| 435 | + $score = wfMsg('search-result-score', $wgLang->formatNum($percent)) . ' - '; |
| 436 | + } |
432 | 437 | |
433 | | - // format score |
434 | | - if ( is_null( $result->getScore() ) ) { |
435 | | - // Search engine doesn't report scoring info |
436 | | - $score = ''; |
437 | | - } else { |
438 | | - $percent = sprintf( '%2.1f', $result->getScore() * 100 ); |
439 | | - $score = wfMsg( 'search-result-score', $wgLang->formatNum( $percent ) ) . ' - '; |
440 | | - } |
| 438 | + // format description |
| 439 | + $byteSize = $result->getByteSize(); |
| 440 | + $wordCount = $result->getWordCount(); |
| 441 | + $timestamp = $result->getTimestamp(); |
| 442 | + $size = wfMsgExt('search-result-size', array('parsemag', 'escape'), $this->sk->formatSize($byteSize), $wgLang->formatNum($wordCount)); |
441 | 443 | |
442 | | - // format description |
443 | | - $byteSize = $result->getByteSize(); |
444 | | - $wordCount = $result->getWordCount(); |
445 | | - $timestamp = $result->getTimestamp(); |
446 | | - $size = wfMsgExt( 'search-result-size', array( 'parsemag', 'escape' ), |
447 | | - $this->sk->formatSize( $byteSize ), $wgLang->formatNum( $wordCount ) ); |
| 444 | + if ($t->getNamespace() == NS_CATEGORY) { |
| 445 | + $cat = Category::newFromTitle($t); |
| 446 | + $size = wfMsgExt('search-result-category-size', array('parsemag', 'escape'), $wgLang->formatNum($cat->getPageCount()), $wgLang->formatNum($cat->getSubcatCount()), $wgLang->formatNum($cat->getFileCount())); |
| 447 | + } |
448 | 448 | |
449 | | - if ( $t->getNamespace() == NS_CATEGORY ) { |
450 | | - $cat = Category::newFromTitle( $t ); |
451 | | - $size = wfMsgExt( 'search-result-category-size', array( 'parsemag', 'escape' ), |
452 | | - $wgLang->formatNum( $cat->getPageCount() ), |
453 | | - $wgLang->formatNum( $cat->getSubcatCount() ), |
454 | | - $wgLang->formatNum( $cat->getFileCount() ) ); |
455 | | - } |
| 449 | + $date = $wgLang->timeanddate($timestamp); |
456 | 450 | |
457 | | - $date = $wgLang->timeanddate( $timestamp ); |
| 451 | + // link to related articles if supported |
| 452 | + $related = ''; |
| 453 | + if ($result->hasRelated()) { |
| 454 | + $st = SpecialPage::getTitleFor('SolrSearch'); |
| 455 | + $stParams = array('solrsearch' => wfMsgForContent('searchrelated') . ':' . $t->getPrefixedText()); |
| 456 | + $related = ' -- ' . $sk->linkKnown($st, wfMsg('search-relatedarticle'), array(), $stParams); |
| 457 | + } |
458 | 458 | |
459 | | - // link to related articles if supported |
460 | | - $related = ''; |
461 | | - if ( $result->hasRelated() ) { |
462 | | - $st = SpecialPage::getTitleFor( 'SolrSearch' ); |
463 | | - $stParams = array( 'solrsearch' => wfMsgForContent( 'searchrelated' ) . ':' . $t->getPrefixedText() ); |
464 | | - $related = ' -- ' . $sk->linkKnown( $st, wfMsg( 'search-relatedarticle' ), array(), $stParams ); |
465 | | - } |
| 459 | + // Include a thumbnail for media files... |
| 460 | + // WE HAVE NEVER TESTED THIS HERE!!! |
| 461 | + if ($t->getNamespace() == NS_FILE) { |
| 462 | + $img = wfFindFile($t); |
| 463 | + if ($img) { |
| 464 | + $thumb = $img->transform(array('width' => 120, 'height' => 120)); |
| 465 | + if ($thumb) { |
| 466 | + $desc = wfMsg('parentheses', $img->getShortDesc()); |
| 467 | + wfProfileOut(__METHOD__); |
| 468 | + // Float doesn't seem to interact well with the bullets. |
| 469 | + // Table messes up vertical alignment of the bullets. |
| 470 | + // Bullets are therefore disabled (didn't look great anyway). |
| 471 | + return "<li>" . |
| 472 | + '<table class="searchResultImage">' . |
| 473 | + '<tr>' . |
| 474 | + '<td width="120" align="center" valign="top">' . |
| 475 | + $thumb->toHtml(array('desc-link' => true)) . |
| 476 | + '</td>' . |
| 477 | + '<td valign="top">' . |
| 478 | + $link . |
| 479 | + $extract . |
| 480 | + "<div class='mw-search-result-data'>{$score}{$desc}{$date}{$related}</div>" . |
| 481 | + '</td>' . |
| 482 | + '</tr>' . |
| 483 | + '</table>' . |
| 484 | + "</li>\n"; |
| 485 | + } |
| 486 | + } |
| 487 | + } |
466 | 488 | |
467 | | - // Include a thumbnail for media files... |
468 | | - // WE HAVE NEVER TESTED THIS HERE! |
469 | | - if ( $t->getNamespace() == NS_FILE ) { |
470 | | - $img = wfFindFile( $t ); |
471 | | - if ( $img ) { |
472 | | - $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) ); |
473 | | - if ( $thumb ) { |
474 | | - $desc = wfMsg( 'parentheses', $img->getShortDesc() ); |
475 | | - wfProfileOut( __METHOD__ ); |
476 | | - // Float doesn't seem to interact well with the bullets. |
477 | | - // Table messes up vertical alignment of the bullets. |
478 | | - // Bullets are therefore disabled (didn't look great anyway). |
479 | | - return '<li>' . |
480 | | - '<table class="searchResultImage">' . |
481 | | - '<tr>' . |
482 | | - '<td width="120" align="center" valign="top">' . |
483 | | - $thumb->toHtml( array( 'desc-link' => true ) ) . |
484 | | - '</td>' . |
485 | | - '<td valign="top">' . |
486 | | - $link . |
487 | | - $extract . |
488 | | - "<div class='mw-search-result-data'>{$score}{$desc}{$date}{$related}</div>" . |
489 | | - '</td>' . |
490 | | - '</tr>' . |
491 | | - '</table>' . |
492 | | - "</li>\n"; |
493 | | - } |
494 | | - } |
495 | | - } |
| 489 | + wfProfileOut(__METHOD__); |
| 490 | + // HIER kommt die score ausgabe: |
| 491 | + return "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section}</div> {$extract}\n" . |
| 492 | + "<div class='mw-search-result-data'>{$score}{$date}{$related}</div>" . |
| 493 | + "</li>\n"; |
| 494 | + } |
496 | 495 | |
497 | | - wfProfileOut( __METHOD__ ); |
498 | | - // HIER kommt die score ausgabe: |
499 | | - return "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section}</div> {$extract}\n" . |
500 | | - "<div class='mw-search-result-data'>{$score}{$date}{$related}</div>" . |
501 | | - "</li>\n"; |
502 | | - } |
| 496 | + protected function formHeader($fieldSet, $resultsShown, $totalNum) { |
| 497 | + global $wgLang; |
503 | 498 | |
504 | | - protected function formHeader( $fieldSet, $resultsShown, $totalNum ) { |
505 | | - global $wgLang; |
| 499 | + $out = Xml::openElement('div', array('class' => 'mw-search-formheader')); |
506 | 500 | |
507 | | - $out = Xml::openElement( 'div', array( 'class' => 'mw-search-formheader' ) ); |
| 501 | + // Results-info |
| 502 | + if ($resultsShown > 0) { |
| 503 | + if ($totalNum > 0) { |
| 504 | + $top = wfMsgExt('showingresultsheader', array('parseinline'), $wgLang->formatNum($this->offset + 1), $wgLang->formatNum($this->offset + $resultsShown), $wgLang->formatNum($totalNum), $wgLang->formatNum($resultsShown) |
| 505 | + ); |
| 506 | + } elseif ($resultsShown >= $this->limit) { |
| 507 | + $top = wfShowingResults($this->offset, $this->limit); |
| 508 | + } else { |
| 509 | + $top = wfShowingResultsNum($this->offset, $this->limit, $resultsShown); |
| 510 | + } |
| 511 | + $out .= Xml::tags('div', array('class' => 'results-info'), Xml::tags('ul', null, Xml::tags('li', null, $top))); |
| 512 | + } |
508 | 513 | |
509 | | - // Results-info |
510 | | - if ( $resultsShown > 0 ) { |
511 | | - if ( $totalNum > 0 ) { |
512 | | - $top = wfMsgExt( |
513 | | - 'showingresultsheader', |
514 | | - array( 'parseinline' ), |
515 | | - $wgLang->formatNum( $this->offset + 1 ), |
516 | | - $wgLang->formatNum( $this->offset + $resultsShown ), |
517 | | - $wgLang->formatNum( $totalNum ), |
518 | | - $wgLang->formatNum( $resultsShown ) |
519 | | - ); |
520 | | - } elseif ( $resultsShown >= $this->limit ) { |
521 | | - $top = wfShowingResults( $this->offset, $this->limit ); |
522 | | - } else { |
523 | | - $top = wfShowingResultsNum( $this->offset, $this->limit, $resultsShown ); |
524 | | - } |
525 | | - $out .= Xml::tags( 'div', array( 'class' => 'results-info' ), Xml::tags( 'ul', null, Xml::tags( 'li', null, $top ) ) ); |
526 | | - } |
| 514 | + $out .= Xml::element('div', array('style' => 'clear:both'), '', false); |
| 515 | + $out .= Xml::closeElement('div'); |
527 | 516 | |
528 | | - $out .= Xml::element( 'div', array( 'style' => 'clear:both' ), '', false ); |
529 | | - $out .= Xml::closeElement( 'div' ); |
| 517 | + return $out; |
| 518 | + } |
530 | 519 | |
531 | | - return $out; |
532 | | - } |
| 520 | + protected function shortDialog($fieldSet) { |
| 521 | + $searchTitle = SpecialPage::getTitleFor('SolrSearch'); |
533 | 522 | |
534 | | - protected function shortDialog( $fieldSet ) { |
535 | | - $searchTitle = SpecialPage::getTitleFor( 'SolrSearch' ); |
536 | 523 | |
537 | | - if ( $fieldSet->getName() != 'search' ) { |
538 | | - $out = Html::hidden( 'title', $searchTitle->getPrefixedText() . '/' . $fieldSet->getName() ) . "\n"; |
539 | | - } else { |
540 | | - $out = Html::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n"; |
541 | | - } |
542 | | - // Term box |
| 524 | + if ($fieldSet->getName() != 'search') { |
| 525 | + $out = Html::hidden('title', $searchTitle->getPrefixedText() . '/' . $fieldSet->getName()) . "\n"; |
| 526 | + } else { |
| 527 | + $out = Html::hidden('title', $searchTitle->getPrefixedText()) . "\n"; |
| 528 | + } |
| 529 | + // Term box |
543 | 530 | |
544 | | - $lable = $fieldSet->getLable(); |
545 | | - $out .= '<table>'; |
| 531 | + $lable = $fieldSet->getLable(); |
| 532 | + $out .= '<table>'; |
546 | 533 | |
547 | | - foreach ( $fieldSet->getFields() as $key => $value ) { |
548 | | - $out .= '<tr>'; |
549 | | - if ( isset( $lable[$key] ) ) { |
550 | | - $out .= '<th>' . $lable[$key] . '</th>'; |
551 | | - } |
552 | | - $out .= '<td>'; |
553 | | - $out .= Html::input( $key, $value, $key, array( |
554 | | - 'id' => $key, |
555 | | - 'size' => '50', |
556 | | - 'autofocus' |
557 | | - ) ) . "\n"; |
558 | | - $out .= '</td></tr>'; |
559 | | - } |
560 | | - $out .= '<table>'; |
561 | | - $out .= Xml::submitButton( wfMsg( 'searchbutton' ) ) . "\n"; |
562 | | - return $out . $this->didYouMeanHtml; |
563 | | - } |
| 534 | + foreach ($fieldSet->getFields() as $key => $value) { |
| 535 | + $out .= '<tr>'; |
| 536 | + if (isset($lable[$key])) { |
| 537 | + $out .= '<th>' . $lable[$key] . '</th>'; |
| 538 | + } |
| 539 | + $out .= '<td>'; |
| 540 | + $out .= Html::input($key, $value, $key, array( |
| 541 | + 'id' => $key, |
| 542 | + 'size' => '50', |
| 543 | + 'autofocus' |
| 544 | + )) . "\n"; |
| 545 | + $out .= '</td></tr>'; |
| 546 | + } |
| 547 | + $out .= '<table>'; |
| 548 | + $out .= Xml::submitButton(wfMsg('searchbutton')) . "\n"; |
| 549 | + return $out . $this->didYouMeanHtml; |
| 550 | + } |
564 | 551 | |
565 | 552 | } |
| 553 | + |
| 554 | +?> |
\ No newline at end of file |