From f8b947062263de99ed61a462acb5502e451cf53d Mon Sep 17 00:00:00 2001 From: "teromene@teromene.fr" Date: Thu, 11 Feb 2016 15:24:40 +0000 Subject: [PATCH 1/2] Added the possibility to use a global array parameter, that is going to be displayed for every parameter count. --- lib/HTMLUtils.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/HTMLUtils.php b/lib/HTMLUtils.php index dce8b8f0..4e6b5e24 100644 --- a/lib/HTMLUtils.php +++ b/lib/HTMLUtils.php @@ -56,8 +56,28 @@ CARD; } + $hasGlobalParameter = array_key_exists("global", $bridgeElement->parameters); + if($hasGlobalParameter) { + $globalParameters = json_decode($bridgeElement->parameters['global'], true); + } + foreach($bridgeElement->parameters as $parameterName => $parameter) { + + $parameter = json_decode($parameter, true); + + if(!is_numeric($parameterName) && $parameterName == "global") { + + continue; + + } + + if($hasGlobalParameter) { + + $parameter = array_merge($parameter, $globalParameters); + + } + if(!is_numeric($parameterName)) { $card .= '
'.$parameterName.'
' . PHP_EOL; } @@ -65,7 +85,6 @@ CARD; ' . PHP_EOL; - $parameter = json_decode($parameter, true); foreach($parameter as $inputEntry) { From 705b266c284e1d024b2fe0cfd3b2a0d5b7af038e Mon Sep 17 00:00:00 2001 From: "teromene@teromene.fr" Date: Thu, 11 Feb 2016 15:30:10 +0000 Subject: [PATCH 2/2] Updated the documentation. --- CREATE_BRIDGE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CREATE_BRIDGE.md b/CREATE_BRIDGE.md index 7041ec93..9948050c 100644 --- a/CREATE_BRIDGE.md +++ b/CREATE_BRIDGE.md @@ -59,6 +59,8 @@ The array can be a key-based array, but it is not necessary. The following synta $this->parameters[] = ... $this->parameters['First usage of my bridge'] = ... ``` +It is worth mentionning that you can also define a set of parameters that will be applied to every possible utilisation of your bridge. +To do this, just create a parameter array with the `global` key. ### Format specifications