From f7e30551a6e0ee165da2a330f9e68e44d0e10072 Mon Sep 17 00:00:00 2001
From: Mathieu Loiseau <mathieu.loiseau@liris.cnrs.fr>
Date: Mon, 9 May 2022 17:18:54 +0200
Subject: [PATCH] 2e tentative

---
 Connected.i18n.magic.php |  4 ++--
 extension.json           |  3 +--
 src/Connected.php        | 16 ++++++++++------
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/Connected.i18n.magic.php b/Connected.i18n.magic.php
index 4d5f911..8f75fd6 100755
--- a/Connected.i18n.magic.php
+++ b/Connected.i18n.magic.php
@@ -2,7 +2,7 @@
 $magicWords = [];
 
 $magicWords['en']  = [
-	'connected'		=> [1, 'LOGGEDIN'],
-	'u_name'		=> [1, 'USERNAME'],
+	/*'connected'		=> [1, 'LOGGEDIN'],
+	'u_name'		=> [1, 'USERNAME'],*/
 	'iflogged'		=> [0, 'ifloggedin']
 ];
diff --git a/extension.json b/extension.json
index 555a7f0..8fd1811 100644
--- a/extension.json
+++ b/extension.json
@@ -13,8 +13,7 @@
 		"ExampleExtensionMagic": "Connected.i18n.magic.php"
 	},
 	"Hooks": {
-		"ParserGetVariableValueSwitch": "ConnectedHooks::onParserFirstCallInit",
-		"MagicWordwgVariableIDs": "ConnectedHooks::connectedDeclareVarIds"
+		"ParserFirstCallInit": "ConnectedHooks::onParserFirstCallInit"
 	},
 	"manifest_version": 1
 }
diff --git a/src/Connected.php b/src/Connected.php
index cefbd88..413ceec 100755
--- a/src/Connected.php
+++ b/src/Connected.php
@@ -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';
+	}*/
-- 
GitLab