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
ad514b7b
Commit
ad514b7b
authored
3 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
+ keywords
parent
2a510adc
No related branches found
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
+2
-2
2 additions, 2 deletions
Connected.i18n.magic.php
extension.json
+3
-1
3 additions, 1 deletion
extension.json
src/Connected.php
+22
-27
22 additions, 27 deletions
src/Connected.php
with
27 additions
and
30 deletions
Connected.i18n.magic.php
+
2
−
2
View file @
ad514b7b
...
...
@@ -2,7 +2,7 @@
$magicWords
=
[];
$magicWords
[
'en'
]
=
[
/*
'connected' => [1, 'LOGGEDIN'],
'u_name' => [1, 'USERNAME'],
*/
'connected'
=>
[
1
,
'LOGGEDIN'
],
'u_name'
=>
[
1
,
'USERNAME'
],
'iflogged'
=>
[
0
,
'ifloggedin'
]
];
This diff is collapsed.
Click to expand it.
extension.json
+
3
−
1
View file @
ad514b7b
...
...
@@ -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
}
This diff is collapsed.
Click to expand it.
src/Connected.php
+
22
−
27
View file @
ad514b7b
...
...
@@ -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'
;
}*/
}
}
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