확장기능:UserFunctions

From mediawiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:UserFunctions and the translation is 17% complete.
Other languages:
English • ‎Türkçe • ‎français • ‎日本語 • ‎한국어
미디어위키 확장 기능 매뉴얼
OOjs UI icon advanced-invert.svg
UserFunctions
출시 상태: 안정
구현 파서 함수
설명 현재 사용자에게 동작하는 일련의 파서 함수 제공
만든이
최신 버전 2.8.0 (2021-04-18)
MediaWiki 1.35+
PHP 7.2+
데이터베이스 변경 아니오
Composer mediawiki/user-functions
라이선스 GNU General Public License 2.0 or later
다운로드
예제 sandbox.semantic-mediawiki.org

  • $wgUFEnablePersonalDataFunctions
  • $wgUFAllowedNamespaces
  • $wgUFEnableSpecialContexts
UserFunctions 확장 기능 번역 (translatewiki.net에서 가능한 경우)

사용법과 버전 매트릭스를 확인합니다.

UserFunctions 확장기능은 현재 사용자에게 동작하는 일련의 동적인 파서 함수를 제공합니다.

사용법

By default functions are only enabled in NS_MEDIAWIKI namespace, for enabling them in other namespaces, see the examples below.
If you are using these functions within you wiki's sidebar, you cannot set $wgEnableSidebarCache = true;.

The following four functions are always available for use:

  • {{#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}}

The following five personal data functions are disabled by default (see #Installation for how to enable them):

The functions described below are called personal data functions. They can be used to leak some of your user's personal data like their email address and real name.


If unsure, do not activate personal data functions.
  • {{#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.

설치

  • Download and place the file(s) in a directory called UserFunctions in your extensions/ folder.
  • 아래의 코드를 LocalSettings.php의 말미에 추가합니다:
    wfLoadExtension( 'UserFunctions' );
    
  • 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’에 이동해서, 확장기능이 올바르게 설치된 것을 확인합니다.

미디어위키 1.35 이하를 실행 중인 사용자에게:

위의 지시사항은 wfLoadExtension()을 사용하여 이 확장기능을 설치하는 새로운 방법을 기술한 것으로, wfLoadExtension( 'UserFunctions' ); 대신 초기 버전(미디어위키 1.35 이하)에 이 확장기능을 설치하려면 다음을 사용해야 합니다:

require_once "$IP/extensions/UserFunctions/UserFunctions.php";

이름공간별 허용 설정

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.

버전 역사

Authors: Algorithm and others

  • Version 2.8.0 (2021-04-18) Convert to ExtensionRegistry and other code cleanups - Universal Omega
  • Version 2.7.0 (2017-07-26) Removed PHP i18n shim - Kghbln
  • Version 2.6.1 (2014-11-15) Provided syntax changes - Kghbln, Umherirrender
  • Version 2.6.0 (2014-09-18) Composer-compatible extension - Toniher
  • Version 2.5.0 (2014-04-01) Migrated to JSON i18n - Siebrand
  • Version 2.4.3 (2014-03-16) Accumulated fixes and code cleaning - Chad and Uckelman
  • Version 2.4.2 (2013-04-08) Some code cleaning - Reedy
  • Version 2.4.1 (2012-07-17) Fixed problems with Sidebar (report Kghbln). Cleared PHP warnings in functions - Toniher
  • Version 2.4 (2012-06-02) Cleaned using current ParserFunctions models. Fix when editing Semantic Forms - Toniher
  • Version 2.3 (2012-05-27) fixed problems when using scripts and allowed multiple groups to be checked against in ifingroup. - Toniher
  • Version 2.2 (2012-01-03) added $wgUFAllowedNamespaces parameter. Users need to define in which allowed NS functions will work. - Toniher
  • Version 2.1 (2011-12-21) added $wgUFEnablePersonalDataFunctions parameter. Migrated $wgUser to ParserOptions equivalent - Toniher
  • Version 2.0 (2011-12-13) added i18n and compatibility with other parser function extensions - Toniher
  • Version 1.5 (2011-10-30) added ip - Kghbln
  • Version 1.4 (2011-09-27) added realname - Kghbln
  • Version 1.3 (2010-02-13) added useremail - Wikinaut
  • Version 1.2 (2008-07-25) added ifingroup - Louperivois
  • Version 1.1 (2008-06-27) added nickname - Lexw
  • Version 1.0 (2006-05-21) Algorithm

같이 보기