r64909 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64908‎ | r64909 | r64910 >
Date:21:27, 10 April 2010
Author:svemir
Status:deferred (Comments)
Tags:
Comment:
* changed wfMsg calls to use numbered args instead of sprintf
* moved colons etc. into the messages so they can be translated as well (not sure what to do with sphinxSearchDidYouMean yet...)
* removed the requirement to set $wgSphinxSuggestMode before ext. is included
* ran stylize.php
* split some long lines
* updated comments (more to come)
Modified paths:
  • /trunk/extensions/SphinxSearch/SphinxSearch.i18n.php (modified) (history)
  • /trunk/extensions/SphinxSearch/SphinxSearch.php (modified) (history)
  • /trunk/extensions/SphinxSearch/SphinxSearch_PersonalDict.php (modified) (history)
  • /trunk/extensions/SphinxSearch/SphinxSearch_body.php (modified) (history)
  • /trunk/extensions/SphinxSearch/SphinxSearch_spell.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SphinxSearch/SphinxSearch_body.php
@@ -1,14 +1,14 @@
22 <?php
33
44 /**
5 - * SphinxSearch extension code for MediaWiki
 5+ * Class file for the SphinxSearch extension
66 *
77 * http://www.mediawiki.org/wiki/Extension:SphinxSearch
88 *
9 - * Developed by Paul Grinberg and Svemir Brkic
10 - *
119 * Released under GNU General Public License (see http://www.fsf.org/licenses/gpl.html)
1210 *
 11+ * @addtogroup Extensions
 12+ * @author Svemir Brkic <svemir@deveblog.com> and Paul Grinberg
1313 */
1414
1515 class SphinxSearch extends SpecialPage {
@@ -19,27 +19,33 @@
2020 var $exc_categories = array(); // categories to exclude
2121 var $page = 1; // results page we are on
2222
 23+ /**
 24+ * Build a set of next/previous links for a given title
 25+ *
 26+ * @param Title $title
 27+ * @return string
 28+ */
2329 function SphinxSearch() {
2430 global $wgDisableInternalSearch, $wgSphinxSuggestMode, $wgAutoloadClasses;
2531
26 - if ($wgDisableInternalSearch) {
 32+ if ( $wgDisableInternalSearch ) {
2733 SpecialPage::SpecialPage( 'Search' );
2834 } else {
2935 SpecialPage::SpecialPage( 'SphinxSearch' );
3036 }
3137
32 - if ($wgSphinxSuggestMode) {
 38+ if ( $wgSphinxSuggestMode ) {
3339 $wgAutoloadClasses['SphinxSearch_spell'] = dirname( __FILE__ ) . '/SphinxSearch_spell.php';
3440 }
3541
36 - if (function_exists('wfLoadExtensionMessages')) {
 42+ if ( function_exists( 'wfLoadExtensionMessages' ) ) {
3743 wfLoadExtensionMessages( 'SphinxSearch' );
3844 } else {
3945 static $messagesLoaded = false;
4046 global $wgMessageCache;
41 - if (!$messagesLoaded) {
 47+ if ( !$messagesLoaded ) {
4248 $messagesLoaded = true;
43 - include dirname(__FILE__) . '/SphinxSearch.i18n.php';
 49+ include dirname( __FILE__ ) . '/SphinxSearch.i18n.php';
4450 foreach ( $messages as $lang => $langMessages ) {
4551 $wgMessageCache->addMessages( $langMessages, $lang );
4652 }
@@ -48,65 +54,88 @@
4955 return true;
5056 }
5157
 58+ /**
 59+ * Determine which namespaces may be included in a search
 60+ *
 61+ * @return array
 62+ */
5263 function searchableNamespaces() {
5364 $namespaces = SearchEngine::searchableNamespaces();
54 - wfRunHooks('SphinxSearchFilterSearchableNamespaces', array(&$namespaces));
 65+
 66+ wfRunHooks( 'SphinxSearchFilterSearchableNamespaces', array( &$namespaces ) );
 67+
5568 return $namespaces;
5669 }
5770
 71+ /**
 72+ * Determine which categories may be included in a search
 73+ *
 74+ * @return array
 75+ */
5876 function searchableCategories() {
5977 global $wgSphinxTopSearchableCategory;
6078
61 - if ($wgSphinxTopSearchableCategory) {
62 - $categories = self::getChildrenCategories($wgSphinxTopSearchableCategory);
 79+ if ( $wgSphinxTopSearchableCategory ) {
 80+ $categories = self::getChildrenCategories( $wgSphinxTopSearchableCategory );
6381 } else {
6482 $categories = array();
6583 }
66 - wfRunHooks('SphinxSearchGetSearchableCategories', array(&$categories));
 84+
 85+ wfRunHooks( 'SphinxSearchGetSearchableCategories', array( &$categories ) );
 86+
6787 return $categories;
6888 }
6989
70 - function getChildrenCategories($parent) {
 90+ /**
 91+ * Determine sub-categories of a given category
 92+ *
 93+ * @param string $parent
 94+ * @return array
 95+ */
 96+ function getChildrenCategories( $parent ) {
7197 global $wgMemc, $wgDBname;
7298
7399 $categories = null;
74 - if (is_object($wgMemc)) {
75 - $cache_key = $wgDBname . ':sphinx_cats:' . md5($parent);
 100+ if ( is_object( $wgMemc ) ) {
 101+ $cache_key = $wgDBname . ':sphinx_cats:' . md5( $parent );
76102 $categories = $wgMemc->get( $cache_key );
77103 }
78 - if (!is_array($categories)) {
 104+ if ( !is_array( $categories ) ) {
79105 $categories = array();
80 - $dbr =& wfGetDB( DB_SLAVE );
 106+ $dbr = wfGetDB( DB_SLAVE );
81107 $res = $dbr->select(
82108 array( 'categorylinks', 'page' ),
83109 array( 'cl_from', 'cl_sortkey', 'page_title' ),
84110 array( '1',
85111 'cl_from = page_id',
86112 'cl_to' => $parent,
87 - 'page_namespace' => NS_CATEGORY),
 113+ 'page_namespace' => NS_CATEGORY ),
88114 'epSearchableCategories',
89115 array( 'ORDER BY' => 'cl_sortkey' )
90116 );
91 - while( $x = $dbr->fetchObject ( $res ) ) {
 117+ while ( $x = $dbr->fetchObject ( $res ) ) {
92118 $categories[$x->cl_from] = $x->cl_sortkey;
93119 }
94 - if ($cache_key) {
 120+ if ( $cache_key ) {
 121+ # cache query results for a day
95122 $wgMemc->set( $cache_key, $categories, 86400 );
96123 }
97 - $dbr->freeResult($res);
 124+ $dbr->freeResult( $res );
98125 }
99126 return $categories;
100127 }
101128
102 - function ajaxGetCategoryChildren($parent_id) {
 129+ function ajaxGetCategoryChildren( $parent_id ) {
103130
104131 $title = Title::newFromID( $parent_id );
105132
106 - if ( ! $title ) return false;
 133+ if ( !$title ) {
 134+ return false;
 135+ }
107136
108137 # Retrieve page_touched for the category
109138 $dbkey = $title->getDBkey();
110 - $dbr =& wfGetDB( DB_SLAVE );
 139+ $dbr = wfGetDB( DB_SLAVE );
111140 $touched = $dbr->selectField(
112141 'page', 'page_touched',
113142 array(
@@ -124,14 +153,14 @@
125154
126155 $categories = self::getChildrenCategories( $dbkey );
127156
128 - $html = self::getCategoryCheckboxes($categories, $parent_id);
 157+ $html = self::getCategoryCheckboxes( $categories, $parent_id );
129158
130159 $response->addText( $html );
131160
132161 return $response;
133162 }
134163
135 - function execute($par) {
 164+ function execute( $par ) {
136165 global $wgRequest, $wgOut, $wgUser, $wgSphinxMatchAll, $wgSphinxSearch_index_list;
137166
138167 # extract the options from the GET query
@@ -144,51 +173,54 @@
145174 # thn try to go to title directly). This is needed because IE has a
146175 # different behavior when the <ENTER> button is pressed in a form -
147176 # it does not send the name of the default button!
148 - if( ! $wgRequest->getVal( 'fulltext' )) {
 177+ if ( !$wgRequest->getVal( 'fulltext' ) ) {
149178 $this->goResult( $term );
150179 }
151180
152181 $this->setHeaders();
153 - $wgOut->setPagetitle(wfMsg('sphinxsearch'));
 182+ $wgOut->setPagetitle( wfMsg( 'sphinxsearch' ) );
154183
155184 $this->namespaces = array();
156185 $all_namespaces = self::searchableNamespaces();
157 - foreach( $all_namespaces as $ns => $name ) {
158 - if ($wgRequest->getCheck("ns{$ns}")) {
 186+ foreach ( $all_namespaces as $ns => $name ) {
 187+ if ( $wgRequest->getCheck( "ns{$ns}" ) ) {
159188 $this->namespaces[] = $ns;
160189 }
161190 }
162 - if (!count($this->namespaces)) {
163 - foreach( $all_namespaces as $ns => $name ) {
164 - if ($wgUser->getOption('searchNs' . $ns)) {
 191+ if ( !count( $this->namespaces ) ) {
 192+ foreach ( $all_namespaces as $ns => $name ) {
 193+ if ( $wgUser->getOption( 'searchNs' . $ns ) ) {
165194 $this->namespaces[] = $ns;
166195 }
167196 }
168197 }
169198
170 - $this->categories = $wgRequest->getIntArray("cat", array());
171 - $this->exc_categories = $wgRequest->getIntArray("exc", array());
 199+ $this->categories = $wgRequest->getIntArray( "cat", array() );
 200+ $this->exc_categories = $wgRequest->getIntArray( "exc", array() );
172201
173 - $this->page = $wgRequest->getInt('page', 1);
174 - $wgSphinxMatchAll = $wgRequest->getInt('match_all', intval($wgSphinxMatchAll));
175 - $match_titles_only = ($wgRequest->getInt('match_titles') == 1);
 202+ $this->page = $wgRequest->getInt( 'page', 1 );
 203+ $wgSphinxMatchAll = $wgRequest->getInt( 'match_all', intval( $wgSphinxMatchAll ) );
 204+ $match_titles_only = ( $wgRequest->getInt( 'match_titles' ) == 1 );
176205
177206 # do the actual search
178207 $found = 0;
179208 $cl = $this->prepareSphinxClient( $term, $match_titles_only );
180209 if ( $cl ) {
181 - $res = $cl->Query( addcslashes($this->search_term, '/()[]"!'), $wgSphinxSearch_index_list );
 210+ $res = $cl->Query(
 211+ addcslashes( $this->search_term, '/()[]"!' ),
 212+ $wgSphinxSearch_index_list
 213+ );
182214 if ( $res === false ) {
183 - $wgOut->addWikiText( wfMsg('sphinxSearchFailed') . wfMsg( 'word-separator' ) . $cl->GetLastError() . ".\n" );
 215+ $wgOut->addWikiText( wfMsg( 'sphinxSearchFailed', $cl->GetLastError() ) . "\n" );
184216 } else {
185217 $found = $this->wfSphinxDisplayResults( $term, $res, $cl );
186218 }
187219 } else {
188 - $wgOut->addWikiText( wfMsg('sphinxClientFailed') . ".\n" );
 220+ $wgOut->addWikiText( wfMsg( 'sphinxClientFailed' ) . "\n" );
189221 }
190222
191223 # prepare for the next search
192 - if ($found) {
 224+ if ( $found ) {
193225 $this->createNextPageBar( $found, $term );
194226 }
195227
@@ -202,21 +234,21 @@
203235 $t = Title::newFromText( $term );
204236
205237 # If the string cannot be used to create a title
206 - if( is_null( $t ) ){
 238+ if ( is_null( $t ) ) {
207239 return;
208240 }
209241
210242 # If there's an exact or very near match, jump right there.
211243 $t = SearchEngine::getNearMatch( $term );
212 - wfRunHooks('SphinxSearchGetNearMatch', array(&$term, &$t));
213 - if( !is_null( $t ) ) {
 244+ wfRunHooks( 'SphinxSearchGetNearMatch', array( &$term, &$t ) );
 245+ if ( !is_null( $t ) ) {
214246 $wgOut->redirect( $t->getFullURL() );
215247 return;
216248 }
217249
218250 # No match, generate an edit URL
219251 $t = Title::newFromText( $term );
220 - if( ! is_null( $t ) ) {
 252+ if ( !is_null( $t ) ) {
221253 # If the feature is enabled, go straight to the edit page
222254 if ( $wgGoToEdit ) {
223255 $wgOut->redirect( $t->getFullURL( 'action=edit' ) );
@@ -268,7 +300,10 @@
269301
270302 $cl = $this->prepareSphinxClient( $term, $titles_only );
271303 if ( $cl ) {
272 - $res = $cl->Query( addcslashes($this->search_term, '/()[]"!'), $wgSphinxSearch_index_list );
 304+ $res = $cl->Query(
 305+ addcslashes( $this->search_term, '/()[]"!' ),
 306+ $wgSphinxSearch_index_list
 307+ );
273308 } else {
274309 $res = false;
275310 }
@@ -296,22 +331,28 @@
297332 * Display the results of the search one page at a time.
298333 * Returns the number of matches.
299334 */
300 - function prepareSphinxClient($term, $match_titles_only = false) {
 335+ function prepareSphinxClient( $term, $match_titles_only = false ) {
301336 global $wgSphinxSearch_sortmode, $wgSphinxSearch_sortby,
302337 $wgSphinxSearch_host, $wgSphinxSearch_port, $wgSphinxSearch_index_weights,
303338 $wgSphinxSearch_index, $wgSphinxSearch_matches, $wgSphinxSearch_mode, $wgSphinxSearch_weights,
304339 $wgSphinxMatchAll, $wgSphinxSearch_maxmatches, $wgSphinxSearch_cutoff;
305340
306341 # don't do anything for blank searches
307 - if (trim($term) === '') {
 342+ if ( trim( $term ) === '' ) {
308343 return false;
309344 }
310345
311 - wfRunHooks( 'SphinxSearchBeforeResults', array( &$term, &$this->page, &$this->namespaces, &$this->categories, &$this->exc_categories ) );
 346+ wfRunHooks( 'SphinxSearchBeforeResults', array(
 347+ &$term,
 348+ &$this->page,
 349+ &$this->namespaces,
 350+ &$this->categories,
 351+ &$this->exc_categories
 352+ ) );
312353
313354 if ( $wgSphinxSearch_mode == SPH_MATCH_EXTENDED && $wgSphinxMatchAll != '1' ) {
314355 # make OR the default in extended mode
315 - $this->search_term = preg_replace( '/[\s_\-&]+/', '|', trim($term) );
 356+ $this->search_term = preg_replace( '/[\s_\-&]+/', '|', trim( $term ) );
316357 } else {
317358 $this->search_term = $term;
318359 }
@@ -319,97 +360,107 @@
320361 $cl = new SphinxClient();
321362
322363 # setup the options for searching
323 - if ( isset($wgSphinxSearch_host) && isset($wgSphinxSearch_port) ) {
324 - $cl->SetServer($wgSphinxSearch_host, $wgSphinxSearch_port);
 364+ if ( isset( $wgSphinxSearch_host ) && isset( $wgSphinxSearch_port ) ) {
 365+ $cl->SetServer( $wgSphinxSearch_host, $wgSphinxSearch_port );
325366 }
326 - if (count($wgSphinxSearch_weights)) {
327 - if (is_string(key($wgSphinxSearch_weights))) {
328 - $cl->SetFieldWeights($wgSphinxSearch_weights);
 367+ if ( count( $wgSphinxSearch_weights ) ) {
 368+ if ( is_string( key( $wgSphinxSearch_weights ) ) ) {
 369+ $cl->SetFieldWeights( $wgSphinxSearch_weights );
329370 } else {
330 - $cl->SetWeights($wgSphinxSearch_weights);
 371+ $cl->SetWeights( $wgSphinxSearch_weights );
331372 }
332373 }
333 - if (is_array($wgSphinxSearch_index_weights)) {
334 - $cl->SetIndexWeights($wgSphinxSearch_index_weights);
 374+ if ( is_array( $wgSphinxSearch_index_weights ) ) {
 375+ $cl->SetIndexWeights( $wgSphinxSearch_index_weights );
335376 }
336 - if (isset($wgSphinxSearch_mode)) {
337 - $cl->SetMatchMode($wgSphinxSearch_mode);
 377+ if ( isset( $wgSphinxSearch_mode ) ) {
 378+ $cl->SetMatchMode( $wgSphinxSearch_mode );
338379 }
339 - if (count($this->namespaces)) {
340 - $cl->SetFilter('page_namespace', $this->namespaces);
 380+ if ( count( $this->namespaces ) ) {
 381+ $cl->SetFilter( 'page_namespace', $this->namespaces );
341382 }
342383
343 - if (count($this->categories)) {
344 - $cl->SetFilter('category', $this->categories);
 384+ if ( count( $this->categories ) ) {
 385+ $cl->SetFilter( 'category', $this->categories );
345386 }
346387
347 - if (count($this->exc_categories)) {
348 - $cl->SetFilter('category', $this->exc_categories, true);
 388+ if ( count( $this->exc_categories ) ) {
 389+ $cl->SetFilter( 'category', $this->exc_categories, true );
349390 }
350391
351 - if (isset($wgSphinxSearch_groupby) && isset($wgSphinxSearch_groupsort)) {
352 - $cl->SetGroupBy($wgSphinxSearch_groupby, SPH_GROUPBY_ATTR, $wgSphinxSearch_groupsort);
 392+ if ( isset( $wgSphinxSearch_groupby ) && isset( $wgSphinxSearch_groupsort ) ) {
 393+ $cl->SetGroupBy( $wgSphinxSearch_groupby, SPH_GROUPBY_ATTR, $wgSphinxSearch_groupsort );
353394 }
354 - $cl->SetSortMode($wgSphinxSearch_sortmode, $wgSphinxSearch_sortby);
355 - $cl->SetLimits( ($this->page - 1) * $wgSphinxSearch_matches, $wgSphinxSearch_matches, $wgSphinxSearch_maxmatches, $wgSphinxSearch_cutoff );
 395+ $cl->SetSortMode( $wgSphinxSearch_sortmode, $wgSphinxSearch_sortby );
 396+ $cl->SetLimits(
 397+ ( $this->page - 1 ) * $wgSphinxSearch_matches,
 398+ $wgSphinxSearch_matches,
 399+ $wgSphinxSearch_maxmatches,
 400+ $wgSphinxSearch_cutoff
 401+ );
356402
357403 if ( $match_titles_only ) {
358404 $this->search_term = '@page_title ' . $this->search_term;
359405 }
360406
361 - wfRunHooks('SphinxSearchBeforeQuery', array(&$this->search_term, &$cl));
 407+ wfRunHooks( 'SphinxSearchBeforeQuery', array( &$this->search_term, &$cl ) );
362408
363409 return $cl;
364410 }
365411
366 - function wfSphinxDisplayResults($term, $res, $cl) {
 412+ function wfSphinxDisplayResults( $term, $res, $cl ) {
367413
368414 global $wgOut, $wgSphinxSuggestMode, $wgSphinxSearch_matches, $wgSphinxSearch_index, $wgSphinxSearch_maxmatches;
369415
370416 if ($cl->GetLastWarning()) {
371 - // FIXME: should be one message with a parameter
372 - $wgOut->addWikiText(wfMsg('sphinxSearchWarning') . wfMsg( 'word-separator' ) . $cl->GetLastWarning() . "\n\n");
 417+ $wgOut->addWikiText( wfMsg( 'sphinxSearchWarning', $cl->GetLastWarning() ) . "\n\n");
373418 }
374419 $found = $res['total_found'];
375420
376 - if ($wgSphinxSuggestMode) {
 421+ if ( $wgSphinxSuggestMode ) {
377422 $sc = new SphinxSearch_spell;
378 - $didyoumean = $sc->spell($this->search_term);
379 - if ($didyoumean) {
380 - $wgOut->addhtml(wfMsg('sphinxSearchDidYouMean') .
381 - " <b><a href='" .
382 - $this->getActionURL($didyoumean, $this->namespaces) .
383 - "1'>" . $didyoumean . '</a></b>?');
 423+ $didyoumean = $sc->spell( $this->search_term );
 424+ if ( $didyoumean ) {
 425+ $wgOut->addhtml( wfMsg( 'sphinxSearchDidYouMean' ) .
 426+ " <b><a href='" .
 427+ $this->getActionURL( $didyoumean, $this->namespaces ) .
 428+ "1'>" . $didyoumean . '</a></b>?'
 429+ );
384430 }
385431 }
386432
387 - $preamble = sprintf(wfMsg('sphinxSearchPreamble'),
388 - ( (($this->page - 1) * $wgSphinxSearch_matches) + 1 > $res['total'] ) ? $res['total'] : (($this->page - 1) * $wgSphinxSearch_matches) + 1,
389 - ($this->page * $wgSphinxSearch_matches > $res['total']) ? $res['total'] : $this->page * $wgSphinxSearch_matches,
390 - $res['total'],
391 - $term,
392 - $res['time']
 433+ $from = min(
 434+ ( ( $this->page - 1 ) * $wgSphinxSearch_matches ) + 1,
 435+ $res['total']
393436 );
394 - // FIXME: should be one message with a parameter ending on a colon
395 - $wgOut->addWikiText($preamble . wfMsg( 'colon-separator' ) );
396 - if (is_array($res["words"])) {
 437+ $to = min(
 438+ $this->page * $wgSphinxSearch_matches,
 439+ $res['total']
 440+ );
 441+ $wgOut->addWikiText( wfMsg( 'sphinxSearchPreamble',
 442+ $from, $to, $res['total'], $term, $res['time'] )
 443+ );
 444+
 445+ if ( is_array( $res["words"] ) ) {
397446 $warn = false;
398 - foreach ($res["words"] as $word => $info) {
399 - $wgOut->addWikiText( '* ' . sprintf( wfMsg('sphinxSearchStats'), $word, $info['hits'], $info['docs'] ) );
 447+ foreach ( $res["words"] as $word => $info ) {
 448+ $wgOut->addWikiText( '* ' .
 449+ wfMsg( 'sphinxSearchStats', $word, $info['hits'], $info['docs'] )
 450+ );
400451 if ( ( $info['docs'] < $wgSphinxSearch_maxmatches ) && ( $info['docs'] > $res['total'] ) ) {
401452 $warn = true;
402453 }
403454 }
404455 if ( $warn ) {
405 - $wgOut->addWikiText( "''" . wfMsg('sphinxSearchStatsInfo') . ".''" );
 456+ $wgOut->addWikiText( "''" . wfMsg( 'sphinxSearchStatsInfo' ) . "''" );
406457 } else {
407458 $wgOut->addWikiText( "\n" );
408459 }
409460 }
410 - $start_time = microtime(true);
 461+ $start_time = microtime( true );
411462
412 - if (isset($res["matches"]) && is_array($res["matches"])) {
413 - $wgOut->addWikiText("----");
 463+ if ( isset( $res["matches"] ) && is_array( $res["matches"] ) ) {
 464+ $wgOut->addWikiText( "----" );
414465 $db = wfGetDB( DB_SLAVE );
415466 $excerpts_opt = array(
416467 "before_match" => "<span style='color:red'>",
@@ -419,73 +470,69 @@
420471 "around" => 15
421472 );
422473
423 - foreach ($res["matches"] as $doc => $docinfo) {
424 - $sql = "SELECT old_text FROM ".$db->tableName('text')." WHERE old_id=".$docinfo['attrs']['old_id'];
 474+ foreach ( $res["matches"] as $doc => $docinfo ) {
 475+ $sql = "SELECT old_text FROM " . $db->tableName( 'text' ) . " WHERE old_id=" . $docinfo['attrs']['old_id'];
425476 $res = $db->query( $sql, __METHOD__ );
426 - if ($db->numRows($res)) {
427 - $row = $db->fetchRow($res);
 477+ if ( $db->numRows( $res ) ) {
 478+ $row = $db->fetchRow( $res );
428479 $title_obj = Title::newFromID( $doc );
429 - if (is_object($title_obj)) {
 480+ if ( is_object( $title_obj ) ) {
430481 $wiki_title = $title_obj->getPrefixedText();
431482 $wiki_path = $title_obj->getPrefixedDBkey();
432 - $wgOut->addWikiText("* <span style='font-size:110%;'>[[:$wiki_path|$wiki_title]]</span>");
 483+ $wgOut->addWikiText( "* <span style='font-size:110%;'>[[:$wiki_path|$wiki_title]]</span>" );
 484+
433485 # uncomment this line to see the weights etc. as HTML comments in the source of the page
434 - #$wgOut->addHTML("<!-- page_id: ".$doc."\ninfo: ".print_r($docinfo, true)." -->");
435 - $excerpts = $cl->BuildExcerpts(array($row[0]), $wgSphinxSearch_index, $term, $excerpts_opt);
436 - if ( !is_array($excerpts) ) {
437 - $excerpts = array( "ERROR: " . $cl->GetLastError() );
 486+ # $wgOut->addHTML("<!-- page_id: ".$doc."\ninfo: ".print_r($docinfo, true)." -->");
 487+
 488+ $excerpts = $cl->BuildExcerpts( array( $row[0] ), $wgSphinxSearch_index, $term, $excerpts_opt );
 489+ if ( !is_array( $excerpts ) ) {
 490+ $excerpts = array( wfMsg( 'sphinxSearchWarning', $cl->GetLastError() ) );
438491 }
439492 foreach ( $excerpts as $entry ) {
440 - # add excerpt to output, removing some wiki markup, and breaking apart long strings
441 - $entry = preg_replace('/([\[\]\{\}\*\#\|\!]+|==+)/',
 493+ # add excerpt to output, removing some wiki markup
 494+ $entry = preg_replace( '/([\[\]\{\}\*\#\|\!]+|==+)/',
442495 ' ',
443 - strip_tags($entry, '<span><br>')
 496+ strip_tags( $entry, '<span><br>' )
444497 );
445 - # force breaks on very
446 - /*$entry = join('<br>',
447 - preg_split('/(\S{60})/',
448 - $entry,
449 - -1,
450 - PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
451 - )
452 - );*/
453 -
454 - $wgOut->addHTML("<div style='margin: 0.2em 1em 1em 1em;'>$entry</div>\n");
 498+ $wgOut->addHTML( "<div style='margin: 0.2em 1em 1em 1em;'>$entry</div>\n" );
455499 }
456500 }
457501 }
458 - $db->freeResult($res);
 502+ $db->freeResult( $res );
459503 }
460 - $wgOut->addWikiText(sprintf(wfMsg('sphinxSearchEpilogue'), microtime(true) - $start_time));
 504+ $time = number_format( microtime( true ) - $start_time, 3);
 505+ $wgOut->addWikiText( wfMsg( 'sphinxSearchEpilogue', $time ) );
461506 }
462507
463 - wfRunHooks('SphinxSearchAfterResults', array($term, $this->page));
 508+ wfRunHooks( 'SphinxSearchAfterResults', array( $term, $this->page ) );
464509
465510 return $found;
466511 }
467512
468 - function getActionURL($term) {
 513+ function getActionURL( $term ) {
469514 global $wgDisableInternalSearch, $wgSphinxMatchAll, $wgRequest;
470515
471 - $search_title = ($wgDisableInternalSearch ? 'Search' : 'SphinxSearch');
 516+ $search_title = ( $wgDisableInternalSearch ? 'Search' : 'SphinxSearch' );
472517 $titleObj = SpecialPage::getTitleFor( $search_title );
473518 $qry = $titleObj->getLocalUrl();
474 - $searchField = strtolower($search_title);
475 - $term = urlencode($term);
476 - $qry .= (strpos($qry, '?') === false ? '?' : '&amp;').$searchField."={$term}&amp;fulltext=".wfMsg('sphinxSearchButton')."&amp;";
477 - if ($wgSphinxMatchAll == '1') {
 519+ $searchField = strtolower( $search_title );
 520+ $term = urlencode( $term );
 521+ $qry .= ( strpos( $qry, '?' ) === false ? '?' : '&amp;' ) .
 522+ $searchField . "={$term}&amp;fulltext=" .
 523+ wfMsg( 'sphinxSearchButton' ) . "&amp;";
 524+ if ( $wgSphinxMatchAll == '1' ) {
478525 $qry .= "match_all=1&amp;";
479526 }
480 - if ($wgRequest->getInt('match_titles')) {
 527+ if ( $wgRequest->getInt( 'match_titles' ) ) {
481528 $qry .= "match_titles=1&amp;";
482529 }
483 - foreach ($this->namespaces as $ns) {
 530+ foreach ( $this->namespaces as $ns ) {
484531 $qry .= "ns{$ns}=1&amp;";
485532 }
486 - foreach ($this->categories as $c) {
 533+ foreach ( $this->categories as $c ) {
487534 $qry .= "cat[]={$c}&amp;";
488535 }
489 - foreach ($this->exc_categories as $c) {
 536+ foreach ( $this->exc_categories as $c ) {
490537 $qry .= "exc[]={$c}&amp;";
491538 }
492539 $qry .= "page=";
@@ -496,144 +543,166 @@
497544 function createNextPageBar( $found, $term ) {
498545 global $wgOut, $wgSphinxSearch_matches;
499546
500 - $qry = $this->getActionURL($term);
 547+ $qry = $this->getActionURL( $term );
501548
502549 $display_pages = 10;
503 - $max_page = ceil($found / $wgSphinxSearch_matches);
504 - $center_page = floor(($this->page + $display_pages) / 2);
 550+ $max_page = ceil( $found / $wgSphinxSearch_matches );
 551+ $center_page = floor( ( $this->page + $display_pages ) / 2 );
505552 $first_page = $center_page - $display_pages / 2;
506 - if ($first_page < 1) {
 553+ if ( $first_page < 1 ) {
507554 $first_page = 1;
508555 }
509556 $last_page = $first_page + $display_pages - 1;
510 - if ($last_page > $max_page) {
 557+ if ( $last_page > $max_page ) {
511558 $last_page = $max_page;
512559 }
513 - if ($first_page != $last_page) {
514 - $wgOut->addWikiText("----");
515 - $wgOut->addHTML("<center><table border='0' cellpadding='0' width='1%' cellspacing='0'><tr align='center' valign='top'><td valign='bottom' nowrap='1'>" . wfMsg('sphinxResultPage') . ":</td>");
 560+ if ( $first_page != $last_page ) {
 561+ $wgOut->addWikiText( "----" );
 562+ $wgOut->addHTML( "<center>
 563+ <table border='0' cellpadding='0' width='1%' cellspacing='0'>
 564+ <tr align='center' valign='top'>
 565+ <td valign='bottom' nowrap='1'>" . wfMsg( 'sphinxResultPage' ) . "</td>" );
516566
517 - if ($first_page > 1) {
 567+ if ( $first_page > 1 ) {
518568 $prev_page = "<td>&nbsp;<a href='{$qry}";
519 - $prev_page .= ($this->page - 1) . "'>" . wfMsg('sphinxPreviousPage') . "</a>&nbsp;</td>";
520 - $wgOut->addHTML($prev_page);
 569+ $prev_page .= ( $this->page - 1 ) . "'>" . wfMsg( 'sphinxPreviousPage' ) . "</a>&nbsp;</td>";
 570+ $wgOut->addHTML( $prev_page );
521571 }
522 - for ($i = $first_page; $i < $this->page; $i++) {
523 - $wgOut->addHTML("<td>&nbsp;<a href='{$qry}{$i}'>{$i}</a>&nbsp;</td>");
 572+ for ( $i = $first_page; $i < $this->page; $i++ ) {
 573+ $wgOut->addHTML( "<td>&nbsp;<a href='{$qry}{$i}'>{$i}</a>&nbsp;</td>" );
524574 }
525 - $wgOut->addHTML("<td>&nbsp;<b>{$this->page}</b>&nbsp;</td>");
526 - for ($i = $this->page + 1; $i <= $last_page; $i++) {
527 - $wgOut->addHTML("<td>&nbsp;<a href='{$qry}{$i}'>{$i}</a>&nbsp;</td>");
 575+ $wgOut->addHTML( "<td>&nbsp;<b>{$this->page}</b>&nbsp;</td>" );
 576+ for ( $i = $this->page + 1; $i <= $last_page; $i++ ) {
 577+ $wgOut->addHTML( "<td>&nbsp;<a href='{$qry}{$i}'>{$i}</a>&nbsp;</td>" );
528578 }
529 - if ($last_page < $max_page) {
 579+ if ( $last_page < $max_page ) {
530580 $next_page = "<td>&nbsp;<a href='{$qry}";
531 - $next_page .= ($this->page + 1) . "'>" . wfMsg('sphinxNextPage') . "</a>&nbsp;</td>";
532 - $wgOut->addHTML($next_page);
 581+ $next_page .= ( $this->page + 1 ) . "'>" . wfMsg( 'sphinxNextPage' ) . "</a>&nbsp;</td>";
 582+ $wgOut->addHTML( $next_page );
533583 }
534584
535 - $wgOut->addHTML("</tr></table></center>");
 585+ $wgOut->addHTML( "</tr></table></center>" );
536586 }
537587 }
538588
539 - function createNewSearchForm($term) {
 589+ function createNewSearchForm( $term ) {
540590 global $wgOut, $wgDisableInternalSearch, $wgSphinxSearch_mode, $wgSphinxMatchAll, $wgUseExcludes;
541591 global $wgUseAjax, $wgJsMimeType, $wgScriptPath, $wgSphinxSearchExtPath, $wgSphinxSearchJSPath, $wgRequest;
542592
543 - $search_title = ($wgDisableInternalSearch ? 'Search' : 'SphinxSearch');
 593+ $search_title = ( $wgDisableInternalSearch ? 'Search' : 'SphinxSearch' );
544594 $titleObj = SpecialPage::getTitleFor( $search_title );
545595 $kiAction = $titleObj->getLocalUrl();
546 - $searchField = strtolower($search_title);
547 - $wgOut->addHTML("<form action='$kiAction' method='GET'>
548 - <input type='hidden' name='title' value='".$titleObj->getPrefixedText()."'>
 596+ $searchField = strtolower( $search_title );
 597+ $wgOut->addHTML( "<form action='$kiAction' method='GET'>
 598+ <input type='hidden' name='title' value='" . $titleObj->getPrefixedText() . "'>
549599 <input type='text' name='$searchField' maxlength='100' value='$term'>
550 - <input type='submit' name='fulltext' value='" . wfMsg('sphinxSearchButton') ."'>");
 600+ <input type='submit' name='fulltext' value='" . wfMsg( 'sphinxSearchButton' ) . "'>" );
551601
552 - $wgOut->addHTML("<div style='margin:0.5em 0 0.5em 0;'>");
553 - if ($wgSphinxSearch_mode == SPH_MATCH_EXTENDED) {
554 - $wgOut->addHTML("<input type='radio' name='match_all' value='0' ".($wgSphinxMatchAll ? "" : "checked='checked'")." />".wfMsg('sphinxMatchAny')." <input type='radio' name='match_all' value='1' ".($wgSphinxMatchAll ? "checked='checked'" : "")." />".wfMsg('sphinxMatchAll'));
 602+ $wgOut->addHTML( "<div style='margin:0.5em 0 0.5em 0;'>" );
 603+ if ( $wgSphinxSearch_mode == SPH_MATCH_EXTENDED ) {
 604+ $wgOut->addHTML( "<input type='radio' name='match_all' value='0' " .
 605+ ( $wgSphinxMatchAll ? "" : "checked='checked'" ) . " />" .
 606+ wfMsg( 'sphinxMatchAny' ) .
 607+ " <input type='radio' name='match_all' value='1' " .
 608+ ( $wgSphinxMatchAll ? "checked='checked'" : "" ) . " />" .
 609+ wfMsg( 'sphinxMatchAll' )
 610+ );
555611 }
556 - $wgOut->addHTML(" &nbsp; <input type='checkbox' name='match_titles' value='1' " . ($wgRequest->getInt('match_titles') ? "checked='checked'" : ""). ">" . wfMsg('sphinxMatchTitles') . "</div>");
 612+ $wgOut->addHTML( " &nbsp; <input type='checkbox' name='match_titles' value='1' " .
 613+ ( $wgRequest->getInt( 'match_titles' ) ? "checked='checked'" : "" ) . ">" .
 614+ wfMsg( 'sphinxMatchTitles' ) . "</div>"
 615+ );
557616 # get user settings for which namespaces to search
558 - $wgOut->addHTML("<div style='width:30%; border:1px #eee solid; padding:4px; margin-right:1px; float:left;'>");
559 - $wgOut->addHTML(wfMsg('sphinxSearchInNamespaces') . '<br />');
 617+ $wgOut->addHTML( "<div style='width:30%; border:1px #eee solid; padding:4px; margin-right:1px; float:left;'>" );
 618+ $wgOut->addHTML( wfMsg( 'sphinxSearchInNamespaces' ) . '<br />' );
560619 $all_namespaces = self::searchableNamespaces();
561 - foreach( $all_namespaces as $ns => $name ) {
562 - $checked = in_array($ns, $this->namespaces) ? ' checked="checked"' : '';
 620+ foreach ( $all_namespaces as $ns => $name ) {
 621+ $checked = in_array( $ns, $this->namespaces ) ? ' checked="checked"' : '';
563622 $name = str_replace( '_', ' ', $name );
564 - if('' == $name) {
565 - $name = wfMsg('blanknamespace');
 623+ if ( '' == $name ) {
 624+ $name = wfMsg( 'blanknamespace' );
566625 }
567 - $wgOut->addHTML("<label><input type='checkbox' value='1' name='ns$ns'$checked />$name</label><br />");
 626+ $wgOut->addHTML( "<label><input type='checkbox' value='1' name='ns$ns'$checked />$name</label><br />" );
568627 }
569628
570629 $all_categories = self::searchableCategories();
571 - if (is_array($all_categories) && count($all_categories)) {
572 - $cat_parents = $wgRequest->getIntArray("catp", array());
573 - $wgOut->addScript(Skin::makeVariablesScript(array(
574 - 'sphinxLoadingMsg' => wfMsg('sphinxLoading'),
575 - 'wgSphinxSearchExtPath' => ($wgSphinxSearchJSPath ? $wgSphinxSearchJSPath : $wgSphinxSearchExtPath)
576 - )));
 630+ if ( is_array( $all_categories ) && count( $all_categories ) ) {
 631+ $cat_parents = $wgRequest->getIntArray( "catp", array() );
 632+ $wgOut->addScript( Skin::makeVariablesScript( array(
 633+ 'sphinxLoadingMsg' => wfMsg( 'sphinxLoading' ),
 634+ 'wgSphinxSearchExtPath' => ( $wgSphinxSearchJSPath ? $wgSphinxSearchJSPath : $wgSphinxSearchExtPath )
 635+ ) ) );
577636 $wgOut->addScript(
578 - "<script type='{$wgJsMimeType}' src='".($wgSphinxSearchJSPath ? $wgSphinxSearchJSPath : $wgSphinxSearchExtPath)."/SphinxSearch.js?2'></script>\n"
579 - );
580 - $wgOut->addHTML("</div><div style='width:30%; border:1px #eee solid; padding:4px; margin-right:1px; float:left;'>");
581 - $wgOut->addHTML(wfMsg('sphinxSearchInCategories') );
582 - if ($wgUseExcludes) {
 637+ "<script type='{$wgJsMimeType}' src='" .
 638+ ( $wgSphinxSearchJSPath ? $wgSphinxSearchJSPath : $wgSphinxSearchExtPath ) .
 639+ "/SphinxSearch.js?2'></script>\n"
 640+ );
 641+ $wgOut->addHTML( "</div>
 642+ <div style='width:30%; border:1px #eee solid; padding:4px; margin-right:1px; float:left;'>"
 643+ );
 644+ $wgOut->addHTML( wfMsg('sphinxSearchInCategories') );
 645+ if ( $wgUseExcludes ) {
583646 $wgOut->addHTML("<div style='float:right; font-size:80%;'>exclude</div>");
584647 }
585648 $wgOut->addHTML('<br />');
586 - $wgOut->addHTML($this->getCategoryCheckboxes($all_categories, '', $cat_parents));
 649+ $wgOut->addHTML( $this->getCategoryCheckboxes( $all_categories, '', $cat_parents ) );
587650 }
588 - $wgOut->addHTML("</div></form><br clear='both'>");
 651+ $wgOut->addHTML( "</div></form><br clear='both'>" );
589652
590653 # Put a Sphinx label for this search
591 - $wgOut->addHTML("<div style='text-align:center'>" . sprintf(wfMsg('sphinxPowered'), "<a href='http://www.sphinxsearch.com/'>Sphinx</a>") . "</div>");
 654+ $wgOut->addHTML( "<div style='text-align:center'>" .
 655+ wfMsg( 'sphinxPowered', "<a href='http://www.sphinxsearch.com/'>Sphinx</a>" ) .
 656+ "</div>"
 657+ );
592658 }
593659
594 - function getCategoryCheckboxes($all_categories, $parent_id, $cat_parents = array()) {
 660+ function getCategoryCheckboxes( $all_categories, $parent_id, $cat_parents = array() ) {
595661 global $wgUseAjax, $wgRequest, $wgUseExcludes;
596662
597663 $html = '';
598664
599 - foreach( $all_categories as $cat => $name ) {
 665+ foreach ( $all_categories as $cat => $name ) {
600666 $input_attrs = '';
601 - if ($this && in_array($cat, $this->categories)) {
 667+ if ( $this && in_array( $cat, $this->categories ) ) {
602668 $input_attrs .= ' checked="checked"';
603669 }
604670 $name = str_replace( '_', ' ', $name );
605 - if('' == $name) {
606 - $name = wfMsg('blanknamespace');
 671+ if ( '' == $name ) {
 672+ $name = wfMsg( 'blanknamespace' );
607673 }
608674 $children = '';
609 - if (isset($cat_parents['_'.$cat]) && ($input_attrs || $cat_parents['_'.$cat] > 0)) {
 675+ if ( isset( $cat_parents['_' . $cat] ) && ( $input_attrs || $cat_parents['_' . $cat] > 0 ) ) {
610676 $title = Title::newFromID( $cat );
611 - $children_cats = self::getChildrenCategories($title->getDBkey());
612 - if (count($children_cats)) {
613 - if ($this) {
614 - $children = $this->getCategoryCheckboxes($children_cats, $cat, $cat_parents);
 677+ $children_cats = self::getChildrenCategories( $title->getDBkey() );
 678+ if ( count( $children_cats ) ) {
 679+ if ( $this ) {
 680+ $children = $this->getCategoryCheckboxes( $children_cats, $cat, $cat_parents );
615681 } else {
616 - $children = self::getCategoryCheckboxes($children_cats, $cat, $cat_parents);
 682+ $children = self::getCategoryCheckboxes( $children_cats, $cat, $cat_parents );
617683 }
618684 }
619685 }
620 - if ($wgUseAjax) {
 686+ if ( $wgUseAjax ) {
621687 $input_attrs .= " onmouseup='sphinxShowCats(this)'";
622688 }
623689 $html .= "<label><input type='checkbox' id='{$parent_id}_$cat' value='$cat' name='cat[]'$input_attrs />$name</label>";
624 - if ($wgUseExcludes) {
 690+ if ( $wgUseExcludes ) {
625691 $input_attrs = '';
626 - if ($this && in_array($cat, $this->exc_categories)) {
 692+ if ( $this && in_array( $cat, $this->exc_categories ) ) {
627693 $input_attrs .= ' checked="checked"';
628694 }
629 - if ($wgUseAjax) {
 695+ if ( $wgUseAjax ) {
630696 $input_attrs .= " onmouseup='sphinxShowCats(this)'";
631697 }
632698 $html .= "<input type='checkbox' id='exc_{$parent_id}_$cat' value='$cat' name='exc[]'$input_attrs style='float:right' />";
633699 }
634700 $html .= "<div id='cat{$cat}_children'>$children</div>\n";
635701 }
636 - if ($parent_id && $html) {
637 - $html = "<input type='hidden' name='catp[_$parent_id]' value='".intval($cat_parents['_'.$parent_id])."' /><div style='margin-left:10px; margin-bottom:4px; padding-left:8px; border-left:1px dashed #ccc; border-bottom:1px solid #ccc;'>".$html."</div>";
 702+ if ( $parent_id && $html ) {
 703+ $html = "<input type='hidden' name='catp[_$parent_id]' value='" .
 704+ intval( $cat_parents['_' . $parent_id] ) .
 705+ "' /><div style='margin-left:10px; margin-bottom:4px; padding-left:8px; border-left:1px dashed #ccc; border-bottom:1px solid #ccc;'>" .
 706+ $html . "</div>";
638707 }
639708 return $html;
640709 }
@@ -650,9 +719,9 @@
651720 global $wgSphinxSearch_index;
652721
653722 $this->mResultSet = array();
654 - if (is_array($rs) && is_array($rs['matches'])) {
 723+ if ( is_array( $rs ) && is_array( $rs['matches'] ) ) {
655724 $dbr = wfGetDB( DB_SLAVE );
656 - foreach ($rs['matches'] as $id => $docinfo) {
 725+ foreach ( $rs['matches'] as $id => $docinfo ) {
657726 $res = $dbr->select(
658727 'page',
659728 array( 'page_id', 'page_title', 'page_namespace' ),
@@ -660,8 +729,8 @@
661730 __METHOD__,
662731 array()
663732 );
664 - if( $dbr->numRows( $res ) > 0 ) {
665 - $this->mResultSet[] = $dbr->fetchObject($res);
 733+ if ( $dbr->numRows( $res ) > 0 ) {
 734+ $this->mResultSet[] = $dbr->fetchObject( $res );
666735 }
667736 }
668737 }
@@ -678,7 +747,7 @@
679748 }
680749
681750 function next() {
682 - if( isset($this->mResultSet[$this->mNdx]) ) {
 751+ if ( isset( $this->mResultSet[$this->mNdx] ) ) {
683752 $row = $this->mResultSet[$this->mNdx];
684753 ++$this->mNdx;
685754 return new SearchResult( $row );
Index: trunk/extensions/SphinxSearch/SphinxSearch.i18n.php
@@ -3,29 +3,29 @@
44 $messages = array();
55
66 /* *** English *** */
7 -$messages['en'] = array(
 7+$messages['en'] = array(
88 'sphinxsearch' => 'Search wiki using Sphinx',
99 'sphinxsearch-desc' => 'Replaces MediaWiki search engine with [http://www.sphinxsearch.com/ Sphinx]',
1010 'sphinxSearchInNamespaces' => 'Search in namespaces:',
1111 'sphinxSearchInCategories' => 'Search in categories:',
1212 'sphinxExcludeCategories' => 'Categories to exclude',
13 - 'sphinxResultPage' => 'Result page',
 13+ 'sphinxResultPage' => 'Result page:',
1414 'sphinxPreviousPage' => 'Previous',
1515 'sphinxNextPage' => 'Next',
16 - 'sphinxSearchPreamble' => "Displaying %d-%d of %d matches for query '''<nowiki>%s</nowiki>''' retrieved in %0.3f sec with these stats",
17 - 'sphinxSearchStats' => "'''%s''' found %d times in %d documents",
18 - 'sphinxSearchStatsInfo' => 'Above numbers may include documents not listed due to search options',
 16+ 'sphinxSearchPreamble' => 'Displaying $1—$2 of $3 matches for query "<nowiki>$4</nowiki>" retrieved in $5 sec with these stats:',
 17+ 'sphinxSearchStats' => '"$1" found $2 times in $3 documents',
 18+ 'sphinxSearchStatsInfo' => 'Above numbers may include documents not listed due to search options.',
1919 'sphinxSearchButton' => 'Search',
20 - 'sphinxSearchEpilogue' => 'Additional database time was %0.3f sec.',
 20+ 'sphinxSearchEpilogue' => 'Additional database time was $1 sec.',
2121 'sphinxSearchDidYouMean' => 'Did you mean',
2222 'sphinxMatchAny' => 'match any word',
2323 'sphinxMatchAll' => 'match all words',
2424 'sphinxMatchTitles' => 'match titles only',
2525 'sphinxLoading' => 'Loading...',
26 - 'sphinxPowered' => 'Powered by %s',
27 - 'sphinxClientFailed' => 'Could not instantiate SphinxClient',
28 - 'sphinxSearchFailed' => 'Query failed:',
29 - 'sphinxSearchWarning' => 'Warning:'
 26+ 'sphinxPowered' => 'Powered by $1',
 27+ 'sphinxClientFailed' => 'Could not instantiate Sphinx client.',
 28+ 'sphinxSearchFailed' => 'Query failed: $1',
 29+ 'sphinxSearchWarning' => 'Warning: $1'
3030 );
3131
3232 /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца))
@@ -38,23 +38,23 @@
3939 'sphinxSearchInNamespaces' => 'Шукаць у прасторах назваў:',
4040 'sphinxSearchInCategories' => 'Шукаць у катэгорыях:',
4141 'sphinxExcludeCategories' => 'За выключэньнем катэгорыяў',
42 - 'sphinxResultPage' => 'Старонка вынікаў',
 42+ 'sphinxResultPage' => 'Старонка вынікаў:',
4343 'sphinxPreviousPage' => 'Папярэдняя',
4444 'sphinxNextPage' => 'Наступная',
45 - 'sphinxSearchPreamble' => "Паказ супадзеньні %d—%d з %d для запыту '''<nowiki>%s</nowiki>''', пошук склаў %0.3f с улічваючы гэтую статыстыку",
46 - 'sphinxSearchStats' => "'''%s''' знойдзена %d разоў у %d дакумэнтах",
47 - 'sphinxSearchStatsInfo' => 'Прыведзеныя лічбы могуць утрымліваць дакумэнты, не паказаныя з-за установак пошуку',
 45+ 'sphinxSearchPreamble' => 'Паказ супадзеньні $1—$2 з $3 для запыту "<nowiki>$4</nowiki>", пошук склаў $5 с улічваючы гэтую статыстыку',
 46+ 'sphinxSearchStats' => '"$1" знойдзена $2 разоў у $3 дакумэнтах',
 47+ 'sphinxSearchStatsInfo' => 'Прыведзеныя лічбы могуць утрымліваць дакумэнты, не паказаныя з-за установак пошуку.',
4848 'sphinxSearchButton' => 'Шукаць',
49 - 'sphinxSearchEpilogue' => 'Дадатковы час базы зьвестак склаў %0.3f с.',
 49+ 'sphinxSearchEpilogue' => 'Дадатковы час базы зьвестак склаў $1 с.',
5050 'sphinxSearchDidYouMean' => 'Вы мелі на ўвазе',
5151 'sphinxMatchAny' => 'супадзеньне з любым словам',
5252 'sphinxMatchAll' => 'супадзеньне па ўсім словам',
5353 'sphinxMatchTitles' => 'супадзеньне толькі загалоўкаў',
5454 'sphinxLoading' => 'Загрузка…',
55 - 'sphinxPowered' => 'Працуе на %s',
56 - 'sphinxClientFailed' => 'Немагчыма стварыць экзэмпляр SphinxClient',
57 - 'sphinxSearchFailed' => 'Памылка запыту:',
58 - 'sphinxSearchWarning' => 'Папярэджаньне:',
 55+ 'sphinxPowered' => 'Працуе на $1',
 56+ 'sphinxClientFailed' => 'Немагчыма стварыць экзэмпляр SphinxClient.',
 57+ 'sphinxSearchFailed' => 'Памылка запыту: $1',
 58+ 'sphinxSearchWarning' => 'Папярэджаньне: $1',
5959 );
6060
6161 /** Bulgarian (Български) */
@@ -70,19 +70,19 @@
7171 'sphinxsearch' => 'Klask er wiki en ur implijout Sphinx',
7272 'sphinxsearch-desc' => "Erlec'hiañ lusker enklask MediaWiki gant [http://www.sphinxsearch.com/ Sphinx].",
7373 'sphinxSearchInNamespaces' => 'Klask en esaouennoù anv :',
74 - 'sphinxSearchInCategories' => 'Klask er rummadoù',
75 - 'sphinxResultPage' => "Pajenn an disoc'hoù",
 74+ 'sphinxSearchInCategories' => 'Klask er rummadoù :',
 75+ 'sphinxResultPage' => "Pajenn an disoc'hoù :",
7676 'sphinxPreviousPage' => 'Kent',
7777 'sphinxNextPage' => "War-lerc'h",
78 - 'sphinxSearchStats' => "'''%s''' bet kavet %d gwech e %d teul",
 78+ 'sphinxSearchStats' => '"$1" bet kavet $2 gwech e $3 teul',
7979 'sphinxSearchButton' => 'Klask',
8080 'sphinxSearchDidYouMean' => "N'hoc'h eus ket soñjet kentoc'h e",
8181 'sphinxMatchAny' => 'kavout forzh peseurt ger',
8282 'sphinxMatchAll' => 'kavout an holl gerioù',
8383 'sphinxMatchTitles' => 'klask en titloù hepken',
8484 'sphinxLoading' => 'O kargañ...',
85 - 'sphinxPowered' => 'Savet diwar %s',
86 - 'sphinxSearchWarning' => 'Diwallit :',
 85+ 'sphinxPowered' => 'Savet diwar $1',
 86+ 'sphinxSearchWarning' => 'Diwallit : $1',
8787 );
8888
8989 /** Spanish (Español)
@@ -97,20 +97,20 @@
9898 'sphinxResultPage' => 'Página de resultados',
9999 'sphinxPreviousPage' => 'Anterior',
100100 'sphinxNextPage' => 'Siguiente',
101 - 'sphinxSearchPreamble' => "Mostrando %d-%d de %d coincidencias para la búsqueda de '''<nowiki>%s</nowiki>''', recuperado en %0.3f segundo(s) incluyendo estas estadísticas",
102 - 'sphinxSearchStats' => "'''%s''' fue encontrado %d veces en %d documentos",
103 - 'sphinxSearchStatsInfo' => 'Los números mostrados arriba pueden incluir documentos no listados debido a las opciones de búsqueda',
 101+ 'sphinxSearchPreamble' => 'Mostrando $1—$2 de $3 coincidencias para la búsqueda de "<nowiki>$4</nowiki>", recuperado en $5 segundo(s) incluyendo estas estadísticas',
 102+ 'sphinxSearchStats' => '"$1" fue encontrado $2 veces en $3 documentos',
 103+ 'sphinxSearchStatsInfo' => 'Los números mostrados arriba pueden incluir documentos no listados debido a las opciones de búsqueda.',
104104 'sphinxSearchButton' => 'Buscar',
105 - 'sphinxSearchEpilogue' => 'El tiempo de base de datos adicional fue de %0.3f segundos.',
 105+ 'sphinxSearchEpilogue' => 'El tiempo de base de datos adicional fue de $1 segundos.',
106106 'sphinxSearchDidYouMean' => 'Quizás quiso decir',
107107 'sphinxMatchAny' => 'coincidencia de cualquier palabra',
108108 'sphinxMatchAll' => 'coincidencia de todas las palabras',
109109 'sphinxMatchTitles' => 'coincidencia únicamente en los títulos',
110110 'sphinxLoading' => 'Cargando',
111 - 'sphinxPowered' => 'Potenciado por %s',
112 - 'sphinxClientFailed' => 'No se pudo instanciar el cliente Sphinx',
113 - 'sphinxSearchFailed' => 'Falló la búsqueda',
114 - 'sphinxSearchWarning' => 'ADVERTENCIA',
 111+ 'sphinxPowered' => 'Potenciado por $1',
 112+ 'sphinxClientFailed' => 'No se pudo instanciar el cliente Sphinx.',
 113+ 'sphinxSearchFailed' => 'Falló la búsqueda $1',
 114+ 'sphinxSearchWarning' => 'Advertencia $1',
115115 );
116116
117117 /** French (Français)
@@ -125,20 +125,20 @@
126126 'sphinxResultPage' => 'Page de résultats',
127127 'sphinxPreviousPage' => 'Précédent',
128128 'sphinxNextPage' => 'Suivant',
129 - 'sphinxSearchPreamble' => "Affichage des résultats %d-%d sur %d pour la requête '''<nowiki>%s</nowiki>''' accomplie en %0.3f secondes avec ces statistiques",
130 - 'sphinxSearchStats' => "'''%s''' trouvé %d fois dans %d documents",
131 - 'sphinxSearchStatsInfo' => 'Les valeurs ci-dessus peuvent inclure des documents masqués par les options de recherche',
 129+ 'sphinxSearchPreamble' => 'Affichage des résultats $1—$2 sur $3 pour la requête "<nowiki>$4</nowiki>" accomplie en $5 secondes avec ces statistiques',
 130+ 'sphinxSearchStats' => '"$1" trouvé $2 fois dans $3 documents',
 131+ 'sphinxSearchStatsInfo' => 'Les valeurs ci-dessus peuvent inclure des documents masqués par les options de recherche.',
132132 'sphinxSearchButton' => 'Rechercher',
133 - 'sphinxSearchEpilogue' => 'Le temps additionnel de la base de données était de %0.3f sec.',
 133+ 'sphinxSearchEpilogue' => 'Le temps additionnel de la base de données était de $1 sec.',
134134 'sphinxSearchDidYouMean' => 'Vouliez-vous dire',
135135 'sphinxMatchAny' => "trouver n'importe quel mot",
136136 'sphinxMatchAll' => 'trouver tous les mots',
137137 'sphinxMatchTitles' => 'ne chercher que dans les titres',
138138 'sphinxLoading' => 'Chargement …',
139 - 'sphinxPowered' => 'Propulsé par %s',
140 - 'sphinxClientFailed' => "Impossible d'instancier SphinxClient",
141 - 'sphinxSearchFailed' => 'Échec de la requête',
142 - 'sphinxSearchWarning' => 'AVERTISSEMENT',
 139+ 'sphinxPowered' => 'Propulsé par $1',
 140+ 'sphinxClientFailed' => "Impossible d'instancier SphinxClient.",
 141+ 'sphinxSearchFailed' => 'Échec de la requête $1',
 142+ 'sphinxSearchWarning' => 'Avertissement $1',
143143 );
144144
145145 /** Galician (Galego)
@@ -153,48 +153,49 @@
154154 'sphinxResultPage' => 'Páxina de resultados',
155155 'sphinxPreviousPage' => 'Anterior',
156156 'sphinxNextPage' => 'Seguinte',
157 - 'sphinxSearchPreamble' => "Mostrando %d-%d coincidencias dun total de %d que deu a pescuda \"'''<nowiki>%s</nowiki>'''\", obtidas en %0.3f segundos coas estatísticas",
158 - 'sphinxSearchStats' => "\"'''%s'''\" atopouse %d veces en %d documentos",
159 - 'sphinxSearchStatsInfo' => 'Os números superiores poden incluír documentos non listados debido ás opcións de procura',
 157+ 'sphinxSearchPreamble' => 'Mostrando $1—$2 coincidencias dun total de $3 que deu a pescuda "<nowiki>$4</nowiki>", obtidas en $5 segundos coas estatísticas',
 158+ 'sphinxSearchStats' => '"$1" atopouse $2 veces en $3 documentos',
 159+ 'sphinxSearchStatsInfo' => 'Os números superiores poden incluír documentos non listados debido ás opcións de procura.',
160160 'sphinxSearchButton' => 'Procurar',
161 - 'sphinxSearchEpilogue' => 'O tempo adicional da base de datos foi de %0.3f segundos.',
 161+ 'sphinxSearchEpilogue' => 'O tempo adicional da base de datos foi de $1 segundos.',
162162 'sphinxSearchDidYouMean' => 'Quizais quixo dicir',
163163 'sphinxMatchAny' => 'atopar calquera palabra',
164164 'sphinxMatchAll' => 'atopar todas as palabras',
165165 'sphinxMatchTitles' => 'atopar só nos títulos',
166166 'sphinxLoading' => 'Cargando...',
167 - 'sphinxPowered' => 'Desenvolvido por %s',
168 - 'sphinxClientFailed' => 'Non se puido conectar co SphinxClient',
169 - 'sphinxSearchFailed' => 'Fallou a pescuda',
170 - 'sphinxSearchWarning' => 'AVISO',
 167+ 'sphinxPowered' => 'Desenvolvido por $1',
 168+ 'sphinxClientFailed' => 'Non se puido conectar co SphinxClient.',
 169+ 'sphinxSearchFailed' => 'Fallou a pescuda $1',
 170+ 'sphinxSearchWarning' => 'Aviso $1',
171171 );
172172
173173 /** Swiss German (Alemannisch)
174174 * @author Als-Holder
175175 */
176176 $messages['gsw'] = array(
 177+
177178 'sphinxsearch' => 'Wiki dursueche mit Sphinx',
178179 'sphinxsearch-desc' => 'Ersetzt d MediaWiki-Suechmahscin dur [http://www.sphinxsearch.com/ Sphinx]',
179180 'sphinxSearchInNamespaces' => 'Suech in Namensryym:',
180181 'sphinxSearchInCategories' => 'In Kategorie sueche:',
181182 'sphinxExcludeCategories' => 'Kategorie, wu solle uusgschlosse syy',
182 - 'sphinxResultPage' => 'Ergebnissyte',
 183+ 'sphinxResultPage' => 'Ergebnissyte:',
183184 'sphinxPreviousPage' => 'Vorigi',
184185 'sphinxNextPage' => 'Negschti',
185 - 'sphinxSearchPreamble' => "%d-%d vu %d Ergebnis fir d Abfrog '''<nowiki>%s</nowiki>'''. Suechzyt: %0.3f Sekunde",
186 - 'sphinxSearchStats' => "'''%s''' %d mol gfunde in %d Dokumänt",
 186+ 'sphinxSearchPreamble' => '$1—$2 vu $3 Ergebnis fir d Abfrog "<nowiki>$4</nowiki>". Suechzyt: $5 Sekunde',
 187+ 'sphinxSearchStats' => '"$1" $2 mol gfunde in $3 Dokumänt',
187188 'sphinxSearchStatsInfo' => 'In däre Zahl wäre villicht Dokumänt mitzellt, wu wäge bstimmte Suechyystellige nit ufglischtet wäre',
188189 'sphinxSearchButton' => 'Sueche',
189 - 'sphinxSearchEpilogue' => 'Zuesätzligi Datebankzyt isch %0.3f Sekunde gsi.',
 190+ 'sphinxSearchEpilogue' => 'Zuesätzligi Datebankzyt isch $1 Sekunde gsi.',
190191 'sphinxSearchDidYouMean' => 'Hesch gmeint',
191192 'sphinxMatchAny' => 'irged e Wort',
192193 'sphinxMatchAll' => 'alli Werter',
193194 'sphinxMatchTitles' => 'nume Sytename',
194195 'sphinxLoading' => 'Am Lade …',
195 - 'sphinxPowered' => 'Betribe mit %s',
 196+ 'sphinxPowered' => 'Betribe mit $1',
196197 'sphinxClientFailed' => 'Het dr SphinxClient nit chenne inizialisiere',
197 - 'sphinxSearchFailed' => 'Abfrog fähl gschlaa:',
198 - 'sphinxSearchWarning' => 'Warnig:',
 198+ 'sphinxSearchFailed' => 'Abfrog fähl gschlaa: $1',
 199+ 'sphinxSearchWarning' => 'Warnig: $1',
199200 );
200201
201202 /** Interlingua (Interlingua)
@@ -206,23 +207,23 @@
207208 'sphinxSearchInNamespaces' => 'Cercar in spatios de nomines',
208209 'sphinxSearchInCategories' => 'Cercar in categorias:',
209210 'sphinxExcludeCategories' => 'Categorias a excluder',
210 - 'sphinxResultPage' => 'Pagina de resultatos',
 211+ 'sphinxResultPage' => 'Pagina de resultatos:',
211212 'sphinxPreviousPage' => 'Precedente',
212213 'sphinxNextPage' => 'Sequente',
213 - 'sphinxSearchPreamble' => "Resultatos %d-%d de %d pro le recerca de '''<nowiki>%s</nowiki>''' recuperate in %0.3f secundas con iste statisticas",
214 - 'sphinxSearchStats' => "'''%s''' trovate %d vices in %d documentos",
215 - 'sphinxSearchStatsInfo' => 'Le numeros hic supra pote includer documentos non listate debite al optiones de recerca',
 214+ 'sphinxSearchPreamble' => 'Resultatos $1—$2 de $3 pro le recerca de "<nowiki>$4</nowiki>" recuperate in $5 secundas con iste statisticas',
 215+ 'sphinxSearchStats' => '"$1" trovate $2 vices in $3 documentos',
 216+ 'sphinxSearchStatsInfo' => 'Le numeros hic supra pote includer documentos non listate debite al optiones de recerca.',
216217 'sphinxSearchButton' => 'Cercar',
217 - 'sphinxSearchEpilogue' => 'Le tempore additional del base de datos esseva %0.3f secundas.',
 218+ 'sphinxSearchEpilogue' => 'Le tempore additional del base de datos esseva $1 secundas.',
218219 'sphinxSearchDidYouMean' => 'Esque tu vole dicer',
219220 'sphinxMatchAny' => 'trovar qualcunque parola',
220221 'sphinxMatchAll' => 'trovar tote le parolas',
221222 'sphinxMatchTitles' => 'cercar solmente in titulos',
222223 'sphinxLoading' => 'Cargamento…',
223 - 'sphinxPowered' => 'Actionate per %s',
224 - 'sphinxClientFailed' => 'Non poteva instantiar SphinxClient',
225 - 'sphinxSearchFailed' => 'Consulta fallite:',
226 - 'sphinxSearchWarning' => 'Advertimento:',
 224+ 'sphinxPowered' => 'Actionate per $1',
 225+ 'sphinxClientFailed' => 'Non poteva instantiar SphinxClient.',
 226+ 'sphinxSearchFailed' => 'Consulta fallite: $1',
 227+ 'sphinxSearchWarning' => 'Advertimento: $1',
227228 );
228229
229230 /** Japanese (日本語)
@@ -231,14 +232,14 @@
232233 $messages['ja'] = array(
233234 'sphinxSearchInNamespaces' => '名前空間で検索:',
234235 'sphinxSearchInCategories' => 'カテゴリで検索:',
235 - 'sphinxResultPage' => '結果ページ',
 236+ 'sphinxResultPage' => '結果ページ:',
236237 'sphinxPreviousPage' => '前',
237238 'sphinxNextPage' => '次',
238 - 'sphinxSearchStats' => "'''%s'''が、%dの文書で、\$dコ見つかりました",
 239+ 'sphinxSearchStats' => '"$1"が、$2の文書で、$3コ見つかりました',
239240 'sphinxSearchButton' => '検索',
240241 'sphinxSearchDidYouMean' => 'もしかして',
241 - 'sphinxPowered' => '%sの提供',
242 - 'sphinxSearchWarning' => '警告:',
 242+ 'sphinxPowered' => '$1の提供',
 243+ 'sphinxSearchWarning' => '警告: $1',
243244 );
244245
245246 /** Luxembourgish (Lëtzebuergesch)
@@ -249,23 +250,23 @@
250251 'sphinxSearchInNamespaces' => 'Sich an den Nummraim:',
251252 'sphinxSearchInCategories' => 'Sichen an de Kategorien:',
252253 'sphinxExcludeCategories' => 'Kategorien fir auszeschléissen',
253 - 'sphinxResultPage' => 'Säit mat de Resultater',
 254+ 'sphinxResultPage' => 'Säit mat de Resultater:',
254255 'sphinxPreviousPage' => 'Vireg',
255256 'sphinxNextPage' => 'Nächst',
256 - 'sphinxSearchStats' => "'''%s''' gouf %d mol an %d Dokumenter fonnt",
 257+ 'sphinxSearchStats' => '"$1" gouf $2 mol an $3 Dokumenter fonnt',
257258 'sphinxSearchButton' => 'Sichen',
258259 'sphinxSearchDidYouMean' => 'Mengt Dir',
259260 'sphinxMatchTitles' => 'nëmmen an den Titele sichen',
260261 'sphinxLoading' => 'Lueden...',
261 - 'sphinxSearchFailed' => 'Ufro huet net fonctionnéiert:',
262 - 'sphinxSearchWarning' => 'Warnung:',
 262+ 'sphinxSearchFailed' => 'Ufro huet net fonctionnéiert: $1',
 263+ 'sphinxSearchWarning' => 'Warnung: $1',
263264 );
264265
265266 /** Macedonian (Македонски)
266267 * @author Bjankuloski06
267268 */
268269 $messages['mk'] = array(
269 - 'sphinxsearch' => 'Пребоарување по вики со Sphinx',
 270+ 'sphinxsearch' => 'Пребарување по вики со Sphinx',
270271 'sphinxsearch-desc' => 'Замена на МедијаВики пребарувачот со [http://www.sphinxsearch.com/ Sphinx].',
271272 'sphinxSearchInNamespaces' => 'Барај во именски простори',
272273 'sphinxSearchInCategories' => 'Барај во категории',
@@ -273,20 +274,20 @@
274275 'sphinxResultPage' => 'Страница за резулати',
275276 'sphinxPreviousPage' => 'Претходна',
276277 'sphinxNextPage' => 'Следна',
277 - 'sphinxSearchPreamble' => "Приказ на %d-%d од вкупно %d совпаѓања за барањето '''<nowiki>%s</nowiki>''' извршено за %0.3f сек. со следниве статистики",
278 - 'sphinxSearchStats' => "'''%s''' е пронајдено %d пати во %d документи",
279 - 'sphinxSearchStatsInfo' => 'Горенаведените бројки може да содржат документи кои не се наведени поради нагодувањата на пребарувањето',
 278+ 'sphinxSearchPreamble' => 'Приказ на $1—$2 од вкупно $3 совпаѓања за барањето "<nowiki>$4</nowiki>" извршено за $5 сек. со следниве статистики',
 279+ 'sphinxSearchStats' => '"$1" е пронајдено $2 пати во $3 документи',
 280+ 'sphinxSearchStatsInfo' => 'Горенаведените бројки може да содржат документи кои не се наведени поради нагодувањата на пребарувањето.',
280281 'sphinxSearchButton' => 'Пребарај',
281 - 'sphinxSearchEpilogue' => 'Дополнителното време за базата на податоци изнесуваше %0.3f сек.',
 282+ 'sphinxSearchEpilogue' => 'Дополнителното време за базата на податоци изнесуваше $1 сек.',
282283 'sphinxSearchDidYouMean' => 'Дали мислевте на',
283284 'sphinxMatchAny' => 'барај било кој збор',
284285 'sphinxMatchAll' => 'барај само зборови',
285286 'sphinxMatchTitles' => 'барај само наслови',
286287 'sphinxLoading' => 'Вчитувам...',
287 - 'sphinxPowered' => 'Овозможено од %s',
288 - 'sphinxClientFailed' => 'Не можев да го повикам SphinxClient',
289 - 'sphinxSearchFailed' => 'Барањето не успеа',
290 - 'sphinxSearchWarning' => 'ПРЕДУПРЕДУВАЊЕ',
 288+ 'sphinxPowered' => 'Овозможено од $1',
 289+ 'sphinxClientFailed' => 'Не можев да го повикам Sphinx клиент.',
 290+ 'sphinxSearchFailed' => 'Барањето не успеа $1',
 291+ 'sphinxSearchWarning' => 'Предупредување $1',
291292 );
292293
293294 /** Dutch (Nederlands)
@@ -298,21 +299,21 @@
299300 'sphinxSearchInNamespaces' => 'Zoeken in naamruimten:',
300301 'sphinxSearchInCategories' => 'Zoeken in categorieën:',
301302 'sphinxExcludeCategories' => 'Uit te sluiten categorieën',
302 - 'sphinxResultPage' => 'Resultatenpagina',
 303+ 'sphinxResultPage' => 'Resultatenpagina:',
303304 'sphinxPreviousPage' => 'Vorige',
304305 'sphinxNextPage' => 'Volgende',
305 - 'sphinxSearchPreamble' => "Resultaten %1\$d tot %2\$d van %3\$d worden weergegeven voor zoekopdracht '''<nowiki>%s</nowiki>'''. Zoektijd: %0.3f seconden",
 306+ 'sphinxSearchPreamble' => 'Resultaten $1 tot $2 van $3 worden weergegeven voor zoekopdracht "<nowiki>$4</nowiki>". Zoektijd: $5 seconden',
306307 'sphinxSearchButton' => 'Zoeken',
307 - 'sphinxSearchEpilogue' => 'Aanvullende databasetijd was %0.3f seconden.',
 308+ 'sphinxSearchEpilogue' => 'Aanvullende databasetijd was $1 seconden.',
308309 'sphinxSearchDidYouMean' => 'Bedoelde u',
309310 'sphinxMatchAny' => 'ieder woord',
310311 'sphinxMatchAll' => 'alle woorden',
311312 'sphinxMatchTitles' => 'alleen paginanamen',
312313 'sphinxLoading' => 'Bezig met laden...',
313 - 'sphinxPowered' => 'Powered by %s',
 314+ 'sphinxPowered' => 'Powered by $1',
314315 'sphinxClientFailed' => 'Het was niet mogelijk SphinxClient te initialiseren',
315 - 'sphinxSearchFailed' => 'Zoekopdracht mislukt',
316 - 'sphinxSearchWarning' => 'Waarschuwing',
 316+ 'sphinxSearchFailed' => 'Zoekopdracht mislukt $1',
 317+ 'sphinxSearchWarning' => 'Waarschuwing $1',
317318 );
318319
319320 /** Norwegian (bokmål)‬ (‪Norsk (bokmål)‬)
@@ -327,20 +328,20 @@
328329 'sphinxResultPage' => 'Resultatside',
329330 'sphinxPreviousPage' => 'Forrige',
330331 'sphinxNextPage' => 'Neste',
331 - 'sphinxSearchPreamble' => "Viser %d-%d av &d treff på søket '''<nowiki>%s</nowiki>''' hentet på %0.3f sek med disse statistikkene",
332 - 'sphinxSearchStats' => "'''%s''' funnet %d ganger i %d dokument",
333 - 'sphinxSearchStatsInfo' => 'Tallene over kan inneholder dokumenter som ikke er oppført på grunn av søkealternativene',
 332+ 'sphinxSearchPreamble' => 'Viser $1—$2 av $3 treff på søket "<nowiki>$4</nowiki>" hentet på $5 sek med disse statistikkene',
 333+ 'sphinxSearchStats' => '"$1" funnet $2 ganger i $3 dokument',
 334+ 'sphinxSearchStatsInfo' => 'Tallene over kan inneholder dokumenter som ikke er oppført på grunn av søkealternativene.',
334335 'sphinxSearchButton' => 'Søk',
335 - 'sphinxSearchEpilogue' => 'Ytterligere databasetid var %0.3f sek.',
 336+ 'sphinxSearchEpilogue' => 'Ytterligere databasetid var $1 sek.',
336337 'sphinxSearchDidYouMean' => 'Mente du',
337338 'sphinxMatchAny' => 'treff hvilket som helst av ordene',
338339 'sphinxMatchAll' => 'treff alle ordene',
339340 'sphinxMatchTitles' => 'treff kun titler',
340341 'sphinxLoading' => 'Laster...',
341 - 'sphinxPowered' => 'Drevet av %s',
 342+ 'sphinxPowered' => 'Drevet av $1',
342343 'sphinxClientFailed' => 'Kunne ikke instansiere SphinxClient',
343 - 'sphinxSearchFailed' => 'Søk feilet',
344 - 'sphinxSearchWarning' => 'ADVARSEL',
 344+ 'sphinxSearchFailed' => 'Søk feilet $1',
 345+ 'sphinxSearchWarning' => 'Advarsel $1',
345346 );
346347
347348 /** Piedmontese (Piemontèis)
@@ -352,23 +353,23 @@
353354 'sphinxSearchInNamespaces' => 'Sërché ant jë spassi nominaj:',
354355 'sphinxSearchInCategories' => 'Sërché ant le categorìe:',
355356 'sphinxExcludeCategories' => 'Categorìe da esclude',
356 - 'sphinxResultPage' => "Pàgina d'arzultà",
 357+ 'sphinxResultPage' => "Pàgina d'arzultà:",
357358 'sphinxPreviousPage' => 'Prima',
358359 'sphinxNextPage' => 'Apress',
359 - 'sphinxSearchPreamble' => "Visualisé %d-%d ëd %d arzultà për query '''<nowiki>%s</nowiki>''' trovà an %0.3f sec con coste statìstiche",
360 - 'sphinxSearchStats' => "'''%s''' trovà %d vire an %d document",
 360+ 'sphinxSearchPreamble' => 'Visualisé $1—$2 ëd $3 arzultà për query "<nowiki>$4</nowiki>" trovà an $5 sec con coste statìstiche',
 361+ 'sphinxSearchStats' => '"$1" trovà $2 vire an $3 document',
361362 'sphinxSearchStatsInfo' => "Ij nùmer sota a peulo anclude document pa listà a motiv dj'opsion d'arserca",
362363 'sphinxSearchButton' => 'Sërca',
363 - 'sphinxSearchEpilogue' => "Temp adissional ëd database a l'é stàit %0.3f sec.",
 364+ 'sphinxSearchEpilogue' => "Temp adissional ëd database a l'é stàit \$1 sec.",
364365 'sphinxSearchDidYouMean' => 'Vorìi-lo pa dì',
365366 'sphinxMatchAny' => 'confronta minca paròla',
366367 'sphinxMatchAll' => 'confranta tute paròle',
367368 'sphinxMatchTitles' => 'confronta mach ij tìtoj',
368369 'sphinxLoading' => 'A caria ...',
369 - 'sphinxPowered' => 'Potensià da %s',
 370+ 'sphinxPowered' => 'Potensià da $1',
370371 'sphinxClientFailed' => 'As peul pa istansié SphinxClient',
371 - 'sphinxSearchFailed' => 'Query falìa:',
372 - 'sphinxSearchWarning' => 'Avis:',
 372+ 'sphinxSearchFailed' => 'Query falìa: $1',
 373+ 'sphinxSearchWarning' => 'Avis: $1',
373374 );
374375
375376 /** Portuguese (Português)
@@ -383,20 +384,20 @@
384385 'sphinxResultPage' => 'Página de resultados',
385386 'sphinxPreviousPage' => 'Anterior',
386387 'sphinxNextPage' => 'Seguinte',
387 - 'sphinxSearchPreamble' => "A mostrar %d-%d de %d resultados para a pesquisa'''<nowiki>%s</nowiki>''' obtidos em %0.3f seg., incluindo estas estatísticas",
388 - 'sphinxSearchStats' => "'''%s''' aparece %d vezes em %d documentos",
389 - 'sphinxSearchStatsInfo' => 'Os números acima podem incluir documentos que não são listados devido às opções de pesquisa',
 388+ 'sphinxSearchPreamble' => 'A mostrar $1—$2 de $3 resultados para a pesquisa"<nowiki>$4</nowiki>" obtidos em $5 seg., incluindo estas estatísticas',
 389+ 'sphinxSearchStats' => '"$1" aparece $2 vezes em $3 documentos',
 390+ 'sphinxSearchStatsInfo' => 'Os números acima podem incluir documentos que não são listados devido às opções de pesquisa.',
390391 'sphinxSearchButton' => 'Pesquisar',
391 - 'sphinxSearchEpilogue' => 'O tempo adicional da base de dados foi %0.3f seg.',
 392+ 'sphinxSearchEpilogue' => 'O tempo adicional da base de dados foi $1 seg.',
392393 'sphinxSearchDidYouMean' => 'Talvez pretendesse',
393394 'sphinxMatchAny' => 'localizar qualquer palavra',
394395 'sphinxMatchAll' => 'localizar todas as palavras',
395396 'sphinxMatchTitles' => 'localizar somente nos títulos',
396397 'sphinxLoading' => 'A carregar...',
397 - 'sphinxPowered' => 'Powered by %s',
398 - 'sphinxClientFailed' => 'Não foi possível instanciar o cliente Sphinx',
399 - 'sphinxSearchFailed' => 'Pesquisa falhou',
400 - 'sphinxSearchWarning' => 'AVISO',
 398+ 'sphinxPowered' => 'Powered by $1',
 399+ 'sphinxClientFailed' => 'Não foi possível instanciar o cliente Sphinx.',
 400+ 'sphinxSearchFailed' => 'Pesquisa falhou $1',
 401+ 'sphinxSearchWarning' => 'Aviso $1',
401402 );
402403
403404 /** Russian (Русский)
@@ -411,19 +412,18 @@
412413 'sphinxResultPage' => 'Страница результатов',
413414 'sphinxPreviousPage' => 'Предыдущая',
414415 'sphinxNextPage' => 'Следующая',
415 - 'sphinxSearchPreamble' => "Отображение %d—%d результатов из %d для запроса '''<nowiki>%s</nowiki>''', поиска занял %0.3f с",
416 - 'sphinxSearchStats' => "'''%s''' найдено %d раз в %d документах",
417 - 'sphinxSearchStatsInfo' => 'Приведённые цифры могут включать в себя документы, не показанные из-за настроек поиска',
 416+ 'sphinxSearchPreamble' => 'Отображение $1—$2 результатов из $3 для запроса "<nowiki>$4</nowiki>", поиска занял $5 с',
 417+ 'sphinxSearchStats' => '"$1" найдено $2 раз в $3 документах',
 418+ 'sphinxSearchStatsInfo' => 'Приведённые цифры могут включать в себя документы, не показанные из-за настроек поиска.',
418419 'sphinxSearchButton' => 'Найти',
419 - 'sphinxSearchEpilogue' => 'Дополнительное время базы данных составило %0.3f с.',
 420+ 'sphinxSearchEpilogue' => 'Дополнительное время базы данных составило $1 с.',
420421 'sphinxSearchDidYouMean' => 'Возможно, вы имели в виду',
421422 'sphinxMatchAny' => 'соответствие любому слову',
422423 'sphinxMatchAll' => 'соответствие всем словам',
423424 'sphinxMatchTitles' => 'соответствие только заголовкам',
424425 'sphinxLoading' => 'Загрузка…',
425 - 'sphinxPowered' => 'При поддержке %s',
426 - 'sphinxClientFailed' => 'Невозможно создать экземпляр SphinxClient',
427 - 'sphinxSearchFailed' => 'Ошибка при выполнении запроса',
428 - 'sphinxSearchWarning' => 'ПРЕДУПРЕЖДЕНИЕ',
 426+ 'sphinxPowered' => 'При поддержке $1',
 427+ 'sphinxClientFailed' => 'Невозможно создать экземпляр SphinxClient.',
 428+ 'sphinxSearchFailed' => 'Ошибка при выполнении запроса $1',
 429+ 'sphinxSearchWarning' => 'Предупреждение $1',
429430 );
430 -
Index: trunk/extensions/SphinxSearch/SphinxSearch_spell.php
@@ -7,15 +7,15 @@
88 var $suggestion_needed; // is the suggestion needed
99 var $suggestion; // the actual suggestion
1010
11 - function spell ($string) {
12 - $this->string = str_replace('"', '', $string);
13 - $this->words = preg_split('/(\s+|\|)/', $this->string, -1, PREG_SPLIT_NO_EMPTY);
14 - if (function_exists('pspell_check')) {
 11+ function spell ( $string ) {
 12+ $this->string = str_replace( '"', '', $string );
 13+ $this->words = preg_split( '/(\s+|\|)/', $this->string, - 1, PREG_SPLIT_NO_EMPTY );
 14+ if ( function_exists( 'pspell_check' ) ) {
1515 $this->suggestion = $this->builtin_spell();
1616 } else {
1717 $this->suggestion = $this->nonnative_spell();
1818 }
19 - if ($this->suggestion_needed)
 19+ if ( $this->suggestion_needed )
2020 return $this->suggestion;
2121 else
2222 return '';
@@ -26,41 +26,41 @@
2727
2828 $ret = '';
2929 $this->suggestion_needed = false;
30 - foreach ($this->words as $word) {
 30+ foreach ( $this->words as $word ) {
3131 $pspell_config = pspell_config_create(
32 - $wgUser->getDefaultOption('language'),
33 - $wgUser->getDefaultOption('variant'));
34 - if ($wgSphinxSearchPspellDictionaryDir) {
35 - pspell_config_data_dir($pspell_config, $wgSphinxSearchPspellDictionaryDir);
36 - pspell_config_dict_dir($pspell_config, $wgSphinxSearchPspellDictionaryDir);
 32+ $wgUser->getDefaultOption( 'language' ),
 33+ $wgUser->getDefaultOption( 'variant' ) );
 34+ if ( $wgSphinxSearchPspellDictionaryDir ) {
 35+ pspell_config_data_dir( $pspell_config, $wgSphinxSearchPspellDictionaryDir );
 36+ pspell_config_dict_dir( $pspell_config, $wgSphinxSearchPspellDictionaryDir );
3737 }
38 - pspell_config_mode($pspell_config, PSPELL_FAST|PSPELL_RUN_TOGETHER);
39 - if ($wgSphinxSearchPersonalDictionary)
40 - pspell_config_personal($pspell_config, $wgSphinxSearchPersonalDictionary);
41 - $pspell_link = pspell_new_config($pspell_config);
 38+ pspell_config_mode( $pspell_config, PSPELL_FAST | PSPELL_RUN_TOGETHER );
 39+ if ( $wgSphinxSearchPersonalDictionary )
 40+ pspell_config_personal( $pspell_config, $wgSphinxSearchPersonalDictionary );
 41+ $pspell_link = pspell_new_config( $pspell_config );
4242
43 - if (!$pspell_link)
 43+ if ( !$pspell_link )
4444 return "Error starting pspell personal dictionary\n";
4545
46 - if (!pspell_check($pspell_link, $word)) {
47 - $suggestions = pspell_suggest($pspell_link, $word);
48 - $guess = $this->bestguess($word, $suggestions);
49 - if (strtolower($word) == strtolower($guess)) {
 46+ if ( !pspell_check( $pspell_link, $word ) ) {
 47+ $suggestions = pspell_suggest( $pspell_link, $word );
 48+ $guess = $this->bestguess( $word, $suggestions );
 49+ if ( strtolower( $word ) == strtolower( $guess ) ) {
5050 $ret .= "$word ";
5151 } else {
5252 $ret .= "$guess ";
5353 $this->suggestion_needed = true;
5454 }
55 - unset($suggestion);
56 - unset($guess);
 55+ unset( $suggestion );
 56+ unset( $guess );
5757 } else {
5858 $ret .= "$word ";
5959 }
6060 }
6161
62 - unset($pspell_config);
63 - unset($pspell_link);
64 - return trim($ret);
 62+ unset( $pspell_config );
 63+ unset( $pspell_link );
 64+ return trim( $ret );
6565
6666 }
6767
@@ -69,46 +69,46 @@
7070
7171 // aspell will only return mis-spelled words, so remember all here
7272 $word_suggestions = array();
73 - foreach ($this->words as $word) {
 73+ foreach ( $this->words as $word ) {
7474 $word_suggestions[$word] = $word;
7575 }
7676
7777 // prepare the system call with optional dictionary
78 - $aspellcommand = 'echo ' . escapeshellarg($this->string) .
79 - ' | ' . escapeshellarg($wgSphinxSearchAspellPath) .
 78+ $aspellcommand = 'echo ' . escapeshellarg( $this->string ) .
 79+ ' | ' . escapeshellarg( $wgSphinxSearchAspellPath ) .
8080 ' -a --ignore-accents --ignore-case';
81 - if ($wgUser) {
82 - $aspellcommand .= ' --lang='.$wgUser->getDefaultOption('language');
 81+ if ( $wgUser ) {
 82+ $aspellcommand .= ' --lang=' . $wgUser->getDefaultOption( 'language' );
8383 }
84 - if ($wgSphinxSearchPersonalDictionary) {
85 - $aspellcommand .= ' --home-dir='.dirname($wgSphinxSearchPersonalDictionary);
86 - $aspellcommand .= ' -p '.basename($wgSphinxSearchPersonalDictionary);
 84+ if ( $wgSphinxSearchPersonalDictionary ) {
 85+ $aspellcommand .= ' --home-dir=' . dirname( $wgSphinxSearchPersonalDictionary );
 86+ $aspellcommand .= ' -p ' . basename( $wgSphinxSearchPersonalDictionary );
8787 }
8888
8989 // run aspell
90 - $shell_return = shell_exec($aspellcommand);
 90+ $shell_return = shell_exec( $aspellcommand );
9191
9292 // parse return line by line
93 - $returnarray = explode("\n", $shell_return);
 93+ $returnarray = explode( "\n", $shell_return );
9494 $this->suggestion_needed = false;
95 - foreach($returnarray as $key=>$value) {
 95+ foreach ( $returnarray as $key => $value ) {
9696 // lines with suggestions start with &
97 - if (substr($value, 0, 1) == "&") {
98 - $correction = explode(" ",$value);
 97+ if ( substr( $value, 0, 1 ) == "&" ) {
 98+ $correction = explode( " ", $value );
9999 $word = $correction[1];
100 - $suggstart = strpos($value, ":") + 2;
101 - $suggestions = substr($value, $suggstart);
102 - $suggestionarray = explode(", ", $suggestions);
103 - $guess = $this->bestguess($word, $suggestionarray);
 100+ $suggstart = strpos( $value, ":" ) + 2;
 101+ $suggestions = substr( $value, $suggstart );
 102+ $suggestionarray = explode( ", ", $suggestions );
 103+ $guess = $this->bestguess( $word, $suggestionarray );
104104
105 - if (strtolower($word) != strtolower($guess)) {
 105+ if ( strtolower( $word ) != strtolower( $guess ) ) {
106106 $word_suggestions[$word] = $guess;
107107 $this->suggestion_needed = true;
108108 }
109109 }
110110 }
111111
112 - return join(' ', $word_suggestions);
 112+ return join( ' ', $word_suggestions );
113113 }
114114
115115 /* This function takes a word, and an array of suggested words
@@ -116,15 +116,15 @@
117117 * the word. Thif is made possible with the use of the
118118 * levenshtein() function.
119119 */
120 - function bestguess($word, $suggestions) {
121 - $shortest = -1;
 120+ function bestguess( $word, $suggestions ) {
 121+ $shortest = - 1;
122122
123 - if (preg_match('/^[^a-zA-Z]*$/', $word))
 123+ if ( preg_match( '/^[^a-zA-Z]*$/', $word ) )
124124 return $word;
125125
126 - foreach ($suggestions as $suggested) {
127 - $lev = levenshtein(strtolower($word), strtolower($suggested));
128 - if ($lev == 0) {
 126+ foreach ( $suggestions as $suggested ) {
 127+ $lev = levenshtein( strtolower( $word ), strtolower( $suggested ) );
 128+ if ( $lev == 0 ) {
129129 // closest word is this one (exact match)
130130 $closest = $word;
131131 $shortest = 0;
@@ -135,7 +135,7 @@
136136
137137 // if this distance is less than the next found shortest
138138 // distance, OR if a next shortest word has not yet been found
139 - if ($lev <= $shortest || $shortest < 0) {
 139+ if ( $lev <= $shortest || $shortest < 0 ) {
140140 // set the closest match, and shortest distance
141141 $closest = $suggested;
142142 $shortest = $lev;
Index: trunk/extensions/SphinxSearch/SphinxSearch.php
@@ -1,7 +1,7 @@
22 <?php
33
44 # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
5 -if (!defined('MEDIAWIKI')) {
 5+if ( !defined( 'MEDIAWIKI' ) ) {
66 echo <<<EOT
77 To install SphinxSearch extension, put the following line in LocalSettings.php:
88 require_once( "\$IP/extensions/SphinxSearch/SphinxSearch.php" );
@@ -15,24 +15,24 @@
1616 'version' => '0.7.0',
1717 'name' => 'SphinxSearch',
1818 'author' => array( 'Svemir Brkic', 'Paul Grinberg' ),
19 - 'email' => 'svemir at thirdblessing dot net, gri6507 at yahoo dot com',
 19+ 'email' => 'svemir at deveblog dot com, gri6507 at yahoo dot com',
2020 'url' => 'http://www.mediawiki.org/wiki/Extension:SphinxSearch',
2121 'descriptionmsg' => 'sphinxsearch-desc'
2222 );
2323
24 -$dir = dirname(__FILE__) . '/';
 24+$dir = dirname( __FILE__ ) . '/';
2525
2626 $wgAutoloadClasses['SphinxSearch'] = $dir . 'SphinxSearch_body.php';
2727 $wgExtensionMessagesFiles['SphinxSearch'] = $dir . 'SphinxSearch.i18n.php';
2828 $wgExtensionAliasesFiles['SphinxSearch'] = $dir . 'SphinxSearch.alias.php';
2929
30 -##########################################################
 30+# #########################################################
3131 # To completely disable the default search and replace it with SphinxSearch,
3232 # set this BEFORE including SphinxSearch.php in LocalSettings.php
3333 # $wgSearchType = 'SphinxSearch';
34 -##########################################################
 34+# #########################################################
3535
36 -if ($wgSearchType == 'SphinxSearch') {
 36+if ( $wgSearchType == 'SphinxSearch' ) {
3737 $wgDisableInternalSearch = true;
3838 $wgDisableSearchUpdate = true;
3939 $wgSpecialPages['Search'] = 'SphinxSearch';
@@ -42,7 +42,7 @@
4343
4444 # this assumes you have copied sphinxapi.php from your Sphinx
4545 # installation folder to your SphinxSearch extension folder
46 -if (!class_exists('SphinxClient')) {
 46+if ( !class_exists( 'SphinxClient' ) ) {
4747 require_once ( $dir . "sphinxapi.php" );
4848 }
4949
@@ -55,15 +55,15 @@
5656
5757 # By default, we search all available indexes
5858 # You can also specify them explicitly, e.g
59 -#$wgSphinxSearch_index_list = "wiki_main,wiki_incremental";
 59+# $wgSphinxSearch_index_list = "wiki_main,wiki_incremental";
6060 $wgSphinxSearch_index_list = "*";
6161
6262 # If you have multiple index files, you can specify their weights like this
6363 # See http://www.sphinxsearch.com/docs/current.html#api-func-setindexweights
64 -#$wgSphinxSearch_index_weights = array(
 64+# $wgSphinxSearch_index_weights = array(
6565 # "wiki_main" => 100,
6666 # "wiki_incremental" => 10
67 -#);
 67+# );
6868
6969 # Default Sphinx search mode
7070 $wgSphinxSearch_mode = SPH_MATCH_EXTENDED;
@@ -84,43 +84,40 @@
8585 $wgSphinxSearch_cutoff = 0;
8686
8787 # Weights of individual indexed columns. This gives page titles extra weight
88 -$wgSphinxSearch_weights = array('old_text'=>1, 'page_title'=>100);
 88+$wgSphinxSearch_weights = array( 'old_text' => 1, 'page_title' => 100 );
8989
9090 # If you want to enable hierarchical category search, specify the top category of your hierarchy like this
91 -#$wgSphinxTopSearchableCategory = 'Subject_areas';
 91+# $wgSphinxTopSearchableCategory = 'Subject_areas';
9292
9393 # If you want sub-categories to be fetched as parent categories are checked,
9494 # also set $wgUseAjax to true in your LocalSettings file, so that the following can be used:
95 -#$wgAjaxExportList[] = 'SphinxSearch::ajaxGetCategoryChildren';
 95+# $wgAjaxExportList[] = 'SphinxSearch::ajaxGetCategoryChildren';
9696
9797 # EXPERIMENTAL: allow excluding selected categories when filtering
98 -#$wgUseExcludes = true;
 98+# $wgUseExcludes = true;
9999
100100 # Web-accessible path to the extension's folder
101101 $wgSphinxSearchExtPath = '/extensions/SphinxSearch';
102102 # Web-accessible path to the folder with SphinxSearch.js file (if different from $wgSphinxSearchExtPath)
103 -#$wgSphinxSearchJSPath = '';
 103+# $wgSphinxSearchJSPath = '';
104104
105 -##########################################################
106 -# Use Aspell to suggest possible misspellings. This could be provided via either
107 -# PHP pspell module (http://www.php.net/manual/en/ref.pspell.php) or command line
108 -# insterface to ASpell
 105+# #########################################################
 106+# Use Aspell to suggest possible misspellings. This can be provided via
 107+# PHP pspell module (http://www.php.net/manual/en/ref.pspell.php)
 108+# or command line insterface to ASpell
109109
110110 # Should the suggestion mode be enabled?
111 -# Should be set BEFORE SphinxSearch.php is included in LocalSettings
112 -if (!isset($wgSphinxSuggestMode)) {
113 - $wgSphinxSuggestMode = false;
114 -}
 111+$wgSphinxSuggestMode = false;
115112
116113 # Path to personal dictionary (for example personal.en.pws.) Needed only if using a personal dictionary
117114 # Should be set BEFORE SphinxSearch.php is included in LocalSettings
118 -if (!isset($wgSphinxSearchPersonalDictionary)) {
 115+if ( !isset( $wgSphinxSearchPersonalDictionary ) ) {
119116 $wgSphinxSearchPersonalDictionary = "";
120117 }
121118
122 -# Here is why some vars need to be set before SphinxSearch is included.
 119+# Here is why above var needs to be set before SphinxSearch is included.
123120 # We setup a special page to edit the personal dictionary.
124 -if ($wgSphinxSuggestMode && $wgSphinxSearchPersonalDictionary) {
 121+if ( $wgSphinxSearchPersonalDictionary ) {
125122 $wgAutoloadClasses['SphinxSearchPersonalDict'] = $dir . 'SphinxSearch_PersonalDict.php';
126123 $wgSpecialPages['SphinxSearchPersonalDict'] = 'SphinxSearchPersonalDict';
127124 }
@@ -129,5 +126,4 @@
130127 $wgSphinxSearchAspellPath = "/usr/bin/aspell";
131128
132129 # Path to aspell location and language data files. Do not set if not sure.
133 -#$wgSphinxSearchPspellDictionaryDir = "/usr/lib/aspell";
134 -
 130+# $wgSphinxSearchPspellDictionaryDir = "/usr/lib/aspell";
Index: trunk/extensions/SphinxSearch/SphinxSearch_PersonalDict.php
@@ -14,7 +14,7 @@
1515 class SphinxSearchPersonalDict extends SpecialPage {
1616
1717 function SphinxSearchPersonalDict() {
18 - SpecialPage::SpecialPage("SphinxSearchPersonalDict", 'delete');
 18+ SpecialPage::SpecialPage( "SphinxSearchPersonalDict", 'delete' );
1919 self::loadMessages();
2020 return true;
2121 }
@@ -22,7 +22,7 @@
2323 function loadMessages() {
2424 static $messagesLoaded = false;
2525 global $wgMessageCache;
26 - if ($messagesLoaded) {
 26+ if ( $messagesLoaded ) {
2727 return;
2828 }
2929 $messagesLoaded = true;
@@ -43,66 +43,66 @@
4444 return true;
4545 }
4646
47 - function execute($par) {
 47+ function execute( $par ) {
4848 global $wgRequest, $wgOut, $wgUser;
4949
5050 $this->setHeaders();
51 - $wgOut->setPagetitle(wfMsg('sphinxsearchpersonaldict'));
 51+ $wgOut->setPagetitle( wfMsg( 'sphinxsearchpersonaldict' ) );
5252
53 - if (!$wgUser->isAllowed("delete")) {
54 - $wgOut->addWikiText(wfMsg('sphinxsearchcantpersonaldict'));
55 - $wgOut->addWikiText('----');
 53+ if ( !$wgUser->isAllowed( "delete" ) ) {
 54+ $wgOut->addWikiText( wfMsg( 'sphinxsearchcantpersonaldict' ) );
 55+ $wgOut->addWikiText( '----' );
5656 }
5757
58 - $toberemoved = $wgRequest->getArray('indictionary', array());
59 - $tobeadded = $wgRequest->getVal('tobeadded','');
60 - $tobeadded = preg_split('/\s/', trim($tobeadded), -1, PREG_SPLIT_NO_EMPTY);
 58+ $toberemoved = $wgRequest->getArray( 'indictionary', array() );
 59+ $tobeadded = $wgRequest->getVal( 'tobeadded', '' );
 60+ $tobeadded = preg_split( '/\s/', trim( $tobeadded ), - 1, PREG_SPLIT_NO_EMPTY );
6161
62 - $this->deleteFromPersonalDictionary($toberemoved);
63 - $this->addToPersonalDictionary($tobeadded);
 62+ $this->deleteFromPersonalDictionary( $toberemoved );
 63+ $this->addToPersonalDictionary( $tobeadded );
6464
65 - $this->CreateForm($wgUser->isAllowed("delete"));
 65+ $this->CreateForm( $wgUser->isAllowed( "delete" ) );
6666 }
6767
68 - function CreateForm($allowed_to_add) {
 68+ function CreateForm( $allowed_to_add ) {
6969 global $wgOut;
7070 global $wgSphinxSearchPersonalDictionary;
7171
72 - $wgOut->addHTML("<form method=post>");
73 - $wgOut->addHTML("<div style=\"border: thin solid #000000; width:90%;\"><table cellpadding=\"15\" width=\"100%\" cellspacing=\"0\" border=\"0\">");
74 - $wgOut->addHTML("<tr><td valign=top>");
75 - $wgOut->addWikiText("<center>'''" . wfMsg('sphinxsearchindictionary') . "'''</center><p>");
76 - $wgOut->addHTML('<select name="indictionary[]" size="15" multiple="multiple">');
 72+ $wgOut->addHTML( "<form method=post>" );
 73+ $wgOut->addHTML( "<div style=\"border: thin solid #000000; width:90%;\"><table cellpadding=\"15\" width=\"100%\" cellspacing=\"0\" border=\"0\">" );
 74+ $wgOut->addHTML( "<tr><td valign=top>" );
 75+ $wgOut->addWikiText( "<center>'''" . wfMsg( 'sphinxsearchindictionary' ) . "'''</center><p>" );
 76+ $wgOut->addHTML( '<select name="indictionary[]" size="15" multiple="multiple">' );
7777
78 - if (file_exists($wgSphinxSearchPersonalDictionary)) {
79 - $this->readPersonalDictionary($langauge, $numwords, $words);
80 - sort($words);
 78+ if ( file_exists( $wgSphinxSearchPersonalDictionary ) ) {
 79+ $this->readPersonalDictionary( $langauge, $numwords, $words );
 80+ sort( $words );
8181
82 - if (sizeof($words)>0) {
83 - foreach ($words as $w)
84 - $wgOut->addHTML("<option value='$w'>$w</option>");
 82+ if ( sizeof( $words ) > 0 ) {
 83+ foreach ( $words as $w )
 84+ $wgOut->addHTML( "<option value='$w'>$w</option>" );
8585 } else {
86 - $wgOut->addHTML("<option disabled value=''>Dictionary empty</option>");
 86+ $wgOut->addHTML( "<option disabled value=''>Dictionary empty</option>" );
8787 }
8888 } else {
89 - $wgOut->addHTML("<option disabled value=''>Dictionary not found</option>");
 89+ $wgOut->addHTML( "<option disabled value=''>Dictionary not found</option>" );
9090 }
9191
92 - $wgOut->addHTML('</select></td><td valign=top>');
93 - if ($allowed_to_add) {
94 - $wgOut->addWikiText("<center>'''" . wfMsg('sphinxsearchtobeadded') . "'''</center><p>");
95 - $wgOut->addHTML("<textarea name=\"tobeadded\" cols=\"30\" rows=\"15\"></textarea>");
96 - $wgOut->addHTML('</td></tr><tr><td colspan=2>');
97 - $wgOut->addHTML("<center><input type=\"submit\" value=\"Execute\" /></center>");
 92+ $wgOut->addHTML( '</select></td><td valign=top>' );
 93+ if ( $allowed_to_add ) {
 94+ $wgOut->addWikiText( "<center>'''" . wfMsg( 'sphinxsearchtobeadded' ) . "'''</center><p>" );
 95+ $wgOut->addHTML( "<textarea name=\"tobeadded\" cols=\"30\" rows=\"15\"></textarea>" );
 96+ $wgOut->addHTML( '</td></tr><tr><td colspan=2>' );
 97+ $wgOut->addHTML( "<center><input type=\"submit\" value=\"Execute\" /></center>" );
9898 }
99 - $wgOut->addHTML("</td></tr></table></div></form>");
 99+ $wgOut->addHTML( "</td></tr></table></div></form>" );
100100 }
101101
102 - function addToPersonalDictionary($list) {
103 - if (function_exists('pspell_config_create')) {
104 - $this->builtin_addword($list);
 102+ function addToPersonalDictionary( $list ) {
 103+ if ( function_exists( 'pspell_config_create' ) ) {
 104+ $this->builtin_addword( $list );
105105 } else {
106 - $this->nonnative_addword($list);
 106+ $this->nonnative_addword( $list );
107107 }
108108 }
109109
@@ -110,18 +110,18 @@
111111 global $wgUser, $wgLanguageCode;
112112
113113 // Try to read the default language from $wgUser:
114 - $language = trim($wgUser->getDefaultOption('language'));
 114+ $language = trim( $wgUser->getDefaultOption( 'language' ) );
115115
116116 // Use global variable: $wgLanguageCode (from LocalSettings.php) as fallback:
117 - if (empty($language)) { $language = trim($wgLanguageCode); }
 117+ if ( empty( $language ) ) { $language = trim( $wgLanguageCode ); }
118118
119119 // If we still don't have a valid language yet, assume English:
120 - if (empty($language)) { $language = 'en'; }
 120+ if ( empty( $language ) ) { $language = 'en'; }
121121
122122 return $language;
123123 }
124124
125 - function builtin_addword($list) {
 125+ function builtin_addword( $list ) {
126126 global $wgUser, $wgOut;
127127 global $wgSphinxSearchPersonalDictionary;
128128 global $wgSphinxSearchPspellDictionaryDir;
@@ -130,109 +130,109 @@
131131
132132 $pspell_config = pspell_config_create(
133133 $language,
134 - $wgUser->getDefaultOption('variant'));
135 - if ($wgSphinxSearchPspellDictionaryDir) {
136 - pspell_config_data_dir($pspell_config, $wgSphinxSearchPspellDictionaryDir);
137 - pspell_config_dict_dir($pspell_config, $wgSphinxSearchPspellDictionaryDir);
 134+ $wgUser->getDefaultOption( 'variant' ) );
 135+ if ( $wgSphinxSearchPspellDictionaryDir ) {
 136+ pspell_config_data_dir( $pspell_config, $wgSphinxSearchPspellDictionaryDir );
 137+ pspell_config_dict_dir( $pspell_config, $wgSphinxSearchPspellDictionaryDir );
138138 }
139 - pspell_config_mode($pspell_config, PSPELL_FAST|PSPELL_RUN_TOGETHER);
140 - if ($wgSphinxSearchPersonalDictionary)
141 - pspell_config_personal($pspell_config, $wgSphinxSearchPersonalDictionary);
142 - $pspell_link = pspell_new_config($pspell_config);
 139+ pspell_config_mode( $pspell_config, PSPELL_FAST | PSPELL_RUN_TOGETHER );
 140+ if ( $wgSphinxSearchPersonalDictionary )
 141+ pspell_config_personal( $pspell_config, $wgSphinxSearchPersonalDictionary );
 142+ $pspell_link = pspell_new_config( $pspell_config );
143143
144144 $write_needed = false;
145 - foreach ($list as $word) {
146 - if ($word == '')
 145+ foreach ( $list as $word ) {
 146+ if ( $word == '' )
147147 continue;
148 - if (preg_match('/[^a-zA-Z]/', $word)) {
149 - $wgOut->addWikiText(sprintf(wfMsg('sphinxsearchnotadded'), $word));
 148+ if ( preg_match( '/[^a-zA-Z]/', $word ) ) {
 149+ $wgOut->addWikiText( sprintf( wfMsg( 'sphinxsearchnotadded' ), $word ) );
150150 continue;
151151 }
152 - pspell_add_to_personal($pspell_link, $word);
 152+ pspell_add_to_personal( $pspell_link, $word );
153153 $write_needed = true;
154154 }
155155
156 - if ($write_needed) {
157 - pspell_save_wordlist($pspell_link);
 156+ if ( $write_needed ) {
 157+ pspell_save_wordlist( $pspell_link );
158158 }
159159 }
160160
161 - function nonnative_addword($list) {
 161+ function nonnative_addword( $list ) {
162162 global $wgUser;
163163 global $wgSphinxSearchPersonalDictionary;
164164
165 - if (!file_exists($wgSphinxSearchPersonalDictionary)) {
 165+ if ( !file_exists( $wgSphinxSearchPersonalDictionary ) ) {
166166 // create the personal dictionary file if it does not already exist
167167 $language = $this->getSearchLanguage();
168168 $numwords = 0;
169169 $words = array();
170170 } else {
171 - $this->readPersonalDictionary($language, $numwords, $words);
 171+ $this->readPersonalDictionary( $language, $numwords, $words );
172172 }
173173
174174 $write_needed = false;
175 - foreach ($list as $word) {
176 - if (!in_array($word, $words)) {
 175+ foreach ( $list as $word ) {
 176+ if ( !in_array( $word, $words ) ) {
177177 $numwords++;
178 - array_push($words, $word);
 178+ array_push( $words, $word );
179179 $write_needed = true;
180180 }
181181 }
182182
183 - if ($write_needed)
184 - $this->writePersonalDictionary($language, $numwords, $words);
 183+ if ( $write_needed )
 184+ $this->writePersonalDictionary( $language, $numwords, $words );
185185 }
186186
187 - function writePersonalDictionary($language, $numwords, $words) {
 187+ function writePersonalDictionary( $language, $numwords, $words ) {
188188 global $wgSphinxSearchPersonalDictionary;
189189
190 - $handle = fopen($wgSphinxSearchPersonalDictionary, "wt");
191 - if ($handle) {
192 - fwrite($handle, "personal_ws-1.1 $language $numwords\n");
193 - foreach ($words as $w) {
194 - fwrite($handle, "$w\n");
 190+ $handle = fopen( $wgSphinxSearchPersonalDictionary, "wt" );
 191+ if ( $handle ) {
 192+ fwrite( $handle, "personal_ws-1.1 $language $numwords\n" );
 193+ foreach ( $words as $w ) {
 194+ fwrite( $handle, "$w\n" );
195195 }
196 - fclose($handle);
 196+ fclose( $handle );
197197 }
198198 }
199199
200 - function readPersonalDictionary(&$language, &$numwords, &$words) {
 200+ function readPersonalDictionary( &$language, &$numwords, &$words ) {
201201 global $wgSphinxSearchPersonalDictionary;
202202
203203 $words = array();
204 - $lines = explode("\n", file_get_contents($wgSphinxSearchPersonalDictionary));
205 - foreach ($lines as $line) {
206 - trim($line);
207 - if (preg_match('/\s(\w+)\s(\d+)/', $line, $matches)) {
 204+ $lines = explode( "\n", file_get_contents( $wgSphinxSearchPersonalDictionary ) );
 205+ foreach ( $lines as $line ) {
 206+ trim( $line );
 207+ if ( preg_match( '/\s(\w+)\s(\d+)/', $line, $matches ) ) {
208208 $language = $matches[1];
209209 $numwords = $matches[2];
210210 } else
211 - if ($line)
212 - array_push($words, $line);
 211+ if ( $line )
 212+ array_push( $words, $line );
213213 }
214214
215215 // Make sure that we have a valid value for language if it wasn't in the .pws file:
216 - if (empty($language)) { $language = $this->getSearchLanguage(); }
 216+ if ( empty( $language ) ) { $language = $this->getSearchLanguage(); }
217217 }
218218
219 - function deleteFromPersonalDictionary($list) {
 219+ function deleteFromPersonalDictionary( $list ) {
220220 // there is no built in way to delete from the personal dictionary.
 221+
 222+ $this->readPersonalDictionary( $language, $numwords, $words );
221223
222 - $this->readPersonalDictionary($language, $numwords, $words);
223 -
224224 $write_needed = false;
225 - foreach ($list as $w) {
226 - if ($w == '')
 225+ foreach ( $list as $w ) {
 226+ if ( $w == '' )
227227 continue;
228 - if (in_array($w, $words)) {
229 - $index = array_keys($words, $w);
230 - unset($words[$index[0]]);
 228+ if ( in_array( $w, $words ) ) {
 229+ $index = array_keys( $words, $w );
 230+ unset( $words[$index[0]] );
231231 $numwords--;
232232 $write_needed = true;
233233 }
234234 }
235235
236 - if ($write_needed)
237 - $this->writePersonalDictionary($language, $numwords, $words);
 236+ if ( $write_needed )
 237+ $this->writePersonalDictionary( $language, $numwords, $words );
238238 }
239239 }

Comments

#Comment by Platonides (talk | contribs)   21:08, 11 April 2010

Try to keep code changes separated from style changes.

I'd also move the * and ''...'' into sphinxSearchStats/sphinxSearchStatsInfo messages.

#Comment by Svemir Brkic (talk | contribs)   22:59, 11 April 2010

Done in rev:64949

#Comment by Platonides (talk | contribs)   23:06, 11 April 2010

Much nicer :)

Status & tagging log