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.
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.)
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 ===
(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
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
'contextlines' => 5,
'contextchars' => 50,
'disablesuggest' => 0,
- 'ajaxsearch' => 0,
'skin' => false,
'math' => 1,
'usenewrc' => 0,
*/
$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
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' );
}
$wgDeferredUpdateList = array();
$wgPostCommitUpdateList = array();
-if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch';
if ( $wgAjaxUploadDestCheck ) $wgAjaxExportList[] = 'UploadForm::ajaxGetExistsWarning';
if( $wgAjaxLicensePreview )
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;
/**
$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' ) &&
$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
$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();
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 );
$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' ),
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' ) )
+++ /dev/null
-// 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");
-}