Extension:Google Custom Search Engine

This is a very simple extension, helping you adding a Google Custom Search Engine (Google Co-op) to your MediaWiki site.

Get Google Co-op Code

 * Before you start install this extension, you need to go to http://www.google.com/coop and find the "code" section at "Control panel" (If you don't have any Custom Search Engine, you need create and config one).


 * At the "code" section, you need expand "Search box and search results code for your website" and file one wiki page in your site which you want to display the search result (I recommend filling the URL like this http://yoursite.com/wiki/yourwikiname:GoogleSearch).


 * After you finish this step, you will get two piece of "code" as the picture shown right.

MediaWiki operation
Copy the code provided by Google below the words: "Place this code in the page you'd like your search results to appear."

And paste it to program shown below between $output=' and ';//google code end here

google-coop.php

 * 4) Ex :
 * 5)   Add this tag to the wiki page you configed at your google co-op control panel.
 * 6) Enjoy !
 * 1) Enjoy !
 * 1) Enjoy !
 * 1) Enjoy !

$wgExtensionFunctions[] = 'GoogleCoop'; $wgExtensionCredits['parserhook'][] = array(       'name' => 'Google Co-op Extension',        'description' => 'Using Google Co-op',        'author' => 'Liang Chen The BiGreat',        'url' => 'http://liang-chen.com' );

function GoogleCoop { global $wgParser; $wgParser->setHook('Googlecoop', 'renderGoogleCoop'); }

function renderGoogleCoop($input) { $output=' @@@@@@@@@@@PASTE YOUR CODE HERE@@@@@@@@@@ When you paste the code from Google, please take care of removing all the blank spaces. It creates a or a  tag. This does not run the code of Google. ';//google code end here
 * 1) The callback function for converting the input text to HTML output

return $output; } ?>

Final Steps

 * Upload the google-coop.php to your extensions/ directory, and add include("extensions/google-coop.php"); to your LocalSettings.php file.
 * Go to the wiki page which you want to display the search result like (http://yoursite.com/wiki/yourwikiname:GoogleSearch), add  to this page and protect it.
 * Then use another code google provided at the pages you want to be the entrance of the search, like adding to sidebar.
 * done

Site users
Please list your site here if you are using this code
 * [Knowledge Without Limits]

Demo

 * I don't Like Exams (MediaWiki 1.9.1)