Author: Astronouth7303
Description:
You should allow for extensions to define new variables (eg, {{FOO}}).
Version: 1.6.x
Severity: enhancement
• bzimport | |
Sep 10 2005, 11:51 PM |
F2256: patch | |
Nov 21 2014, 8:47 PM |
Author: Astronouth7303
Description:
You should allow for extensions to define new variables (eg, {{FOO}}).
Version: 1.6.x
Severity: enhancement
Astronouth7303 wrote:
Proposed implementation (1.5)
This is my implementation of this bug. It modifies MagicWord.php, Parser.php,
and SpecialVersion.php.
attachment VariableExtensions.patch ignored as obsolete
Astronouth7303 wrote:
Example Extension using the previous implementation
This is an example extension that creates the variable RANDOM. It should be
fairly self-explainatory.
attachment random.php ignored as obsolete
Astronouth7303 wrote:
Proposed implementation (1.5)
Added a few more comments in MagicWord.php
attachment VariableExtensions.patch ignored as obsolete
Astronouth7303 wrote:
Proposed implementation (1.5)
Some phpdoc corrections, other comment changes.
attachment VariableExtensions.patch ignored as obsolete
Astronouth7303 wrote:
I just realized that in Parser.php, it does not cache the result of it in the
static $varCache. (Parser::getVariableValue().)
I'm not sure this would be a bug or a feature.
avarab wrote:
Implementation using the existing hook system
Your implementation of this was overly complex and redundant, we already have
an all purpose hook system in place and there's no need to write a custom one
for this occation when that one will do perfectly. I've commited my own
implementation of this (attached) using the existing system. You can find an
example extension that implements it called Variable_hook.php in the examples
directory in the extensions module in CVS HEAD.
Attached:
Astronouth7303 wrote:
(In reply to comment #6)
Created an attachment (id=1099) [edit]
Implementation using the existing hook systemYour implementation of this was overly complex and redundant, we already have
an all purpose hook system in place and there's no need to write a custom one
for this occation when that one will do perfectly. I've commited my own
implementation of this (attached) using the existing system. You can find an
example extension that implements it called Variable_hook.php in the examples
directory in the extensions module in CVS HEAD.
I was aiming for implementation similar to the parser extensions. (ie, you
register your variable, and the parser calls your function.)
But in hindsight, your version is more flexible in that you could use it to do
simple {{foo:...}} extensions (but no params).