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

+ keywords

parent 2a510adc
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,7 +13,9 @@
"ExampleExtensionMagic": "Connected.i18n.magic.php"
},
"Hooks": {
"ParserFirstCallInit": "ConnectedHooks::onParserFirstCallInit"
"ParserFirstCallInit": "ConnectedHooks::onParserFirstCallInit",
"ParserGetVariableValueSwitch": "ConnectedHooks::wfConnectedAssignValue",
"MagicWordwgVariableIDs": "ConnectedHooks::connectedDeclareVarIds"
},
"manifest_version": 1
}
......@@ -10,12 +10,11 @@
class ConnectedHooks {
// Register any render callbacks with the parser
public static function onParserFirstCallInit( Parser $parser ) {
// Create a function hook associating the "example" magic word with renderExample()
$parser->setFunctionHook( 'iflogged', [ self::class, 'ifConnectedRender' ] );
}
// Render the output of {{#example:}}.
// Render the output of {{#ifloggedin:}} i.e. iflogged function.
public static function ifConnectedRender( Parser $parser, $ifLoggedIn = '', $ifNot = '') {
// The input parameters are wikitext with templates expanded.
// The output should be wikitext too.
......@@ -30,47 +29,43 @@ class ConnectedHooks {
}
return [ $output, 'noparse' => false ];
}
}
/* Removed Hooks
,
"ParserGetVariableValueSwitch": "ConnectedHooks::onParserFirstCallInit",
"MagicWordwgVariableIDs": "ConnectedHooks::connectedDeclareVarIds"
public static function wfConnectedAssignValue( Parser $parser, &$cache, &$magicWordId, &$ret ) {
//calcul des variables
public static function wfConnectedAssignValue( Parser $parser, &$cache, $magicWordId, &$ret, $frame) {
global $wgUser;
$result = false;
if($wgUser->isSafeToLoad()){
if ( !$wgUser->isLoggedIn() ) {
switch($magicWordId){
case 'connected' :
switch($magicWordId){
case 'connected' :
if ( !$wgUser->isLoggedIn() ) {
$ret = 0;
$result = true;
break;
case 'u_name':
$ret = $wgUser->getName();
$result = true;
break;
}
}
else{
switch($magicWordId){
case 'connected' :
}
else{
$ret = 1;
$result = true;
break;
case 'u_name':
}
break;
case 'u_name':
if ( !$wgUser->isLoggedIn() ) {
$ret = $wgUser->getName();
$result = true;
}
else{
$ret = $wgUser->getName();
$result = true;
break;
}
}
break;
}
}
return $result;
}
function connectedDeclareVarIds( &$customVariableIds ) {
//mettre à jour la liste de variables
public static function connectedDeclareVarIds( &$customVariableIds ) {
// $customVariableIds is where MediaWiki wants to store its list of custom
// variable IDs. We oblige by adding ours:
$customVariableIds[] = 'connected';
$customVariableIds[] = 'u_name';
}*/
}
}
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