r106682 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106681‎ | r106682 | r106683 >
Date:20:11, 19 December 2011
Author:foxtrott
Status:deferred (Comments)
Tags:
Comment:
stylize; insert messages for qqq
Modified paths:
  • /trunk/extensions/SolrStore/SolrConnector.php (modified) (history)
  • /trunk/extensions/SolrStore/SolrConnectorStore.php (modified) (history)
  • /trunk/extensions/SolrStore/SolrDoc.php (modified) (history)
  • /trunk/extensions/SolrStore/SolrSearch.php (modified) (history)
  • /trunk/extensions/SolrStore/SolrSearchFieldSet.php (modified) (history)
  • /trunk/extensions/SolrStore/SolrStore.alias.php (modified) (history)
  • /trunk/extensions/SolrStore/SolrStore.i18n.php (modified) (history)
  • /trunk/extensions/SolrStore/SolrStore.php (modified) (history)
  • /trunk/extensions/SolrStore/SolrTalker.php (modified) (history)
  • /trunk/extensions/SolrStore/SpecialSolrSearch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SolrStore/SolrConnector.php
@@ -1,9 +1,9 @@
22 <?php
33 /**
44 * Early versions of the extension had to include SolrConnector.php.
5 - *
 5+ *
66 * This file keeps backward compatibility for a while.
7 - *
 7+ *
88 * @ingroup SolrStore
99 * @file
1010 */
Index: trunk/extensions/SolrStore/SolrStore.i18n.php
@@ -16,6 +16,14 @@
1717 'searchFieldSets-title' => 'SolrSearch: SearchSet Select',
1818 );
1919
 20+$messages['qqq'] = array(
 21+ 'solrconnector-desc' => '{{desc}}',
 22+ 'solrsearch' => 'The title of the Special:SolrSearch page as appearing in Special:SpecialPages. Should probably the same as message \'\'searchFieldSets\'\'',
 23+ 'searchFieldSets' => 'The pagetitle (heading) of the Special:SolrSearch page',
 24+ 'searchFieldSets-select' => 'A message',
 25+ 'searchFieldSets-title' => 'The title of the Special:SolrSearch page',
 26+);
 27+
