Extension:UserFunctions/ja

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced.svg
UserFunctions
リリースの状態: ベータ
実装 パーサー関数
説明 Provides a set of dynamic parser functions that trigger on the current user
作者 Algorithm, Toniher and others
最新バージョン 2.5.0 (2014-04-01)
MediaWiki 1.12 以降
データベースの変更 いいえ
ライセンス GPLv2 +
ダウンロード
  • $wgUFEnablePersonalDataFunctions
  • $wgUFAllowedNamespaces
  • $wgUFEnableSpecialContexts
translatewiki.net で翻訳を利用できる場合は、UserFunctions 拡張機能の翻訳にご協力ください
使用状況とバージョン マトリクスを確認してください。

The UserFunctions extension provides a set of dynamic parser functions that trigger on the current user.

使用法[edit]

  • {{#ifanon:then|else}} - Tests whether the current user is anonymous.
  • {{#ifblocked:then|else}} - Tests whether the current user is blocked.
  • {{#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}}
  • {{#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 e-mail 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.

By default the personal data functions #realname, #username, #useremail, #nickname and #ip are disabled. See here to see how to enable them.

By default functions are only enabled in NS_MEDIAWIKI namespace, for enabling them in other namespaces, check out the examples below.

If you are using these functions within you wiki's sidebar, you cannot set $wgEnableSidebarCache = true;

インストール[edit]

  • ダウンロードして、ファイルを extensions/ フォルダー内の UserFunctions という名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php の末尾に追加します:
    require_once "$IP/extensions/UserFunctions/UserFunctions.php";
    
  • If you want to use the following functions: #realname, #username, #useremail, #nickname and #ip, add:
    $wgUFEnablePersonalDataFunctions = true;
    
    just after that line.
  • 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」に移動して、拡張機能が正しくインストールされたことを確認します。

Allowing namespaces[edit]

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 UserFunctions in Main Namespace
$wgUFAllowedNamespaces[NS_MAIN] = true;
# User Functions enabled in User Mainspace, but not in Main one.
$wgUFAllowedNamespaces = array(
        NS_MAIN => false,
        NS_USER => true
);
# Enable all User Functions in all NS numbered from 0 to 200
$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 Semantic 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.

バージョン履歴[edit]

Authors: Algorithm and others

  • バージョン 2.5.0 (2014-04-01) Migrated to JSON i18n - Siebrand
  • バージョン 2.4.3 (2014-03-16) Accumulated fixes and code cleaning - Chad and Uckelman
  • バージョン 2.4.2 (2013-04-08) Some code cleaning - Reedy
  • バージョン 2.4.1 (2012-07-17) Fixed problems with Sidebar (report Kghbln). Cleared PHP warnings in functions - Toniher
  • バージョン 2.4 (2012-06-02) Cleaned using current ParserFunctions models. Fix when editing Semantic Forms - Toniher
  • バージョン 2.3 (2012-05-27) fixed problems when using scripts and allowed multiple groups to be checked against in ifingroup. - Toniher
  • バージョン 2.2 (2012-01-03) added $wgUFAllowedNamespaces parameter. Users need to define in which allowed NS functions will work. - Toniher
  • バージョン 2.1 (2011-12-21) added $wgUFEnablePersonalDataFunctions parameter. Migrated $wgUser to ParserOptions equivalent - Toniher
  • バージョン 2.0 (2011-12-13) added i18n and compatibility with other parser function extensions - Toniher
  • バージョン 1.5 (2011-10-30) added ip - Kghbln
  • バージョン 1.4 (2011-09-27) added realname - Kghbln
  • バージョン 1.3 (2010-02-13) added useremail - Wikinaut
  • バージョン 1.2 (2008-07-25) added ifingroup - Louperivois
  • バージョン 1.1 (2008-06-27) added nickname - Lexw
  • バージョン 1.0 (2006-05-21) - Algorithm

関連項目[edit]

言語: English  • 日本語