From: Brion Vibber Date: Wed, 20 Aug 2008 18:11:59 +0000 (+0000) Subject: * $wgAjaxSearch has been removed; use $wgEnableMWSuggest instead. X-Git-Tag: 1.31.0-rc.0~45768 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=e2f1a14d9e27ff6da71be14619e878a78e9385e1;p=lhc%2Fweb%2Fwiklou.git * $wgAjaxSearch has been removed; use $wgEnableMWSuggest instead. 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. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f4bb65bf26..1fb2af22da 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/docs/memcached.txt b/docs/memcached.txt index b31554cc7f..2a9048726e 100644 --- a/docs/memcached.txt +++ b/docs/memcached.txt @@ -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 diff --git a/includes/AjaxFunctions.php b/includes/AjaxFunctions.php index 6d80b29eb8..9e892f1abc 100644 --- a/includes/AjaxFunctions.php +++ b/includes/AjaxFunctions.php @@ -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 .= '
  • ' . $sk->makeKnownLink( $titleText ) . "
  • \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 = '' . - $sk->makeKnownLinkObj( - SpecialPage::getTitleFor( 'Specialpages' ), - wfMsgHtml( 'moredotdotdot' ) ) . - ''; - } - } else { - if( count( $results ) > $limit ) { - $more = '' . - $sk->makeKnownLinkObj( - SpecialPage::getTitleFor( "Allpages", $term ), - wfMsgHtml( 'moredotdotdot' ) ) . - ''; - } - } - } - - $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 = '
    ' - . wfMsgHtml( 'hideresults' ) . '
    ' - . '

    '.wfMsgHtml('search') - . '

    '. $subtitle . '
    '; - if( $canSearch ) { - $html .= '"; - } - if( $r ) { - $html .= "

    " . wfMsgHtml( 'articletitles', $term_display ) . "

    " - . '' . $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 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index e3a48d401f..4409e38570 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f6bd91d170..4640608cb8 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -853,11 +853,6 @@ class OutputPage { wfRunHooks( 'AjaxAddScript', array( &$this ) ); - if( $wgAjaxSearch && $wgUser->getBoolOption( 'ajaxsearch' ) ) { - $this->addScriptFile( 'ajaxsearch.js' ); - $this->addScript( "\n" ); - } - if( $wgAjaxWatch && $wgUser->isLoggedIn() ) { $this->addScriptFile( 'ajaxwatch.js' ); } diff --git a/includes/Setup.php b/includes/Setup.php index 877ea76659..158b1c0efb 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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 ) diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 1b00bed24d..b5727497c9 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -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( '' ); # 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 index b9fb56f391..0000000000 --- a/skins/common/ajaxsearch.js +++ /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= '
    ' ; - 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"); -}