2028 $messages['de'] = array(
2129 'solrsearch' => 'SolrSuche',
2230 'searchFieldSets' => 'SolrSuche',
Index: trunk/extensions/SolrStore/SolrStore.php
@@ -30,7 +30,7 @@
3131 define( 'SC_VERSION', '0.5 Beta' );
3232
3333 // register the extension
34 -//TODO: Add other authors here and in the file header
 34+// TODO: Add other authors here and in the file header
3535 $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'other'][] = array(
3636 'path' => __FILE__,
3737 'name' => 'SolrStore',
@@ -72,7 +72,6 @@
7373
7474 // Solr Configuration
7575 $wgSolrTalker = new SolrTalker();
76 -if ( !isset( $wgSolrUrl ) ){
77 - //Url to the Solr Server
78 - $wgSolrUrl = 'http://svbosofixwiki:8180/solr';
79 -}
 76+
 77+$wgSolrUrl = 'http://127.0.0.1:8080/solr';
 78+$wgSolrFields = array();
Index: trunk/extensions/SolrStore/SolrTalker.php
@@ -1,7 +1,7 @@
22 <?php
33 /**
44 * File holding the SolrTalker class
5 - *
 5+ *
66 * @ingroup SolrStore
77 * @file
88 * @author Simon Bachenberg
@@ -9,107 +9,107 @@
1010
1111 /**
1212 * This class should do all the talk to the Solr server.
13 - *
 13+ *
1414 * @ingroup SolrStore
1515 */
1616 class SolrTalker {
1717
18 - private $header = array("Content-type:text/xml; charset=utf-8");
 18+ private $header = array( "Content-type:text/xml; charset=utf-8" );
1919 private $schema;
2020
2121 /**
2222 * Get the Schema from SOLR as XML
2323 * This Includes all Dynamic Fields
24 - *
 24+ *
2525 * @return type $xml schema
2626 */
2727 public function getSchema() {
2828 global $wgSolrUrl;
29 - $xml = $this->solrSend($wgSolrUrl . '/admin/luke?numTerms=0');
 29+ $xml = $this->solrSend( $wgSolrUrl . '/admin/luke?numTerms=0' );
3030
3131 try {
3232 $this->schema = $xml;
33 - } catch (Exception $exc) {
 33+ } catch ( Exception $exc ) {
3434 return false;
3535 }
3636
3737 return $this->schema;
3838 }
3939
40 - public function encodeSolr($query) {
41 - //Using the urlencode from php doenst work!?, so we need to do it our self
42 - $query = str_replace('"', '%22', trim($query));
43 - $query = str_replace(' ', '+', $query);
44 - $query = str_replace('ü', '%FC', $query);
45 - $query = str_replace('Ü', '%DC', $query);
46 - $query = str_replace('ö', '%F6', $query);
47 - $query = str_replace('Ö', '%D6', $query);
48 - $query = str_replace('ä', '%E4', $query);
49 - $query = str_replace('ä', '%C4', $query);
 40+ public function encodeSolr( $query ) {
 41+ // Using the urlencode from php doenst work!?, so we need to do it our self
 42+ $query = str_replace( '"', '%22', trim( $query ) );
 43+ $query = str_replace( ' ', '+', $query );
 44+ $query = str_replace( 'ü', '%FC', $query );
 45+ $query = str_replace( 'Ü', '%DC', $query );
 46+ $query = str_replace( 'ö', '%F6', $query );
 47+ $query = str_replace( 'Ö', '%D6', $query );
 48+ $query = str_replace( 'ä', '%E4', $query );
 49+ $query = str_replace( 'ä', '%C4', $query );
5050 return $query;
5151 }
5252
5353 /**
5454 * Perform a SolrSearch
55 - *
 55+ *
5656 * @global type $wgSolrUrl
5757 * @param type $query - Search Term
5858 * @param type $start - Offset
5959 * @param type $end - Limit
60 - * @return type $xml - Solr Result as XML
61 - *
 60+ * @return type $xml - Solr Result as XML
 61+ *
6262 */
63 - public function solrQuery($query, $start, $end, $highlight=false, $score=false) {
 63+ public function solrQuery( $query, $start, $end, $highlight = false, $score = false ) {
6464 global $wgSolrUrl;
65 - $query = trim($query);
66 - if (empty($query)) {
 65+ $query = trim( $query );
 66+ if ( empty( $query ) ) {
6767 $query = '*';
6868 }
69 - $url = $wgSolrUrl . '/select?q=' . $query . '&start=' . $start . '&rows=' . $end; //. '&fl=*%2Cscore'; No Score for now, ther seems to be a BUG
70 - if ($highlight) {
71 - $url.='&hl=on&hl.fl=*';
 69+ $url = $wgSolrUrl . '/select?q=' . $query . '&start=' . $start . '&rows=' . $end; // . '&fl=*%2Cscore'; No Score for now, ther seems to be a BUG
 70+ if ( $highlight ) {
 71+ $url .= '&hl=on&hl.fl=*';
7272 }
73 - if ($score) {
74 - $url.='&fl=*%2Cscore';
 73+ if ( $score ) {
 74+ $url .= '&fl=*%2Cscore';
7575 }
76 - return $this->solrSend($url);
 76+ return $this->solrSend( $url );
7777 }
7878
7979 /**
8080 * Find the real name of the Field in the SOlr schema
81 - *
 81+ *
8282 * @param type $searchField
8383 * @param type $sort = ASC or DESC
8484 * @return type Name of the Field you are searching for
8585 */
86 - public function findField($searchField, $sort = 'ASC') {
 86+ public function findField( $searchField, $sort = 'ASC' ) {
8787 $xml = $this->getSchema();
88 - //$searchField = trim($searchField);
89 - $searchField = str_replace(' ', '_', trim($searchField)); // Trim and Replace all Spaces with underscore for better matching
 88+ // $searchField = trim($searchField);
 89+ $searchField = str_replace( ' ', '_', trim( $searchField ) ); // Trim and Replace all Spaces with underscore for better matching
9090 $result = false;
9191 $stop = false;
9292
93 - //TODO: Decide on ASC + DESC parameter for Max or Min Sort Field
94 - foreach ($xml->lst as $item) {
95 - if ($item['name'] == 'fields') {
96 - foreach ($item->lst as $field) {
97 - if (count($field) > 2) {
98 - $dynamicBase = substr($field->str[2], 1); // Get The dynamicbase of the Field eg. "*_dtmax"
99 - $newField = str_replace($dynamicBase, '', $field['name']); // Get the Fieldname without the dynamicbase
100 - if (strcasecmp(str_replace(' ', '_', $newField), $searchField) == 0) { // Replace all Spaces with underscore for better matching
101 - if (stripos($dynamicBase, 'max') && stripos($sort, 'desc')) {
 93+ // TODO: Decide on ASC + DESC parameter for Max or Min Sort Field
 94+ foreach ( $xml->lst as $item ) {
 95+ if ( $item['name'] == 'fields' ) {
 96+ foreach ( $item->lst as $field ) {
 97+ if ( count( $field ) > 2 ) {
 98+ $dynamicBase = substr( $field->str[2], 1 ); // Get The dynamicbase of the Field eg. "*_dtmax"
 99+ $newField = str_replace( $dynamicBase, '', $field['name'] ); // Get the Fieldname without the dynamicbase
 100+ if ( strcasecmp( str_replace( ' ', '_', $newField ), $searchField ) == 0 ) { // Replace all Spaces with underscore for better matching
 101+ if ( stripos( $dynamicBase, 'max' ) && stripos( $sort, 'desc' ) ) {
102102 // For Descending Sorting use the MaX value Field
103 - continue 2; //we got the right Field Stop it!
104 - } else if (stripos($dynamicBase, 'min') && stripos($sort, 'asc')) {
105 - // For Ascending Sorting use the MIN value Field
106 - continue 2; //we got the right Field Stop it!
 103+ continue 2; // we got the right Field Stop it!
 104+ } else if ( stripos( $dynamicBase, 'min' ) && stripos( $sort, 'asc' ) ) {
 105+ // For Ascending Sorting use the MIN value Field
 106+ continue 2; // we got the right Field Stop it!
107107 }
108 - } else if (strcasecmp(str_replace(' ', '_', $field['name']), $searchField) == 0) { // Replace all Spaces with underscore for better matching
109 - $result = trim($searchField);
 108+ } else if ( strcasecmp( str_replace( ' ', '_', $field['name'] ), $searchField ) == 0 ) { // Replace all Spaces with underscore for better matching
 109+ $result = trim( $searchField );
110110 }
111111 } else {
112 - if (strcasecmp(trim($field['name']), trim($searchField)) == 0) {
113 - $result = trim($field['name']);
 112+ if ( strcasecmp( trim( $field['name'] ), trim( $searchField ) ) == 0 ) {
 113+ $result = trim( $field['name'] );
114114 }
115115 }
116116 }
@@ -120,20 +120,20 @@
121121
122122 /**
123123 * Check the Query for existing fields
124 - *
 124+ *
125125 * @param type $queryStr - Wiki QueryString
126126 * @return type $queryStr - Solr QueryString
127127 */
128 - public function queryChecker($queryStr) {
129 - $queryStr = str_replace('=', ':', $queryStr); // Now you can use = insted : for querying Fields
130 - if (strpos($queryStr, ':') !== false) {
131 - $queryParts = explode(" ", $queryStr); //Split on Spaces and Search for Fields
 128+ public function queryChecker( $queryStr ) {
 129+ $queryStr = str_replace( '=', ':', $queryStr ); // Now you can use = insted : for querying Fields
 130+ if ( strpos( $queryStr, ':' ) !== false ) {
 131+ $queryParts = explode( " ", $queryStr ); // Split on Spaces and Search for Fields
132132 $queryStr = '';
133 - foreach ($queryParts as $value) {
134 - if (strpos($value, ':') !== false) { //Value conatins a ":" ?
135 - $parts = explode(':', $value); //Split the Query part in Key (Parts[0]) and Value (Parts[1])
136 - $solrField = $this->findField($parts[0]); //Search for a Solr Field for the Key
137 - if ($solrField) {
 133+ foreach ( $queryParts as $value ) {
 134+ if ( strpos( $value, ':' ) !== false ) { // Value conatins a ":" ?
 135+ $parts = explode( ':', $value ); // Split the Query part in Key (Parts[0]) and Value (Parts[1])
 136+ $solrField = $this->findField( $parts[0] ); // Search for a Solr Field for the Key
 137+ if ( $solrField ) {
138138 $queryStr = $queryStr . ' ' . $solrField . ':' . $parts[1];
139139 } else {
140140 $queryStr = $queryStr . ' ' . $parts[0] . ' ' . $parts[1];
@@ -144,105 +144,105 @@
145145 }
146146 }
147147
148 - return $queryStr = $this->encodeSolr($queryStr);
 148+ return $queryStr = $this->encodeSolr( $queryStr );
149149 }
150150
151151 /**
152152 * Transform a Wiki Query to a Solr Query
153153 * TODO: Do more Wiki2Solr transformation
154 - *
 154+ *
155155 * @param type $queryStr - Wiki QueryString
156156 * @return type $queryStr - Solr QueryString
157157 */
158 - public function parseSolrQuery($queryStr) {
159 - //TODO: Parse the QueryString to make it work in Solr
160 - $queryParts = explode("[[", $queryStr);
 158+ public function parseSolrQuery( $queryStr ) {
 159+ // TODO: Parse the QueryString to make it work in Solr
 160+ $queryParts = explode( "[[", $queryStr );
161161
162 - //Clean the queryStr
 162+ // Clean the queryStr
163163 $queryStr = '';
164 - foreach ($queryParts as $part) {
165 - if (stripos($part, '::')) {
166 - $parts = split('::', $part); //Split the Query part in Key (Parts[0]) and Value (Parts[1])
167 - $parts[0] = $this->findField($parts[0]); //Search for a Solr Field for the Key
168 - $queryStr = $queryStr . ' ' . $parts[0] . ':' . $parts[1]; //Build Querystring
169 - } elseif (stripos($part, ':')) {
170 - $queryStr = $queryStr . ' category' . substr($part, stripos($part, ':'));
 164+ foreach ( $queryParts as $part ) {
 165+ if ( stripos( $part, '::' ) ) {
 166+ $parts = split( '::', $part ); // Split the Query part in Key (Parts[0]) and Value (Parts[1])
 167+ $parts[0] = $this->findField( $parts[0] ); // Search for a Solr Field for the Key
 168+ $queryStr = $queryStr . ' ' . $parts[0] . ':' . $parts[1]; // Build Querystring
 169+ } elseif ( stripos( $part, ':' ) ) {
 170+ $queryStr = $queryStr . ' category' . substr( $part, stripos( $part, ':' ) );
171171 } else {
172172 $queryStr = $queryStr . $part;
173173 }
174174 }
175 - $queryStr = str_replace('[', '', $queryStr);
176 - $queryStr = str_replace(']', '', $queryStr);
 175+ $queryStr = str_replace( '[', '', $queryStr );
 176+ $queryStr = str_replace( ']', '', $queryStr );
177177
178178 return $queryStr;
179179 }
180180
181181 /**
182182 * Add an XML Document to the Solr Index
183 - *
 183+ *
184184 * @param $xmlcontent - Solr XML Document
185185 */
186 - public function solrAdd($xmlcontent) {
 186+ public function solrAdd( $xmlcontent ) {
187187 global $wgSolrUrl;
188188
189189 $url = $wgSolrUrl . '/update?commit=true';
190 - $xmlcontent = str_replace('&', '+', $xmlcontent);
191 - $xmlcontent = str_replace('&nbsp;', ' ', $xmlcontent);
192 - $xmlcontent = str_replace('&nbsp', ' ', $xmlcontent);
193 - $xmlcontent = str_replace('&amp;', ' ', $xmlcontent);
194 - $xmlcontent = str_replace('&amp', ' ', $xmlcontent);
 190+ $xmlcontent = str_replace( '&', '+', $xmlcontent );
 191+ $xmlcontent = str_replace( '&nbsp;', ' ', $xmlcontent );
 192+ $xmlcontent = str_replace( '&nbsp', ' ', $xmlcontent );
 193+ $xmlcontent = str_replace( '&amp;', ' ', $xmlcontent );
 194+ $xmlcontent = str_replace( '&amp', ' ', $xmlcontent );
195195
196 - return $this->solrSend($url, $xmlcontent);
 196+ return $this->solrSend( $url, $xmlcontent );
197197 }
198198
199199 /**
200200 * Private Function for interactinig with Solr.
201 - *
 201+ *
202202 * @param type $url
203203 * @param type $xmlcontent
204 - * @return SimpleXMLElement
 204+ * @return SimpleXMLElement
205205 */
206 - private function solrSend($url, $xmlcontent = false) {
 206+ private function solrSend( $url, $xmlcontent = false ) {
207207 $ch = curl_init();
208208
209 - $url = str_replace(' ', '+', $url);
 209+ $url = str_replace( ' ', '+', $url );
210210
211 - curl_setopt($ch, CURLOPT_URL, $url);
212 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
213 - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
214 - curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
215 -
216 - if ($xmlcontent) {
217 - curl_setopt($ch, CURLOPT_POST, 1);
218 - curl_setopt($ch, CURLOPT_HTTPHEADER, $this->header);
219 - curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlcontent);
 211+ curl_setopt( $ch, CURLOPT_URL, $url );
 212+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
 213+ curl_setopt( $ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
 214+ curl_setopt( $ch, CURLINFO_HEADER_OUT, 1 );
 215+
 216+ if ( $xmlcontent ) {
 217+ curl_setopt( $ch, CURLOPT_POST, 1 );
 218+ curl_setopt( $ch, CURLOPT_HTTPHEADER, $this->header );
 219+ curl_setopt( $ch, CURLOPT_POSTFIELDS, $xmlcontent );
220220 }
221221
222 - $data = curl_exec($ch);
223 -
 222+ $data = curl_exec( $ch );
 223+
224224 if ( curl_errno( $ch ) != 0 ) {
225225 throw new MWException( curl_error( $ch ) );
226226 }
227 -
228 - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
229 -
230 - curl_close($ch);
231227
 228+ $httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
 229+
 230+ curl_close( $ch );
 231+
232232 // if the request was successful
233233 if ( $httpCode == 200 ) {
234 -
 234+
235235 try {
236 - $xml = new SimpleXMLElement($data);
237 - } catch (Exception $exc) {
 236+ $xml = new SimpleXMLElement( $data );
 237+ } catch ( Exception $exc ) {
238238 throw new MWException( $exc->getMessage() );
239239 }
240 -
 240+
241241 } else { // some error occurred
242 -
 242+
243243 // have to scrape the error message from the returned HTML
244244 $xml = new DOMDocument;
245245 $xml->loadHTML( $data );
246 -
 246+
247247 $u = $xml->getElementsByTagName( 'u' );
248248 $errmsg = $xml->saveXML( $u->item( $u->length - 1 )->firstChild );
249249
@@ -252,41 +252,41 @@
253253 return $xml;
254254 }
255255
256 - //SOLR Functions
 256+ // SOLR Functions
257257
258258 /**
259259 * Add a Document to the SolrIndex
260 - * @param SolrDoc $file
 260+ * @param SolrDoc $file
261261 */
262 - public function addDoc(SolrDoc $file) {
 262+ public function addDoc( SolrDoc $file ) {
263263 $filekopf = "<add><doc>";
264264 $filefuss = "</doc></add>";
265265 $xmlcontent = $filekopf . $file->printFields() . $filefuss;
266 - return $this->solrAdd($xmlcontent);
 266+ return $this->solrAdd( $xmlcontent );
267267 }
268268
269269 /**
270270 * Remove a Document with the $id from the SolrIndex
271 - * @param type $id
 271+ * @param type $id
272272 * @return type $xml - Response from Solr
273273 */
274 - public function deleteDocId($id) {
 274+ public function deleteDocId( $id ) {
275275 $filekopf = "<delte><id>";
276276 $filefuss = "</id></delte>";
277277 $xmlcontent = $filekopf . $id . $filefuss;
278 - return $this->solrAdd($xmlcontent);
 278+ return $this->solrAdd( $xmlcontent );
279279 }
280280
281281 /**
282282 * Delete all Documents found by this Query
283 - * @param type $query
 283+ * @param type $query
284284 * @return type $xml - Response from Solr
285285 */
286 - public function deleteDocQuery($query) {
 286+ public function deleteDocQuery( $query ) {
287287 $filekopf = "<delte><query>";
288288 $filefuss = "</query></delte>";
289289 $xmlcontent = $filekopf . $query . $filefuss;
290 - return $this->solrAdd($xmlcontent);
 290+ return $this->solrAdd( $xmlcontent );
291291 }
292292
293293 /**
@@ -295,35 +295,35 @@
296296 */
297297 public function deleteAllDocs() {
298298 $xmlcontent = '<delete><query>*:*</query></delete>';
299 - return $this->solrAdd($xmlcontent);
 299+ return $this->solrAdd( $xmlcontent );
300300 }
301301
302302 /**
303303 * This Function is used for Storing an SMWSemanticData Item in the Solr Index
304304 *
305 - * @param SMWSemanticData $data
 305+ * @param SMWSemanticData $data
306306 */
307 - public function parseSemanticData(SMWSemanticData $data) {
 307+ public function parseSemanticData( SMWSemanticData $data ) {
308308 $solritem = new SolrDoc ();
309309
310 - $solritem->addField("pagetitle", $data->getSubject()->getTitle()->getText());
311 - $solritem->addField("namespace", $data->getSubject()->getNamespace());
312 - $solritem->addField("dbkey", $data->getSubject()->getDBkey());
313 - $solritem->addField("interwiki", $data->getSubject()->getInterwiki());
314 - $solritem->addField("subobjectname", $data->getSubject()->getSubobjectName());
 310+ $solritem->addField( "pagetitle", $data->getSubject()->getTitle()->getText() );
 311+ $solritem->addField( "namespace", $data->getSubject()->getNamespace() );
 312+ $solritem->addField( "dbkey", $data->getSubject()->getDBkey() );
 313+ $solritem->addField( "interwiki", $data->getSubject()->getInterwiki() );
 314+ $solritem->addField( "subobjectname", $data->getSubject()->getSubobjectName() );
315315
316 - foreach ($data->getProperties() as $property) {
317 - if (( $property->getKey() == '_SKEY' ) || ( $property->getKey() == '_REDI' )) {
 316+ foreach ( $data->getProperties() as $property ) {
 317+ if ( ( $property->getKey() == '_SKEY' ) || ( $property->getKey() == '_REDI' ) ) {
318318 continue; // skip these here, we store them differently
319319 }
320320
321321 $propertyName = $property->getLabel();
322322
323 - foreach ($data->getPropertyValues($property) as $di) {
324 - if ($di instanceof SMWDIError) { // error values, ignore
 323+ foreach ( $data->getPropertyValues( $property ) as $di ) {
 324+ if ( $di instanceof SMWDIError ) { // error values, ignore
325325 continue;
326326 }
327 - switch ($di->getDIType()) {
 327+ switch ( $di->getDIType() ) {
328328 case 0:
329329 // /// Data item ID that can be used to indicate that no data item class is appropriate
330330 // const TYPE_NOTYPE = 0;
@@ -332,58 +332,58 @@
333333 case 1:
334334 // /// Data item ID for SMWDINumber
335335 // const TYPE_NUMBER = 1;
336 - $solritem->addField($propertyName . '_i', $di->getNumber());
337 - $solritem->addSortField($propertyName . '_i', $di->getNumber());
 336+ $solritem->addField( $propertyName . '_i', $di->getNumber() );
 337+ $solritem->addSortField( $propertyName . '_i', $di->getNumber() );
338338 break;
339339
340340 case 2:
341341 // /// Data item ID for SMWDIString
342342 // const TYPE_STRING = 2;
343 - $solritem->addField($propertyName . '_t', $di->getString());
344 - $solritem->addSortField($propertyName . '_t', $di->getString());
 343+ $solritem->addField( $propertyName . '_t', $di->getString() );
 344+ $solritem->addSortField( $propertyName . '_t', $di->getString() );
345345 break;
346346
347347 case 3:
348348 // /// Data item ID for SMWDIBlob
349349 // const TYPE_BLOB = 3;
350 - $solritem->addField($propertyName . '_t', $di->getString());
351 - $solritem->addSortField($propertyName . '_t', $di->getString());
 350+ $solritem->addField( $propertyName . '_t', $di->getString() );
 351+ $solritem->addSortField( $propertyName . '_t', $di->getString() );
352352 break;
353353
354354 case 4:
355355 // /// Data item ID for SMWDIBoolean
356356 // const TYPE_BOOLEAN = 4;
357 - $solritem->addField($propertyName . '_b', $di->getBoolean());
358 - $solritem->addSortField($propertyName . '_b', $di->getBoolean());
 357+ $solritem->addField( $propertyName . '_b', $di->getBoolean() );
 358+ $solritem->addSortField( $propertyName . '_b', $di->getBoolean() );
359359 break;
360360
361361 case 5:
362362 // /// Data item ID for SMWDIUri
363363 // const TYPE_URI = 5;
364 - $solritem->addField($propertyName . '_t', $di->getURI());
365 - $solritem->addSortField($propertyName . '_t', $di->getURI());
 364+ $solritem->addField( $propertyName . '_t', $di->getURI() );
 365+ $solritem->addSortField( $propertyName . '_t', $di->getURI() );
366366 break;
367367
368368 case 6:
369369 // /// Data item ID for SMWDITimePoint
370370 // const TYPE_TIME = 6;
371371 $date = $di->getYear() . '-' . $di->getMonth() . '-' . $di->getDay() . 'T' . $di->getHour() . ':' . $di->getMinute() . ':' . $di->getSecond() . 'Z';
372 - $solritem->addField($propertyName . '_dt', $date);
373 - $solritem->addSortField($propertyName . '_dt', $date);
 372+ $solritem->addField( $propertyName . '_dt', $date );
 373+ $solritem->addSortField( $propertyName . '_dt', $date );
374374 break;
375375
376376 case 7:
377377 // /// Data item ID for SMWDIGeoCoord
378378 // const TYPE_GEO = 7;
379 - //TODO: Implement range Search in SOLR
380 - $solritem->addField($propertyName . '_lat', $di->getLatitude());
381 - $solritem->addField($propertyName . '_lng', $di->getLongitude());
 379+ // TODO: Implement range Search in SOLR
 380+ $solritem->addField( $propertyName . '_lat', $di->getLatitude() );
 381+ $solritem->addField( $propertyName . '_lng', $di->getLongitude() );
382382 break;
383383
384384 case 8:
385385 // /// Data item ID for SMWDIContainer
386386 // const TYPE_CONTAINER = 8
387 - //TODO: What the Hell is this used for ???
 387+ // TODO: What the Hell is this used for ???
388388 $data->getSubject()->getTitle()->getText() . " : ";
389389 break;
390390
@@ -391,12 +391,12 @@
392392 // /// Data item ID for SMWDIWikiPage
393393 // const TYPE_WIKIPAGE = 9;
394394 $ns = $di->getNamespace();
395 - if ($ns == 0) {
396 - $solritem->addField($propertyName . '_s', $di->getTitle());
397 - } elseif ($ns == 14) {
 395+ if ( $ns == 0 ) {
 396+ $solritem->addField( $propertyName . '_s', $di->getTitle() );
 397+ } elseif ( $ns == 14 ) {
398398 $title = $di->getTitle();
399 - $solritem->addField('category', substr($title, stripos($title, ':') + 1));
400 - }
 399+ $solritem->addField( 'category', substr( $title, stripos( $title, ':' ) + 1 ) );
 400+ }
401401 break;
402402
403403 case 10:
@@ -421,7 +421,7 @@
422422 }
423423 }
424424 }
425 - $this->addDoc($solritem);
 425+ $this->addDoc( $solritem );
426426 }
427427
428428 }
Index: trunk/extensions/SolrStore/SolrStore.alias.php
@@ -6,9 +6,8 @@
77 * @file
88 * @author Simon Bachenberg
99 */
10 -
1110 $specialPageAliases = array();
1211
13 -$specialPageAliases['en'] = array('solrsearch' => array('SolrSearch', 'SpecialSolrSearch'));
14 -$specialPageAliases['de'] = array('solrsearch' => array('SolrSearch', 'SpecialSolrSearch'));
 12+$specialPageAliases['en'] = array( 'solrsearch' => array( 'SolrSearch', 'SpecialSolrSearch' ) );
 13+$specialPageAliases['de'] = array( 'solrsearch' => array( 'SolrSearch', 'SpecialSolrSearch' ) );
1514
Index: trunk/extensions/SolrStore/SolrDoc.php
@@ -16,50 +16,50 @@
1717 private $output;
1818 private $min = array ();
1919 private $max = array ();
20 -
 20+
2121 /**
2222 * Add a Field to the SolrDoc
23 - *
 23+ *
2424 * @param type $name of the Field
2525 * @param type $value of the Field
2626 */
27 - public function addField($name,$value){
28 - $this->output.= '<field name="' . $name . '">' . $value . '</field>' ;
 27+ public function addField( $name, $value ) {
 28+ $this->output .= '<field name="' . $name . '">' . $value . '</field>' ;
2929 }
30 -
 30+
3131 /**
3232 * This Function gets a Multivalued Field and splits it into a max and a min value for Sorting
33 - *
 33+ *
3434 * @param type $name of the Field
3535 * @param type $value of the Field
3636 */
37 - public function addSortField($name, $value) {
38 - //Does a min/max Field with this name exist ?
39 - if (isset ($this->min[$name]) && isset ($this->max[$name])){
40 - if (strcasecmp($this->min[$name], $value) > 0){
41 - //If the new String is Less the Old one replace them
 37+ public function addSortField( $name, $value ) {
 38+ // Does a min/max Field with this name exist ?
 39+ if ( isset ( $this->min[$name] ) && isset ( $this->max[$name] ) ) {
 40+ if ( strcasecmp( $this->min[$name], $value ) > 0 ) {
 41+ // If the new String is Less the Old one replace them
4242 $this->min[$name] = $value;
4343 }
44 - if(strcasecmp($this->max[$name], $value) < 0){
45 - //If the new String is Bigger than Old one replace them
 44+ if ( strcasecmp( $this->max[$name], $value ) < 0 ) {
 45+ // If the new String is Bigger than Old one replace them
4646 $this->max[$name] = $value;
4747 }
48 - }else{
 48+ } else {
4949 $this->min[$name] = $value;
5050 $this->max[$name] = $value;
5151 }
5252 }
53 -
 53+
5454 public function printFields() {
5555 $all = $this->output;
56 -
57 - foreach ($this->min as $name => $value) {
 56+
 57+ foreach ( $this->min as $name => $value ) {
5858 $all .= '<field name="' . $name . 'min">' . $value . '</field>' ;
5959 }
60 - foreach ($this->max as $name => $value) {
 60+ foreach ( $this->max as $name => $value ) {
6161 $all .= '<field name="' . $name . 'max">' . $value . '</field>' ;
6262 }
63 -
 63+
6464 return $all;
6565 }
6666 }
Index: trunk/extensions/SolrStore/SolrSearch.php
@@ -9,7 +9,7 @@
1010
1111 /**
1212 * TODO: Insert class description
13 - *
 13+ *
1414 * @ingroup SolrStore
1515 */
1616 class SolrSearch extends SearchEngine {
@@ -18,11 +18,11 @@
1919 var $offset = 0;
2020 var $prefix = '';
2121 var $searchTerms = array();
22 - var $namespaces = array(NS_MAIN);
 22+ var $namespaces = array( NS_MAIN );
2323 var $showRedirects = false;
2424 var $solrTalker;
2525
26 - function __construct($db = null) {
 26+ function __construct( $db = null ) {
2727 global $wgSolrTalker;
2828 }
2929
@@ -34,8 +34,8 @@
3535 * @return SolrSearchSet
3636 * @access public
3737 */
38 - function searchText($term) {
39 - return SolrSearchSet::newFromQuery(isset($this->related) ? 'related' : 'search', $term, $this->namespaces, $this->limit, $this->offset, $this->searchingEverything());
 38+ function searchText( $term ) {
 39+ return SolrSearchSet::newFromQuery( isset( $this->related ) ? 'related' : 'search', $term, $this->namespaces, $this->limit, $this->offset, $this->searchingEverything() );
4040 }
4141
4242 /**
@@ -45,19 +45,19 @@
4646 * @return SolrSearchSet
4747 * @access public
4848 */
49 - function searchTitle($term) {
 49+ function searchTitle( $term ) {
5050 return null;
5151 }
5252
5353 /**
5454 * PrefixSearchBackend override for OpenSearch results
5555 */
56 - static function prefixSearch($ns, $search, $limit, &$results) {
 56+ static function prefixSearch( $ns, $search, $limit, &$results ) {
5757 echo "Prefix Search!<br/>";
58 - $it = SolrSearchSet::newFromQuery('prefix', $search, $ns, $limit, 0);
 58+ $it = SolrSearchSet::newFromQuery( 'prefix', $search, $ns, $limit, 0 );
5959 $results = array();
60 - if ($it) { // $it can be null
61 - while ($res = $it->next()) {
 60+ if ( $it ) { // $it can be null
 61+ while ( $res = $it->next() ) {
6262 $results[] = $res->getTitle()->getPrefixedText();
6363 }
6464 }
@@ -66,30 +66,30 @@
6767
6868 /**
6969 * Check if we are searching all the namespaces on this wiki
70 - *
 70+ *
7171 * @return boolean
7272 */
7373 function searchingEverything() {
74 - return $this->namespaces == array_keys(SearchEngine::searchableNamespaces());
 74+ return $this->namespaces == array_keys( SearchEngine::searchableNamespaces() );
7575 }
7676
7777 /**
7878 * Prepare query for the Solr-search daemon:
79 - *
80 - * 1) rewrite namespaces into standardized form
 79+ *
 80+ * 1) rewrite namespaces into standardized form
8181 * e.g. image:clouds -> [6]:clouds
82 - *
 82+ *
8383 * 2) rewrite localizations of "search everything" keyword
8484 * e.g. alle:heidegger -> all:heidegger
8585 *
86 - * @param string query
 86+ * @param string query
8787 * @return string rewritten query
8888 * @access private
8989 */
90 - function replacePrefixes($query) {
 90+ function replacePrefixes( $query ) {
9191 global $wgContLang, $wgSolrUseRelated;
9292 $fname = 'SolrSearch::replacePrefixes';
93 - wfProfileIn($fname);
 93+ wfProfileIn( $fname );
9494 $start = 0;
9595 $len = 0; // token start pos and length
9696 $rewritten = ''; // rewritten query
@@ -97,65 +97,65 @@
9898 $inquotes = false;
9999
100100 // "search everything" keyword
101 - $allkeyword = wfMsgForContent('searchall');
 101+ $allkeyword = wfMsgForContent( 'searchall' );
102102
103 - $qlen = strlen($query);
 103+ $qlen = strlen( $query );
104104
105105 // quick check, most of the time we don't need any rewriting
106 - if (strpos($query, ':') === false) {
107 - wfProfileOut($fname);
 106+ if ( strpos( $query, ':' ) === false ) {
 107+ wfProfileOut( $fname );
108108 return $query;
109109 }
110110
111111 // check if this is query for related articles
112 - $relatedkey = wfMsgForContent('searchrelated') . ':';
113 - if ($wgSolrUseRelated && strncmp($query, $relatedkey, strlen($relatedkey)) == 0) {
 112+ $relatedkey = wfMsgForContent( 'searchrelated' ) . ':';
 113+ if ( $wgSolrUseRelated && strncmp( $query, $relatedkey, strlen( $relatedkey ) ) == 0 ) {
114114 $this->related = true;
115 - list($dummy, $ret) = explode(":", $query, 2);
116 - wfProfileOut($fname);
117 - return trim($ret);
 115+ list( $dummy, $ret ) = explode( ":", $query, 2 );
 116+ wfProfileOut( $fname );
 117+ return trim( $ret );
118118 }
119119
120120 global $wgCanonicalNamespaceNames, $wgNamespaceAliases;
121 - $nsNamesRaw = array_merge($wgContLang->getNamespaces(), $wgCanonicalNamespaceNames, array_keys(array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases())));
 121+ $nsNamesRaw = array_merge( $wgContLang->getNamespaces(), $wgCanonicalNamespaceNames, array_keys( array_merge( $wgNamespaceAliases, $wgContLang->getNamespaceAliases() ) ) );
122122
123123 # add all namespace names w/o spaces
124124 $nsNames = array();
125 - foreach ($nsNamesRaw as $ns) {
126 - if ($ns != '') {
 125+ foreach ( $nsNamesRaw as $ns ) {
 126+ if ( $ns != '' ) {
127127 $nsNames[] = $ns;
128 - $nsNames[] = str_replace('_', ' ', $ns);
 128+ $nsNames[] = str_replace( '_', ' ', $ns );
129129 }
130130 }
131131
132 - $regexp = implode('|', array_unique($nsNames));
 132+ $regexp = implode( '|', array_unique( $nsNames ) );
133133
134134 # rewrite the query by replacing valid namespace names
135 - $parts = preg_split('/(")/', $query, -1, PREG_SPLIT_DELIM_CAPTURE);
 135+ $parts = preg_split( '/(")/', $query, -1, PREG_SPLIT_DELIM_CAPTURE );
136136 $inquotes = false;
137137 $rewritten = '';
138 - foreach ($parts as $part) {
139 - if ($part == '"') { # stuff in quote doesnt get rewritten
 138+ foreach ( $parts as $part ) {
 139+ if ( $part == '"' ) { # stuff in quote doesnt get rewritten
140140 $rewritten .= $part;
141141 $inquotes = !$inquotes;
142 - } elseif ($inquotes) {
 142+ } elseif ( $inquotes ) {
143143 $rewritten .= $part;
144144 } else {
145145 # replace namespaces
146 - $r = preg_replace_callback('/(^|[| :])(' . $regexp . '):/i', array($this, 'replaceNamespace'), $part);
 146+ $r = preg_replace_callback( '/(^|[| :])(' . $regexp . '):/i', array( $this, 'replaceNamespace' ), $part );
147147 # replace to backend all: notation
148 - $rewritten .= str_replace($allkeyword . ':', 'all:', $r);
 148+ $rewritten .= str_replace( $allkeyword . ':', 'all:', $r );
149149 }
150150 }
151 - wfProfileOut($fname);
 151+ wfProfileOut( $fname );
152152 return $rewritten;
153153 }
154154
155155 /** callback to replace namespace names to internal notation, e.g. User: -> [2]: */
156 - function replaceNamespace($matches) {
 156+ function replaceNamespace( $matches ) {
157157 global $wgContLang;
158 - $inx = $wgContLang->getNsIndex(str_replace(' ', '_', $matches[2]));
159 - if ($inx === false)
 158+ $inx = $wgContLang->getNsIndex( str_replace( ' ', '_', $matches[2] ) );
 159+ if ( $inx === false )
160160 return $matches[0];
161161 else
162162 return $matches[1] . "[$inx]:";
@@ -166,11 +166,11 @@
167167 }
168168
169169 /** Merge the prefix into the query (if any) */
170 - function transformSearchTerm($term) {
 170+ function transformSearchTerm( $term ) {
171171 global $wgSolrSearchVersion;
172172
173 - if ($wgSolrSearchVersion >= 2.1 && $this->prefix != '') {
174 -# convert to internal backend prefix notation
 173+ if ( $wgSolrSearchVersion >= 2.1 && $this->prefix != '' ) {
 174+# convert to internal backend prefix notation
175175 $term = $term . ' prefix:' . $this->prefix;
176176 }
177177 return $term;
@@ -182,7 +182,7 @@
183183
184184 /**
185185 * Construct a result object from single result line
186 - *
 186+ *
187187 * @param array $lines
188188 * @param string $method - method used to fetch these results
189189 * @return array (float, Title)
@@ -192,7 +192,7 @@
193193 return false;
194194 }
195195
196 - function SolrResult($result, $method) {
 196+ function SolrResult( $result, $method ) {
197197 global $wgContLang;
198198
199199 $score = null;
@@ -201,7 +201,7 @@
202202 $title = null;
203203
204204 $xml = $result;
205 - wfDebug("Solr line: '$result'\n");
 205+ wfDebug( "Solr line: '$result'\n" );
206206
207207 // Defining Results
208208
@@ -210,29 +210,29 @@
211211 $this->mScore = $score;
212212
213213
214 - //-------------------------------------
 214+ // -------------------------------------
215215 // Get The Shit out of da XML
216 - //-------------------------------------
217 - foreach ($xml->arr as $doc) {
218 - switch ($doc['name']) {
 216+ // -------------------------------------
 217+ foreach ( $xml->arr as $doc ) {
 218+ switch ( $doc['name'] ) {
219219 case 'text':
220220 $nsText = $doc->str;
221221
222222 $this->mSize = "";
223 - $this->mWordCount = count($doc->str);
 223+ $this->mWordCount = count( $doc->str );
224224 $snipmax = 10;
225225 $textsnip = "";
226226 $textsnipvar = 0;
227 - foreach ($doc->str as $inner) {
 227+ foreach ( $doc->str as $inner ) {
228228 $textsnipvar++;
229 - if ($textsnipvar >= 4 && $textsnipvar <= $snipmax) {
230 - $textsnip.=" " . $inner;
 229+ if ( $textsnipvar >= 4 && $textsnipvar <= $snipmax ) {
 230+ $textsnip .= " " . $inner;
231231 }
232 - $this->mSize = $this->mSize + strlen($inner);
 232+ $this->mSize = $this->mSize + strlen( $inner );
233233 }
234 - $textsnip.="...";
235 - $this->mSize = ($this->mSize / 3);
236 - //$this->mSize=$size;
 234+ $textsnip .= "...";
 235+ $this->mSize = ( $this->mSize / 3 );
 236+ // $this->mSize=$size;
237237 break;
238238 case 'Zuletzt geändert_dt':
239239 $this->mDate = $doc->date;
@@ -240,8 +240,8 @@
241241 }
242242 }
243243
244 - foreach ($xml->str as $docs) {
245 - switch ($docs['name']) {
 244+ foreach ( $xml->str as $docs ) {
 245+ switch ( $docs['name'] ) {
246246 case 'pagetitle':
247247 $this->mTitle = $doc->str;
248248 break;
@@ -253,47 +253,47 @@
254254 break;
255255 }
256256 }
257 - foreach ($xml->int as $doci) {
258 - switch ($doci['name']) {
 257+ foreach ( $xml->int as $doci ) {
 258+ switch ( $doci['name'] ) {
259259 case 'namespace':
260260 $namespace = $doc->str;
261261 break;
262262 }
263263 }
264264
265 - $title = urldecode($title);
266 - if (!isset($nsText))
267 - $nsText = $wgContLang->getNsText($namespace);
 265+ $title = urldecode( $title );
 266+ if ( !isset( $nsText ) )
 267+ $nsText = $wgContLang->getNsText( $namespace );
268268 else
269 - $nsText = urldecode($nsText);
 269+ $nsText = urldecode( $nsText );
270270
271271 // make title
272 - $this->mTitle = Title::makeTitle($namespace, $title);
 272+ $this->mTitle = Title::makeTitle( $namespace, $title );
273273
274274 // HIGHLIHT
275275 // <em> & </em> Fix to <b> // if not, no highlighting !!
276276 // TITLE (LINK)
277 - if ($xml->highlight->title != '') {
278 - $this->mHighlightTitle = str_replace("<em>", "<b>", $xml->highlight->title);
279 - $this->mHighlightTitle = str_replace("</em>", "</b>", $this->mHighlightTitle);
 277+ if ( $xml->highlight->title != '' ) {
 278+ $this->mHighlightTitle = str_replace( "<em>", "<b>", $xml->highlight->title );
 279+ $this->mHighlightTitle = str_replace( "</em>", "</b>", $this->mHighlightTitle );
280280 } else {
281281 $this->mHighlightTitle = '';
282282 }
283283 // TEXT (under Link)
284 - //$this->mHighlightText=$xml->highlight->title;
285 - if ($xml->highlight->Inhalt != '') {
286 - $this->mHighlightText = str_replace("<em>", "<b>", $xml->highlight->Inhalt);
287 - $this->mHighlightText = str_replace("</em>", "</b>", $this->mHighlightText);
288 - $this->mHighlightText.="...";
289 - } else {//$this->mHighlightText=textsnip;
290 - if (isset($_REQUEST['search']) != '' && isset($textsnip) != '') {
291 - if (strpos(strtolower($textsnip), strtolower($_REQUEST['search']))) {
292 - $tempc = strlen($_REQUEST['search']);
293 - $pos1 = strpos(strtolower($textsnip), strtolower($_REQUEST['search']));
294 - $tmpa = substr($textsnip, 0, $pos1);
295 - $tmpb = substr($textsnip, ($pos1 + $tempc));
296 - $this->mHighlightText = $tmpa . "<b>" . substr($textsnip, $pos1, $tempc) . "</b>" . $tmpb;
297 - //str_replace($_REQUEST['search'],"<b>".$_REQUEST['search']."</b>",$textsnip);
 284+ // $this->mHighlightText=$xml->highlight->title;
 285+ if ( $xml->highlight->Inhalt != '' ) {
 286+ $this->mHighlightText = str_replace( "<em>", "<b>", $xml->highlight->Inhalt );
 287+ $this->mHighlightText = str_replace( "</em>", "</b>", $this->mHighlightText );
 288+ $this->mHighlightText .= "...";
 289+ } else {// $this->mHighlightText=textsnip;
 290+ if ( isset( $_REQUEST['search'] ) != '' && isset( $textsnip ) != '' ) {
 291+ if ( strpos( strtolower( $textsnip ), strtolower( $_REQUEST['search'] ) ) ) {
 292+ $tempc = strlen( $_REQUEST['search'] );
 293+ $pos1 = strpos( strtolower( $textsnip ), strtolower( $_REQUEST['search'] ) );
 294+ $tmpa = substr( $textsnip, 0, $pos1 );
 295+ $tmpb = substr( $textsnip, ( $pos1 + $tempc ) );
 296+ $this->mHighlightText = $tmpa . "<b>" . substr( $textsnip, $pos1, $tempc ) . "</b>" . $tmpb;
 297+ // str_replace($_REQUEST['search'],"<b>".$_REQUEST['search']."</b>",$textsnip);
298298 } else {
299299 $this->mHighlightText = $textsnip;
300300 }
@@ -315,19 +315,19 @@
316316 * @param boolean $useFinalSeparator
317317 * @return array (highlighted, unmodified text)
318318 */
319 - function extractSnippet($lines, $nsText, $type, $useFinalSeparator=false) {
320 - if (!array_key_exists($type, $lines))
321 - return array(null, null);
 319+ function extractSnippet( $lines, $nsText, $type, $useFinalSeparator = false ) {
 320+ if ( !array_key_exists( $type, $lines ) )
 321+ return array( null, null );
322322 $ret = "";
323323 $original = null;
324 - foreach ($lines[$type] as $h) {
325 - list($s, $o) = $this->extractSnippetLine($h, $useFinalSeparator);
 324+ foreach ( $lines[$type] as $h ) {
 325+ list( $s, $o ) = $this->extractSnippetLine( $h, $useFinalSeparator );
326326 $ret .= $s;
327327 $original = $o;
328328 }
329 - if ($nsText != '')
 329+ if ( $nsText != '' )
330330 $ret = $nsText . ':' . $ret;
331 - return array($ret, $original);
 331+ return array( $ret, $original );
332332 }
333333
334334 /**
@@ -338,67 +338,67 @@
339339 * @access protected
340340 * @return array(snippet,unmodified text)
341341 */
342 - function extractSnippetLine($line, $useFinalSeparator) {
343 - $parts = explode(" ", $line);
344 - if (count($parts) != 4 && count($parts) != 5) {
345 - wfDebug("Bad result line:" . $line . "\n");
 342+ function extractSnippetLine( $line, $useFinalSeparator ) {
 343+ $parts = explode( " ", $line );
 344+ if ( count( $parts ) != 4 && count( $parts ) != 5 ) {
 345+ wfDebug( "Bad result line:" . $line . "\n" );
346346 return "";
347347 }
348 - $splits = $this->stripBracketsSplit($parts[0]);
349 - $highlight = $this->stripBracketsSplit($parts[1]);
350 - $suffix = urldecode($this->stripBrackets($parts[2]));
351 - $text = urldecode($parts[3]);
 348+ $splits = $this->stripBracketsSplit( $parts[0] );
 349+ $highlight = $this->stripBracketsSplit( $parts[1] );
 350+ $suffix = urldecode( $this->stripBrackets( $parts[2] ) );
 351+ $text = urldecode( $parts[3] );
352352 $original = null;
353 - if (count($parts) > 4)
354 - $original = urldecode($parts[4]);
 353+ if ( count( $parts ) > 4 )
 354+ $original = urldecode( $parts[4] );
355355
356 - $splits[] = strlen($text);
 356+ $splits[] = strlen( $text );
357357 $start = 0;
358358 $snippet = "";
359359 $hi = 0;
360 - $ellipsis = wfMsgForContent('ellipsis');
 360+ $ellipsis = wfMsgForContent( 'ellipsis' );
361361
362 - foreach ($splits as $sp) {
363 - $sp = intval($sp);
 362+ foreach ( $splits as $sp ) {
 363+ $sp = intval( $sp );
364364 // highlight words!
365 - while ($hi < count($highlight) && intval($highlight[$hi]) < $sp) {
366 - $s = intval($highlight[$hi]);
367 - $e = intval($highlight[$hi + 1]);
368 - $snippet .= substr($text, $start, $s - $start) . "<span class='searchmatch'>" . substr($text, $s, $e - $s) . "</span>";
 365+ while ( $hi < count( $highlight ) && intval( $highlight[$hi] ) < $sp ) {
 366+ $s = intval( $highlight[$hi] );
 367+ $e = intval( $highlight[$hi + 1] );
 368+ $snippet .= substr( $text, $start, $s - $start ) . "<span class='searchmatch'>" . substr( $text, $s, $e - $s ) . "</span>";
369369 $start = $e;
370370 $hi += 2;
371371 }
372372 // copy till split point
373 - $snippet .= substr($text, $start, $sp - $start);
374 - if ($sp == strlen($text) && $suffix != '')
 373+ $snippet .= substr( $text, $start, $sp - $start );
 374+ if ( $sp == strlen( $text ) && $suffix != '' )
375375 $snippet .= $suffix;
376 - else if ($useFinalSeparator)
 376+ else if ( $useFinalSeparator )
377377 $snippet .= " <b>" . $ellipsis . "</b> ";
378378
379379 $start = $sp;
380380 }
381 - return array($snippet, $original);
 381+ return array( $snippet, $original );
382382 }
383383
384384 /**
385385 * @access private
386386 */
387 - function stripBrackets($str) {
388 - if ($str == '[]')
 387+ function stripBrackets( $str ) {
 388+ if ( $str == '[]' )
389389 return '';
390 - return substr($str, 1, strlen($str) - 2);
 390+ return substr( $str, 1, strlen( $str ) - 2 );
391391 }
392392
393393 /**
394394 * @access private
395395 * @return array
396396 */
397 - function stripBracketsSplit($str) {
398 - $strip = $this->stripBrackets($str);
399 - if ($strip == '')
 397+ function stripBracketsSplit( $str ) {
 398+ $strip = $this->stripBrackets( $str );
 399+ if ( $strip == '' )
400400 return array();
401401 else
402 - return explode(",", $strip);
 402+ return explode( ",", $strip );
403403 }
404404
405405 function getTitle() {
@@ -406,27 +406,27 @@
407407 }
408408
409409 function getScore() {
410 - if (is_null($this->mScore))
411 - return null; // Solr scores are meaningless to the user...
412 -
 410+ if ( is_null( $this->mScore ) )
 411+ return null; // Solr scores are meaningless to the user...
 412+
413413 // echo($this->mScore." ");
414 - return floatval($this->mScore);
 414+ return floatval( $this->mScore );
415415 }
416416
417 - function getTitleSnippet($terms) {
418 - if (is_null($this->mHighlightTitle))
 417+ function getTitleSnippet( $terms ) {
 418+ if ( is_null( $this->mHighlightTitle ) )
419419 return '';
420420 return $this->mHighlightTitle;
421421 }
422422
423 - function getTextSnippet($terms) {
424 - if (is_null($this->mHighlightText))
425 - return parent::getTextSnippet($terms);
 423+ function getTextSnippet( $terms ) {
 424+ if ( is_null( $this->mHighlightText ) )
 425+ return parent::getTextSnippet( $terms );
426426 return $this->mHighlightText;
427427 }
428428
429 - function getRedirectSnippet($terms) {
430 - /* if (isset($this->mHighlightRedirect))
 429+ function getRedirectSnippet( $terms ) {
 430+ /* if (isset($this->mHighlightRedirect))
431431 if (is_null($this->mHighlightRedirect))
432432 return '';
433433 return $this->mHighlightRedirect;
@@ -439,13 +439,13 @@
440440 }
441441
442442 function getSectionSnippet() {
443 - if (is_null($this->mHighlightSection))
 443+ if ( is_null( $this->mHighlightSection ) )
444444 return null;
445445 return $this->mHighlightSection;
446446 }
447447
448448 function getSectionTitle() {
449 - if (is_null($this->mSectionTitle))
 449+ if ( is_null( $this->mSectionTitle ) )
450450 return null;
451451 return $this->mSectionTitle;
452452 }
@@ -459,19 +459,19 @@
460460 }
461461
462462 function getTimestamp() {
463 - if (is_null($this->mDate))
 463+ if ( is_null( $this->mDate ) )
464464 return parent::getTimestamp();
465465 return $this->mDate;
466466 }
467467
468468 function getWordCount() {
469 - if (is_null($this->mWordCount))
 469+ if ( is_null( $this->mWordCount ) )
470470 return parent::getWordCount();
471471 return $this->mWordCount;
472472 }
473473
474474 function getByteSize() {
475 - if (is_null($this->mSize))
 475+ if ( is_null( $this->mSize ) )
476476 return parent::getByteSize();
477477 return $this->mSize;
478478 }
@@ -497,30 +497,30 @@
498498 * @return array
499499 * @access public
500500 */
501 - static function newFromQuery($method, $query, $namespaces = array(), $limit = 20, $offset = 0, $searchAll = False) {
 501+ static function newFromQuery( $method, $query, $namespaces = array(), $limit = 20, $offset = 0, $searchAll = False ) {
502502 $fname = 'SolrSearchSet::newFromQuery';
503 - wfProfileIn($fname);
 503+ wfProfileIn( $fname );
504504
505505 $wgSolrTalker = new SolrTalker();
506506
507 - $query = $wgSolrTalker->queryChecker($query);
508 - $xml = $wgSolrTalker->solrQuery($query, $offset, $limit, true, true); // Abfrage ok, ergebniss in XML
 507+ $query = $wgSolrTalker->queryChecker( $query );
 508+ $xml = $wgSolrTalker->solrQuery( $query, $offset, $limit, true, true ); // Abfrage ok, ergebniss in XML
509509 $totalHits = $xml->result['numFound'];
510510
511 - $resultLines = array();;
 511+ $resultLines = array(); ;
512512
513 - $highl = $xml->xpath('//lst[@name="highlighting"]/lst');
 513+ $highl = $xml->xpath( '//lst[@name="highlighting"]/lst' );
514514
515515 $hli = 0;
516516
517 - foreach ($xml->result->doc as $doc) {
 517+ foreach ( $xml->result->doc as $doc ) {
518518
519 - if (isset($highl[$hli]->arr)) {
 519+ if ( isset( $highl[$hli]->arr ) ) {
520520
521 - foreach ($highl[$hli]->arr as $feld) {
522 - if (isset($feld['name'])) {
 521+ foreach ( $highl[$hli]->arr as $feld ) {
 522+ if ( isset( $feld['name'] ) ) {
523523
524 - switch ($feld['name']) {
 524+ switch ( $feld['name'] ) {
525525
526526 case 'title':
527527 $doc[]->highlight->title = $feld->str;
@@ -542,20 +542,20 @@
543543 $interwiki = null;
544544
545545
546 - $resultSet = new SolrSearchSet($method, $query, $resultLines, count($resultLines), $totalHits,
547 - $suggestion, $info, $interwiki);
 546+ $resultSet = new SolrSearchSet( $method, $query, $resultLines, count( $resultLines ), $totalHits,
 547+ $suggestion, $info, $interwiki );
548548
549 - wfProfileOut($fname);
 549+ wfProfileOut( $fname );
550550 return $resultSet;
551551 }
552552
553 - static function startsWith($source, $prefix) {
554 - return strncmp($source, $prefix, strlen($prefix)) == 0;
 553+ static function startsWith( $source, $prefix ) {
 554+ return strncmp( $source, $prefix, strlen( $prefix ) ) == 0;
555555 }
556556
557557 /**
558558 * Private constructor. Use SolrSearchSet::newFromQuery().
559 - *
 559+ *
560560 * @param string $method
561561 * @param string $query
562562 * @param array $lines
@@ -565,7 +565,7 @@
566566 * @param string $info
567567 * @access private
568568 */
569 - function SolrSearchSet($method, $query, $lines, $resultCount, $totalHits = null, $suggestion = null, $info = null, $interwiki = null) {
 569+ function SolrSearchSet( $method, $query, $lines, $resultCount, $totalHits = null, $suggestion = null, $info = null, $interwiki = null ) {
570570 $this->mMethod = $method;
571571 $this->mQuery = $query;
572572 $this->mTotalHits = $totalHits;
@@ -574,46 +574,46 @@
575575 $this->mPos = 0;
576576 $this->mSuggestionQuery = null;
577577 $this->mSuggestionSnippet = '';
578 - $this->parseSuggestion($suggestion);
 578+ $this->parseSuggestion( $suggestion );
579579 $this->mInfo = $info;
580580 $this->mInterwiki = $interwiki;
581581 }
582582
583583 /** Get suggestions from a suggestion result line */
584 - function parseSuggestion($suggestion) {
585 - if (is_null($suggestion))
 584+ function parseSuggestion( $suggestion ) {
 585+ if ( is_null( $suggestion ) )
586586 return;
587587 // parse split points and highlight changes
588 - list($dummy, $points, $sug) = explode(" ", $suggestion);
589 - $sug = urldecode($sug);
590 - $points = explode(",", substr($points, 1, -1));
591 - array_unshift($points, 0);
 588+ list( $dummy, $points, $sug ) = explode( " ", $suggestion );
 589+ $sug = urldecode( $sug );
 590+ $points = explode( ",", substr( $points, 1, -1 ) );
 591+ array_unshift( $points, 0 );
592592 $suggestText = "";
593 - for ($i = 1; $i < count($points); $i+=2) {
594 - $suggestText .= htmlspecialchars(substr($sug, $points[$i - 1], $points[$i] - $points[$i - 1]));
595 - $suggestText .= '<em>' . htmlspecialchars(substr($sug, $points[$i], $points[$i + 1] - $points[$i])) . "</em>";
 593+ for ( $i = 1; $i < count( $points ); $i += 2 ) {
 594+ $suggestText .= htmlspecialchars( substr( $sug, $points[$i - 1], $points[$i] - $points[$i - 1] ) );
 595+ $suggestText .= '<em>' . htmlspecialchars( substr( $sug, $points[$i], $points[$i + 1] - $points[$i] ) ) . "</em>";
596596 }
597 - $suggestText .= htmlspecialchars(substr($sug, end($points)));
 597+ $suggestText .= htmlspecialchars( substr( $sug, end( $points ) ) );
598598
599 - $this->mSuggestionQuery = $this->replaceGenericPrefixes($sug);
600 - $this->mSuggestionSnippet = $this->replaceGenericPrefixes($suggestText);
 599+ $this->mSuggestionQuery = $this->replaceGenericPrefixes( $sug );
 600+ $this->mSuggestionSnippet = $this->replaceGenericPrefixes( $suggestText );
601601 }
602602
603603 /** replace prefixes like [2]: that are not in phrases */
604 - function replaceGenericPrefixes($text) {
 604+ function replaceGenericPrefixes( $text ) {
605605 $out = "";
606 - $phrases = explode('"', $text);
607 - for ($i = 0; $i < count($phrases); $i+=2) {
608 - $out .= preg_replace_callback('/\[([0-9]+)\]:/', array($this, 'genericPrefixCallback'), $phrases[$i]);
609 - if ($i + 1 < count($phrases))
610 - $out .= '"' . $phrases[$i + 1] . '"'; // phrase text
 606+ $phrases = explode( '"', $text );
 607+ for ( $i = 0; $i < count( $phrases ); $i += 2 ) {
 608+ $out .= preg_replace_callback( '/\[([0-9]+)\]:/', array( $this, 'genericPrefixCallback' ), $phrases[$i] );
 609+ if ( $i + 1 < count( $phrases ) )
 610+ $out .= '"' . $phrases[$i + 1] . '"'; // phrase text
611611 }
612612 return $out;
613613 }
614614
615 - function genericPrefixCallback($matches) {
 615+ function genericPrefixCallback( $matches ) {
616616 global $wgContLang;
617 - return $wgContLang->getFormattedNsText($matches[1]) . ":";
 617+ return $wgContLang->getFormattedNsText( $matches[1] ) . ":";
618618 }
619619
620620 function numRows() {
@@ -621,8 +621,8 @@
622622 }
623623
624624 function termMatches() {
625 - $resq = preg_replace("/\\[.*?\\]:/", " ", $this->mQuery); # generic prefixes
626 - $resq = preg_replace("/all:/", " ", $resq);
 625+ $resq = preg_replace( "/\\[.*?\\]:/", " ", $this->mQuery ); # generic prefixes
 626+ $resq = preg_replace( "/all:/", " ", $resq );
627627
628628 // Fixme: this is ripped from SearchMySQL and probably kind of sucks,
629629 // but it handles quoted phrase searches more or less correctly.
@@ -631,22 +631,22 @@
632632 $regexes = array();
633633 $m = array();
634634 $lc = SearchEngine::legalSearchChars();
635 - if (preg_match_all('/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $resq, $m, PREG_SET_ORDER)) {
636 - foreach ($m as $terms) {
637 - if (!empty($terms[3])) {
 635+ if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $resq, $m, PREG_SET_ORDER ) ) {
 636+ foreach ( $m as $terms ) {
 637+ if ( !empty( $terms[3] ) ) {
638638 // Match individual terms in result highlighting...
639 - $regexp = preg_quote($terms[3], '/');
640 - if ($terms[4])
 639+ $regexp = preg_quote( $terms[3], '/' );
 640+ if ( $terms[4] )
641641 $regexp .= "[0-9A-Za-z_]+";
642642 } else {
643643 // Match the quoted term in result highlighting...
644 - $regexp = preg_quote(str_replace('"', '', $terms[2]), '/');
 644+ $regexp = preg_quote( str_replace( '"', '', $terms[2] ), '/' );
645645 }
646646 $regexes[] = $regexp;
647647 }
648 - wfDebug(__METHOD__ . ': Match with /' . implode('|', $regexes) . "/\n");
 648+ wfDebug( __METHOD__ . ': Match with /' . implode( '|', $regexes ) . "/\n" );
649649 } else {
650 - wfDebug("Can't understand search query '{$resq}'\n");
 650+ wfDebug( "Can't understand search query '{$resq}'\n" );
651651 }
652652 return $regexes;
653653 }
@@ -655,12 +655,12 @@
656656 * Stupid hack around PHP's limited lambda support
657657 * @access private
658658 */
659 - function regexQuote($term) {
660 - return preg_quote($term, '/');
 659+ function regexQuote( $term ) {
 660+ return preg_quote( $term, '/' );
661661 }
662662
663663 function hasResults() {
664 - return count($this->mResults) > 0;
 664+ return count( $this->mResults ) > 0;
665665 }
666666
667667 /**
@@ -678,12 +678,12 @@
679679
680680 /**
681681 * Return information about how and from where the results were fetched,
682 - * should be useful for diagnostics and debugging
 682+ * should be useful for diagnostics and debugging
683683 *
684684 * @return string
685685 */
686686 function getInfo() {
687 - if (is_null($this->mInfo))
 687+ if ( is_null( $this->mInfo ) )
688688 return null;
689689 return "Search results fetched via " . $this->mInfo;
690690 }
@@ -705,7 +705,7 @@
706706 * @access public
707707 */
708708 function hasSuggestion() {
709 - return is_string($this->mSuggestionQuery) && $this->mSuggestionQuery != '';
 709+ return is_string( $this->mSuggestionQuery ) && $this->mSuggestionQuery != '';
710710 }
711711
712712 function getSuggestionQuery() {
@@ -723,9 +723,9 @@
724724 * @abstract
725725 */
726726 function next() {
727 - if ($this->mPos < $this->mResultCount) {
 727+ if ( $this->mPos < $this->mResultCount ) {
728728 $this->mPos++;
729 - return new SolrResult($this->mResults[$this->mPos - 1], $this->mMethod);
 729+ return new SolrResult( $this->mResults[$this->mPos - 1], $this->mMethod );
730730 } else {
731731 return null;
732732 }
Index: trunk/extensions/SolrStore/SolrSearchFieldSet.php
@@ -1,7 +1,7 @@
22 <?php
33 /**
44 * File holding the SolrSearchFieldSet class
5 - *
 5+ *
66 * @ingroup SolrStore
77 * @file
88 * @author Simon Bachenberg
@@ -9,13 +9,13 @@
1010
1111 /**
1212 * TODO: Insert class description
13 - *
 13+ *
1414 * To create a SearchSet for your Wiki add the Following Lines to you LocalSettings.php
1515 * $wgSolrFields = array(
1616 * new SolrSearchFieldSet('<Name of the SearchSet>', '<Semicolon Seperated List of your Semantic Propertys>', ''<Semicolon Seperated List of the Lable for your Fields>', '<Extra Query Parameters>'),
1717 * new SolrSearchFieldSet('Institution', 'has_name; has_country', 'Name, Country', ' AND category:Event')
1818 * );
19 - *
 19+ *
2020 * @ingroup SolrStore
2121 */
2222 class SolrSearchFieldSet {
@@ -25,10 +25,10 @@
2626 var $mLable;
2727 var $mQuery;
2828
29 - public function __construct($name, $fields = 'search', $lable = 'Alles', $query = null) {
 29+ public function __construct( $name, $fields = 'search', $lable = 'Alles', $query = null ) {
3030 $this->mName = $name;
31 - $this->mFields = explode(';', $fields);
32 - $this->mLable = explode(';', $lable);
 31+ $this->mFields = explode( ';', $fields );
 32+ $this->mLable = explode( ';', $lable );
3333 $this->mQuery = $query;
3434 }
3535
@@ -48,19 +48,19 @@
4949 return $this->mQuery;
5050 }
5151
52 - public function setName($value) {
 52+ public function setName( $value ) {
5353 $this->mName = $value;
5454 }
5555
56 - public function setFields($value) {
 56+ public function setFields( $value ) {
5757 $this->mFields = $value;
5858 }
5959
60 - public function setLable($value) {
 60+ public function setLable( $value ) {
6161 $this->mLable = $value;
6262 }
6363
64 - public function setQuery($value) {
 64+ public function setQuery( $value ) {
6565 $this->mQuery = $value;
6666 }
6767
Index: trunk/extensions/SolrStore/SpecialSolrSearch.php
@@ -1,9 +1,9 @@
22 <?php
33 /**
44 * File holding the SpecialSolrSearch class
5 - *
 5+ *
66 * This is the SpecialPage, displaying the SearchSets and Results
7 - *
 7+ *
88 * @ingroup SolrStore
99 * @file
1010 * @author Simon Bachenberg
@@ -11,7 +11,7 @@
1212
1313 /**
1414 * TODO: Insert class description
15 - *
 15+ *
1616 * @ingroup SolrStore
1717 */
1818 class SpecialSolrSearch extends SpecialPage {
@@ -24,27 +24,27 @@
2525 * @param $user User
2626 */
2727 public function __construct() {
28 - parent::__construct("SolrSearch");
 28+ parent::__construct( "SolrSearch" );
2929 global $wgRequest, $wgUser, $wgOut, $wgSolrFields;
3030 $user = $wgUser;
3131 $request = $wgRequest;
32 - list( $this->limit, $this->offset ) = $request->getLimitOffset(20, 'searchlimit');
 32+ list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, 'searchlimit' );
3333
3434 $this->sk = $user->getSkin();
3535 $this->didYouMeanHtml = ''; # html of did you mean... link
3636 }
3737
38 - function execute($par) {
 38+ function execute( $par ) {
3939 global $wgRequest, $wgUser, $wgOut, $wgSolrFields;
4040
4141 $this->setHeaders();
42 - $SpecialSolrSearch = new SpecialSolrSearch($wgRequest, $wgUser);
 42+ $SpecialSolrSearch = new SpecialSolrSearch( $wgRequest, $wgUser );
4343
4444 # Get request data from, e.g.
45 - $param = $wgRequest->getText('param');
 45+ $param = $wgRequest->getText( 'param' );
4646
47 - foreach ($wgSolrFields as $set) {
48 - if ($par == $set->getName()) {
 47+ foreach ( $wgSolrFields as $set ) {
 48+ if ( $par == $set->getName() ) {
4949 $fieldSet = $set;
5050 }
5151 }
@@ -52,29 +52,29 @@
5353 # ...
5454 // Strip underscores from title parameter; most of the time we'll want
5555 // text form here. But don't strip underscores from actual text params!
56 - $titleParam = str_replace('_', ' ', $par);
 56+ $titleParam = str_replace( '_', ' ', $par );
5757 // Fetch the search term
5858 // $search = str_replace("\n", " ", $wgRequest->getText('solrsearch', $titleParam));
5959
60 - if (!isset($fieldSet)) {
 60+ if ( !isset( $fieldSet ) ) {
6161 $SpecialSolrSearch->showFieldSets();
6262 } else {
6363 $lable = $fieldSet->getLable();
6464 $firstTimeHere = true;
65 - foreach ($fieldSet->getFields() as $field) {
66 - if ($firstTimeHere) {
67 - $newLable ['solr' . trim($field)] = trim($lable[0]);
 65+ foreach ( $fieldSet->getFields() as $field ) {
 66+ if ( $firstTimeHere ) {
 67+ $newLable ['solr' . trim( $field )] = trim( $lable[0] );
6868 $firstTimeHere = false;
6969 } else {
70 - $newLable ['solr' . trim($field)] = trim(next($lable));
 70+ $newLable ['solr' . trim( $field )] = trim( next( $lable ) );
7171 }
7272
73 - $newFields ['solr' . trim($field)] = $wgRequest->getText('solr' . trim($field));
 73+ $newFields ['solr' . trim( $field )] = $wgRequest->getText( 'solr' . trim( $field ) );
7474 }
75 - $fieldSet->setFields($newFields);
76 - $fieldSet->setLable($newLable);
 75+ $fieldSet->setFields( $newFields );
 76+ $fieldSet->setLable( $newLable );
7777
78 - $SpecialSolrSearch->showResults($fieldSet);
 78+ $SpecialSolrSearch->showResults( $fieldSet );
7979 }
8080 }
8181
@@ -83,92 +83,92 @@
8484 */
8585 public function showFieldSets() {
8686 global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang, $wgScript, $wgSolrFields;
87 - wfProfileIn(__METHOD__);
 87+ wfProfileIn( __METHOD__ );
8888
8989 $sk = $wgUser->getSkin();
9090
9191
92 - $wgOut->setPageTitle(wfMsg('searchFieldSets'));
93 - $wgOut->setHTMLTitle(wfMsg('pagetitle', wfMsg('searchFieldSets-title', 'SolrSearch: Select FieldSet')));
 92+ $wgOut->setPageTitle( wfMsg( 'searchFieldSets' ) );
 93+ $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'searchFieldSets-title', 'SolrSearch: Select FieldSet' ) ) );
9494
95 - $wgOut->setArticleRelated(false);
96 - $wgOut->addHtml('<div class="solrsearch-fieldset">');
97 - $wgOut->addHtml(wfMsg('searchFieldSets-select'));
98 - $wgOut->addHtml('<ul>');
 95+ $wgOut->setArticleRelated( false );
 96+ $wgOut->addHtml( '<div class="solrsearch-fieldset">' );
 97+ $wgOut->addHtml( wfMsg( 'searchFieldSets-select' ) );
 98+ $wgOut->addHtml( '<ul>' );
9999
100 - //TODO: If no SearchSets exist, provide a shot Manual how to create some!
101 - foreach ($wgSolrFields as $set) {
 100+ // TODO: If no SearchSets exist, provide a shot Manual how to create some!
 101+ foreach ( $wgSolrFields as $set ) {
102102 $name = $set->getName();
103 - $wgOut->addHtml("<li><a href=\"$wgScript/Special:SolrSearch/$name\">$name</a></li>");
 103+ $wgOut->addHtml( "<li><a href=\"$wgScript/Special:SolrSearch/$name\">$name</a></li>" );
104104 }
105 - $wgOut->addHtml('</ul>');
106 - $wgOut->addHtml("</div>");
 105+ $wgOut->addHtml( '</ul>' );
 106+ $wgOut->addHtml( "</div>" );
107107
108 - wfProfileOut(__METHOD__);
 108+ wfProfileOut( __METHOD__ );
109109 }
110 -
 110+
111111 /**
112112 * @param $fieldSet String
113113 */
114 - public function showResults($fieldSet) {
 114+ public function showResults( $fieldSet ) {
115115 global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang, $wgScript;
116 - wfProfileIn(__METHOD__);
 116+ wfProfileIn( __METHOD__ );
117117
118118 $sk = $wgUser->getSkin();
119119
120120 $this->searchEngine = SearchEngine::create();
121121 $search = & $this->searchEngine;
122 - $search->setLimitOffset($this->limit, $this->offset);
 122+ $search->setLimitOffset( $this->limit, $this->offset );
123123
124 - $this->setupPage($fieldSet);
 124+ $this->setupPage( $fieldSet );
125125
126 - $t = Title::newFromText($fieldSet->getName());
 126+ $t = Title::newFromText( $fieldSet->getName() );
127127
128 - //DO we have Title matches
 128+ // DO we have Title matches
129129 $fields = $fieldSet->getFields();
130130
131 - //BUILD SOLR QUERY STRING FROM DA FIELDS
132 - if (isset($fields['solrsearch'])) {
 131+ // BUILD SOLR QUERY STRING FROM DA FIELDS
 132+ if ( isset( $fields['solrsearch'] ) ) {
133133 $query = $fields['solrsearch'];
134134 } else {
135135 $query = '';
136136 }
137137
138138
139 - foreach ($fields as $key => $value) {
140 - if ($key != 'solrsearch' && !empty($value)) {
141 - $query = trim($query).' '.trim(substr($key, 4)) . ':' . '(' . ($value) . ')';
 139+ foreach ( $fields as $key => $value ) {
 140+ if ( $key != 'solrsearch' && !empty( $value ) ) {
 141+ $query = trim( $query ) . ' ' . trim( substr( $key, 4 ) ) . ':' . '(' . ( $value ) . ')';
142142 }
143143 }
144144
145 - if (!empty($query)) {
146 - $query .=$fieldSet->getQuery();
 145+ if ( !empty( $query ) ) {
 146+ $query .= $fieldSet->getQuery();
147147 }
148 -
149 - $titleMatches = $search->searchTitle($query);
150148
151 - if (!($titleMatches instanceof SearchResultTooMany))
152 - $textMatches = $search->searchText($query);
 149+ $titleMatches = $search->searchTitle( $query );
153150
 151+ if ( !( $titleMatches instanceof SearchResultTooMany ) )
 152+ $textMatches = $search->searchText( $query );
 153+
154154 // did you mean... suggestions
155 - if ($textMatches && $textMatches->hasSuggestion()) {
156 - $st = SpecialPage::getTitleFor('SolrSearch');
 155+ if ( $textMatches && $textMatches->hasSuggestion() ) {
 156+ $st = SpecialPage::getTitleFor( 'SolrSearch' );
157157
158158 # mirror Go/Search behaviour of original request ..
159 - $didYouMeanParams = array('solrsearch' => $textMatches->getSuggestionQuery());
 159+ $didYouMeanParams = array( 'solrsearch' => $textMatches->getSuggestionQuery() );
160160
161161 $stParams = $didYouMeanParams;
162162
163163 $suggestionSnippet = $textMatches->getSuggestionSnippet();
164164
165 - if ($suggestionSnippet == '')
 165+ if ( $suggestionSnippet == '' )
166166 $suggestionSnippet = null;
167167
168168 $suggestLink = $sk->linkKnown(
169169 $st, $suggestionSnippet, array(), $stParams
170170 );
171171
172 - $this->didYouMeanHtml = '<div class="searchdidyoumean">' . wfMsg('search-suggest', $suggestLink) . '</div>';
 172+ $this->didYouMeanHtml = '<div class="searchdidyoumean">' . wfMsg( 'search-suggest', $suggestLink ) . '</div>';
173173 }
174174 // start rendering the page
175175 $wgOut->addHtml(
@@ -181,28 +181,28 @@
182182 )
183183 );
184184 $wgOut->addHtml(
185 - Xml::openElement('table', array('id' => 'mw-search-top-table', 'border' => 0, 'cellpadding' => 0, 'cellspacing' => 0)) .
186 - Xml::openElement('tr') .
187 - Xml::openElement('td') . "\n" .
188 - $this->shortDialog($fieldSet) .
189 - Xml::closeElement('td') .
190 - Xml::closeElement('tr') .
191 - Xml::closeElement('table')
 185+ Xml::openElement( 'table', array( 'id' => 'mw-search-top-table', 'border' => 0, 'cellpadding' => 0, 'cellspacing' => 0 ) ) .
 186+ Xml::openElement( 'tr' ) .
 187+ Xml::openElement( 'td' ) . "\n" .
 188+ $this->shortDialog( $fieldSet ) .
 189+ Xml::closeElement( 'td' ) .
 190+ Xml::closeElement( 'tr' ) .
 191+ Xml::closeElement( 'table' )
192192 );
193193
194194 // Sometimes the search engine knows there are too many hits
195 - if ($titleMatches instanceof SearchResultTooMany) {
196 - $wgOut->addWikiText('==' . wfMsg('toomanymatches') . "==\n");
197 - wfProfileOut(__METHOD__);
 195+ if ( $titleMatches instanceof SearchResultTooMany ) {
 196+ $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" );
 197+ wfProfileOut( __METHOD__ );
198198 return;
199199 }
200200
201 - $filePrefix = $wgContLang->getFormattedNsText(NS_FILE) . ':';
202 - if (trim($query) === '' || $filePrefix === trim($query)) {
203 - $wgOut->addHTML($this->formHeader($query, 0, 0));
204 - $wgOut->addHTML('</form>');
 201+ $filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
 202+ if ( trim( $query ) === '' || $filePrefix === trim( $query ) ) {
 203+ $wgOut->addHTML( $this->formHeader( $query, 0, 0 ) );
 204+ $wgOut->addHTML( '</form>' );
205205 // Empty query -- straight view of search form
206 - wfProfileOut(__METHOD__);
 206+ wfProfileOut( __METHOD__ );
207207 return;
208208 }
209209 // Get number of results
@@ -212,105 +212,105 @@
213213 $num = $titleMatchesNum + $textMatchesNum;
214214
215215 // Get total actual results (after second filtering, if any)
216 - $numTitleMatches = $titleMatches && !is_null($titleMatches->getTotalHits()) ?
 216+ $numTitleMatches = $titleMatches && !is_null( $titleMatches->getTotalHits() ) ?
217217 $titleMatches->getTotalHits() : $titleMatchesNum;
218 - $numTextMatches = $textMatches && !is_null($textMatches->getTotalHits()) ?
 218+ $numTextMatches = $textMatches && !is_null( $textMatches->getTotalHits() ) ?
219219 $textMatches->getTotalHits() : $textMatchesNum;
220220
221221 // get total number of results if backend can calculate it
222222 $totalRes = 0;
223 - if ($titleMatches && !is_null($titleMatches->getTotalHits()))
 223+ if ( $titleMatches && !is_null( $titleMatches->getTotalHits() ) )
224224 $totalRes += $titleMatches->getTotalHits();
225 - if ($textMatches && !is_null($textMatches->getTotalHits()))
 225+ if ( $textMatches && !is_null( $textMatches->getTotalHits() ) )
226226 $totalRes += $textMatches->getTotalHits();
227227 // show number of results and current offset
228 - $wgOut->addHTML($this->formHeader($query, $num, $totalRes));
 228+ $wgOut->addHTML( $this->formHeader( $query, $num, $totalRes ) );
229229
230 - $wgOut->addHtml(Xml::closeElement('form'));
231 - $wgOut->addHtml("<div class='searchresults'>");
 230+ $wgOut->addHtml( Xml::closeElement( 'form' ) );
 231+ $wgOut->addHtml( "<div class='searchresults'>" );
232232
233233 // prev/next links
234 - if ($num || $this->offset) {
 234+ if ( $num || $this->offset ) {
235235 // Show the create link ahead
236 - $this->showCreateLink($t);
237 - $prevnext = wfViewPrevNext($this->offset, $this->limit, SpecialPage::getTitleFor('SolrSearch'), wfArrayToCGI(array('solrsearch' => $query)), max($titleMatchesNum, $textMatchesNum) < $this->limit
 236+ $this->showCreateLink( $t );
 237+ $prevnext = wfViewPrevNext( $this->offset, $this->limit, SpecialPage::getTitleFor( 'SolrSearch' ), wfArrayToCGI( array( 'solrsearch' => $query ) ), max( $titleMatchesNum, $textMatchesNum ) < $this->limit
238238 );
239 - //$wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
240 - wfRunHooks('SpecialSolrSearchResults', array($fieldSet, &$titleMatches, &$textMatches));
 239+ // $wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
 240+ wfRunHooks( 'SpecialSolrSearchResults', array( $fieldSet, &$titleMatches, &$textMatches ) );
241241 } else {
242 - wfRunHooks('SpecialSolrSearchNoResults', array($fieldSet));
 242+ wfRunHooks( 'SpecialSolrSearchNoResults', array( $fieldSet ) );
243243 }
244244
245 - if ($titleMatches) {
246 - if ($numTitleMatches > 0) {
247 - $wgOut->wrapWikiMsg("==$1==\n", 'titlematches');
248 - $wgOut->addHTML($this->showMatches($titleMatches));
 245+ if ( $titleMatches ) {
 246+ if ( $numTitleMatches > 0 ) {
 247+ $wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' );
 248+ $wgOut->addHTML( $this->showMatches( $titleMatches ) );
249249 }
250250 $titleMatches->free();
251251 }
252 - if ($textMatches) {
 252+ if ( $textMatches ) {
253253 // output appropriate heading
254 - if ($numTextMatches > 0 && $numTitleMatches > 0) {
 254+ if ( $numTextMatches > 0 && $numTitleMatches > 0 ) {
255255 // if no title matches the heading is redundant
256 - $wgOut->wrapWikiMsg("==$1==\n", 'textmatches');
257 - } elseif ($totalRes == 0) {
 256+ $wgOut->wrapWikiMsg( "==$1==\n", 'textmatches' );
 257+ } elseif ( $totalRes == 0 ) {
258258 # Don't show the 'no text matches' if we received title matches
259259 # $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' );
260260 }
261261
262262 // show results
263 - if ($numTextMatches > 0) {
264 - $wgOut->addHTML($this->showMatches($textMatches));
 263+ if ( $numTextMatches > 0 ) {
 264+ $wgOut->addHTML( $this->showMatches( $textMatches ) );
265265 }
266266
267267 $textMatches->free();
268268 }
269269
270 - $wgOut->addHtml("</div>");
 270+ $wgOut->addHtml( "</div>" );
271271
272 - if ($num || $this->offset) {
273 - $wgOut->addHTML("<p class='mw-search-pager-bottom'>{$prevnext}</p>\n");
 272+ if ( $num || $this->offset ) {
 273+ $wgOut->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
274274 }
275 - wfProfileOut(__METHOD__);
 275+ wfProfileOut( __METHOD__ );
276276 }
277277
278 - protected function showCreateLink($t) {
 278+ protected function showCreateLink( $t ) {
279279 global $wgOut;
280280
281281 // show direct page/create link if applicable
282282 $messageName = null;
283 - if (!is_null($t)) {
284 - if ($t->isKnown()) {
 283+ if ( !is_null( $t ) ) {
 284+ if ( $t->isKnown() ) {
285285 $messageName = 'searchmenu-exists';
286 - } elseif ($t->userCan('create')) {
 286+ } elseif ( $t->userCan( 'create' ) ) {
287287 $messageName = 'searchmenu-new';
288288 } else {
289289 $messageName = 'searchmenu-new-nocreate';
290290 }
291291 }
292 - if ($messageName) {
293 - $wgOut->wrapWikiMsg("<p class=\"mw-search-createlink\">\n$1</p>", array($messageName, wfEscapeWikiText($t->getPrefixedText())));
 292+ if ( $messageName ) {
 293+ $wgOut->wrapWikiMsg( "<p class=\"mw-search-createlink\">\n$1</p>", array( $messageName, wfEscapeWikiText( $t->getPrefixedText() ) ) );
294294 } else {
295295 // preserve the paragraph for margins etc...
296 - $wgOut->addHtml('<p></p>');
 296+ $wgOut->addHtml( '<p></p>' );
297297 }
298298 }
299299
300300 /**
301301 *
302302 */
303 - protected function setupPage($fieldSet) {
 303+ protected function setupPage( $fieldSet ) {
304304 global $wgOut;
305305
306 - if (!empty($fieldSet)) {
307 - $wgOut->setPageTitle(wfMsg('searchresults'));
308 - $wgOut->setHTMLTitle(wfMsg('pagetitle', wfMsg('searchresults-title', $fieldSet->getName())));
 306+ if ( !empty( $fieldSet ) ) {
 307+ $wgOut->setPageTitle( wfMsg( 'searchresults' ) );
 308+ $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'searchresults-title', $fieldSet->getName() ) ) );
309309 }
310 - $wgOut->setArticleRelated(false);
311 - $wgOut->setRobotPolicy('noindex,nofollow');
 310+ $wgOut->setArticleRelated( false );
 311+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
312312 // add javascript specific to special:search
313 - $wgOut->addModules('mediawiki.legacy.search');
314 - $wgOut->addModules('mediawiki.special.search');
 313+ $wgOut->addModules( 'mediawiki.legacy.search' );
 314+ $wgOut->addModules( 'mediawiki.special.search' );
315315 }
316316
317317 /**
@@ -318,27 +318,27 @@
319319 *
320320 * @param $matches SearchResultSet
321321 */
322 - protected function showMatches(&$matches) {
 322+ protected function showMatches( &$matches ) {
323323 global $wgContLang;
324 - wfProfileIn(__METHOD__);
 324+ wfProfileIn( __METHOD__ );
325325
326 - $fieldSets = $wgContLang->convertForSearchResult($matches->termMatches());
 326+ $fieldSets = $wgContLang->convertForSearchResult( $matches->termMatches() );
327327
328328 $out = "";
329329 $infoLine = $matches->getInfo();
330 - if (!is_null($infoLine)) {
 330+ if ( !is_null( $infoLine ) ) {
331331 $out .= "\n<!-- {$infoLine} -->\n";
332332 }
333333 $out .= "<ul class='mw-search-results'>\n";
334334 $xxx = 0;
335 - while ($result = $matches->next()) {
336 - $out .= $this->showHit($result, $fieldSets);
 335+ while ( $result = $matches->next() ) {
 336+ $out .= $this->showHit( $result, $fieldSets );
337337 }
338338 $out .= "</ul>\n";
339339
340340 // convert the whole thing to desired language variant
341 - $out = $wgContLang->convert($out);
342 - wfProfileOut(__METHOD__);
 341+ $out = $wgContLang->convert( $out );
 342+ wfProfileOut( __METHOD__ );
343343 return $out;
344344 }
345345
@@ -348,119 +348,119 @@
349349 * @param $result SearchResult
350350 * @param $fieldSets Array: terms to highlight
351351 */
352 - protected function showHit($result, $fieldSets) {
 352+ protected function showHit( $result, $fieldSets ) {
353353 global $wgLang, $wgUser;
354 - wfProfileIn(__METHOD__);
 354+ wfProfileIn( __METHOD__ );
355355
356 - if ($result->isBrokenTitle()) {
357 - wfProfileOut(__METHOD__);
 356+ if ( $result->isBrokenTitle() ) {
 357+ wfProfileOut( __METHOD__ );
358358 return "<!-- Broken link in search result -->\n";
359359 }
360360
361361 $sk = $wgUser->getSkin();
362362 $t = $result->getTitle();
363363
364 - $titleSnippet = $result->getTitleSnippet($fieldSets);
 364+ $titleSnippet = $result->getTitleSnippet( $fieldSets );
365365
366 - if ($titleSnippet == '')
 366+ if ( $titleSnippet == '' )
367367 $titleSnippet = null;
368368
369369 $link_t = clone $t;
370370
371 - wfRunHooks('ShowSearchHitTitle', array(&$link_t, &$titleSnippet, $result, $fieldSets, $this));
 371+ wfRunHooks( 'ShowSearchHitTitle', array( &$link_t, &$titleSnippet, $result, $fieldSets, $this ) );
372372
373373 $link = $this->sk->linkKnown(
374374 $link_t, $titleSnippet
375375 );
376376 // FÜLLEN
377 - //If page content is not readable, just return the title.
378 - //This is not quite safe, but better than showing excerpts from non-readable pages
379 - //Note that hiding the entry entirely would screw up paging.
 377+ // If page content is not readable, just return the title.
 378+ // This is not quite safe, but better than showing excerpts from non-readable pages
 379+ // Note that hiding the entry entirely would screw up paging.
380380 // ---- HIER
381 - if (!$t->userCanRead()) {
382 - wfProfileOut(__METHOD__);
 381+ if ( !$t->userCanRead() ) {
 382+ wfProfileOut( __METHOD__ );
383383 return "<li>{$link}</li>\n";
384384 }
385 - //return "<li>{$link}</li>\n";
 385+ // return "<li>{$link}</li>\n";
386386 // If the page doesn't *exist*... our search index is out of date.
387387 // The least confusing at this point is to drop the result.
388388 // You may get less results, but... oh well. :P
389389 // ---- HIER
390 - if ($result->isMissingRevision()) {
391 - wfProfileOut(__METHOD__);
392 - return "<!-- missing page " . htmlspecialchars($t->getPrefixedText()) . "-->\n";
 390+ if ( $result->isMissingRevision() ) {
 391+ wfProfileOut( __METHOD__ );
 392+ return "<!-- missing page " . htmlspecialchars( $t->getPrefixedText() ) . "-->\n";
393393 }
394394
395395 // format redirects / relevant sections
396396 $redirectTitle = $result->getRedirectTitle();
397 - $redirectText = $result->getRedirectSnippet($fieldSets);
 397+ $redirectText = $result->getRedirectSnippet( $fieldSets );
398398 $sectionTitle = $result->getSectionTitle();
399 - $sectionText = $result->getSectionSnippet($fieldSets);
 399+ $sectionText = $result->getSectionSnippet( $fieldSets );
400400 $redirect = '';
401401
402 - if (!is_null($redirectTitle)) {
403 - if ($redirectText == '')
 402+ if ( !is_null( $redirectTitle ) ) {
 403+ if ( $redirectText == '' )
404404 $redirectText = null;
405405
406406 $redirect = "<span class='searchalttitle'>" .
407 - wfMsg('search-redirect', $this->sk->linkKnown($redirectTitle, $redirectText)) .
 407+ wfMsg( 'search-redirect', $this->sk->linkKnown( $redirectTitle, $redirectText ) ) .
408408 "</span>";
409409 }
410410
411411 $section = '';
412412
413413
414 - if (!is_null($sectionTitle)) {
415 - if ($sectionText == '')
 414+ if ( !is_null( $sectionTitle ) ) {
 415+ if ( $sectionText == '' )
416416 $sectionText = null;
417417
418418 $section = "<span class='searchalttitle'>" .
419 - wfMsg('search-section', $this->sk->linkKnown($sectionTitle, $sectionText)) .
 419+ wfMsg( 'search-section', $this->sk->linkKnown( $sectionTitle, $sectionText ) ) .
420420 "</span>";
421421 }
422422
423423 // format text extract
424 - $extract = "<div class='searchresult'>" . $result->getTextSnippet($fieldSets) . "</div>";
 424+ $extract = "<div class='searchresult'>" . $result->getTextSnippet( $fieldSets ) . "</div>";
425425
426426 // format score
427 - if (is_null($result->getScore())) {
 427+ if ( is_null( $result->getScore() ) ) {
428428 // Search engine doesn't report scoring info
429429 $score = '';
430430 } else {
431 - $percent = sprintf('%2.1f', $result->getScore() * 100);
432 - $score = wfMsg('search-result-score', $wgLang->formatNum($percent)) . ' - ';
 431+ $percent = sprintf( '%2.1f', $result->getScore() * 100 );
 432+ $score = wfMsg( 'search-result-score', $wgLang->formatNum( $percent ) ) . ' - ';
433433 }
434434
435435 // format description
436436 $byteSize = $result->getByteSize();
437437 $wordCount = $result->getWordCount();
438438 $timestamp = $result->getTimestamp();
439 - $size = wfMsgExt('search-result-size', array('parsemag', 'escape'), $this->sk->formatSize($byteSize), $wgLang->formatNum($wordCount));
 439+ $size = wfMsgExt( 'search-result-size', array( 'parsemag', 'escape' ), $this->sk->formatSize( $byteSize ), $wgLang->formatNum( $wordCount ) );
440440
441 - if ($t->getNamespace() == NS_CATEGORY) {
442 - $cat = Category::newFromTitle($t);
443 - $size = wfMsgExt('search-result-category-size', array('parsemag', 'escape'), $wgLang->formatNum($cat->getPageCount()), $wgLang->formatNum($cat->getSubcatCount()), $wgLang->formatNum($cat->getFileCount()));
 441+ if ( $t->getNamespace() == NS_CATEGORY ) {
 442+ $cat = Category::newFromTitle( $t );
 443+ $size = wfMsgExt( 'search-result-category-size', array( 'parsemag', 'escape' ), $wgLang->formatNum( $cat->getPageCount() ), $wgLang->formatNum( $cat->getSubcatCount() ), $wgLang->formatNum( $cat->getFileCount() ) );
444444 }
445445
446 - $date = $wgLang->timeanddate($timestamp);
 446+ $date = $wgLang->timeanddate( $timestamp );
447447
448448 // link to related articles if supported
449449 $related = '';
450 - if ($result->hasRelated()) {
451 - $st = SpecialPage::getTitleFor('SolrSearch');
452 - $stParams = array('solrsearch' => wfMsgForContent('searchrelated') . ':' . $t->getPrefixedText());
453 - $related = ' -- ' . $sk->linkKnown($st, wfMsg('search-relatedarticle'), array(), $stParams);
 450+ if ( $result->hasRelated() ) {
 451+ $st = SpecialPage::getTitleFor( 'SolrSearch' );
 452+ $stParams = array( 'solrsearch' => wfMsgForContent( 'searchrelated' ) . ':' . $t->getPrefixedText() );
 453+ $related = ' -- ' . $sk->linkKnown( $st, wfMsg( 'search-relatedarticle' ), array(), $stParams );
454454 }
455455
456456 // Include a thumbnail for media files...
457457 // WE HAVE NEVER TESTED THIS HERE!!!
458 - if ($t->getNamespace() == NS_FILE) {
459 - $img = wfFindFile($t);
460 - if ($img) {
461 - $thumb = $img->transform(array('width' => 120, 'height' => 120));
462 - if ($thumb) {
463 - $desc = wfMsg('parentheses', $img->getShortDesc());
464 - wfProfileOut(__METHOD__);
 458+ if ( $t->getNamespace() == NS_FILE ) {
 459+ $img = wfFindFile( $t );
 460+ if ( $img ) {
 461+ $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
 462+ if ( $thumb ) {
 463+ $desc = wfMsg( 'parentheses', $img->getShortDesc() );
 464+ wfProfileOut( __METHOD__ );
465465 // Float doesn't seem to interact well with the bullets.
466466 // Table messes up vertical alignment of the bullets.
467467 // Bullets are therefore disabled (didn't look great anyway).
@@ -468,7 +468,7 @@
469469 '<table class="searchResultImage">' .
470470 '<tr>' .
471471 '<td width="120" align="center" valign="top">' .
472 - $thumb->toHtml(array('desc-link' => true)) .
 472+ $thumb->toHtml( array( 'desc-link' => true ) ) .
473473 '</td>' .
474474 '<td valign="top">' .
475475 $link .
@@ -482,66 +482,66 @@
483483 }
484484 }
485485
486 - wfProfileOut(__METHOD__);
 486+ wfProfileOut( __METHOD__ );
487487 // HIER kommt die score ausgabe:
488488 return "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section}</div> {$extract}\n" .
489489 "<div class='mw-search-result-data'>{$score}{$date}{$related}</div>" .
490490 "</li>\n";
491491 }
492492
493 - protected function formHeader($fieldSet, $resultsShown, $totalNum) {
 493+ protected function formHeader( $fieldSet, $resultsShown, $totalNum ) {
494494 global $wgLang;
495495
496 - $out = Xml::openElement('div', array('class' => 'mw-search-formheader'));
 496+ $out = Xml::openElement( 'div', array( 'class' => 'mw-search-formheader' ) );
497497
498498 // Results-info
499 - if ($resultsShown > 0) {
500 - if ($totalNum > 0) {
501 - $top = wfMsgExt('showingresultsheader', array('parseinline'), $wgLang->formatNum($this->offset + 1), $wgLang->formatNum($this->offset + $resultsShown), $wgLang->formatNum($totalNum), $wgLang->formatNum($resultsShown)
 499+ if ( $resultsShown > 0 ) {
 500+ if ( $totalNum > 0 ) {
 501+ $top = wfMsgExt( 'showingresultsheader', array( 'parseinline' ), $wgLang->formatNum( $this->offset + 1 ), $wgLang->formatNum( $this->offset + $resultsShown ), $wgLang->formatNum( $totalNum ), $wgLang->formatNum( $resultsShown )
502502 );
503 - } elseif ($resultsShown >= $this->limit) {
504 - $top = wfShowingResults($this->offset, $this->limit);
 503+ } elseif ( $resultsShown >= $this->limit ) {
 504+ $top = wfShowingResults( $this->offset, $this->limit );
505505 } else {
506 - $top = wfShowingResultsNum($this->offset, $this->limit, $resultsShown);
 506+ $top = wfShowingResultsNum( $this->offset, $this->limit, $resultsShown );
507507 }
508 - $out .= Xml::tags('div', array('class' => 'results-info'), Xml::tags('ul', null, Xml::tags('li', null, $top)));
 508+ $out .= Xml::tags( 'div', array( 'class' => 'results-info' ), Xml::tags( 'ul', null, Xml::tags( 'li', null, $top ) ) );
509509 }
510510
511 - $out .= Xml::element('div', array('style' => 'clear:both'), '', false);
512 - $out .= Xml::closeElement('div');
 511+ $out .= Xml::element( 'div', array( 'style' => 'clear:both' ), '', false );
 512+ $out .= Xml::closeElement( 'div' );
513513
514514 return $out;
515515 }
516516
517 - protected function shortDialog($fieldSet) {
518 - $searchTitle = SpecialPage::getTitleFor('SolrSearch');
 517+ protected function shortDialog( $fieldSet ) {
 518+ $searchTitle = SpecialPage::getTitleFor( 'SolrSearch' );
519519
520520
521 - if ($fieldSet->getName() != 'search') {
522 - $out = Html::hidden('title', $searchTitle->getPrefixedText() . '/' . $fieldSet->getName()) . "\n";
 521+ if ( $fieldSet->getName() != 'search' ) {
 522+ $out = Html::hidden( 'title', $searchTitle->getPrefixedText() . '/' . $fieldSet->getName() ) . "\n";
523523 } else {
524 - $out = Html::hidden('title', $searchTitle->getPrefixedText()) . "\n";
 524+ $out = Html::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n";
525525 }
526526 // Term box
527527
528528 $lable = $fieldSet->getLable();
529529 $out .= '<table>';
530530
531 - foreach ($fieldSet->getFields() as $key => $value) {
 531+ foreach ( $fieldSet->getFields() as $key => $value ) {
532532 $out .= '<tr>';
533 - if (isset($lable[$key])) {
 533+ if ( isset( $lable[$key] ) ) {
534534 $out .= '<th>' . $lable[$key] . '</th>';
535535 }
536536 $out .= '<td>';
537 - $out .= Html::input($key, $value, $key, array(
 537+ $out .= Html::input( $key, $value, $key, array(
538538 'id' => $key,
539539 'size' => '50',
540540 'autofocus'
541 - )) . "\n";
 541+ ) ) . "\n";
542542 $out .= '</td></tr>';
543543 }
544544 $out .= '<table>';
545 - $out .= Xml::submitButton(wfMsg('searchbutton')) . "\n";
 545+ $out .= Xml::submitButton( wfMsg( 'searchbutton' ) ) . "\n";
546546 return $out . $this->didYouMeanHtml;
547547 }
548548
Index: trunk/extensions/SolrStore/SolrConnectorStore.php
@@ -9,7 +9,7 @@
1010
1111 /**
1212 * TODO: Insert class description
13 - *
 13+ *
1414 * @ingroup SolrStore
1515 */
1616 class SolrConnectorStore extends SMWStore {
@@ -28,14 +28,14 @@
2929 static function &getBaseStore() {
3030 global $wgscBaseStore;
3131
32 - if (self::$smBaseStore === null) {
 32+ if ( self::$smBaseStore === null ) {
3333 self::$smBaseStore = new $wgscBaseStore();
3434 }
3535
3636 return self::$smBaseStore;
3737 }
3838
39 -///// Reading methods /////
 39+//// / Reading methods /////
4040
4141 /**
4242 * Retrieve all data stored about the given subject and return it as a
@@ -49,8 +49,8 @@
5050 * data than requested when a filter is used. Filtering just ensures
5151 * that only necessary requests are made, i.e. it improves performance.
5252 */
53 - public function getSemanticData(SMWDIWikiPage $subject, $filter = false) {
54 - return self::getBaseStore()->getSemanticData($subject, $filter);
 53+ public function getSemanticData( SMWDIWikiPage $subject, $filter = false ) {
 54+ return self::getBaseStore()->getSemanticData( $subject, $filter );
5555 }
5656
5757 /**
@@ -66,8 +66,8 @@
6767 *
6868 * @return array of SMWDataItem
6969 */
70 - public function getPropertyValues($subject, SMWDIProperty $property, $requestoptions = null) {
71 - return self::getBaseStore()->getPropertyValues($subject, $property, $requestoptions);
 70+ public function getPropertyValues( $subject, SMWDIProperty $property, $requestoptions = null ) {
 71+ return self::getBaseStore()->getPropertyValues( $subject, $property, $requestoptions );
7272 }
7373
7474 /**
@@ -75,16 +75,16 @@
7676 * property. The result is an array of SMWDIWikiPage objects. If null
7777 * is given as a value, all subjects having that property are returned.
7878 */
79 - public function getPropertySubjects(SMWDIProperty $property, $value, $requestoptions = null) {
80 - return self::getBaseStore()->getPropertySubjects($property, $value, $requestoptions);
 79+ public function getPropertySubjects( SMWDIProperty $property, $value, $requestoptions = null ) {
 80+ return self::getBaseStore()->getPropertySubjects( $property, $value, $requestoptions );
8181 }
8282
8383 /**
8484 * Get an array of all subjects that have some value for the given
8585 * property. The result is an array of SMWDIWikiPage objects.
8686 */
87 - public function getAllPropertySubjects(SMWDIProperty $property, $requestoptions = null) {
88 - return self::getBaseStore()->getAllPropertySubjects($property, $requestoptions);
 87+ public function getAllPropertySubjects( SMWDIProperty $property, $requestoptions = null ) {
 88+ return self::getBaseStore()->getAllPropertySubjects( $property, $requestoptions );
8989 }
9090
9191 /**
@@ -94,8 +94,8 @@
9595 * @param $subject SMWDIWikiPage denoting the subject
9696 * @param $requestoptions SMWRequestOptions optionally defining further options
9797 */
98 - public function getProperties(SMWDIWikiPage $subject, $requestoptions = null) {
99 - return self::getBaseStore()->getProperties($subject, $requestoptions);
 98+ public function getProperties( SMWDIWikiPage $subject, $requestoptions = null ) {
 99+ return self::getBaseStore()->getProperties( $subject, $requestoptions );
100100 }
101101
102102 /**
@@ -105,11 +105,11 @@
106106 * @note In some stores, this function might be implemented partially
107107 * so that only values of type Page (_wpg) are supported.
108108 */
109 - public function getInProperties(SMWDataItem $object, $requestoptions = null) {
110 - return self::getBaseStore()->getInProperties($object, $requestoptions);
 109+ public function getInProperties( SMWDataItem $object, $requestoptions = null ) {
 110+ return self::getBaseStore()->getInProperties( $object, $requestoptions );
111111 }
112112
113 -///// Writing methods /////
 113+//// / Writing methods /////
114114
115115 /**
116116 * Delete all semantic properties that the given subject has. This
@@ -119,12 +119,12 @@
120120 *
121121 * @param Title $subject
122122 */
123 - public function deleteSubject(Title $subject) {
 123+ public function deleteSubject( Title $subject ) {
124124 global $wgSolrTalker;
125 - //TODO: Update Solr to reflect the deleting of semantic properties
 125+ // TODO: Update Solr to reflect the deleting of semantic properties
126126
127 - $wgSolrTalker->deleteDocId($subject);
128 - return self::getBaseStore()->deleteSubject($subject);
 127+ $wgSolrTalker->deleteDocId( $subject );
 128+ return self::getBaseStore()->deleteSubject( $subject );
129129 }
130130
131131 /**
@@ -134,10 +134,10 @@
135135 *
136136 * @param SMWSemanticData $data
137137 */
138 - public function doDataUpdate(SMWSemanticData $data) {
 138+ public function doDataUpdate( SMWSemanticData $data ) {
139139 global $wgSolrTalker;
140 - $wgSolrTalker->parseSemanticData($data);
141 - return self::getBaseStore()->doDataUpdate($data);
 140+ $wgSolrTalker->parseSemanticData( $data );
 141+ return self::getBaseStore()->doDataUpdate( $data );
142142 }
143143
144144 /**
@@ -150,13 +150,13 @@
151151 * redirect, if any, is given by $redirid. If no new page was created,
152152 * $redirid will be 0.
153153 */
154 - public function changeTitle(Title $oldtitle, Title $newtitle, $pageid, $redirid = 0) {
155 -
156 - //TODO: Update Solr to reflect a renaming of some article
157 - return self::getBaseStore()->changeTitle($oldtitle, $newtitle, $pageid, $redirid);
 154+ public function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 ) {
 155+
 156+ // TODO: Update Solr to reflect a renaming of some article
 157+ return self::getBaseStore()->changeTitle( $oldtitle, $newtitle, $pageid, $redirid );
158158 }
159159
160 -///// Query answering /////
 160+//// / Query answering /////
161161
162162 /**
163163 * Execute the provided query and return the result as an
@@ -169,56 +169,56 @@
170170 *
171171 * @return SMWQueryResult
172172 */
173 - public function getQueryResult(SMWQuery $query) {
174 - //IF YOU SEE THIS HERE PLEASE IGNORE IT!
175 - //Our first aproche was it to create new SMWStore for Querying Data
176 - //but we had big Problems recreating and parsing the SMW Query Syntax
177 - //that we just Stoped at this Point here. Maybe we will finish it someday
 173+ public function getQueryResult( SMWQuery $query ) {
 174+ // IF YOU SEE THIS HERE PLEASE IGNORE IT!
 175+ // Our first aproche was it to create new SMWStore for Querying Data
 176+ // but we had big Problems recreating and parsing the SMW Query Syntax
 177+ // that we just Stoped at this Point here. Maybe we will finish it someday
178178 $wgSolrTalker = new SolrTalker();
179 - if (property_exists($query, 'params') &&
180 - array_key_exists('source', $query->params) &&
181 - $query->params['source'] == 'solr') {
 179+ if ( property_exists( $query, 'params' ) &&
 180+ array_key_exists( 'source', $query->params ) &&
 181+ $query->params['source'] == 'solr' ) {
182182
183183 $results = array();
184184 $dbkey = '';
185185 $namespace = 0;
186186 $interwiki = '';
187187
188 - echo("SOLR query: {$query->getQueryString()}\n");
 188+ echo( "SOLR query: {$query->getQueryString()}\n" );
189189
190 - echo("Search is Powered by Solr!");
191 - echo $queryStr = urldecode($wgSolrTalker->parseSolrQuery($query->getQueryString()));
192 -
193 -
194 - //Get Sort Parameters and add them to the QueryString
195 - if ($query->sort) {
196 - //TODO: Der Inhalt von Sort muss genau der Name eines der Felder von Solr sein
 190+ echo( "Search is Powered by Solr!" );
 191+ echo $queryStr = urldecode( $wgSolrTalker->parseSolrQuery( $query->getQueryString() ) );
 192+
 193+
 194+ // Get Sort Parameters and add them to the QueryString
 195+ if ( $query->sort ) {
 196+ // TODO: Der Inhalt von Sort muss genau der Name eines der Felder von Solr sein
197197 // um danach Sortieren zu können. Deshalb Wird eine Liste alle Solr Felder
198198 // Benötigt um Festzustellen welches Feld gemeint ist bzw. welche _XYZ Endung
199199 // an dem Ende des Feldes angehängt wurde.
200 - //
 200+ //
201201
202202
203 - $sort = $wgSolrTalker->findField($query->params['sort'], $query->params['order']);
204 - $queryStr .= '&sort%3D' . $sort . '+' . trim($query->params['order']);
 203+ $sort = $wgSolrTalker->findField( $query->params['sort'], $query->params['order'] );
 204+ $queryStr .= '&sort%3D' . $sort . '+' . trim( $query->params['order'] );
205205 // $queryStr = $queryStr . '&sort=' . trim($sort . '+' . trim($query->params['order']));
206 - //TODO: Mehrer Sort parameter auslesen wenn sie vorhanden sind.
207 - }
 206+ // TODO: Mehrer Sort parameter auslesen wenn sie vorhanden sind.
 207+ }
208208 // else {
209209 // $queryStr = $queryStr . '&sort=pagetitle';
210210 // }
211 -
212 - //TODO: Prüfen wieso nur 1 Ergebniss ausgegeben wird
213 - echo 'Query Limit:'.$query->getLimit();
214211
215 - echo ("SEARCHRESULT: " . $xml = $wgSolrTalker->solrQuery($queryStr, $query->getOffset(), $query->getLimit()));
216 - echo("<br/>");
217 - //TODO: Move this Code to parseSolrResult
 212+ // TODO: Prüfen wieso nur 1 Ergebniss ausgegeben wird
 213+ echo 'Query Limit:' . $query->getLimit();
 214+
 215+ echo ( "SEARCHRESULT: " . $xml = $wgSolrTalker->solrQuery( $queryStr, $query->getOffset(), $query->getLimit() ) );
 216+ echo( "<br/>" );
 217+ // TODO: Move this Code to parseSolrResult
218218 $numFound = $xml->result['numFound'];
219219 // print_r('1: ' . $xml->{"result"});
220 - foreach ($xml->result->doc as $doc) {
221 - foreach ($doc->str as $field) {
222 - switch ($field['name']) {
 220+ foreach ( $xml->result->doc as $doc ) {
 221+ foreach ( $doc->str as $field ) {
 222+ switch ( $field['name'] ) {
223223 case 'dbkey':
224224 $dbkey = $field;
225225 break;
@@ -230,9 +230,9 @@
231231 break;
232232 }
233233 }
234 - // Multivalue Felder
235 - foreach ($doc->arr as $field) {
236 - switch ($field['name']) {
 234+ // Multivalue Felder
 235+ foreach ( $doc->arr as $field ) {
 236+ switch ( $field['name'] ) {
237237 case 'dbkey':
238238 $dbkey = $field;
239239 break;
@@ -243,29 +243,29 @@
244244 $namespace = $field;
245245 break;
246246 }
247 - foreach ($field->str as $value) {
 247+ foreach ( $field->str as $value ) {
248248 $value;
249249 }
250250 }
251 - $results[] = new SMWDIWikiPage($dbkey, $namespace, $interwiki);
 251+ $results[] = new SMWDIWikiPage( $dbkey, $namespace, $interwiki );
252252 }
253 -
 253+
254254 // Do we have more Results ?
255255 $more = false;
256 - //TODO: Does this Work ?
257 - echo 'Number of Records: '.$numFound;
258 - if ($numFound > 10) {
 256+ // TODO: Does this Work ?
 257+ echo 'Number of Records: ' . $numFound;
 258+ if ( $numFound > 10 ) {
259259 $more = true;
260260 }
261 -
262 - //return new SMWQueryResult($printRequests, $query, $results, $store);
263 - return new SMWQueryResult($query->getDescription()->getPrintrequests(), $query, $results, $this, $more);
 261+
 262+ // return new SMWQueryResult($printRequests, $query, $results, $store);
 263+ return new SMWQueryResult( $query->getDescription()->getPrintrequests(), $query, $results, $this, $more );
264264 } else {
265 - return self::getBaseStore()->getQueryResult($query);
 265+ return self::getBaseStore()->getQueryResult( $query );
266266 }
267267 }
268268
269 -///// Special page functions /////
 269+//// / Special page functions /////
270270
271271 /**
272272 * Return all properties that have been used on pages in the wiki. The
@@ -277,8 +277,8 @@
278278 *
279279 * @return array
280280 */
281 - public function getPropertiesSpecial($requestoptions = null) {
282 - return self::getBaseStore()->getPropertiesSpecial($requestoptions);
 281+ public function getPropertiesSpecial( $requestoptions = null ) {
 282+ return self::getBaseStore()->getPropertiesSpecial( $requestoptions );
283283 }
284284
285285 /**
@@ -291,8 +291,8 @@
292292 *
293293 * @return array of SMWDIProperty
294294 */
295 - public function getUnusedPropertiesSpecial($requestoptions = null) {
296 - return self::getBaseStore()->getUnusedPropertiesSpecial($requestoptions);
 295+ public function getUnusedPropertiesSpecial( $requestoptions = null ) {
 296+ return self::getBaseStore()->getUnusedPropertiesSpecial( $requestoptions );
297297 }
298298
299299 /**
@@ -305,8 +305,8 @@
306306 *
307307 * @return array of array( SMWDIProperty, int )
308308 */
309 - public function getWantedPropertiesSpecial($requestoptions = null) {
310 - return self::getBaseStore()->getWantedPropertiesSpecial($requestoptions);
 309+ public function getWantedPropertiesSpecial( $requestoptions = null ) {
 310+ return self::getBaseStore()->getWantedPropertiesSpecial( $requestoptions );
311311 }
312312
313313 /**
@@ -322,7 +322,7 @@
323323 return self::getBaseStore()->getStatistics();
324324 }
325325
326 -///// Setup store /////
 326+//// / Setup store /////
327327
328328 /**
329329 * Setup all storage structures properly for using the store. This
@@ -341,11 +341,11 @@
342342 *
343343 * @param boolean $verbose
344344 */
345 - public function setup($verbose = true) {
 345+ public function setup( $verbose = true ) {
346346
347 - //TODO: Setup data structures on the the Solr server, if necessary
 347+ // TODO: Setup data structures on the the Solr server, if necessary
348348
349 - return self::getBaseStore()->setup($verbose);
 349+ return self::getBaseStore()->setup( $verbose );
350350 }
351351
352352 /**
@@ -354,12 +354,12 @@
355355 *
356356 * @param boolean $verbose
357357 */
358 - public function drop($verbose = true) {
 358+ public function drop( $verbose = true ) {
359359 global $wgSolrTalker;
360360 $wgSolrTalker->deleteAllDocs();
361 - //Drop all data from Solr
 361+ // Drop all data from Solr
362362
363 - return self::getBaseStore()->drop($verbose);
 363+ return self::getBaseStore()->drop( $verbose );
364364 }
365365
366366 /**
@@ -389,11 +389,11 @@
390390 *
391391 * @return decimal between 0 and 1 to indicate the overall progress of the refreshing
392392 */
393 - public function refreshData(&$index, $count, $namespaces = false, $usejobs = true) {
 393+ public function refreshData( &$index, $count, $namespaces = false, $usejobs = true ) {
394394
395 - //TODO: Do we need to do something here for Solr? Can we do something?
 395+ // TODO: Do we need to do something here for Solr? Can we do something?
396396
397 - return self::getBaseStore()->refreshData($index, $count, $namespaces, $usejobs);
 397+ return self::getBaseStore()->refreshData( $index, $count, $namespaces, $usejobs );
398398 }
399399
400400 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r106688r106682: Consistency tweaks in preparation for adding extension to translatew...raymond20:32, 19 December 2011
r106691r106682: Consistency tweaks in preparation for adding extension to translatew...raymond20:36, 19 December 2011
r106692r106682: Adding extension to translatewiki.netraymond20:39, 19 December 2011
r107203SolrStore: follow-up to r106682: convert spaces to tabsashley14:43, 24 December 2011

Comments

#Comment by Siebrand (talk | contribs)   17:48, 20 December 2011

+ 'searchFieldSets-select' => 'A message',

That's a pretty lame comment to a willing translator. Can you please improve on that?

I've also searched Google, and was not able to find a definition of the concept "SearchSet" in a Solr context. Can you please also define that everywhere it is used in messages?

#Comment by F.trott (talk | contribs)   22:09, 20 December 2011

I agree it's not ideal. Problem is, I only formatted it to prepare it for translatewiki. Not sure what a better word for SearchSet would be. I pinged someone who might know better (sbachenberg).

#Comment by Johnduhart (talk | contribs)   23:07, 20 December 2011

Should be using tabs for indentation.

#Comment by SBachenberg (talk | contribs)   00:16, 21 December 2011

We have a Overview Page of defined "SearchSets":

'searchFieldSets-select' , is something like "Please select a Searchset" 'searchFieldSets-title' , is the Title of the Page

A Searchset is predefined Search form, which contains 1 to X Fields for your Field based search.

This is a German Version of the Overview page http://www(dot)gesis(dot)org/sofiswiki/Spezial:SolrSearch

If you click on one of the Links you see on this Page, you go to one of my per-defined SearchSets.

#Comment by Siebrand (talk | contribs)   07:34, 21 December 2011

Thanks.

#Comment by F.trott (talk | contribs)   10:01, 4 January 2012

Should be fixed. Setting to new.

Status & tagging log