From 81f89b12467cb78ab0409a01232e7380a4be0688 Mon Sep 17 00:00:00 2001 From: teromene Date: Mon, 14 Sep 2015 13:59:20 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Ajout=20de=20la=20possibilit=C3=A9=20d'avoi?= =?UTF-8?q?r=20une=20liste=20en=20param=C3=A8tre,=20voir=20exemple=20d'uti?= =?UTF-8?q?lisation=20dans=20DauphineLibereBridge.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridges/DauphineLibereBridge.php | 4 ++-- index.php | 18 +++++++++++++++--- lib/Bridge.php | 23 +++++++++++++++++++---- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/bridges/DauphineLibereBridge.php b/bridges/DauphineLibereBridge.php index ad96130f..9ce39ae2 100644 --- a/bridges/DauphineLibereBridge.php +++ b/bridges/DauphineLibereBridge.php @@ -2,9 +2,9 @@ /** * @name DauphineLibereBridge Bridge * @homepage http://www.ledauphine.com/ -* @description Returns the newest articles. For choice « à la une » leave empty the input. For « France-Monde » input "france-monde". For « Faits Divers » input "faits-divers". For « Economie et Finance » input "economie-et-finance". For « Politique » input "politique". For « Sport » input "sport". For « Ain » input "ain". For « Alpes-de-Haute-Provence » input "haute-provence". For « Hautes-Alpes » input "hautes-alpes". For « Ardèche » input "ardeche". For « Drôme » input "drome". For « Isere Sud » input "isere-sud". For « Isere Nord » input "isere-nord". For « Savoie » input "savoie". For « Haute-Savoie » input "haute-savoie". For « Vaucluse » input "vaucluse". +* @description Returns the newest articles. * @maintainer qwertygc -* @use1(u="edition") +* @use1(list|u="À la une=>;France Monde=>france-monde;Faits Divers=>faits-divers;Économie et Finance =>economie-et-finance;Politique=>politique;Sport=>sport;Ain=>ain;Alpes-de-Haute-Provence=>haute-provence;Hautes-Alpes=>hautes-alpes;Ardèche=>ardeche;Drôme=>drome;Isère Sud=>isere-sud;Isère Nord=>isere-nord;Savoie=>savoie;Haute-Savoie=>haute-savoie;Vaucluse=>vaucluse") */ class DauphineLibereBridge extends BridgeAbstract{ diff --git a/index.php b/index.php index 34c05096..d1429736 100644 --- a/index.php +++ b/index.php @@ -155,10 +155,22 @@ CARD; ' . PHP_EOL; - foreach($anUse as $argName => $argDescription) + foreach($anUse as $argValue) { - $idArg = 'arg-' . $bridgeReference . '-' . $anUseNum . '-' . $argName; - $card .= '' . PHP_EOL; + $idArg = 'arg-' . $bridgeReference . '-' . $anUseNum . '-' . $argValue['query-name']; + if($argValue['type'] == "text") { + $card .= '' . PHP_EOL; + } else if($argValue['type'] == "list") { + $card .= '"; + } + } $card .= '
'; diff --git a/lib/Bridge.php b/lib/Bridge.php index fcb5fbae..f4960b9e 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -266,18 +266,32 @@ class Bridge{ } preg_match_all('#@use(?[1-9][0-9]*)\s?\((?.+)\)(?:\r|\n)#', $commentary, $outComment); // Catch specific information about "use". + if( isset($outComment['args']) && is_array($outComment['args']) ){ $infos['use'] = array(); + foreach($outComment['args'] as $num => $args){ // Each use - preg_match_all('#(?[a-z]+)="(?.*)"(?:,|$)#U', $args, $outArg); // Catch arguments for current use - if( isset($outArg['name']) ){ + + preg_match_all('#(?[a-z]+)\|(?[a-z]+)="(?.*)"(?:,|$)#U', $args, $outArg); // Catch arguments for current use + + if(!isset($outArg['name']) || count($outArg['name']) == 0) { + preg_match_all('#(?[a-z]+)="(?.*)"(?:,|$)#U', $args, $outArg); // Catch arguments + } + + + if( isset($outArg['name'])){ $usePos = $outComment['num'][$num]; // Current use name if( !isset($infos['use'][$usePos]) ){ // Not information actually for this "use" ? $infos['use'][$usePos] = array(); } - + foreach($outArg['name'] as $numArg => $name){ // Each arguments - $infos['use'][$usePos][$name] = $outArg['value'][$numArg]; + $infos['use'][$usePos][$name] = array(); + + $infos['use'][$usePos][$name]['query-name'] = $name; + $infos['use'][$usePos][$name]['value'] = $outArg['value'][$numArg]; + $infos['use'][$usePos][$name]['type'] = $outArg['type'][$numArg]; + } } } @@ -295,3 +309,4 @@ class Bridge{ return $listBridge; } } + From eb2448780719b21b7a737caa64af13c42487ea58 Mon Sep 17 00:00:00 2001 From: teromene Date: Mon, 14 Sep 2015 14:04:38 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Ajout=20d'une=20option=20de=20compatibilit?= =?UTF-8?q?=C3=A9=20pour=20les=20bridges=20n'utilisant=20pas=20le=20nouvea?= =?UTF-8?q?u=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index d1429736..0e9a7524 100644 --- a/index.php +++ b/index.php @@ -158,7 +158,7 @@ CARD; foreach($anUse as $argValue) { $idArg = 'arg-' . $bridgeReference . '-' . $anUseNum . '-' . $argValue['query-name']; - if($argValue['type'] == "text") { + if($argValue['type'] == null || $argValue['type'] == "text") { //If we have no type, treat it as a text field for compatibility $card .= '' . PHP_EOL; } else if($argValue['type'] == "list") { $card .= '