Index: trunk/extensions/SolrStore/SolrStore.i18n.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * SolrStore: The SolrStore Extesion is Semantic Mediawiki Searchprovieder based on Apache Solr. |
5 | 6 | * |
— | — | @@ -6,12 +7,12 @@ |
7 | 8 | * @file |
8 | 9 | * @author Simon Bachenberg |
9 | 10 | */ |
10 | | -$messages = array(); |
| 11 | +$messages = array ( ); |
11 | 12 | |
12 | | -$messages['en'] = array( |
| 13 | +$messages[ 'en' ] = array ( |
13 | 14 | 'solrstore-desc' => 'Search semantic properties with the power of a fulltext search engine', |
14 | 15 | 'solrsearch' => 'SolrSearch', |
15 | | - 'solrstore-error' => 'Error: Please Check your Query', |
| 16 | + 'solrstore-error' => 'Error: Please Check your Query', |
16 | 17 | 'solrstore-searchFieldSets' => 'SolrSearch', |
17 | 18 | 'solrstore-searchFieldSets-select' => 'Please select a SearchSet', |
18 | 19 | 'solrstore-searchFieldSets-title' => 'SolrSearch: SearchSet select', |
— | — | @@ -21,10 +22,10 @@ |
22 | 23 | * @author F.trott |
23 | 24 | * @author Siebrand |
24 | 25 | */ |
25 | | -$messages['qqq'] = array( |
| 26 | +$messages[ 'qqq' ] = array ( |
26 | 27 | 'solrstore-desc' => '{{desc}}', |
27 | 28 | '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"', |
29 | 30 | 'solrstore-searchFieldSets' => 'The pagetitle (heading) of the Special:SolrSearch page', |
30 | 31 | 'solrstore-searchFieldSets-select' => 'A SearchSet is a predefined search form for a field based search.', |
31 | 32 | '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 @@ |
36 | 37 | * @author Jim-by |
37 | 38 | * @author Wizardist |
38 | 39 | */ |
39 | | -$messages['be-tarask'] = array( |
| 40 | +$messages[ 'be-tarask' ] = array ( |
40 | 41 | 'solrstore-desc' => 'Пошук сэмантычных уласьцівасьцяў з выкарыстаньнем рухавіка поўнатэкстнага пошуку', |
41 | 42 | 'solrsearch' => 'SolrSearch', |
42 | 43 | 'solrstore-searchFieldSets' => 'SolrSearch', |
— | — | @@ -47,10 +48,10 @@ |
48 | 49 | * @author Kghbln |
49 | 50 | * @author SBachenberg |
50 | 51 | */ |
51 | | -$messages['de'] = array( |
| 52 | +$messages[ 'de' ] = array ( |
52 | 53 | 'solrstore-desc' => 'Ermöglicht die Suche nach semantischen Attributen mit einer Volltextsuchmaschine', |
53 | 54 | 'solrsearch' => 'SolrSuche', |
54 | | - 'solrstore-error' => 'Fehler: Bitte überprüfen Sie ihre Suchanfrage', |
| 55 | + 'solrstore-error' => 'Fehler: Bitte überprüfen Sie ihre Suchanfrage', |
55 | 56 | 'solrstore-searchFieldSets' => 'SolrSuche', |
56 | 57 | 'solrstore-searchFieldSets-select' => 'Bitte wähle ein SearchSet aus', |
57 | 58 | 'solrstore-searchFieldSets-title' => 'SolrSearch: SearchSet Auswahl', |
— | — | @@ -59,7 +60,7 @@ |
60 | 61 | /** French (Français) |
61 | 62 | * @author Gomoko |
62 | 63 | */ |
63 | | -$messages['fr'] = array( |
| 64 | +$messages[ 'fr' ] = array ( |
64 | 65 | 'solrstore-desc' => "Rechercher des propriétés avec la puissance d'un moteur de recherche plein texte", |
65 | 66 | 'solrsearch' => 'SolrSearch', |
66 | 67 | 'solrstore-searchFieldSets' => 'SolrSearch', |
— | — | @@ -70,7 +71,7 @@ |
71 | 72 | /** Galician (Galego) |
72 | 73 | * @author Toliño |
73 | 74 | */ |
74 | | -$messages['gl'] = array( |
| 75 | +$messages[ 'gl' ] = array ( |
75 | 76 | 'solrstore-desc' => 'Procurar propiedades semánticas co poder dun motor de procuras de texto', |
76 | 77 | 'solrsearch' => 'SolrSearch', |
77 | 78 | 'solrstore-searchFieldSets' => 'SolrSearch', |
— | — | @@ -81,7 +82,7 @@ |
82 | 83 | /** Upper Sorbian (Hornjoserbsce) |
83 | 84 | * @author Michawiki |
84 | 85 | */ |
85 | | -$messages['hsb'] = array( |
| 86 | +$messages[ 'hsb' ] = array ( |
86 | 87 | 'solrstore-desc' => 'Pytanje za semantiskimi atributami z połnotekstowej pytawu', |
87 | 88 | 'solrsearch' => 'SolrSearch', |
88 | 89 | 'solrstore-searchFieldSets' => 'SolrSearch', |
— | — | @@ -92,7 +93,7 @@ |
93 | 94 | /** Interlingua (Interlingua) |
94 | 95 | * @author McDutchie |
95 | 96 | */ |
96 | | -$messages['ia'] = array( |
| 97 | +$messages[ 'ia' ] = array ( |
97 | 98 | 'solrstore-desc' => 'Cercar proprietates semantic con le poter de un motor de recerca de plen texto', |
98 | 99 | 'solrsearch' => 'SolrSearch', |
99 | 100 | 'solrstore-searchFieldSets' => 'SolrSearch', |
— | — | @@ -103,7 +104,7 @@ |
104 | 105 | /** Luxembourgish (Lëtzebuergesch) |
105 | 106 | * @author Robby |
106 | 107 | */ |
107 | | -$messages['lb'] = array( |
| 108 | +$messages[ 'lb' ] = array ( |
108 | 109 | 'solrsearch' => 'SolrSich', |
109 | 110 | 'solrstore-searchFieldSets' => 'SolrSich', |
110 | 111 | ); |
— | — | @@ -111,7 +112,7 @@ |
112 | 113 | /** Macedonian (Македонски) |
113 | 114 | * @author Bjankuloski06 |
114 | 115 | */ |
115 | | -$messages['mk'] = array( |
| 116 | +$messages[ 'mk' ] = array ( |
116 | 117 | 'solrstore-desc' => 'Пребарување на семантички својства со способностите на пребарувачот на полн текст', |
117 | 118 | 'solrsearch' => 'SolrSearch', |
118 | 119 | 'solrstore-searchFieldSets' => 'SolrSearch', |
— | — | @@ -122,7 +123,7 @@ |
123 | 124 | /** Dutch (Nederlands) |
124 | 125 | * @author Siebrand |
125 | 126 | */ |
126 | | -$messages['nl'] = array( |
| 127 | +$messages[ 'nl' ] = array ( |
127 | 128 | 'solrstore-desc' => 'Semantische eigenschappen doorzoeken met de kracht van een fulltext zoekmachine', |
128 | 129 | 'solrsearch' => 'SolrSearch', |
129 | 130 | 'solrstore-searchFieldSets' => 'SolrSearch', |
— | — | @@ -134,7 +135,7 @@ |
135 | 136 | * @author Borichèt |
136 | 137 | * @author Dragonòt |
137 | 138 | */ |
138 | | -$messages['pms'] = array( |
| 139 | +$messages[ 'pms' ] = array ( |
139 | 140 | 'solrstore-desc' => "Arserché dle proprietà semàntiche con la potensa d'un motor d'arserca a test pien", |
140 | 141 | 'solrsearch' => 'SolrSearch', |
141 | 142 | 'solrstore-searchFieldSets' => 'SolrSearch', |
— | — | @@ -145,7 +146,7 @@ |
146 | 147 | /** Russian (Русский) |
147 | 148 | * @author Eleferen |
148 | 149 | */ |
149 | | -$messages['ru'] = array( |
| 150 | +$messages[ 'ru' ] = array ( |
150 | 151 | 'solrstore-desc' => 'Семантический поиск с использованием ресурсов полнотекстовой поисковой системы', |
151 | 152 | 'solrsearch' => 'SolrSearch', |
152 | 153 | 'solrstore-searchFieldSets' => 'SolrSearch', |
Index: trunk/extensions/SolrStore/SpecialSolrSearch.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * SolrStore: The SolrStore Extesion is Semantic Mediawiki Searchprovieder based on Apache Solr. |
5 | 6 | * |
— | — | @@ -9,545 +10,544 @@ |
10 | 11 | */ |
11 | 12 | class SpecialSolrSearch extends SpecialPage { |
12 | 13 | |
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' ); |
26 | 27 | |
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 | + } |
30 | 31 | |
31 | | - function execute($par) { |
32 | | - global $wgRequest, $wgUser, $wgOut, $wgSolrFields; |
| 32 | + function execute ( $par ) { |
| 33 | + global $wgRequest, $wgUser, $wgOut, $wgSolrFields; |
33 | 34 | |
34 | | - $this->setHeaders(); |
35 | | - $SpecialSolrSearch = new SpecialSolrSearch($wgRequest, $wgUser); |
| 35 | + $this->setHeaders (); |
| 36 | + $SpecialSolrSearch = new SpecialSolrSearch ( $wgRequest, $wgUser ); |
36 | 37 | |
37 | | - # Get request data from, e.g. |
38 | | - $param = $wgRequest->getText('param'); |
| 38 | + # Get request data from, e.g. |
| 39 | + $param = $wgRequest->getText ( 'param' ); |
39 | 40 | |
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 |
51 | 52 | // $search = str_replace("\n", " ", $wgRequest->getText('solrsearch', $titleParam)); |
52 | 53 | |
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 | + } |
65 | 66 | |
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 ); |
70 | 71 | |
71 | | - $SpecialSolrSearch->showResults($fieldSet); |
72 | | - } |
73 | | - } |
| 72 | + $SpecialSolrSearch->showResults ( $fieldSet ); |
| 73 | + } |
| 74 | + } |
74 | 75 | |
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__ ); |
81 | 82 | |
82 | | - $sk = $wgUser->getSkin(); |
| 83 | + $sk = $wgUser->getSkin (); |
83 | 84 | |
84 | 85 | |
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' ) ) ); |
87 | 88 | |
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>' ); |
92 | 93 | |
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>" ); |
100 | 101 | |
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 | + } |
110 | 104 | |
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__ ); |
112 | 111 | |
113 | | - $this->searchEngine = SearchEngine::create(); |
114 | | - $search = & $this->searchEngine; |
115 | | - $search->setLimitOffset($this->limit, $this->offset); |
| 112 | + $sk = $wgUser->getSkin (); |
116 | 113 | |
117 | | - $this->setupPage($fieldSet); |
| 114 | + $this->searchEngine = SearchEngine::create (); |
| 115 | + $search = & $this->searchEngine; |
| 116 | + $search->setLimitOffset ( $this->limit, $this->offset ); |
118 | 117 | |
119 | | - $t = Title::newFromText($fieldSet->getName()); |
| 118 | + $this->setupPage ( $fieldSet ); |
120 | 119 | |
121 | | - //DO we have Title matches |
122 | | - $fields = $fieldSet->getFields(); |
| 120 | + $t = Title::newFromText ( $fieldSet->getName () ); |
123 | 121 | |
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 (); |
130 | 124 | |
| 125 | + //BUILD SOLR QUERY STRING FROM DA FIELDS |
| 126 | + if ( isset ( $fields[ 'solrsearch' ] ) ) { |
| 127 | + $query = $fields[ 'solrsearch' ]; |
| 128 | + } else { |
| 129 | + $query = ''; |
| 130 | + } |
131 | 131 | |
132 | | - foreach ($fields as $key => $value) { |
133 | | - if ($key != 'solrsearch' && !empty($value)) { |
134 | | - $query = trim($query).' '.trim(substr($key, 4)) . ':' . '(' . ($value) . ')'; |
135 | | - } |
136 | | - } |
137 | 132 | |
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 | + } |
144 | 138 | |
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 ); |
147 | 145 | |
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 ); |
151 | 148 | |
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' ); |
154 | 152 | |
155 | | - $stParams = $didYouMeanParams; |
| 153 | + # mirror Go/Search behaviour of original request .. |
| 154 | + $didYouMeanParams = array ( 'solrsearch' => $textMatches->getSuggestionQuery () ); |
156 | 155 | |
157 | | - $suggestionSnippet = $textMatches->getSuggestionSnippet(); |
| 156 | + $stParams = $didYouMeanParams; |
158 | 157 | |
159 | | - if ($suggestionSnippet == '') |
160 | | - $suggestionSnippet = null; |
| 158 | + $suggestionSnippet = $textMatches->getSuggestionSnippet (); |
161 | 159 | |
162 | | - $suggestLink = $sk->linkKnown( |
163 | | - $st, $suggestionSnippet, array(), $stParams |
164 | | - ); |
| 160 | + if ( $suggestionSnippet == '' ) |
| 161 | + $suggestionSnippet = null; |
165 | 162 | |
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 | + ); |
196 | 166 | |
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 | + ); |
203 | 196 | |
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 | + } |
217 | 203 | |
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; |
223 | 217 | |
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; |
232 | 223 | |
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 ) ); |
235 | 232 | |
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'>" ); |
247 | 235 | |
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 | + } |
264 | 247 | |
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 | + } |
269 | 264 | |
270 | | - $textMatches->free(); |
271 | | - } |
| 265 | + // show results |
| 266 | + if ( $numTextMatches > 0 ) { |
| 267 | + $wgOut->addHTML ( $this->showMatches ( $textMatches ) ); |
| 268 | + } |
272 | 269 | |
273 | | - $wgOut->addHtml("</div>"); |
| 270 | + $textMatches->free (); |
| 271 | + } |
274 | 272 | |
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>" ); |
280 | 274 | |
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 | + } |
283 | 280 | |
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; |
302 | 283 | |
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 | + } |
308 | 302 | |
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; |
319 | 308 | |
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 | + } |
328 | 319 | |
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__ ); |
330 | 328 | |
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 () ); |
342 | 330 | |
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"; |
348 | 342 | |
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 | + } |
358 | 348 | |
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__ ); |
363 | 358 | |
364 | | - $sk = $wgUser->getSkin(); |
365 | | - $t = $result->getTitle(); |
| 359 | + if ( $result->isBrokenTitle () ) { |
| 360 | + wfProfileOut ( __METHOD__ ); |
| 361 | + return "<!-- Broken link in search result -->\n"; |
| 362 | + } |
366 | 363 | |
367 | | - $titleSnippet = $result->getTitleSnippet($fieldSets); |
| 364 | + $sk = $wgUser->getSkin (); |
| 365 | + $t = $result->getTitle (); |
368 | 366 | |
369 | | - if ($titleSnippet == '') |
370 | | - $titleSnippet = null; |
| 367 | + $titleSnippet = $result->getTitleSnippet ( $fieldSets ); |
371 | 368 | |
372 | | - $link_t = clone $t; |
| 369 | + if ( $titleSnippet == '' ) |
| 370 | + $titleSnippet = null; |
373 | 371 | |
374 | | - wfRunHooks('ShowSearchHitTitle', array(&$link_t, &$titleSnippet, $result, $fieldSets, $this)); |
| 372 | + $link_t = clone $t; |
375 | 373 | |
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 ) ); |
397 | 375 | |
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 | + } |
404 | 397 | |
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 = ''; |
408 | 404 | |
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; |
413 | 408 | |
414 | | - $section = ''; |
| 409 | + $redirect = "<span class='searchalttitle'>" . |
| 410 | + wfMsg ( 'search-redirect', $this->sk->linkKnown ( $redirectTitle, $redirectText ) ) . |
| 411 | + "</span>"; |
| 412 | + } |
415 | 413 | |
| 414 | + $section = ''; |
416 | 415 | |
417 | | - if (!is_null($sectionTitle)) { |
418 | | - if ($sectionText == '') |
419 | | - $sectionText = null; |
420 | 416 | |
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; |
425 | 420 | |
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 | + } |
428 | 425 | |
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>"; |
437 | 428 | |
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 | + } |
443 | 437 | |
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 ) ); |
448 | 443 | |
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 | + } |
450 | 448 | |
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 ); |
458 | 450 | |
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 | + } |
488 | 458 | |
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 | + } |
495 | 488 | |
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 | + } |
498 | 495 | |
499 | | - $out = Xml::openElement('div', array('class' => 'mw-search-formheader')); |
| 496 | + protected function formHeader ( $fieldSet, $resultsShown, $totalNum ) { |
| 497 | + global $wgLang; |
500 | 498 | |
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' ) ); |
513 | 500 | |
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 | + } |
516 | 513 | |
517 | | - return $out; |
518 | | - } |
| 514 | + $out .= Xml::element ( 'div', array ( 'style' => 'clear:both' ), '', false ); |
| 515 | + $out .= Xml::closeElement ( 'div' ); |
519 | 516 | |
520 | | - protected function shortDialog($fieldSet) { |
521 | | - $searchTitle = SpecialPage::getTitleFor('SolrSearch'); |
| 517 | + return $out; |
| 518 | + } |
522 | 519 | |
| 520 | + protected function shortDialog ( $fieldSet ) { |
| 521 | + $searchTitle = SpecialPage::getTitleFor ( 'SolrSearch' ); |
523 | 522 | |
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 |
530 | 523 | |
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 |
533 | 530 | |
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>'; |
551 | 533 | |
| 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 | + |
552 | 552 | } |
553 | 553 | |
554 | 554 | ?> |
\ No newline at end of file |