* $wgAjaxSearch has been removed; use $wgEnableMWSuggest instead.
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 20 Aug 2008 18:11:59 +0000 (18:11 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 20 Aug 2008 18:11:59 +0000 (18:11 +0000)
I never liked the take-over-the-screen UI of the old ajax search; the new suggestion search does the same thing in a more natural, integrated way.

RELEASE-NOTES
docs/memcached.txt
includes/AjaxFunctions.php
includes/DefaultSettings.php
includes/OutputPage.php
includes/Setup.php
includes/specials/SpecialPreferences.php
skins/common/ajaxsearch.js [deleted file]

index f4bb65b..1fb2af2 100644 (file)
@@ -19,6 +19,7 @@ Those wishing to use the latest code instead of a branch release can obtain
 it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 
 === Configuration changes in 1.14 ===
+
 * $wgExemptFromUserRobotsControl is an array of namespaces to be exempt from
   the effect of the new __INDEX__/__NOINDEX__ magic words.  (Default: null, ex-
   empt all content namespaces.)
@@ -38,6 +39,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   word is restricted to titles equivalent to the actual page title. This
   is true per default, but can be set to false to allow any title.
 * $wgSpamRegex may now be an array of multiple regular expressions.
+* $wgAjaxSearch has been removed; use $wgEnableMWSuggest instead.
 
 === New features in 1.14 ===
 
index b31554c..2a90487 100644 (file)
@@ -97,13 +97,6 @@ this is mentionned below.
 
 (incomplete, out of date)
 
-Ajax Search:
-       key: $wgDBname:ajaxsearch:md5( $search )
-       ex: wikidb:ajaxsearch:9565814d5d564fa898dd6111b94fae0b
-       stores: array with the result of research of a given text
-       cleared by: nothing
-       expiry: 30 minutes
-
 Date Formatter:
        key: $wgDBname:dateformatter
        ex: wikidb:dateformatter
index 6d80b29..9e892f1 100644 (file)
@@ -72,89 +72,6 @@ function code2utf($num){
    return '';
 }
 
-define( 'AJAX_SEARCH_VERSION', 2 );    //AJAX search cache version
-
-function wfSajaxSearch( $term ) {
-       global $wgContLang, $wgUser, $wgMemc;
-       $limit = 16;
-       $sk = $wgUser->getSkin();
-       $output = '';
-
-       $term = trim( $term );
-       $term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) );
-       $term_title = Title::newFromText( $term );
-
-       $memckey = $term_title ? wfMemcKey( 'ajaxsearch', md5( $term_title->getFullText() ) ) : wfMemcKey( 'ajaxsearch', md5( $term ) );
-       $cached = $wgMemc->get($memckey);
-       if( is_array( $cached ) && $cached['version'] == AJAX_SEARCH_VERSION ) {
-               $response = new AjaxResponse( $cached['html'] );
-               $response->setCacheDuration( 30*60 );
-               return $response;
-       }
-
-       $r = $more = '';
-       $canSearch = true;
-
-       $results = PrefixSearch::titleSearch( $term, $limit + 1 );
-       foreach( array_slice( $results, 0, $limit ) as $titleText ) {
-               $r .= '<li>' . $sk->makeKnownLink( $titleText ) . "</li>\n";
-       }
-
-       // Hack to check for specials
-       if( $results ) {
-               $t = Title::newFromText( $results[0] );
-               if( $t && $t->getNamespace() == NS_SPECIAL ) {
-                       $canSearch = false;
-                       if( count( $results ) > $limit ) {
-                               $more = '<i>' .
-                                       $sk->makeKnownLinkObj(
-                                               SpecialPage::getTitleFor( 'Specialpages' ),
-                                               wfMsgHtml( 'moredotdotdot' ) ) .
-                                       '</i>';
-                       }
-               } else {
-                       if( count( $results ) > $limit ) {
-                               $more = '<i>' .
-                                       $sk->makeKnownLinkObj(
-                                               SpecialPage::getTitleFor( "Allpages", $term ),
-                                               wfMsgHtml( 'moredotdotdot' ) ) .
-                                       '</i>';
-                       }
-               }
-       }
-
-       $valid = (bool) $term_title;
-       $term_url = urlencode( $term );
-       $term_normalized = $valid ? $term_title->getFullText() : $term;
-       $term_display = htmlspecialchars( $term );
-       $subtitlemsg = ( $valid ? 'searchsubtitle' : 'searchsubtitleinvalid' );
-       $subtitle = wfMsgExt( $subtitlemsg, array( 'parse' ), wfEscapeWikiText( $term_normalized ) );
-       $html = '<div id="searchTargetHide"><a onclick="Searching_Hide_Results();">'
-               . wfMsgHtml( 'hideresults' ) . '</a></div>'
-               . '<h1 class="firstHeading">'.wfMsgHtml('search')
-               . '</h1><div id="contentSub">'. $subtitle . '</div>';
-       if( $canSearch ) {
-               $html .= '<ul><li>'
-                       . $sk->makeKnownLink( $wgContLang->specialPage( 'Search' ),
-                                               wfMsgHtml( 'searchcontaining', $term_display ),
-                                               "search={$term_url}&fulltext=Search" )
-                       . '</li><li>' . $sk->makeKnownLink( $wgContLang->specialPage( 'Search' ),
-                                               wfMsgHtml( 'searchnamed', $term_display ) ,
-                                               "search={$term_url}&go=Go" )
-                       . "</li></ul>";
-       }
-       if( $r ) {
-               $html .= "<h2>" . wfMsgHtml( 'articletitles', $term_display ) . "</h2>"
-                       . '<ul>' .$r .'</ul>' . $more;
-       }
-
-       $wgMemc->set( $memckey, array( 'version' => AJAX_SEARCH_VERSION, 'html' => $html ), 30 * 60 );
-
-       $response = new AjaxResponse( $html );
-       $response->setCacheDuration( 30*60 );
-       return $response;
-}
-
 /**
  * Called for AJAX watch/unwatch requests.
  * @param $pagename Prefixed title string for page to watch/unwatch
index e3a48d4..4409e38 100644 (file)
@@ -2206,7 +2206,6 @@ $wgDefaultUserOptions = array(
        'contextlines'            => 5,
        'contextchars'            => 50,
        'disablesuggest'          => 0,
-       'ajaxsearch'              => 0,
        'skin'                    => false,
        'math'                    => 1,
        'usenewrc'                => 0,
@@ -3127,13 +3126,6 @@ $wgUpdateRowsPerQuery = 10;
  */
 $wgUseAjax = true;
 
