Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Connected
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathieu Loiseau
Connected
Commits
c666fb76
Commit
c666fb76
authored
2 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
LOGGEDIN & USERNAME = OK
parent
e6d4cd30
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Connected.i18n.magic.php
+8
-0
8 additions, 0 deletions
Connected.i18n.magic.php
Connected.php
+59
-0
59 additions, 0 deletions
Connected.php
README.md
+2
-1
2 additions, 1 deletion
README.md
with
69 additions
and
1 deletion
Connected.i18n.magic.php
0 → 100644
+
8
−
0
View file @
c666fb76
<?php
$magicWords
=
[];
$magicWords
[
'en'
]
=
[
'connected'
=>
[
1
,
'LOGGEDIN'
],
'u_name'
=>
[
1
,
'USERNAME'
],
'iflogged'
=>
[
0
,
'ifloggedin'
]
];
This diff is collapsed.
Click to expand it.
Connected.php
0 → 100644
+
59
−
0
View file @
c666fb76
<?php
/**
* Connected
*
* @license GPL
* @package Connected
* @link https://gitlab.liris.cnrs.fr/mloiseau/mw_connected
*
**/
$wgExtensionMessagesFiles
[
'Connected'
]
=
__DIR__
.
'/Connected.i18n.magic.php'
;
$wgHooks
[
'ParserGetVariableValueSwitch'
][]
=
'wfConnectedAssignValue'
;
function
wfConnectedAssignValue
(
&
$parser
,
&
$cache
,
&
$magicWordId
,
&
$ret
)
{
global
$wgUser
;
$result
=
false
;
if
(
$wgUser
->
isSafeToLoad
()){
if
(
!
$wgUser
->
isLoggedIn
()
)
{
switch
(
$magicWordId
){
case
'connected'
:
$ret
=
0
;
$result
=
true
;
break
;
case
'u_name'
:
$ret
=
$wgUser
->
getName
();
$result
=
true
;
break
;
}
}
else
{
switch
(
$magicWordId
){
case
'connected'
:
$ret
=
1
;
$result
=
true
;
break
;
case
'u_name'
:
$ret
=
$wgUser
->
getName
();
$result
=
true
;
break
;
}
}
}
return
$result
;
}
$wgExtensionCredits
[
'variable'
][]
=
[
'name'
=>
'Connected'
,
'author'
=>
'Mathieu Loiseau'
,
'version'
=>
'0'
,
'description'
=>
'A small mediawiki extension to have a variable to know if the user is logged in or not.'
,
'url'
=>
'https://gitlab.liris.cnrs.fr/mloiseau/mw_connected'
,
];
$wgHooks
[
'MagicWordwgVariableIDs'
][]
=
'connectedMyDeclareVarIds'
;
function
connectedMyDeclareVarIds
(
&
$customVariableIds
)
{
// $customVariableIds is where MediaWiki wants to store its list of custom
// variable IDs. We oblige by adding ours:
$customVariableIds
[]
=
'connected'
;
$customVariableIds
[]
=
'u_name'
;
}
This diff is collapsed.
Click to expand it.
README.md
+
2
−
1
View file @
c666fb76
...
@@ -14,9 +14,10 @@ full text and terms of the license.
...
@@ -14,9 +14,10 @@ full text and terms of the license.
Connected is an extension to MediaWiki that provides elements to adapt the content of a page to the user (or lack thereof).
Connected is an extension to MediaWiki that provides elements to adapt the content of a page to the user (or lack thereof).
The extension defines the following parser functions and variables:
The extension defines the following parser functions and variables:
*
``
connected
``
:
``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, empty string 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
## Installation
TODO
TODO
To install the extension, place the entire 'Cargo' directory within
To install the extension, place the entire 'Cargo' directory within
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment