From 056f2e220ddbddb9279df0f42738e6d12f347f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Badet=20Aur=C3=A9lien?= Date: Sat, 19 Nov 2016 00:35:37 +0100 Subject: [PATCH] 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. --- lib/html.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/html.php b/lib/html.php index c58228cb..55591259 100644 --- a/lib/html.php +++ b/lib/html.php @@ -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 .= '' - . PHP_EOL; - } + . PHP_EOL; } - return $buttons; };