1
0
Fork 0
forked from blallo/rss-bridge

Merge pull request #210 from teromene/master

Add the possibility to have global parameters
This commit is contained in:
Mitsu 2016-02-13 15:15:00 +01:00
commit 9153071a0e
2 changed files with 22 additions and 1 deletions

View file

@ -59,6 +59,8 @@ The array can be a key-based array, but it is not necessary. The following synta
$this->parameters[] = ... $this->parameters[] = ...
$this->parameters['First usage of my bridge'] = ... $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 ### Format specifications

View file

@ -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) 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)) { if(!is_numeric($parameterName)) {
$card .= '<h5>'.$parameterName.'</h5>' . PHP_EOL; $card .= '<h5>'.$parameterName.'</h5>' . PHP_EOL;
} }
@ -65,7 +85,6 @@ CARD;
<input type="hidden" name="action" value="display" /> <input type="hidden" name="action" value="display" />
<input type="hidden" name="bridge" value="' . $bridgeName . '" />' . PHP_EOL; <input type="hidden" name="bridge" value="' . $bridgeName . '" />' . PHP_EOL;
$parameter = json_decode($parameter, true);
foreach($parameter as $inputEntry) { foreach($parameter as $inputEntry) {