Extension:Google

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Google

Release status: unknown

Implementation Tag
Description Allows to insert a Google search form in your wiki page.
License No license specified
Download see below

Translate the Google extension if possible

Check usage and version matrix; code metrics

Purpose[edit | edit source]

This is a simple extension could be used to insert a Google search form in your wiki page. It is based on the PayPal extension.

See the talk page for some alternative code (its all very simple really).


Installation[edit | edit source]

Create a new file in your extension-folder, named Google.php with following content:

<?php
 
# To activate the extension, include it from your LocalSettings.php
# with: include("extensions/Google.php");
# 
# Syntax: <google/>
#

$wgExtensionFunctions[] = "wfGoogle";
 
function wfGoogle() {
    global $wgParser;
 
    $wgParser->setHook( "google", "renderGoogle" );
}
 
# The callback function for converting the input text to HTML output
function renderGoogle( $input ) {
    $output = '<!-- Search Google -->';
    $output .= '<center>';
    $output .= '<form method="GET" action="http://www.google.com/search">';
    $output .= '<input type="hidden" name="ie" value="UTF-8"/>';
    $output .= '<input type="hidden" name="oe" value="UTF-8"/>';
    $output .= '<table bgcolor="#FFFFFF"><tr><td>';
    $output .= '<a href="http://www.google.com/">';
    $output .= '<img src="http://www.google.com/logos/Logo_40wht.gif" ';
    $output .= 'border="0" alt="Google" align="absmiddle"/></a>';
    $output .= '<input type="text" name="q" size="25" maxlength="255" value=""/>';
    $output .= '<input type="submit" name="btnG" value="Google Search"/>';
    $output .= '</td></tr></table>';
    $output .= '</form>';
    $output .= '</center>';
    $output .= '<!-- Search Google -->';
    return $output;
}


Open your LocalSettings.php, and insert at the end of file:

require_once("$IP/extensions/Google.php");

And that's pretty much it!

You can then insert the Form on your wiki page by using:

<google></google>

See also[edit | edit source]