1
0
Fork 0
forked from blallo/rss-bridge

Merge pull request #156 from teromene/master

Add support for list parameters
This commit is contained in:
Mitsu 2015-10-30 12:26:29 +01:00
commit fcc072170c
3 changed files with 36 additions and 9 deletions

View file

@ -2,9 +2,9 @@
/** /**
* @name DauphineLibereBridge Bridge * @name DauphineLibereBridge Bridge
* @homepage http://www.ledauphine.com/ * @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 * @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{ class DauphineLibereBridge extends BridgeAbstract{

View file

@ -156,10 +156,22 @@ CARD;
<input type="hidden" name="action" value="display" /> <input type="hidden" name="action" value="display" />
<input type="hidden" name="bridge" value="' . $bridgeReference . '" />' . PHP_EOL; <input type="hidden" name="bridge" value="' . $bridgeReference . '" />' . PHP_EOL;
foreach($anUse as $argName => $argDescription) foreach($anUse as $argValue)
{ {
$idArg = 'arg-' . $bridgeReference . '-' . $anUseNum . '-' . $argName; $idArg = 'arg-' . $bridgeReference . '-' . $anUseNum . '-' . $argValue['query-name'];
$card .= '<input id="' . $idArg . '" type="text" value="" placeholder="' . $argDescription . '" name="' . $argName . '" />' . PHP_EOL; if($argValue['type'] == null || $argValue['type'] == "text") { //If we have no type, treat it as a text field for compatibility
$card .= '<input id="' . $idArg . '" type="text" value="" placeholder="' . $argValue['value'] . '" name="' . $argValue['query-name'] . '" />' . PHP_EOL;
} else if($argValue['type'] == "list") {
$card .= '<select id="' . $idArg . '" name="' . $argValue['query-name'] . '" >' . PHP_EOL;
$optionList = explode(";", $argValue['value']);
foreach($optionList as $option) {
$option = explode("=>", $option);
$card .= "<option value='".$option[1]."'>".$option[0]."</option>";
}
$card .= "</select>";
}
} }
$card .= '<br />'; $card .= '<br />';

View file

@ -266,18 +266,32 @@ class Bridge{
} }
preg_match_all('#@use(?<num>[1-9][0-9]*)\s?\((?<args>.+)\)(?:\r|\n)#', $commentary, $outComment); // Catch specific information about "use". preg_match_all('#@use(?<num>[1-9][0-9]*)\s?\((?<args>.+)\)(?:\r|\n)#', $commentary, $outComment); // Catch specific information about "use".
if( isset($outComment['args']) && is_array($outComment['args']) ){ if( isset($outComment['args']) && is_array($outComment['args']) ){
$infos['use'] = array(); $infos['use'] = array();
foreach($outComment['args'] as $num => $args){ // Each use foreach($outComment['args'] as $num => $args){ // Each use
preg_match_all('#(?<name>[a-z]+)="(?<value>.*)"(?:,|$)#U', $args, $outArg); // Catch arguments for current use
if( isset($outArg['name']) ){ preg_match_all('#(?<type>[a-z]+)\|(?<name>[a-z]+)="(?<value>.*)"(?:,|$)#U', $args, $outArg); // Catch arguments for current use
if(!isset($outArg['name']) || count($outArg['name']) == 0) {
preg_match_all('#(?<name>[a-z]+)="(?<value>.*)"(?:,|$)#U', $args, $outArg); // Catch arguments
}
if( isset($outArg['name'])){
$usePos = $outComment['num'][$num]; // Current use name $usePos = $outComment['num'][$num]; // Current use name
if( !isset($infos['use'][$usePos]) ){ // Not information actually for this "use" ? if( !isset($infos['use'][$usePos]) ){ // Not information actually for this "use" ?
$infos['use'][$usePos] = array(); $infos['use'][$usePos] = array();
} }
foreach($outArg['name'] as $numArg => $name){ // Each arguments 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; return $listBridge;
} }
} }