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

Documentation

parent ad514b7b
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
A small mediawiki extension to have a variable to know if the user is connected or not. A small mediawiki extension to have a variable to know if the user is connected or not.
Version 0 Version 0.1
Mathieu Loiseau Mathieu Loiseau
This is free software licensed under the GNU General Public License. Please This is free software licensed under the GNU General Public License. Please
...@@ -15,18 +15,19 @@ Connected is an extension to MediaWiki that provides elements to adapt the conte ...@@ -15,18 +15,19 @@ Connected is an extension to MediaWiki that provides elements to adapt the conte
The extension defines the following parser functions and variables: The extension defines the following parser functions and variables:
* ``LOGGEDIN`` : ``1`` if the user is logged in, ``0`` otherwise ; * ``LOGGEDIN`` : ``1`` if the user is logged in, ``0`` otherwise ;
* ``USERNAME`` : the user's screen name, if they are logged in, empty string otherwise ; * ``USERNAME`` : the user's screen name, if they are logged in, their ip address otherwise ;
* ``#ifloggedin`` : displays the first parameter if the user is logged in, the second otherwise. * ``#ifloggedin`` : displays the first parameter if the user is logged in, the second otherwise.
## Installation The extension hides the sidebar for not logged in users.
TODO
To install the extension, place the entire 'Cargo' directory within
your MediaWiki 'extensions' directory, then add the following line to
your 'LocalSettings.php' file:
wfLoadExtension( 'Cargo' );
Then, go to core MediaWiki's /maintenance directory, and call the It also provides two css depending on the status of the user :
following: * ``MediaWiki:NotLoggedIn.css``
* ``MediaWiki:LoggedIn.css``
php update.php ## Installation
To install the extension, place the entire 'Connected' directory within
your MediaWiki `extensions` directory, then add the following line to
your `LocalSettings.php` file:
```php
wfLoadExtension( 'Connected' );
```
{ {
"name": "Connected", "name": "Connected",
"author": "Mathieu Loiseau", "author": "Mathieu Loiseau",
"version": "0.0", "version": "0.1",
"url": "https://gitlab.liris.cnrs.fr/mloiseau/mw_connected", "url": "https://gitlab.liris.cnrs.fr/mloiseau/mw_connected",
"descriptionmsg": "A small mediawiki extension to have a variable to know if the user is logged in or not.",
"license-name": "GPL-2.0-or-later", "license-name": "GPL-2.0-or-later",
"descriptionmsg": "connected-desc",
"type": "parserhook", "type": "parserhook",
"MessagesDirs": {
"Connected": [
"i18n"
]
},
"AutoloadClasses": { "AutoloadClasses": {
"ConnectedHooks": "src/Connected.php" "ConnectedHooks": "src/Connected.php"
}, },
...@@ -15,7 +20,9 @@ ...@@ -15,7 +20,9 @@
"Hooks": { "Hooks": {
"ParserFirstCallInit": "ConnectedHooks::onParserFirstCallInit", "ParserFirstCallInit": "ConnectedHooks::onParserFirstCallInit",
"ParserGetVariableValueSwitch": "ConnectedHooks::wfConnectedAssignValue", "ParserGetVariableValueSwitch": "ConnectedHooks::wfConnectedAssignValue",
"MagicWordwgVariableIDs": "ConnectedHooks::connectedDeclareVarIds" "MagicWordwgVariableIDs": "ConnectedHooks::connectedDeclareVarIds",
"SkinBuildSidebar": "ConnectedHooks::lfHideSidebar",
"BeforePageDisplay": "ConnectedHooks::add_NotLoggedIncss"
}, },
"manifest_version": 1 "manifest_version": 1
} }
{"@metadata": {
"authors": [
"Loizbek"
]
},
"connected-desc": "Small mediawiki to have a different view for logged-in users.\n*Hides the side-bar for external users.\n* Provides differentiated css [[MediaWiki:NotLoggedIn.css]] and [[MediaWiki:LoggedIn.css]] loaded accordingly.\n*Also provides <code><nowiki>{{LOGGEDIN}}</nowiki></code>, <code><nowiki>{{USERNAME}}</nowiki></code> [https://www.mediawiki.org/wiki/Help:Magic_words/en magic words] and <code><nowiki>{{#ifloggedin:yes|no}}</nowiki></code> [https://www.mediawiki.org/wiki/Manual:Parser_functions/en parser function]."
}
{"@metadata": {
"authors": [
"Loizbek"
]
},
"connected-desc": "Petite extension mediawiki pour un affichage différent selon que l'utilisateur est connecté ou non.\n* Supprime la barre latérale pour les utilisateurs non connectés ;\n* Fournit des css différentiées [[MediaWiki:NotLoggedIn.css]] et [[MediaWiki:LoggedIn.css]].\n* Fournit les ''[https://www.mediawiki.org/wiki/Help:Magic_words/fr mots magiques]'' <code><nowiki>{{LOGGEDIN}}</nowiki></code>, <code><nowiki>{{USERNAME}}</nowiki></code> et la ''[https://www.mediawiki.org/wiki/Manual:Parser_functions/fr fonction d'analyse]'' <code><nowiki>{{#ifloggedin:yes|no}}</nowiki></code>."
}
...@@ -68,4 +68,38 @@ class ConnectedHooks { ...@@ -68,4 +68,38 @@ class ConnectedHooks {
$customVariableIds[] = 'connected'; $customVariableIds[] = 'connected';
$customVariableIds[] = 'u_name'; $customVariableIds[] = 'u_name';
} }
#Cacher la barre de menu quand on n'est pas logué et charger une css supplémentaire
//https://www.mediawiki.org/wiki/Manual:Interface/Sidebar#Change_sidebar_content_when_logged_in_(PHP)
//https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
public static function lfHideSidebar( $skin, &$bar ) {
global $wgUser;
// Hide sidebar for anonymous users
if ( !$wgUser->isLoggedIn() ) {
$bar = array(
'navigation' => array(
array(
'text' => wfMessage( 'login' ) -> text(),
'href' => SpecialPage::getTitleFor( 'Login' )->getLocalURL(),
'id' => 'n-login',
'active' => ''
)
)
);
}
return true;
}
#Ajouter une feuille de style quand pas connecté
public static function add_NotLoggedIncss( OutputPage $out, Skin $skin ) {
global $wgUser;
if ( !$wgUser->isLoggedIn() ) {
$out->addStyle('/w/index.php?title=MediaWiki:NotLoggedIn.css&action=raw&ctype=text/css');
$out->addMeta( "logged", "no" );
}
else{
$out->addStyle('/w/index.php?title=MediaWiki:LoggedIn.css&action=raw&ctype=text/css');
$out->addMeta( "logged", "yes" );
}
}
} }
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