additional check on Bridge's compatibles FORMATS list before showing helperbuttons

If there is errors in compatibles formats list, the malformed formats are skipped.
If there is no compatible format, we use le list of available formats instead.
This commit is contained in:
Badet Aurélien 2016-11-19 00:35:37 +01:00 committed by GitHub
parent 35c9ff85a3
commit 056f2e220d

View File

@ -9,23 +9,29 @@ function displayBridgeCard($bridgeName, $formats, $isActive = true){
// If we have a defined array of compatibles formats : show only helperbuttons for thoses formats.
// If we dont have any defined array of compatibles formats : show helperbuttons for every availables formats.
$compatiblesFormats = array();
if (defined($bridgeClass::FORMATS)&&(count($bridgeClass::FORMATS) > 0)){
$bridgeFormats = $bridgeClass::FORMATS;}
else {$bridgeFormats = $formats};
$bridgeFormats = $bridgeClass::FORMATS;
//check if format exists
foreach($bridgeFormats as $name){
if(in_array($name , $formats){
$compatiblesFormats[] = $name ;
}
}
}
// if no compatible format, nevermind
if (count($compatibles)==0){$compatiblesFormats = $formats};
$getHelperButtonsFormat = function($formats){
$getHelperButtonsFormat = function($compatiblesFormats){
$buttons = '';
foreach($formats as $name){
if(in_array($name , $bridgeFormats){
foreach($compatiblesFormats as $name){
$buttons .= '<button type="submit" name="format" value="'
. $name
. '">'
. $name
. '</button>'
. PHP_EOL;
}
. PHP_EOL;
}
return $buttons;
};