Erweiterung:UserFunctions
UserFunctions Freigabestatus: stabil |
|
---|---|
Einbindung | Parser-Funktion |
Beschreibung | Provides a set of parser functions that trigger on the current user |
Autor(en) |
|
Letzte Version | 2.8.1 (2022-07-20) |
MediaWiki | 1.35+ |
PHP | 7.2+ |
Datenbankänderungen | Nein |
Composer | mediawiki/user-functions |
Lizenz | GNU General Public License 2.0 oder neuer |
Herunterladen | |
Beispiel | sandbox.semantic-mediawiki.org |
|
|
Quarterly downloads | 16 (Ranked 115th) |
Übersetze die UserFunctions-Erweiterung, wenn sie auf translatewiki.net verfügbar ist | |
The UserFunctions extension provides a set of dynamic parser functions that trigger on the current user.
Verwendung
NS_MEDIAWIKI
namespace, for enabling them in other namespaces, see the examples below.$wgEnableSidebarCache = true;
.Functions (always available)
The following four functions are always available for use:
{{#ifanon:then|else}}
- Testet, ob der aktuelle Benutzer anonym ist.
{{#ifblocked:then|else}}
- Testet, ob der aktuelle Benutzer gesperrt ist.
{{#ifsysop:then|else}}
- Tests whether the current user is a sysop.
{{#ifingroup:group|then|else}}
- Tests whether the current user is a member of the group "group". You can check for multiple groups as well:
{{#ifingroup:group1, group2, group3|then|else}}
Functions (disabled by default)
The following five personal data functions are disabled by default (see #Installation for how to enable them):
{{#realname:alt}}
- Returns the current user's real name. If the user is not logged in, this function returns the given alternate text, or the user IP if no alternate is provided.
{{#username:alt}}
- Returns the current username. If the user is not logged in, this function returns the given alternate text, or the user IP if no alternate is provided.
{{#useremail:alt}}
- Returns the current user's email address. If the user is not logged in, this function returns the given alternate text, or the user IP if no alternate is provided.
{{#nickname:alt}}
- Returns the current user's nickname. If the user has no nickname, returns the username. If the user is not logged in, this function returns the given alternate text, or the user IP if no alternate is provided.
{{#ip:}}
- Returns the current user's IP address.
Installation
- Die Erweiterung herunterladen und die Datei(en) in ein Verzeichnis namens
UserFunctions
im Ordnerextensions/
ablegen.
Entwickler und Code-Beitragende sollten stattdessen die Erweiterung von Git installieren, mit:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UserFunctions - Folgenden Code am Ende deiner LocalSettings.php -Datei einfügen:
wfLoadExtension( 'UserFunctions' );
- If you want to use any of the following functions:
#realname
,#username
,#useremail
,#nickname
or#ip
, add the following just after that line:$wgUFEnabledPersonalDataFunctions = [ 'ip', 'nickname', 'realname', 'useremail', 'username', ];
- If you are using an older version of the extension, the functions were included in bulk via:
$wgUFEnablePersonalDataFunctions = true;
- If you want to enable functions in other namespaces apart from
NS_MEDIAWIKI
(default), follow the model of some of the examples below. - Erledigt – Navigiere zu Special:Version in deinem Wiki, um zu überprüfen, ob die Erweiterung erfolgreich installiert wurde.
Für Benutzer, die MediaWiki in der Version 1.35 und früher betreiben:
Die oben stehenden Anweisungen beschreiben die neue Installationsanweisung für diese Erweiterung unter der Verwendung von wfLoadExtension()
.
Wird diese Erweiterung in einer dieser früheren Versionen (MediaWiki 1.35 und früher) – an Stelle von wfLoadExtension( 'UserFunctions' );
– installiert, benutze:
require_once "$IP/extensions/UserFunctions/UserFunctions.php";
Namensräume erlauben
By default, user functions only work in NS_MEDIAWIKI
namespace.
Below there are some examples of allowing or disallowing the functions to work in other namespaces. The syntax is based on the one used with subpages.
// Enable user functions additionally in namespace "Main"
// Adds values to the existing array
$wgUFAllowedNamespaces[NS_MAIN] = true;
// Enable user functions in namespaces "Main" and "User", but not in namespace "MediaWiki"
// Replaces values in the existing array
$wgUFAllowedNamespaces = [
NS_MAIN => true,
NS_USER => true
];
// Enable user functions in namespaces with the indexes from 0 to 200
// Replaces values in the existing array
$wgUFAllowedNamespaces = array_fill( 0, 200, true );
More info on namespace numbering.
In other contexts (recognized as NS -1, but not always a Special Page), such as in Page Forms pages, check you have the following parameter enabled:
$wgUFEnableSpecialContexts = true;
The parameter above is enabled by default.
If you experience any problem with bots or maintenance scripts, turn it to false and report it to this talk page.
Versionsgeschichte
Authors: Algorithm and others
- Version 2.8.1 () Allow disabling/enabling specific personal data functions - Universal Omega
- Prior to this, the
$wgUFEnabledPersonalDataFunctions
configuration variable was named$wgUFEnablePersonalDataFunctions
, and setting it to true would enable all personal data functions, and was only able to enable/disable all of them or none of them.
- Version 2.8.0 () Convert to ExtensionRegistry and other code cleanups - Universal Omega
- Version 2.7.0 () Removed PHP i18n shim - Kghbln
- Version 2.6.1 () Provided syntax changes - Kghbln, Umherirrender
- Version 2.6.0 () Composer-kompatible Erweiterung - Toniher
- Version 2.5.0 () Migrated to JSON i18n - Siebrand
- Version 2.4.3 () Accumulated fixes and code cleaning - Chad Uckelman
- Version 2.4.2 () Some code cleaning - Reedy
- Version 2.4.1 () Fixed problems with Sidebar (report Kghbln). Cleared PHP warnings in functions - Toniher
- Version 2.4 () Cleaned using current ParserFunctions models. Fix when editing Semantic Forms - Toniher
- Version 2.3 () fixed problems when using scripts and allowed multiple groups to be checked against in ifingroup. - Toniher
- Version 2.2 () added $wgUFAllowedNamespaces parameter. Users need to define in which allowed NS functions will work. - Toniher
- Version 2.1 () added $wgUFEnablePersonalDataFunctions parameter. Migrated $wgUser to ParserOptions equivalent - Toniher
- Version 2.0 () added i18n and compatibility with other parser function extensions - Toniher
- Version 1.5 () added ip - Kghbln
- Version 1.4 () added realname - Kghbln
- Version 1.3 () added useremail - Wikinaut
- Version 1.2 () added ifingroup - Louperivois
- Version 1.1 () added nickname - Lexw
- Version 1.0 () Algorithmus
Issues and feature requests
- Please report them on the talk page.
Troubleshooting
- Invalid magic word
If you are getting an error that looks like this Error: invalid magic word 'ifanon'
, then you should try rebuilding the localization cache. The functions within this extension will not load correctly without this extension's localization information within the cache.
Siehe auch
Diese Erweiterung ist in den folgenden Softwarepaketen enthalten und/oder wird von den folgenden Wiki-Farmen, bzw. Wiki-Hostern verwendet: Dies ist keine maßgebliche Liste. Softwarepakete und/oder Wiki-Farmen, bzw. Wiki-Hoster nutzen diese Erweiterung ggf., obwohl sie nicht in dieser Liste enthalten sind. Prüfe daher stets die Nutzung im verwendeten Softwarepaket und/oder bei der Wiki-Farm, bzw. dem Wiki-Hoster. |