MediaWiki r37956 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r37955‎ | r37956 (on ViewVC)‎ | r37957 >
Date:14:51, 23 July 2008
Author:tstarling
Status:old
Tags:
Comment:
Some documentation for SFH_OBJECT_ARGS
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -3947,6 +3947,9 @@
39483948 * The callback function should have the form:
39493949 * function myParserFunction( &$parser, $arg1, $arg2, $arg3 ) { ... }
39503950 *
 3951+ * Or with SFH_OBJECT_ARGS:
 3952+ * function myParserFunction( $parser, $frame, $args ) { ... }
 3953+ *
39513954 * The callback may either return the text result of the function, or an array with the text
39523955 * in element 0, and a number of flags in the other elements. The names of the flags are
39533956 * specified in the keys. Valid flags are:
@@ -3960,8 +3963,27 @@
39613964 * @param string $id The magic word ID
39623965 * @param mixed $callback The callback function (and object) to use
39633966 * @param integer $flags a combination of the following flags:
3964 - * SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}}
 3967+ * SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}}
39653968 *
 3969+ * SFH_OBJECT_ARGS Pass the template arguments as PPNode objects instead of text. This
 3970+ * allows for conditional expansion of the parse tree, allowing you to eliminate dead
 3971+ * branches and thus speed up parsing. It is also possible to analyse the parse tree of
 3972+ * the arguments, and to control the way they are expanded.
 3973+ *
 3974+ * The $frame parameter is a PPFrame. This can be used to produce expanded text from the
 3975+ * arguments, for instance:
 3976+ * $text = isset( $args[0] ) ? $frame->expand( $args[0] ) : '';
 3977+ *
 3978+ * For technical reasons, $args[0] is pre-expanded and will be a string. This may change in
 3979+ * future versions. Please call $frame->expand() on it anyway so that your code keeps
 3980+ * working if/when this is changed.
 3981+ *
 3982+ * If you want whitespace to be trimmed from $args, you need to do it yourself, post-
 3983+ * expansion.
 3984+ *
 3985+ * Please read the documentation in includes/parser/Preprocessor.php for more information
 3986+ * about the methods available in PPFrame and PPNode.
 3987+ *
39663988 * @return The old callback function for this name, if any
39673989 */
39683990 function setFunctionHook( $id, $callback, $flags = 0 ) {

Status & tagging log

  • 15:29, 12 September 2011 Meno25 (talk | contribs) changed the status of r37956 [removed: ok added: old]