From MediaWiki.org
Jump to navigation Jump to search
MediaWiki 拡張機能マニュアルManual:Extensions
Crystal Clear action run.svg

リリースの状態:Extension status 安定

実装Template:Extension#type Extended syntax, Parser extension, Tag
説明Template:Extension#description Adds an interpreted language to MediaWiki
作者Template:Extension#username Swiftly Tilting (Frantiktalk)
最新バージョンTemplate:Extension#version 2.2.1 (03:58, 27 September 2010 (UTC))
MediaWikiTemplate:Extension#mediawiki 1.5 以降 (1.15.1 で動作確認済)
ライセンスTemplate:Extension#license GNU GPL
ダウンロード Winter.2.2.1.zip
* $wgWinterNamespaces
  • $wgWinterMaxNesting
  • $wgWinterMaxOperations
  • $wgWinterMaxIterations
  • $wgWinterNotAllowed
* <winterprewiki>
  • <nowinter>

translatewiki.net で翻訳を利用できる場合は、Winter 拡張機能の翻訳にご協力ください

使用状況とバージョン マトリクスを確認してください。


Winter (Wiki Interpreter) is an extension which adds an interpreted language to MediaWiki pages. It is intended to enhance the templating system but can be used on any page.

注記: While Winter can be installed along-side パーサー関数 extensions without issues, intertwining code from the two systems may have unexpected results. Please check the documentation for details.


Features of the Winter language include:

  • Simple syntax
  • Alphanumeric variables & arrays
  • if-then-else conditional statement
  • for and while conditional loops
  • User definable functions (in Winter and PHP)
  • Basic arithmetic
  • String manipulation

Try out Winter[edit]

You are welcome to test out Winter in the Sandbox area.


Quick Installation[edit]

  1. Place Winter.php in your wiki's extensions directory.
  2. Add require_once("extensions/Winter.php"); to the bottom of LocalSettings.php
  3. You're done!


Extensive documentation is available.


例 1[edit]

This example demonstrates the use of defined functions, for loops, and variable assignment

