From 81f89b12467cb78ab0409a01232e7380a4be0688 Mon Sep 17 00:00:00 2001 From: teromene Date: Mon, 14 Sep 2015 13:59:20 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20possibilit=C3=A9=20d'avoir=20?= =?UTF-8?q?une=20liste=20en=20param=C3=A8tre,=20voir=20exemple=20d'utilisa?= =?UTF-8?q?tion=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; } } +