Extension: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.

''Note: While Winter can be installed along-side parser function extensions without issues, intertwining code from the two systems may have unexpected results. Please check the documentation for details.

Features
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
You are welcome to test out Winter in the Sandbox area.

Download

 * Winter 2.2.1 - Added 03:58, 27 September 2010 (UTC)
 * Winter 2.2.0 - Added 10:46, 21 May 2009 (UTC)
 * Winter 2.1.1 - Added 23:39, 1 November 2007 (UTC)
 * Winter 2.1.0 - Added 11:27, 2 September 2007 (UTC)
 * Winter 2.0.2 - Added 11:49, 12 August 2007 (UTC)
 * Winter 2.0.1 - Added 01:33, 11 August 2007 (UTC)
 * Winter 2.0.0 - Added 13:04, 4 August 2007 (UTC)
 * Winter 1.5.0 - Added 03:04, 12 January 2006 (UTC)
 * Winter 1.4.1 - Added 11:55, 2 January 2006 (UTC)
 * Winter 1.4.0 - Added 10:32, 2 January 2006 (UTC)
 * Winter 1.3 - Added 10:25, 6 December 2005 (UTC)
 * Winter 1.2 - Added 19:23, 23 November 2005 (UTC)
 * Winter 1.1 - Added 05:06, 18 November 2005 (UTC)
 * Winter 1.0 - Added 09:04, 16 November 2005 (UTC)

Quick Installation

 * 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!

Documentation
Extensive documentation is available.

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

Will return . foobar1 .. foobar2 .. foobar3 .. foobar4 .. foobar5.

Example 2
Template parameters can be accessed easily

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

Example 4 - Creating a Calendar
This example is too large to include on this page.

View Example 4

v2.2.1

 * 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

v2.2.0

 * 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)

v2.1.1

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

v2.1.0

 * 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

v2.0.2

 * Fixed allow_call_time_pass_reference bug
 * Fixed bug with tag
 * Fixed bug when undefined variables were referenced
 * Added alternative comment syntax

v2.0.1

 * 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

v2.0.0

 * 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 &lt;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

v1.5.0

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

v1.4.1

 * &lt;nowinter> tag added to replace #noeval command

v1.4.0

 * 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.

v1.3

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

v1.2
and are now equivalent, as are  and  (an all other operators), assuming a has already been defined by a #setvar or #var command.
 * Introduced new shortcut syntax for variables:

v1.1

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

v1.0

 * Original Public release

Updates by RSS
Winter updates are published on my blog.

RSS Feed

User feedback desired
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.