MediaWiki 拡張機能マニュアル
リリースの状態: 安定
実装 パーサー関数
説明 Defines a superset of string parser functions that allow character escaping in the 'search for' and 'replace with' arguments.
作者 Jack D. Pond (jpondトーク)
最新バージョン 1.0.1 (2010-06-07)
MediaWiki Tested with 1.14,1.15,1.16A, Should work with all
ライセンス GNU Version 2
四半期ごとのダウンロード数 0
translatewiki.net で翻訳を利用できる場合は、StringFunctionsEscaped 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

この拡張機能でできること edit

Wikitext allows the imbedding of certain control characters (newline, tab, etc.). These parser functions allows the developer to find and manipulate standard c-type escape character sequence (\n,\t, etc.) within wikitext.

These parser functions can be used to make infoblox-type templates and/or forms much more WYSIWIG (see examples) for novice/non-technical users.

使用法 edit

All parser functions are invoked exactly as their string parser functions would be (except with the '_e' appended). They can be used exactly as their counterparts are, even if there are no embedded special characters.

pos_e: (string position) edit


Returns the first position of key inside the given value, or an empty string. If offset is defined, this method will not search the first offset characters.

See: https://php.net/function.strpos

rpos_e: (string position, reverse) edit


Returns the last position of key inside the given value, or -1 if the key is not found. When using this to search for the last delimiter, add +1 to the result to retreive position after the last delimiter. This also works when the delimiter is not found, because "-1 + 1" is zero, which is the beginning of the given value.

See: https://php.net/function.strrpos

pad_e: (pad string) edit


Returns the value padded to the certain length with the given with string. If the with string is not given, spaces are used for padding. The direction may be specified as: 'left', 'center' or 'right'.

See: https://php.net/function.str-pad

replace_e: (string replace) edit


Returns the given value with all occurences of 'from' replaced with 'to'.

See: https://php.net/function.str-replace

explode_e: (explode string) edit


Splits the given value into pieces by the given delimiter and returns the position-th piece. Empty string is returned if there are not enough pieces.

Note: Pieces are counted from 0.
Note: A negative value can be used to count pieces from the end, instead of counting from the beginning. The last piece is at position -1.

See: https://php.net/function.explode

stripnewlines: (remove multiple newlines) edit


Any time there is more than one newline in "value", they are changed to a single newline. This is useful for creating templates with complex but readable wiki text that wont impact on the layout of the calling page.

ダウンロード手順 edit

Download the extension from SVN and place it in $IP/extensions/StringFunctionsEscaped/StringFunctionsEscaped.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

インストール edit

String functions were integrated into Extension:ParserFunctions extension as of r50997. This revision of Extension:ParserFunctions is designed for MediaWiki 1.16, but updating to the trunk version may work on previous versions. If you are using a prior version of Extension:ParserFunctions, you will also have to include Extension:StringFunctions.

Install and test Extension:ParserFunctions and (if necessary) Extension:StringFunctions prior to installing this extension.

This extension must be included AFTER the invocation of the string parser functions. To install this extension, add the following to LocalSettings.php:

MediaWiki 1.15.1 以前 edit


MediaWiki 1.16a 以降 edit

$wgPFEnableStringFunctions = true;  // Note: this must be after ParserFunctions and before StringFunctionsEscaped


pos_e edit

{{#pos_e:Line 1
Line 2
Line 3|\n|7}}



rpos_e edit

{{#rpos_e:Line 1
Line 2
Line 3|\n}}



pad_e edit






replace_e edit

{{#replace_e:Line 1
Line 2
Line 3|\n|<br>\n}}


Line 1<br>
Line 2<br>
Line 3

Which would display as:

Line 1
Line 2
Line 3

Rather than the unescaped:

Line 1 Line 2 Line 3

explode_e edit

{{#explode_e:Line 1
Line 2
Line 3|\n|1}}


Line 2

stripnewlines edit

{{#stripnewlines:Line 1

Line 2

Line 3}}


Line 1
Line 2 
Line 3

Printed version:

Line 1 Line 2 Line 3

関連項目 edit