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
f7e30551
Commit
f7e30551
authored
2 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
2e tentative
parent
72d7fccc
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
+1
-2
1 addition, 2 deletions
extension.json
src/Connected.php
+10
-6
10 additions, 6 deletions
src/Connected.php
with
13 additions
and
10 deletions
Connected.i18n.magic.php
+
2
−
2
View file @
f7e30551
...
...
@@ -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
+
1
−
2
View file @
f7e30551
...
...
@@ -13,8 +13,7 @@
"ExampleExtensionMagic"
:
"Connected.i18n.magic.php"
},
"Hooks"
:
{
"ParserGetVariableValueSwitch"
:
"ConnectedHooks::onParserFirstCallInit"
,
"MagicWordwgVariableIDs"
:
"ConnectedHooks::connectedDeclareVarIds"
"ParserFirstCallInit"
:
"ConnectedHooks::onParserFirstCallInit"
},
"manifest_version"
:
1
}
This diff is collapsed.
Click to expand it.
src/Connected.php
+
10
−
6
View file @
f7e30551
...
...
@@ -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
(
'iflogged
in
'
,
[
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'
;
}*/
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