r109519 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109518‎ | r109519 | r109520 >
Date:10:50, 19 January 2012
Author:sbachenberg
Status:deferred
Tags:
Comment:
Fixed: Format from Last commit
Modified paths:
  • /trunk/extensions/SolrStore/SolrStore.i18n.php (modified) (history)
  • /trunk/extensions/SolrStore/SpecialSolrSearch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SolrStore/SolrStore.i18n.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 /**
45 * SolrStore: The SolrStore Extesion is Semantic Mediawiki Searchprovieder based on Apache Solr.
56 *
@@ -6,12 +7,12 @@
78 * @file
89 * @author Simon Bachenberg
910 */
10 -$messages = array();
 11+$messages = array ( );
1112
12 -$messages['en'] = array(
 13+$messages[ 'en' ] = array (
1314 'solrstore-desc' => 'Search semantic properties with the power of a fulltext search engine',
1415 'solrsearch' => 'SolrSearch',
15 - 'solrstore-error' => 'Error: Please Check your Query',
 16+ 'solrstore-error' => 'Error: Please Check your Query',
1617 'solrstore-searchFieldSets' => 'SolrSearch',
1718 'solrstore-searchFieldSets-select' => 'Please select a SearchSet',
1819 'solrstore-searchFieldSets-title' => 'SolrSearch: SearchSet select',
@@ -21,10 +22,10 @@
2223 * @author F.trott
2324 * @author Siebrand
2425 */
25 -$messages['qqq'] = array(
 26+$messages[ 'qqq' ] = array (
2627 'solrstore-desc' => '{{desc}}',
2728 '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"',
 29+ 'solrstore-error' => 'Currently we have just One Error Message, "Error: Please Check your Query"',
2930 'solrstore-searchFieldSets' => 'The pagetitle (heading) of the Special:SolrSearch page',
3031 'solrstore-searchFieldSets-select' => 'A SearchSet is a predefined search form for a field based search.',
3132 'solrstore-searchFieldSets-title' => 'The title of the Special:SolrSearch page. A SearchSet is a predefined search form for a field based search.',
@@ -35,7 +36,7 @@
3637 * @author Jim-by
3738 * @author Wizardist
3839 */
39 -$messages['be-tarask'] = array(
 40+$messages[ 'be-tarask' ] = array (
4041 'solrstore-desc' => 'Пошук сэмантычных уласьцівасьцяў з выкарыстаньнем рухавіка поўнатэкстнага пошуку',
4142 'solrsearch' => 'SolrSearch',
4243 'solrstore-searchFieldSets' => 'SolrSearch',
@@ -47,10 +48,10 @@
4849 * @author Kghbln
4950 * @author SBachenberg
5051 */
51 -$messages['de'] = array(
 52+$messages[ 'de' ] = array (
5253 'solrstore-desc' => 'Ermöglicht die Suche nach semantischen Attributen mit einer Volltextsuchmaschine',
5354 'solrsearch' => 'SolrSuche',
54 - 'solrstore-error' => 'Fehler: Bitte überprüfen Sie ihre Suchanfrage',
 55+ 'solrstore-error' => 'Fehler: Bitte überprüfen Sie ihre Suchanfrage',
5556 'solrstore-searchFieldSets' => 'SolrSuche',
5657 'solrstore-searchFieldSets-select' => 'Bitte wähle ein SearchSet aus',
5758 'solrstore-searchFieldSets-title' => 'SolrSearch: SearchSet Auswahl',
@@ -59,7 +60,7 @@
6061 /** French (Français)
6162 * @author Gomoko
6263 */
63 -$messages['fr'] = array(
 64+$messages[ 'fr' ] = array (
6465 'solrstore-desc' => "Rechercher des propriétés avec la puissance d'un moteur de recherche plein texte",
6566 'solrsearch' => 'SolrSearch',
6667 'solrstore-searchFieldSets' => 'SolrSearch',
@@ -70,7 +71,7 @@
7172 /** Galician (Galego)
7273 * @author Toliño
7374 */
74 -$messages['gl'] = array(
 75+$messages[ 'gl' ] = array (
7576 'solrstore-desc' => 'Procurar propiedades semánticas co poder dun motor de procuras de texto',
7677 'solrsearch' => 'SolrSearch',
7778 'solrstore-searchFieldSets' => 'SolrSearch',
@@ -81,7 +82,7 @@
8283 /** Upper Sorbian (Hornjoserbsce)
8384 * @author Michawiki
8485 */
85 -$messages['hsb'] = array(
 86+$messages[ 'hsb' ] = array (
8687 'solrstore-desc' => 'Pytanje za semantiskimi atributami z połnotekstowej pytawu',
8788 'solrsearch' => 'SolrSearch',
8889 'solrstore-searchFieldSets' => 'SolrSearch',
@@ -92,7 +93,7 @@
9394 /** Interlingua (Interlingua)
9495 * @author McDutchie
9596 */
96 -$messages['ia'] = array(
 97+$messages[ 'ia' ] = array (
9798 'solrstore-desc' => 'Cercar proprietates semantic con le poter de un motor de recerca de plen texto',
9899 'solrsearch' => 'SolrSearch',
99100 'solrstore-searchFieldSets' => 'SolrSearch',
@@ -103,7 +104,7 @@
104105 /** Luxembourgish (Lëtzebuergesch)
105106 * @author Robby
106107 */
107 -$messages['lb'] = array(
 108+$messages[ 'lb' ] = array (
108109 'solrsearch' => 'SolrSich',
109110 'solrstore-searchFieldSets' => 'SolrSich',
110111 );
@@ -111,7 +112,7 @@
112113 /** Macedonian (Македонски)
113114 * @author Bjankuloski06
114115 */
115 -$messages['mk'] = array(
 116+$messages[ 'mk' ] = array (
116117 'solrstore-desc' => 'Пребарување на семантички својства со способностите на пребарувачот на полн текст',
117118 'solrsearch' => 'SolrSearch',
118119 'solrstore-searchFieldSets' => 'SolrSearch',
@@ -122,7 +123,7 @@
123124 /** Dutch (Nederlands)
124125 * @author Siebrand
125126 */
126 -$messages['nl'] = array(
 127+$messages[ 'nl' ] = array (
127128 'solrstore-desc' => 'Semantische eigenschappen doorzoeken met de kracht van een fulltext zoekmachine',
128129 'solrsearch' => 'SolrSearch',
129130 'solrstore-searchFieldSets' => 'SolrSearch',
@@ -134,7 +135,7 @@
135136 * @author Borichèt
136137 * @author Dragonòt
137138 */
138 -$messages['pms'] = array(
 139+$messages[ 'pms' ] = array (
139140 'solrstore-desc' => "Arserché dle proprietà semàntiche con la potensa d'un motor d'arserca a test pien",
140141 'solrsearch' => 'SolrSearch',
141142 'solrstore-searchFieldSets' => 'SolrSearch',
@@ -145,7 +146,7 @@
146147 /** Russian (Русский)
147148 * @author Eleferen
148149 */
149 -$messages['ru'] = array(
 150+$messages[ 'ru' ] = array (
150151 'solrstore-desc' => 'Семантический поиск с использованием ресурсов полнотекстовой поисковой системы',
151152 'solrsearch' => 'SolrSearch',
152153 'solrstore-searchFieldSets' => 'SolrSearch',
Index: trunk/extensions/SolrStore/SpecialSolrSearch.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 /**
45 * SolrStore: The SolrStore Extesion is Semantic Mediawiki Searchprovieder based on Apache Solr.
56 *
@@ -9,545 +10,544 @@
1011 */
1112 class SpecialSolrSearch extends SpecialPage {
1213
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');
 14+ /**
 15+ * Set up basic search parameters from the request and user settings.
 16+ * Typically you'll pass $wgRequest and $wgUser.
 17+ *
 18+ * @param $request WebRequest
 19+ * @param $user User
 20+ */
 21+ public function __construct () {
 22+ parent::__construct ( "SolrSearch" );
 23+ global $wgRequest, $wgUser, $wgOut, $wgSolrFields;
 24+ $user = $wgUser;
 25+ $request = $wgRequest;
 26+ list( $this->limit, $this->offset ) = $request->getLimitOffset ( 20, 'searchlimit' );
2627
27 - $this->sk = $user->getSkin();
28 - $this->didYouMeanHtml = ''; # html of did you mean... link
29 - }
 28+ $this->sk = $user->getSkin ();
 29+ $this->didYouMeanHtml = ''; # html of did you mean... link
 30+ }
3031
31 - function execute($par) {
32 - global $wgRequest, $wgUser, $wgOut, $wgSolrFields;
 32+ function execute ( $par ) {
 33+ global $wgRequest, $wgUser, $wgOut, $wgSolrFields;
3334
34 - $this->setHeaders();
35 - $SpecialSolrSearch = new SpecialSolrSearch($wgRequest, $wgUser);
 35+ $this->setHeaders ();
 36+ $SpecialSolrSearch = new SpecialSolrSearch ( $wgRequest, $wgUser );
3637
37 - # Get request data from, e.g.
38 - $param = $wgRequest->getText('param');
 38+ # Get request data from, e.g.
 39+ $param = $wgRequest->getText ( 'param' );
3940
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
 41+ foreach ( $wgSolrFields as $set ) {
 42+ if ( $par == $set->getName () ) {
 43+ $fieldSet = $set;
 44+ }
 45+ }
 46+ # Do stuff
 47+ # ...
 48+ // Strip underscores from title parameter; most of the time we'll want
 49+ // text form here. But don't strip underscores from actual text params!
 50+ $titleParam = str_replace ( '_', ' ', $par );
 51+ // Fetch the search term
5152 // $search = str_replace("\n", " ", $wgRequest->getText('solrsearch', $titleParam));
5253
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 - }
 54+ if ( !isset ( $fieldSet ) ) {
 55+ $SpecialSolrSearch->showFieldSets ();
 56+ } else {
 57+ $lable = $fieldSet->getLable ();
 58+ $firstTimeHere = true;
 59+ foreach ( $fieldSet->getFields () as $field ) {
 60+ if ( $firstTimeHere ) {
 61+ $newLable [ 'solr' . trim ( $field ) ] = trim ( $lable[ 0 ] );
 62+ $firstTimeHere = false;
 63+ } else {
 64+ $newLable [ 'solr' . trim ( $field ) ] = trim ( next ( $lable ) );
 65+ }
6566
66 - $newFields ['solr' . trim($field)] = $wgRequest->getText('solr' . trim($field));
67 - }
68 - $fieldSet->setFields($newFields);
69 - $fieldSet->setLable($newLable);
 67+ $newFields [ 'solr' . trim ( $field ) ] = $wgRequest->getText ( 'solr' . trim ( $field ) );
 68+ }
 69+ $fieldSet->setFields ( $newFields );
 70+ $fieldSet->setLable ( $newLable );
7071
71 - $SpecialSolrSearch->showResults($fieldSet);
72 - }
73 - }
 72+ $SpecialSolrSearch->showResults ( $fieldSet );
 73+ }
 74+ }
7475
75 - /**
76 - * @param $fieldSet String
77 - */
78 - public function showFieldSets() {
79 - global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang, $wgScript, $wgSolrFields;
80 - wfProfileIn(__METHOD__);
 76+ /**
 77+ * @param $fieldSet String
 78+ */
 79+ public function showFieldSets () {
 80+ global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang, $wgScript, $wgSolrFields;
 81+ wfProfileIn ( __METHOD__ );
8182
82 - $sk = $wgUser->getSkin();
 83+ $sk = $wgUser->getSkin ();
8384
8485
85 - $wgOut->setPageTitle(wfMsg('searchFieldSets'));
86 - $wgOut->setHTMLTitle(wfMsg('pagetitle', wfMsg('searchFieldSets-title', 'SolrSearch: Select FieldSet')));
 86+ $wgOut->setPageTitle ( wfMsg ( 'searchFieldSets' ) );
 87+ $wgOut->setHTMLTitle ( wfMsg ( 'pagetitle', wfMsg ( 'searchFieldSets-title', 'SolrSearch: Select FieldSet' ) ) );
8788
88 - $wgOut->setArticleRelated(false);
89 - $wgOut->addHtml('<div class="solrsearch-fieldset">');
90 - $wgOut->addHtml(wfMsg('searchFieldSets-select'));
91 - $wgOut->addHtml('<ul>');
 89+ $wgOut->setArticleRelated ( false );
 90+ $wgOut->addHtml ( '<div class="solrsearch-fieldset">' );
 91+ $wgOut->addHtml ( wfMsg ( 'searchFieldSets-select' ) );
 92+ $wgOut->addHtml ( '<ul>' );
9293
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>");
 94+ //TODO: If no SearchSets exist, provide a shot Manual how to create some!
 95+ foreach ( $wgSolrFields as $set ) {
 96+ $name = $set->getName ();
 97+ $wgOut->addHtml ( "<li><a href=\"$wgScript/Special:SolrSearch/$name\">$name</a></li>" );
 98+ }
 99+ $wgOut->addHtml ( '</ul>' );
 100+ $wgOut->addHtml ( "</div>" );
100101
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__);
 102+ wfProfileOut ( __METHOD__ );
 103+ }
110104
111 - $sk = $wgUser->getSkin();
 105+ /**
 106+ * @param $fieldSet String
 107+ */
 108+ public function showResults ( $fieldSet ) {
 109+ global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang, $wgScript;
 110+ wfProfileIn ( __METHOD__ );
112111
113 - $this->searchEngine = SearchEngine::create();
114 - $search = & $this->searchEngine;
115 - $search->setLimitOffset($this->limit, $this->offset);
 112+ $sk = $wgUser->getSkin ();
116113
117 - $this->setupPage($fieldSet);
 114+ $this->searchEngine = SearchEngine::create ();
 115+ $search = & $this->searchEngine;
 116+ $search->setLimitOffset ( $this->limit, $this->offset );
118117
119 - $t = Title::newFromText($fieldSet->getName());
 118+ $this->setupPage ( $fieldSet );
120119
121 - //DO we have Title matches
122 - $fields = $fieldSet->getFields();
 120+ $t = Title::newFromText ( $fieldSet->getName () );
123121
124 - //BUILD SOLR QUERY STRING FROM DA FIELDS
125 - if (isset($fields['solrsearch'])) {
126 - $query = $fields['solrsearch'];
127 - } else {
128 - $query = '';
129 - }
 122+ //DO we have Title matches
 123+ $fields = $fieldSet->getFields ();
130124
 125+ //BUILD SOLR QUERY STRING FROM DA FIELDS
 126+ if ( isset ( $fields[ 'solrsearch' ] ) ) {
 127+ $query = $fields[ 'solrsearch' ];
 128+ } else {
 129+ $query = '';
 130+ }
131131
132 - foreach ($fields as $key => $value) {
133 - if ($key != 'solrsearch' && !empty($value)) {
134 - $query = trim($query).' '.trim(substr($key, 4)) . ':' . '(' . ($value) . ')';
135 - }
136 - }
137132
138 - if (!empty($query)) {
139 - $query .=$fieldSet->getQuery();
140 - }
141 - // TODO: More Exception Handling for Format Exceptions
142 - try {
143 - $titleMatches = $search->searchTitle($query);
 133+ foreach ( $fields as $key => $value ) {
 134+ if ( $key != 'solrsearch' && !empty ( $value ) ) {
 135+ $query = trim ( $query ) . ' ' . trim ( substr ( $key, 4 ) ) . ':' . '(' . ($value) . ')';
 136+ }
 137+ }
144138
145 - if (!($titleMatches instanceof SearchResultTooMany))
146 - $textMatches = $search->searchText($query);
 139+ if ( !empty ( $query ) ) {
 140+ $query .=$fieldSet->getQuery ();
 141+ }
 142+ // TODO: More Exception Handling for Format Exceptions
 143+ try {
 144+ $titleMatches = $search->searchTitle ( $query );
147145
148 - // did you mean... suggestions
149 - if ($textMatches && $textMatches->hasSuggestion()) {
150 - $st = SpecialPage::getTitleFor('SolrSearch');
 146+ if ( !($titleMatches instanceof SearchResultTooMany) )
 147+ $textMatches = $search->searchText ( $query );
151148
152 - # mirror Go/Search behaviour of original request ..
153 - $didYouMeanParams = array('solrsearch' => $textMatches->getSuggestionQuery());
 149+ // did you mean... suggestions
 150+ if ( $textMatches && $textMatches->hasSuggestion () ) {
 151+ $st = SpecialPage::getTitleFor ( 'SolrSearch' );
154152
155 - $stParams = $didYouMeanParams;
 153+ # mirror Go/Search behaviour of original request ..
 154+ $didYouMeanParams = array ( 'solrsearch' => $textMatches->getSuggestionQuery () );
156155
157 - $suggestionSnippet = $textMatches->getSuggestionSnippet();
 156+ $stParams = $didYouMeanParams;
158157
159 - if ($suggestionSnippet == '')
160 - $suggestionSnippet = null;
 158+ $suggestionSnippet = $textMatches->getSuggestionSnippet ();
161159
162 - $suggestLink = $sk->linkKnown(
163 - $st, $suggestionSnippet, array(), $stParams
164 - );
 160+ if ( $suggestionSnippet == '' )
 161+ $suggestionSnippet = null;
165162
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 - );
 163+ $suggestLink = $sk->linkKnown (
 164+ $st, $suggestionSnippet, array ( ), $stParams
 165+ );
196166
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 - }
 167+ $this->didYouMeanHtml = '<div class="searchdidyoumean">'
 168+ . wfMsg ( 'search-suggest', $suggestLink )
 169+ . '</div>';
 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+ );
203196
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;
 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+ }
217203
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;
 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;
223217
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));
 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;
232223
233 - $wgOut->addHtml(Xml::closeElement('form'));
234 - $wgOut->addHtml("<div class='searchresults'>");
 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 ) );
235232
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 - }
 233+ $wgOut->addHtml ( Xml::closeElement ( 'form' ) );
 234+ $wgOut->addHtml ( "<div class='searchresults'>" );
247235
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 - }
 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+ }
264247
265 - // show results
266 - if ($numTextMatches > 0) {
267 - $wgOut->addHTML($this->showMatches($textMatches));
268 - }
 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+ }
269264
270 - $textMatches->free();
271 - }
 265+ // show results
 266+ if ( $numTextMatches > 0 ) {
 267+ $wgOut->addHTML ( $this->showMatches ( $textMatches ) );
 268+ }
272269
273 - $wgOut->addHtml("</div>");
 270+ $textMatches->free ();
 271+ }
274272
275 - if ($num || $this->offset) {
276 - $wgOut->addHTML("<p class='mw-search-pager-bottom'>{$prevnext}</p>\n");
277 - }
278 - wfProfileOut(__METHOD__);
279 - }
 273+ $wgOut->addHtml ( "</div>" );
280274
281 - protected function showCreateLink($t) {
282 - global $wgOut;
 275+ if ( $num || $this->offset ) {
 276+ $wgOut->addHTML ( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
 277+ }
 278+ wfProfileOut ( __METHOD__ );
 279+ }
283280
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 - }
 281+ protected function showCreateLink ( $t ) {
 282+ global $wgOut;
302283
303 - /**
304 - *
305 - */
306 - protected function setupPage($fieldSet) {
307 - 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+ }
308302
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 - }
 303+ /**
 304+ *
 305+ */
 306+ protected function setupPage ( $fieldSet ) {
 307+ global $wgOut;
319308
320 - /**
321 - * Show whole set of results
322 - *
323 - * @param $matches SearchResultSet
324 - */
325 - protected function showMatches(&$matches) {
326 - global $wgContLang;
327 - wfProfileIn(__METHOD__);
 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+ }
328319
329 - $fieldSets = $wgContLang->convertForSearchResult($matches->termMatches());
 320+ /**
 321+ * Show whole set of results
 322+ *
 323+ * @param $matches SearchResultSet
 324+ */
 325+ protected function showMatches ( &$matches ) {
 326+ global $wgContLang;
 327+ wfProfileIn ( __METHOD__ );
330328
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";
 329+ $fieldSets = $wgContLang->convertForSearchResult ( $matches->termMatches () );
342330
343 - // convert the whole thing to desired language variant
344 - $out = $wgContLang->convert($out);
345 - wfProfileOut(__METHOD__);
346 - return $out;
347 - }
 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";
348342
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__);
 343+ // convert the whole thing to desired language variant
 344+ $out = $wgContLang->convert ( $out );
 345+ wfProfileOut ( __METHOD__ );
 346+ return $out;
 347+ }
358348
359 - if ($result->isBrokenTitle()) {
360 - wfProfileOut(__METHOD__);
361 - return "<!-- Broken link in search result -->\n";
362 - }
 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__ );
363358
364 - $sk = $wgUser->getSkin();
365 - $t = $result->getTitle();
 359+ if ( $result->isBrokenTitle () ) {
 360+ wfProfileOut ( __METHOD__ );
 361+ return "<!-- Broken link in search result -->\n";
 362+ }
366363
367 - $titleSnippet = $result->getTitleSnippet($fieldSets);
 364+ $sk = $wgUser->getSkin ();
 365+ $t = $result->getTitle ();
368366
369 - if ($titleSnippet == '')
370 - $titleSnippet = null;
 367+ $titleSnippet = $result->getTitleSnippet ( $fieldSets );
371368
372 - $link_t = clone $t;
 369+ if ( $titleSnippet == '' )
 370+ $titleSnippet = null;
373371
374 - wfRunHooks('ShowSearchHitTitle', array(&$link_t, &$titleSnippet, $result, $fieldSets, $this));
 372+ $link_t = clone $t;
375373
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 - }
 374+ wfRunHooks ( 'ShowSearchHitTitle', array ( &$link_t, &$titleSnippet, $result, $fieldSets, $this ) );
397375
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 = '';
 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+ }
404397
405 - if (!is_null($redirectTitle)) {
406 - if ($redirectText == '')
407 - $redirectText = null;
 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 = '';
408404
409 - $redirect = "<span class='searchalttitle'>" .
410 - wfMsg('search-redirect', $this->sk->linkKnown($redirectTitle, $redirectText)) .
411 - "</span>";
412 - }
 405+ if ( !is_null ( $redirectTitle ) ) {
 406+ if ( $redirectText == '' )
 407+ $redirectText = null;
413408
414 - $section = '';
 409+ $redirect = "<span class='searchalttitle'>" .
 410+ wfMsg ( 'search-redirect', $this->sk->linkKnown ( $redirectTitle, $redirectText ) ) .
 411+ "</span>";
 412+ }
415413
 414+ $section = '';
416415
417 - if (!is_null($sectionTitle)) {
418 - if ($sectionText == '')
419 - $sectionText = null;
420416
421 - $section = "<span class='searchalttitle'>" .
422 - wfMsg('search-section', $this->sk->linkKnown($sectionTitle, $sectionText)) .
423 - "</span>";
424 - }
 417+ if ( !is_null ( $sectionTitle ) ) {
 418+ if ( $sectionText == '' )
 419+ $sectionText = null;
425420
426 - // format text extract
427 - $extract = "<div class='searchresult'>" . $result->getTextSnippet($fieldSets) . "</div>";
 421+ $section = "<span class='searchalttitle'>" .
 422+ wfMsg ( 'search-section', $this->sk->linkKnown ( $sectionTitle, $sectionText ) ) .
 423+ "</span>";
 424+ }
428425
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 - }
 426+ // format text extract
 427+ $extract = "<div class='searchresult'>" . $result->getTextSnippet ( $fieldSets ) . "</div>";
437428
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));
 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+ }
443437
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 - }
 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 ) );
448443
449 - $date = $wgLang->timeanddate($timestamp);
 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+ }
