I think this is really what I want.
I added this 'extension' on test installations MW 1.8.2 and 1.11.0.
Both wikis are installed on a windows host.
Calling the wikis results in the following php warning:
Warning: array_slice() [function.array-slice]:
The first argument should be an array in
...\languages\Language.php on line 1153 (for MW 1.11.0)
This warning occurs in function getMagic:
function getMagic( &$mw ) {
...
line 1153: $mw->mSynonyms = array_slice( $rawEntry, 1 );
}
Creating a test page with {{#iflogged: A | B }}
the 'iflogged' function is not recognized but treated as normal text.
Therefore it doesn't show the wanted result 'A' or 'B' but
the raw page content '{{#iflogged: A | B }}'.
May be there's something missing in the code.
Do you have further hints what's going wrong.
-----Original Message-----
From: Platonides [mailto:Platonides@gmail.com]
Sent: Saturday, October 06, 2007 11:41 PM
To: mediawiki-l(a)lists.wikimedia.org
Subject: Re: [Mediawiki-l] Conditional page content depending
on user is logged in or not
Schmid, Wolfgang wrote:
@Jim
what you propose is a php based solution but I'm a beginner in php
programming and I'm looking for a wiki based solution without
programming own php code if possible.
The following code included from LocalSettigns.php would do:
$wgExtensionFunctions[] = 'wfIsLoggedFunctions';
function wfIsLoggedFunctions() {
global $wgParser, $wgExtIsLoggedFunctions;
$wgExtIsLoggedFunctions = new ExtIsLoggedFunctions();
$wgParser->setFunctionHook( 'iflogged', array(
&$wgExtIsLoggedFunctions , 'ifLogged' ) );
$wgParser->setFunctionHook( 'islogged', array(
&$wgExtIsLoggedFunctions , 'isLogged' ) );
}
class wgExtIsLoggedFunctions
{
function ifLogged( &$parser, $then = '', $else = '' )
{
global $wgUser;
$parser->disableCache();
if ($wgUser->isLoggedIn()) {
return $then;
} else {
return $else;
}
}
function isLogged( &$parser, $then = '', $else = '' )
{
global $wgUser;
$parser->disableCache();
return $wgUser->isLoggedIn();
}
}
?>
Usage:
{{#iflogged: Congratulations, you're a registered user.|You're
anonymous. Go to create an account!}}
I also added #islogged to return the raw boolean value.
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l