-/**
- * Enable auto suggestion for the search bar
- * Requires $wgUseAjax to be true too.
- * Causes wfSajaxSearch to be added to $wgAjaxExportList
- */
-$wgAjaxSearch = false;
-
 /**
  * List of Ajax-callable functions.
  * Extensions acting as Ajax callbacks must register here
index f6bd91d..4640608 100644 (file)
@@ -853,11 +853,6 @@ class OutputPage {
 
                        wfRunHooks( 'AjaxAddScript', array( &$this ) );
 
-                       if( $wgAjaxSearch && $wgUser->getBoolOption( 'ajaxsearch' ) ) {
-                               $this->addScriptFile( 'ajaxsearch.js' );
-                               $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" );
-                       }
-
                        if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
                                $this->addScriptFile( 'ajaxwatch.js' );
                        }
index 877ea76..158b1c0 100644 (file)
@@ -277,7 +277,6 @@ wfProfileIn( $fname.'-misc2' );
 $wgDeferredUpdateList = array();
 $wgPostCommitUpdateList = array();
 
-if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
 if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch';
 if ( $wgAjaxUploadDestCheck ) $wgAjaxExportList[] = 'UploadForm::ajaxGetExistsWarning';
 if( $wgAjaxLicensePreview )
index 1b00bed..b572749 100644 (file)
@@ -25,7 +25,7 @@ class PreferencesForm {
        var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
        var $mUserLanguage, $mUserVariant;
        var $mSearch, $mRecent, $mRecentDays, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
-       var $mReset, $mPosted, $mToggles, $mUseAjaxSearch, $mSearchNs, $mRealName, $mImageSize;
+       var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
        var $mUnderline, $mWatchlistEdits;
 
        /**
@@ -66,7 +66,6 @@ class PreferencesForm {
                $this->mSuccess = $request->getCheck( 'success' );
                $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' );
                $this->mWatchlistEdits = $request->getVal( 'wpWatchlistEdits' );
-               $this->mUseAjaxSearch = $request->getCheck( 'wpUseAjaxSearch' );
                $this->mDisableMWSuggest = $request->getCheck( 'wpDisableMWSuggest' );
 
                $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
@@ -289,7 +288,6 @@ class PreferencesForm {
                $wgUser->setOption( 'thumbsize', $this->mThumbSize );
                $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) );
                $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays, 0, 7 ) );
-               $wgUser->setOption( 'ajaxsearch', $this->mUseAjaxSearch );
                $wgUser->setOption( 'disablesuggest', $this->mDisableMWSuggest );
 
                # Set search namespace options
@@ -402,7 +400,6 @@ class PreferencesForm {
                $this->mWatchlistEdits = $wgUser->getOption( 'wllimit' );
                $this->mUnderline = $wgUser->getOption( 'underline' );
                $this->mWatchlistDays = $wgUser->getOption( 'watchlistdays' );
-               $this->mUseAjaxSearch = $wgUser->getBoolOption( 'ajaxsearch' );
                $this->mDisableMWSuggest = $wgUser->getBoolOption( 'disablesuggest' );
 
                $togs = User::getToggles();
@@ -518,7 +515,7 @@ class PreferencesForm {
                global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
                global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
                global $wgContLanguageCode, $wgDefaultSkin, $wgCookieExpiration;
-               global $wgEmailConfirmToEdit, $wgAjaxSearch, $wgEnableMWSuggest;
+               global $wgEmailConfirmToEdit, $wgEnableMWSuggest;
 
                $wgOut->setPageTitle( wfMsg( 'preferences' ) );
                $wgOut->setArticleRelated( false );
@@ -1045,11 +1042,6 @@ class PreferencesForm {
                $wgOut->addHtml( '</fieldset>' );
 
                # Search
-               $ajaxsearch = $wgAjaxSearch ?
-                       $this->addRow(
-                               Xml::label( wfMsg( 'useajaxsearch' ), 'wpUseAjaxSearch' ),
-                               Xml::check( 'wpUseAjaxSearch', $this->mUseAjaxSearch, array( 'id' => 'wpUseAjaxSearch' ) )
-                       ) : '';
                $mwsuggest = $wgEnableMWSuggest ?
                        $this->addRow(
                                Xml::label( wfMsg( 'mwsuggest-disable' ), 'wpDisableMWSuggest' ),
@@ -1063,7 +1055,6 @@ class PreferencesForm {
                        Xml::openElement( 'fieldset' ) .
                        Xml::element( 'legend', null, wfMsg( 'prefs-searchoptions' ) ) .
                        Xml::openElement( 'table' ) .
-                       $ajaxsearch .
                        $this->addRow(
                                Xml::label( wfMsg( 'resultsperpage' ), 'wpSearch' ),
                                Xml::input( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) )
diff --git a/skins/common/ajaxsearch.js b/skins/common/ajaxsearch.js
deleted file mode 100644 (file)
index b9fb56f..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-// remote scripting library
-// (c) copyright 2005 modernmethod, inc
-
-var started;
-var typing;
-var memory=null;
-var body=null;
-var oldbody=null;
-
-// Remove the typing barrier to allow call() to complete
-function Search_doneTyping()
-{
-       typing=false;
-}
-
-// Wait 500ms to run call()
-function Searching_Go()
-{
-        setTimeout("Searching_Call()", 500);
-}
-
-// If the user is typing wait until they are done.
-function Search_Typing() {
-       started=true;
-       typing=true;
-       setTimeout("Search_doneTyping()", 500);
-
-       // I believe these are needed by IE for when the users press return?
-       if (window.event)
-       {
-               if (event.keyCode == 13)
-               {
-                       event.cancelBubble = true;
-                       event.returnValue = true;
-               }
-       }
-}
-
-// Set the body div to the results
-function Searching_SetResult( request )
-{
-       if ( request.status != 200 ) {
-               alert("Error: " + request.status + " " + request.statusText + ": " + request.responseText);
-               return;
-       }
-
-       var result = request.responseText;
-
-        //body.innerHTML = result;
-       t = document.getElementById("searchTarget");
-       if ( t == null ) {
-               oldbody=body.innerHTML;
-               body.innerHTML= '<div id="searchTargetContainer"><div id="searchTarget" ></div></div>' ;
-               t = document.getElementById("searchTarget");
-       }
-       t.innerHTML = result;
-       t.style.display='block';
-}
-
-function Searching_Hide_Results()
-{
-       t = document.getElementById("searchTarget");
-       t.style.display='none';
-       body.innerHTML = oldbody;
-}
-
-
-// This will call the php function that will eventually
-// return a results table
-function Searching_Call()
-{
-       var x;
-       Searching_Go();
-
-       //Don't proceed if user is typing
-       if (typing)
-               return;
-
-       x = document.getElementById("searchInput").value;
-
-       // Don't search again if the query is the same
-       if (x==memory)
-               return;
-
-       memory=x;
-       if (started) {
-               // Don't search for blank or < 3 chars.
-               if ((x=="") || (x.length < 3))
-               {
-                       return;
-               }
-
-               sajax_do_call( "wfSajaxSearch", [ x ], Searching_SetResult );
-       }
-}
-
-//Initialize
-function sajax_onload() {
-       x = document.getElementById( 'searchInput' );
-       x.onkeypress= function() { Search_Typing(); };
-       Searching_Go();
-       body = document.getElementById("content");
-}