Skip to content
Snippets Groups Projects
Commit f7e30551 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

2e tentative

parent 72d7fccc
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
$magicWords = [];
$magicWords['en'] = [
'connected' => [1, 'LOGGEDIN'],
'u_name' => [1, 'USERNAME'],
/*'connected' => [1, 'LOGGEDIN'],
'u_name' => [1, 'USERNAME'],*/
'iflogged' => [0, 'ifloggedin']
];
......@@ -13,8 +13,7 @@
"ExampleExtensionMagic": "Connected.i18n.magic.php"
},
"Hooks": {
"ParserGetVariableValueSwitch": "ConnectedHooks::onParserFirstCallInit",
"MagicWordwgVariableIDs": "ConnectedHooks::connectedDeclareVarIds"
"ParserFirstCallInit": "ConnectedHooks::onParserFirstCallInit"
},
"manifest_version": 1
}
......@@ -12,13 +12,15 @@ class ConnectedHooks {
public static function onParserFirstCallInit( Parser $parser ) {
// Create a function hook associating the "example" magic word with renderExample()
$parser->setFunctionHook( 'ifloggedin', [ self::class, 'ifConnectedRender' ] );
$parser->setFunctionHook( 'iflogged', [ self::class, 'ifConnectedRender' ] );
}
// Render the output of {{#example:}}.
public static function ifConnectedRender( Parser $parser, $ifLoggedIn = '', $ifNot = '') {
// The input parameters are wikitext with templates expanded.
// The output should be wikitext too.
$output = "ok";/**/
/*
global $wgUser;
if($wgUser->isSafeToLoad()){
if ( $wgUser->isLoggedIn() ) {
......@@ -27,9 +29,14 @@ class ConnectedHooks {
else{
$output = $ifNot;
}
}*/
return $output;
}
}
/* Removed Hooks
,
"ParserGetVariableValueSwitch": "ConnectedHooks::onParserFirstCallInit",
"MagicWordwgVariableIDs": "ConnectedHooks::connectedDeclareVarIds"
public static function wfConnectedAssignValue( Parser $parser, &$cache, &$magicWordId, &$ret ) {
global $wgUser;
......@@ -68,7 +75,4 @@ class ConnectedHooks {
// variable IDs. We oblige by adding ours:
$customVariableIds[] = 'connected';
$customVariableIds[] = 'u_name';
}
}
$wgHooks['MagicWordwgVariableIDs'][] = 'connectedMyDeclareVarIds';
}*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment