Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/109497


Change subject: Fix problems with textsearch
......................................................................

Fix problems with textsearch

Change-Id: I0b8864c481b0c339b5c0cb4ac05b18675a89f958
---
M SpecialMathSearch.php
1 file changed, 18 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch 
refs/changes/97/109497/1

diff --git a/SpecialMathSearch.php b/SpecialMathSearch.php
index a7b888e..f35da1a 100644
--- a/SpecialMathSearch.php
+++ b/SpecialMathSearch.php
@@ -33,11 +33,11 @@
 
        /**
         *
-        * @return \CirrusSearch|boolean
+        * @return SearchEngine|boolean
         */
        public static function getCirrusSearch() {
                if ( class_exists( 'CirrusSearch' ) ) {
-                       return new CirrusSearch();
+                       return SearchEngine::create();
                } else {
                        wfDebugLog( 'MathSearch', 'Text search not possible. 
Class CirrusSearch is missing.' );
                        return false;
@@ -216,16 +216,25 @@
                        }
                }
                $ls = self::getCirrusSearch();
+               $ls = new CirrusSearch();
                if ( $ls ) {
-                       $ls->limit = 1000000;
+                       //$ls->limit = 1000000;
                        if ( $this->textpattern ) {
                                $textpattern = $this->textpattern;
-                               $sres = $ls->searchText( $textpattern );
-                               if ( $sres && $sres->hasResults() ) {
-                                       $out->addWikiText( "You searched for 
the text '$textpattern' and the TeX-Pattern '$pattern'." );
+                                               $search = 
SearchEngine::create();
+                                               $ns = 
SearchEngine::userNamespaces( $this->getUser() );
+               $search->setLimitOffset( 1000, 0 );
+               $search->setNamespaces( $ns );
+               $term = $search->transformSearchTerm( $textpattern );
+                               $sres = $search->searchText( $term );
+                               if ( $sres ) {
+                                       if ( !$sres->numRows() ){
+                                               $out->addWikiText('No results 
found.');
+                                       } else {
+                                       $out->addWikiText( "You searched for 
the text '$textpattern' and the TeX-Pattern '{$this->mathpattern}'." );
                                        $out->addWikiText( "The text search 
results in [{{canonicalurl:search|search=$textpattern}} " .
                                                        $sres->getTotalHits()
-                                                       . "] hits and the math 
pattern matched $this->numMathResults times on 
[{{canonicalurl:{{FULLPAGENAMEE}}|pattern=$pattern}} " .
+                                                       . "] hits and the math 
pattern matched $this->numMathResults times on 
[{{canonicalurl:{{FULLPAGENAMEE}}|pattern={$this->mathpattern}}} " .
                                                        sizeof( 
$this->relevantMathMap ) .
                                                        "] pages." );
                                        //// var_dump($sres);
@@ -249,7 +258,7 @@
 
                                        wfDebugLog( 'mathsearch', 'EOF' );
                                        wfDebugLog( 'mathsearch', var_export( 
$this->mathResults, true ) );
-                               }
+                               }}
                        }
                }
                // $out->addHtml(htmlspecialchars( $pattern) );
@@ -272,7 +281,7 @@
         * @return boolean
         */
        function render() {
-               $renderer = new MathLaTeXMLML( $this->mathpattern );
+               $renderer = new MathLaTeXML( $this->mathpattern );
                $renderer->setLaTeXMLSettings( 'profile=mwsquery' );
                $renderer->setAllowedRootElments( array( 'query' ) );
                $renderer->render( true );

-- 
To view, visit https://gerrit.wikimedia.org/r/109497
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b8864c481b0c339b5c0cb4ac05b18675a89f958
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to