PDA

View Full Version : Using with mediawiki?


johnsona
11-30-2004, 03:14 PM
Gidday, I use wikimedia for our Intranet and am looking for a calendar for corporate events. I like the look of ESC, but am unsure if it will work for us. WikiMedia requires extensions to return HTML based on a call to a function e.g.

function renderExample( $input )
{
$output = "<b>here is some text</b>";
return $output;
}

Can I use ESC this way - can I call an ESC function that will return the code which I can then return to WikiMedia?

Regards,

Al.

Alistair Johnson
IT Manager
Rembrandt Suits Ltd

Brian
12-01-2004, 11:10 AM
I'm sure it could be made to work but, not being familiar with wikimedia, I'm not sure how this would be done? You could try the trial version and see what results you can get?

johnsona
12-01-2004, 01:25 PM
Hi Brian, thanks for the quick response. Some background:
MediaWiki first renders all output to a (for example) $output variable. Once the output from the core wiki + extensions has been inserted in the correct order into the $output variable it then returns the result to the client as HTML.

What happens with the trial version of ESC is MediaWiki busily renders output to the $output variable until the ESC function is called to show the calendar (I'm at home and don't have my notes here so can't remember the exact ESC function that is called - but as per the installation/usage notes). The ESC function then returns the HTML code directly to the client, MediaWiki then finishes rendering its content to the $output variable & then returns $output to the client.

What we then end up with is ESC appearing in the top left corner of the page (no matter from where in the page it was called) & the HTML code being absolutely stuffed as ESC is being displayed even before the <html> tag is!

One workaround for me would be to pre-render the ESC output via a scheduled task to a file which I could then include in the MediaWiki $output stream. But this is non-optimal. It would be better to be able to somehow pipe the output from ESC into the $output variable when the ESC function is called.

Does that help? Or are things just murkier after my wandering explanation?

Cheers,

al.

Brian
12-01-2004, 03:43 PM
Have you tried using ob_start before you "require" the calendar then store that data into a variable for display?

johnsona
12-01-2004, 04:19 PM
I have now :-)

Unfortunately mediawiki uses output buffering itself, so while:
ob_start("callback");
require ("escal/showCalendar.php");
$output = ob_get_contents ();
return $output;
works well in showing the calendar where it should be, as soon as I add a
ob_clean();
to stop ESC displaying twice it kills the complete mediawiki output stream.

I haven't seriously used PHP for a couple of years, so maybe I'm just missing something?

Cheers,

al.

johnsona
12-01-2004, 04:23 PM
Ignore previous, I should have used
ob_end_clean();
to just kill the top buffer ;-)

Ok, I'll play some more with this now and see how well it will work in mediawiki.

Thanks for your help.

al.

Brian
12-01-2004, 04:30 PM
Let me know how it goes... :computer:

johnsona
12-07-2004, 05:56 PM
Thanks for your help Brian,

This is now up and working & purchased!

What was necessary was:
1. creation of a new custom tag in MediaWiki (e.g. via /Extensions/exampleextension.php)
The render code for the custom tag to contain:

function renderCalendar( $input )
{
//force any page containing this code not to be displayed
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=$readFile&readSQL=$readSQL\",\"ESCalendar\",\"scrollbars=yes,status=no,location=no,toolbar=no,me nubar=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);
$output = $output = '<script language="JavaScript" type="text/JavaScript" src="/extensions/escalpopup_js.php"></script>' . $temp4;
//dump the current buffer to stop the calendar being displayed twice
ob_end_clean();
return $output;
}

2. creation of /extensions/escalpopup_js.php containing:

<!--
function popupEvent(ev, w, h) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
win = window.open("/escal/popups/escalEV.php?ev=" + ev + "&readFile=1&readSQL=0","ESCalendar","scrollbars=yes,status=no,location=no,toolbar=no,me nubar=no,directories=no,resizable=yes,width=" + w + ",height=" + h + ",top=" + wint + ",left=" + winl + "");
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
//-->

3. Adding the css code for ESC to the css file for the template that MediaWiki is using (in my case /stylesheets/monobook/main.css)

This now works fine for popups. I'm still having problems with mouse overs, but that's non-critical.

Cheers,

al.

fernbuck
10-29-2006, 02:10 AM
I am still trying to get the calendar to install in the upper left corner of my Mediawiki page. But, my question is, did you ever get the mouse-over function to work? Because once I figure this out, that is eventually what I'm going to want it to do.

ve9gra
10-29-2006, 12:10 PM
This post is close to 2 years old... Back then there was no mouse-overs...

This post (http://www.easyphpcalendar.com/forums/showthread.php?t=3917) should help. (Open a new thread if you have problems)