Open main menu

Extension:Startpagesearch

MediaWiki extensions manual
OOjs UI icon advanced.svg
startpagesearch
Release status: stable
Implementation Tag
Description Lets you insert a StartPage search box on your wiki pages
License No license specified
Download see below
Translate the Startpagesearch extension if it is available at translatewiki.net
Check usage and version matrix.

PurposeEdit

Provides a StartPage searchbox on any of your wiki pages. I used the php from Extension:Google and changed the contents and added a few items using the html from StartPage as a template. It has been tested and does work.

InstallationEdit

Copy the following code and paste it into a new document and save it to your extensions folder using the name startpagesearch.php.

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

$wgExtensionFunctions[] = "wfstartpage";
 
function wfstartpage() {
    global $wgParser;
 
    $wgParser->setHook( "startpage", "renderstartpage" );
}
 
# The callback function for converting the input text to HTML output
function renderstartpage( $input ) {
    $output = '<!-- Search Startpage -->';
    $output .= '<center>';
    $output .= '<form method="POST" action="http://startpage.com/do/metasearch.pl"';
    $output .= 'style="margin:0; padding:0;"';
    $output .= 'onSubmit="javascript:document.metasearch.query.value=document.metasearch.keyword.value;">';
    $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://startpage.com/">';
    $output .= '<img src="http://startpage.com/graphics/startpage_small_logo.gif" ';
    $output .= 'border="0" alt="Startpage" align="absmiddle"/></a></td>';
    $output .= '<td>';
    $output .= '<input type="hidden" name="from" value="searchbox"/>';
    $output .= '<input type="hidden" name="language" value="english"/>';
    $output .= '<input type="hidden" name="cat" value="web"/>';
    $output .= '<input type="hidden" name="query" size=32/>';
    $output .= '<input type="text" name ="keyword" size=32/>';
    $output .= '<input type="hidden" name="cmd" value="process_search"/>';
    $output .= '<input type="hidden" name="frm" value="sb"/>';
    $output .= '<td>';
    $output .= '<input type="Submit" value="Search"/>';
    $output .= '</td></tr></table>';
    $output .= '</form>';
    $output .= '</center>';
    $output .= '<!-- Search Startpage -->';
    return $output;
}


Then add the following at the end of your LocalSettings.php

 include("extensions/startpagesearch.php");

To use insert

<startpage></startpage>

on any of your wiki pages.