Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Extension:StringFunctionsEscaped

From mediawiki.org

This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored.

If you are interested in taking on the task of developing and maintaining this extension,you can request repository ownership. As a courtesy, you may want to contact the author. You should also remove this template and list yourself as maintaining the extension in the page's {{Extension}} infobox.

MediaWiki extensions manual
StringFunctionsEscaped
Release status: unmaintained
ImplementationParser function
DescriptionDefines a superset of string parser functions that allow character escaping in the 'search for' and 'replace with' arguments.
Author(s)Jack D. Pond (jpondtalk)
Latest version1.0.1 (2010-07-07)
MediaWiki1.16+
LicenseGNU General Public License 2.0 only
Download
README
Example examples
$wgPFEnableStringFunctions
Translate the StringFunctionsEscaped extension if it is available at translatewiki.net
IssuesOpen tasks ·Report a bug

TheStringFunctionsEscaped extension defines a superset of string parser functions that allow character escaping in the 'search for' and 'replace with' arguments.

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.

Usage

[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]

{{#pos_e:value|key|offset}}

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://secure.php.net/function.strpos

rpos_e: (string position, reverse)

[edit]

{{#rpos_e:value|key}}

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://secure.php.net/function.strrpos

pad_e: (pad string)

[edit]

{{#pad_e:value|length|with|direction}}

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://secure.php.net/function.str-pad

replace_e: (string replace)

[edit]

{{#replace_e:value|from|to}}

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

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

explode_e: (explode string)

[edit]

{{#explode_e:value|delimiter|position}}

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://secure.php.net/function.explode

stripnewlines: (remove multiple newlines)

[edit]

{{#stripnewlines:value}}

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 won't impact on the layout of the calling page.

Examples

[edit]

pos_e

[edit]
{{#pos_e:Line 1Line 2Line 3|\n|7}}Returns:13

rpos_e

[edit]
{{#rpos_e:Line 1Line 2Line 3|\n}}Returns:13

pad_e

[edit]
~~{{#pad_e:xox|9|\n|center}}~~Returns:~~ xox ~~

replace_e

[edit]
{{#replace_e:Line 1Line 2Line 3|\n|<br>\n}}Returns:Line 1<br>Line 2<br>Line 3Which would display as:Line 1Line 2Line 3Rather than the unescaped:Line 1 Line 2 Line 3

explode_e

[edit]
{{#explode_e:Line 1Line 2Line 3|\n|1}}Returns:Line 2

stripnewlines

[edit]
{{#stripnewlines:Line 1Line 2Line 3}}Returns:Line 1Line 2 Line 3Printed version:Line 1 Line 2 Line 3

Installation

[edit]
  • Download, extract theParserFunctions extension and place the file(s) in a directory calledParserFunctions in yourextensions/ folder.
  • Download and move the extractedStringFunctionsEscaped folder to yourextensions/ directory.
    Developers and code contributors should install the extensionfrom Git instead, using:
    cdextensions/gitclonehttps://gerrit.wikimedia.org/r/mediawiki/extensions/StringFunctionsEscaped
  • Add the following code at the bottom of yourLocalSettings.php file:
    wfLoadExtension('ParserFunctions');$wgPFEnableStringFunctions=true;require_once"$IP/extensions/StringFunctionsEscaped/StringFunctionsEscaped.php";
  • YesDone – Navigate toSpecial:Version on your wiki to verify that the extension is successfully installed.
Retrieved from "https://www.mediawiki.org/w/index.php?title=Extension:StringFunctionsEscaped&oldid=7734645"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp