Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/109855
Change subject: Improve loading of textSearch Engine ...................................................................... Improve loading of textSearch Engine * works now even if CirrusSearch is not enabled Change-Id: I4f3fb9a6626155de1043cfdfa29d152335aa2c6d --- M SpecialMathSearch.php 1 file changed, 38 insertions(+), 59 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch refs/changes/55/109855/1 diff --git a/SpecialMathSearch.php b/SpecialMathSearch.php index f35da1a..4d16a7c 100644 --- a/SpecialMathSearch.php +++ b/SpecialMathSearch.php @@ -31,18 +31,6 @@ parent::__construct( 'MathSearch' ); } - /** - * - * @return SearchEngine|boolean - */ - public static function getCirrusSearch() { - if ( class_exists( 'CirrusSearch' ) ) { - return SearchEngine::create(); - } else { - wfDebugLog( 'MathSearch', 'Text search not possible. Class CirrusSearch is missing.' ); - return false; - } - } /** * The main function @@ -81,10 +69,6 @@ 'default' => $this->textpattern, ) ); - if ( !self::getCirrusSearch() ) { - $formDescriptor['textpattern']['disabled'] = true; - $formDescriptor['textpattern']['help'] = 'CirrusSearch not found. Text search <b>disabled</b>!<br/> For details see <a href=\"http://www.mediawiki.org/wiki/Extension:MWSearch\">MWSearch</a>.'; - } $htmlForm = new HTMLForm( $formDescriptor, $this->getContext() ); # We build the HTMLForm object $htmlForm->setSubmitText( 'Search' ); $htmlForm->setSubmitCallback( array( get_class( $this ), 'processInput' ) ); @@ -215,50 +199,45 @@ } } } - $ls = self::getCirrusSearch(); - $ls = new CirrusSearch(); - if ( $ls ) { - //$ls->limit = 1000000; - if ( $this->textpattern ) { - $textpattern = $this->textpattern; - $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={$this->mathpattern}}} " . - sizeof( $this->relevantMathMap ) . - "] pages." ); - //// var_dump($sres); - wfDebugLog( 'mathsearch', 'BOF' ); - // $out->addWikiText(var_export($this->relevantMathMap,true)); - $pageList = ""; - while ( $tres = $sres->next() ) { - $pageID = $tres->getTitle()->getArticleID(); - // $out->addWikiText($pageID); + if ( $this->textpattern ) { + $textpattern = $this->textpattern; + global $wgSearchType; + var_dump($wgSearchType); + die(); + $search = SearchEngine::create( "CirrusSearch"); + $search->setLimitOffset( 10000 ); + $sres = $search->searchText( $textpattern ); + 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={$this->mathpattern}}} " . + sizeof( $this->relevantMathMap ) . + "] pages." ); + //// var_dump($sres); + wfDebugLog( 'mathsearch', 'BOF' ); + // $out->addWikiText(var_export($this->relevantMathMap,true)); + $pageList = ""; + while ( $tres = $sres->next() ) { + $pageID = $tres->getTitle()->getArticleID(); + // $out->addWikiText($pageID); + if ( isset( $this->relevantMathMap[$pageID] ) ) { + $out->addWikiText( "[[" . $tres->getTitle() . "]]" ); + $out->addHtml( $tres->getTextSnippet( $textpattern ) ); + $pageList .= "OR [[" . $pageID . "]]"; + // $out->addHtml($this->showHit($tres),$textpattern); + $this->DisplayMath( $pageID ); + } /* else { + $out->addWikiText(":NO MATH"); + }// */ + } // $tres->mHighlightTitle)} - if ( isset( $this->relevantMathMap[$pageID] ) ) { - $out->addWikiText( "[[" . $tres->getTitle() . "]]" ); - $out->addHtml( $tres->getTextSnippet( $textpattern ) ); - $pageList .= "OR [[" . $pageID . "]]"; - // $out->addHtml($this->showHit($tres),$textpattern); - $this->DisplayMath( $pageID ); - } /* else { - $out->addWikiText(":NO MATH"); - }// */ - } // $tres->mHighlightTitle)} - - wfDebugLog( 'mathsearch', 'EOF' ); - wfDebugLog( 'mathsearch', var_export( $this->mathResults, true ) ); - }} + wfDebugLog( 'mathsearch', 'EOF' ); + wfDebugLog( 'mathsearch', var_export( $this->mathResults, true ) ); + } } } // $out->addHtml(htmlspecialchars( $pattern) ); -- To view, visit https://gerrit.wikimedia.org/r/109855 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4f3fb9a6626155de1043cfdfa29d152335aa2c6d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits