Extension:UserFunctions/ja

Category:GPL licensed extensions/ja
MediaWiki 拡張機能マニュアル
UserFunctions
リリースの状態: 安定Category:Stable extensions/ja
実装 パーサー関数 Category:Parser function extensions/ja
説明 現在の利用者で発動するパーサー関数のセットを提供する
作者
最新バージョン 2.8.1 (2022-07-20)
MediaWiki 1.35+Category:Extensions with manual MediaWiki version
PHP 7.2+
データベースの変更 いいえ
Composer mediawiki/user-functionsCategory:Extensions supporting Composer/ja
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード Category:Extensions in Wikimedia version control/ja
sandbox.semantic-mediawiki.org
  • $wgUFEnabledPersonalDataFunctions
  • $wgUFAllowedNamespaces
  • $wgUFEnableSpecialContexts
四半期ごとのダウンロード数 26 (Ranked 87th)
translatewiki.net で翻訳を利用できる場合は、UserFunctions 拡張機能の翻訳にご協力ください
Category:All extensions/ja

UserFunctions拡張機能は、現在の利用者で発動する一連の動的パーサー関数を提供します。

使用法

既定では、関数は NS_MEDIAWIKI 名前空間でのみ有効です。他の名前空間で有効にするには下記の例を参照してください。
これらの機能をウィキのサイドバー内で使用する場合、$wgEnableSidebarCache = true; は設定できません。

Functions (always available)

以下の4つの機能は常時使用可能です。

  • {{#ifanon:then|else}}
現在の利用者が匿名かどうかを確認する。
  • {{#ifblocked:then|else}}
現在の利用者がブロックされているかどうかを確認する。
  • {{#ifsysop:then|else}}
現在の利用者がsysopであるかどうかを確認する。
  • {{#ifingroup:group|then|else}}
現在の利用者が"group"グループのメンバーであるかどうかを確認する。 複数のグループにもチェックを入れることができます。
{{#ifingroup:group1, group2, group3|then|else}}

Functions (disabled by default)

以下の5つの個人データ関数は、既定で無効になっています(有効にする方法は、#インストールを参照してください)。

以下に説明する機能を個人データ関数と呼びます。 メールアドレスや本名など、利用者の個人情報の一部が流出する可能性があります。


よく分からない場合は、これを使用しないでください
  • {{#realname:alt}}
現在の利用者の本名を返します。 利用者がログインしていない場合、この関数は与えられた代替テキストを返し、代替テキストが設定されていない場合は利用者IPを返します。
  • {{#username:alt}}
現在の利用者名を返します。 利用者がログインしていない場合、この関数は与えられた代替テキストを返し、代替テキストが設定されていない場合は利用者IPを返します。
  • {{#useremail:alt}}
現在の利用者のメールアドレスを返します。 利用者がログインしていない場合、この関数は与えられた代替テキストを返し、代替テキストが設定されていない場合は利用者IPを返します。
  • {{#nickname:alt}}
現在の利用者のニックネームを返します。 利用者にニックネームがない場合は、利用者名を返します。 利用者がログインしていない場合、この関数は与えられた代替テキストを返し、代替テキストが設定されていない場合は利用者IPを返します。
  • {{#ip:}}
現在の利用者のIPアドレスを返します。

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のUserFunctionsという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UserFunctions
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'UserFunctions' );
    
  • もし、#realname, #username, #useremail, #nickname, #ip のいずれかの関数を使いたい場合は、その行のすぐ後に以下を追加してください。
    $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.
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

名前空間の許可

既定では、利用者関数は NS_MEDIAWIKI 名前空間でのみ動作します。

以下に、他の名前空間での関数の動作を許可または禁止する例を示します。 この構文は、$wgNamespacesWithSubpagesをベースにしています。

// 名前空間 "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;

上記のパラメータは既定で有効になっています。

If you experience any problem with bots or maintenance scripts, turn it to false and report it to this talk page.

バージョン履歴

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-compatible extension - 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 () アルゴリズム

Issues and feature requests

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.

関連項目

Category:Menu extensions/ja Category:Real name display extensions/ja
Category:All extensions/ja Category:Extensions in Wikimedia version control/ja Category:Extensions included in BlueSpice/ja Category:Extensions included in Canasta/ja Category:Extensions included in Miraheze/ja Category:Extensions included in ProWiki/ja Category:Extensions included in WikiForge/ja Category:Extensions included in semantic::core/ja Category:Extensions supporting Composer/ja Category:Extensions with manual MediaWiki version Category:GPL licensed extensions/ja Category:Menu extensions/ja Category:ParserClearState extensions/ja Category:ParserFirstCallInit extensions/ja Category:Parser function extensions/ja Category:Real name display extensions/ja Category:Stable extensions/ja