{{#function | foo || " foobar{{#1}} " }}

{{#for | {{#a = 1}} || {{#a <=  5}} || {{#a ++}} ||
.{{#foo | {{#a}} }}.                                                                                        

Will return

. foobar1 .. foobar2 .. foobar3 .. foobar4 .. foobar5 .

例 2[edit]

Template parameters can be accessed easily

{{#if| {{{1}}} || First parameter is set to:{{{1}}} || First parameter not set }}

Using the code above in a template will return First parameter is set to:param1 if the template is called with a first paramter set to param1 (eg [[Template:xyz|param1]]). If the first parameter is blank or not used, the template would return nothing.

例 3 - 99 Bottles of Beer on the Wall[edit]

{{#function | formatNum ||
   {{#if | {{#1}} || {{#1}} || no more }} bottle{{#if | {{#1 == 1}} || || s}}

{{#for | {{#i @= 99}} || {{#i >= 0}} || {{#i --}} ||  
   {{#bottles | @= | {{#formatNum | {{#i}} }} }}
   {{#ucfirst | {{#bottles}} }} of beer on the wall, {{#bottles}} of beer.<br />
   {{#if | {{#i}} ||
      Take one down and pass it around, {{#formatNum| {{#i - 1}} }}
      Go to the store and buy some more, 99 bottles
   }} of beer on the wall.<br /><br />

例 4 - Creating a Calendar[edit]

This example is too large to include on this page.

例 4 を閲覧

リリース履歴 & 更新履歴[edit]

バージョン 2.2.1[edit]

  • added ^o and ^c escape characters
  • added + to allowed characters in function names and functions
  • added #reset_all_vars function
  • added ++ and -- functions
  • fixed bug with #strpos and #substr returning false when it shouldn't
  • added #is_numeric, #is_int and #is_string functions
  • fixed bug with array assignment
  • other minor bug fixes

バージョン 2.2.0[edit]

  • added #include and #include_raw functions
  • fixed bug with long template content introduced in 2.1.1
  • fixed NOTICE of missing variables (some server configs don't supply SCRIPT_URL or SCRIPT_URI)

バージョン 2.1.1[edit]

  • fixed NOTICE of undefined variable
  • fixed count command which would return the incorrect value

バージョン 2.1.0[edit]

  • changed syntax so that carriage returns are ignored if followed by a space
  • added template variable access
  • added time, microtime, date, urlencode, explode, implode, request_var, template_var, to_str, to_int, show_page_text, version, wordwrap, keep_nl
  • added ^. escape char
  • added tag which allows winter to be used before mediawiki processes it
  • added addVar for external user functions to add variables
  • added WinterBeforeProcess and WinterAfterProcess hooks
  • added various information available at runtime such as user name, page name, etc
  • fixed bug with nowinter tag
  • fixed bug when using foreach with noexistent array
  • fixed bugs with & and ? operators (they’re turned into html entities)
  • fixed bug caused by pipes being returned in error messages
  • updated error messages

バージョン 2.0.2[edit]

  • Fixed allow_call_time_pass_reference bug
  • Fixed bug with <nowinter> tag
  • Fixed bug when undefined variables were referenced
  • Added alternative comment syntax

バージョン 2.0.1[edit]

  • Fixed some bugs with #eval
  • Changed the | (bitwise or) operator to ? since | is a reserved symbol in Winter
  • Improved #comment so that it does not evaluate code
  • Improved the escape character system

バージョン 2.0.0[edit]

  • fixed bug in operation count which severely under counted operations
  • fixed bug when trying to loop inside of a function
  • improved #if so that it does not evaluate all parameters unnecessarily
  • improved <nowinter> tag
  • improved error messages
  • deprecated #define in favor of #str_replace_all
  • deprecated #default in favor of #set_param_default
  • added ability to nest control structures
  • added installation settings $wgWinterMaxNesting, $wgWinterMaxOperations, $wgWinterMaxIterations, $wgWinterNotAllowed
  • added external function definition support
  • added charachters - and $ to acceptable function and variable name characters, also explicitly defined _
  • added @ (silence) modifier for variable assignment operators
  • added <- and <=> variable assignment operators
  • added & | xor << >> bitwise operators
  • added ^ arithmetic operator
  • added #add, #subtract, #multiply, #divide arithmetic functions
  • added #strtoupper, #strtolower, #ucfirst, #trim, #ltrim, #rtrim, #strip_tags string functions
  • added #comment as another name for #null
  • added #debug for easy debugging stub display
  • added #rand function
  • added #html_to_xml and #xml_xpath xml function
  • added array variable type (2 dimensions maximum)
  • added #foreach loop construct for traversing arrays
  • added []= and [][]= operators for array assignment
  • added #count, #array_rand, #array_rand_value, #sort, #rsort, #asort, #arsort, #natsort, #ksort, #krsort array functions

バージョン 1.5.0[edit]

  • Added new shortcut syntax: {{#command param1 param2 ... paramN}} is the same as {{#command| #param1 | #param2 | ... | paramN }}. Each span of whitespace is converted to a pipe character. This is especially useful for math operations: {{#op 1 + 1}} = {{#op| 1 | +| 1}}
  • #op can now accept any amount of operations. However, the order of operations is only left to right. ie {{#op 2 - 2 * 3}} will return 0 and not 4.
  • Added #formula command
  • Added #eval command
  • Added #repeat command
  • fixed some bugs in #strpos

バージョン 1.4.1[edit]

  • <nowinter> tag added to replace #noeval command

バージョン 1.4.0[edit]

  • Added #noeval command to allow Winter code to be displayed without being evaluated.
  • Reworked escape character code. Escape characters are now only translated inside of a Winter command instead of anywhere on the page. This ensures that users who are unaware Winter is installed are not confused.
  • #define actually works now.
  • Switched to x.y.z version numbering system.

バージョン 1.3[edit]

  • Fixed problems with certain commands inside of a for loop. Also fixed the problem with newlines in variable values.
  • Added mod (modulus) operator.

バージョン 1.2[edit]

  • Introduced new shortcut syntax for variables:
    {{#a}} and {{#var|a}} are now equivalent, as are {{#a|+|1}} and {{#var|a|+|1}} (an all other operators), assuming a has already been defined by a #setvar or #var command.

バージョン 1.1[edit]

  • Fixed a few bugs
    • Nesting didn't always work right depending on syntax
    •  != didn't work

バージョン 1.0[edit]

  • Original Public release

Updates by RSS[edit]

Winter updates are published on my blog.

RSS Feed

User feedback desired[edit]

Please feel free to submit feedback either on the talk pages here on mediawiki.org or leave a comment on my blog. You may also find my email address inside the Winter.php file. Questions, comments, bug reports, example code, etc are all welcome. I'm also interested to know for what purpose you are using Winter; let me know your site name and I'll give you a shout out on my blog.

言語:Project:Language policy English  • 日本語