450448
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 - }
 449+ $date = $wgLang->timeanddate ( $timestamp );
458450
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 - }
 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+ }
488458
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 - }
 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+ }
495488
496 - protected function formHeader($fieldSet, $resultsShown, $totalNum) {
497 - global $wgLang;
 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+ }
498495
499 - $out = Xml::openElement('div', array('class' => 'mw-search-formheader'));
 496+ protected function formHeader ( $fieldSet, $resultsShown, $totalNum ) {
 497+ global $wgLang;
500498
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 - }
 499+ $out = Xml::openElement ( 'div', array ( 'class' => 'mw-search-formheader' ) );
513500
514 - $out .= Xml::element('div', array('style' => 'clear:both'), '', false);
515 - $out .= Xml::closeElement('div');
 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+ }
516513
517 - return $out;
518 - }
 514+ $out .= Xml::element ( 'div', array ( 'style' => 'clear:both' ), '', false );
 515+ $out .= Xml::closeElement ( 'div' );
519516
520 - protected function shortDialog($fieldSet) {
521 - $searchTitle = SpecialPage::getTitleFor('SolrSearch');
 517+ return $out;
 518+ }
522519
 520+ protected function shortDialog ( $fieldSet ) {
 521+ $searchTitle = SpecialPage::getTitleFor ( 'SolrSearch' );
523522
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
530523
531 - $lable = $fieldSet->getLable();
532 - $out .= '<table>';
 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
533530
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 - }
 531+ $lable = $fieldSet->getLable ();
 532+ $out .= '<table>';
551533
 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+ }
 551+
552552 }
553553
554554 ?>
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r109526Partly revert r109519: This was a bit overdone....raymond12:20, 19 January 2012

Status & tagging log