[Mediawiki-l] including a web page

Alistair Johnson JohnsonA at rembrandt.co.nz
Tue Aug 16 20:56:05 UTC 2005


As far as I am aware you have to write the extension yourself.

A simple example of what we do is this snipped below which will embed a html
img tag.

<?php
$wgExtensionFunctions[] = "wfTotalSalesGraph";

function wfTotalSalesGraph() {
    global $wgParser;
    $wgParser->setHook( "totalsalesgraph", "renderTotalSalesGraph" );
}

function renderTotalSalesGraph( $input )
{
    $output = "<nowiki><img
src='/rembrandt/rems/totalsalesgraph.php'></nowiki>";
    return $output;
}
?> 


A more complex example embeds a commercial calendar applet into our
mediawiki pages:
<?php
$wgExtensionFunctions[] = "wfCalendar";

function wfCalendar() {
    global $wgParser;
    $wgParser->setHook( "Calendar", "renderCalendar" );
}

function renderCalendar( $input )
{
    //force any page containing this code not to be cached
    global $wgOut;
    $wgOut->enableClientCache(false);

    //capture output into the buffer
    ob_start();

    //get the ESC calendar output
    require ("d:/mediawiki/escal/showCalendar.php");

    //manipulate the ESC output to allow it to work with MediaWiki
    //1. remove the <script> code & instead add a call to an external .js
file
    //2. replace "\n " with "\n" as MediaWiki interprets a space at the
start of a line
    //3. manipulate the links to previous, current, next months to work with
MediaWiki
    $temp0 = ob_get_contents ();
    $temp1 = str_replace("<script language=\"JavaScript\"
type=\"text/JavaScript\">\n<!--\nfunction popupEvent(ev,w,h) {\n var
winl=(screen.width-w) / 2;\n var wint=(screen.height-h) / 2;\n
win=window.open(\"".$urlPath."popups/escalEV.php?ev=\"+ev+\"&readFile=$readF
ile&readSQL=$readSQL\",\"ESCalendar\",\"scrollbars=yes,status=no,location=no
,toolbar=no,menubar=no,directories=no,resizable=yes,width=\"+w+\",height=\"+
h+\",top=\"+wint+\",left=\"+winl+\"\");\n if (parseInt(navigator.appVersion)
>=4) { win.window.focus();}\n }\n//-->\n</script>", "", $temp0);
    $temp2 = str_replace("\n ", "\n", $temp1);
    $temp3 = str_replace("index.php?", "?", $temp2);
    $temp4 = str_replace("index.php", "?", $temp3);
    $temp5 = str_replace("/?/","/index.php/",$temp4);
    $output = $output = '<script language="JavaScript"
type="text/JavaScript" src="/extensions/escalpopup_js.php"></script>' .
$temp5;

    //dump the current buffer to stop the calendar being displayed twice
    ob_end_clean();
    return $output;
}
?>

Hope that helps, al.

-----Original Message-----
From: Mark Johnson [mailto:crvmp3 at hotmail.com] 

What's the name of the extension or are you saying that we need to custom
write the exention for ourselves?

-----Original Message-----
From: Alistair Johnson

You can include external content through use of an extension that reads the
external page in, processes it in any way you like then outputs it as html
to the wiki engine.  We do this extensively on our mediawiki-based Intranet.

-----Original Message-----
From: jdd [mailto:jdd at dodin.org]

is it possible to include an external web page in mediawiki?

I would like to show an html page as an article and use the discussion page
to discuss it



More information about the MediaWiki-l mailing list