forked from blallo/rss-bridge
Ajout de la possibilité d'avoir une liste en paramètre, voir exemple d'utilisation dans DauphineLibereBridge.
This commit is contained in:
parent
c030d011d2
commit
81f89b1246
3 changed files with 36 additions and 9 deletions
|
@ -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{
|
||||
|
||||
|
|
18
index.php
18
index.php
|
@ -155,10 +155,22 @@ CARD;
|
|||
<input type="hidden" name="action" value="display" />
|
||||
<input type="hidden" name="bridge" value="' . $bridgeReference . '" />' . PHP_EOL;
|
||||
|
||||
foreach($anUse as $argName => $argDescription)
|
||||
foreach($anUse as $argValue)
|
||||
{
|
||||
$idArg = 'arg-' . $bridgeReference . '-' . $anUseNum . '-' . $argName;
|
||||
$card .= '<input id="' . $idArg . '" type="text" value="" placeholder="' . $argDescription . '" name="' . $argName . '" />' . PHP_EOL;
|
||||
$idArg = 'arg-' . $bridgeReference . '-' . $anUseNum . '-' . $argValue['query-name'];
|
||||
if($argValue['type'] == "text") {
|
||||
$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 />';
|
||||
|
|
|
@ -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".
|
||||
|
||||
if( isset($outComment['args']) && is_array($outComment['args']) ){
|
||||
$infos['use'] = array();
|
||||
|
||||
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
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue