<php> /* Récupère les données du plugin:data Ne prend que les fiches de class “association” Permet le filtrage avec un paramtre dans l'url: datafilter=epn ⇒ seuls les assos avec epn sont affichées */

$dataPluginFile = DOKU_PLUGIN.'data/syntax/table.php'; if(!file_exists($dataPluginFile)){ msg('Cannot find Data plugin.', -1); } require_once $dataPluginFile; $pdt = new syntax_plugin_data_table();

$data = array( 'classes' ⇒ 'association', 'limit' ⇒ 0, 'dynfilters' ⇒ false, 'summarize' ⇒ false, 'rownumbers' ⇒ false, 'sepbyheaders' ⇒ false, 'headers' ⇒ array(), 'widths' ⇒ array(), 'filter' ⇒ array() );

if( isset($_REQUEST['datafilter']) && $_REQUEST['datafilter']=='epn' ) {

$flt = $pdt->dthlp->_parse_filter('epn=oui');
$flt['logic'] = 'AND' ;
$data['filter'][] = $flt;

}

$column = $pdt→dthlp→_column('%pageid%'); $data['cols'][$column['key']] = $column; $column = $pdt→dthlp→_column('lat'); $data['cols'][$column['key']] = $column; $column = $pdt→dthlp→_column('lon'); $data['cols'][$column['key']] = $column; $column = $pdt→dthlp→_column('nom'); $data['cols'][$column['key']] = $column; $column = $pdt→dthlp→_column('adresse1'); $data['cols'][$column['key']] = $column; $column = $pdt→dthlp→_column('adresse2'); $data['cols'][$column['key']] = $column; $column = $pdt→dthlp→_column('adresse3'); $data['cols'][$column['key']] = $column; $column = $pdt→dthlp→_column('codepostal'); $data['cols'][$column['key']] = $column; $column = $pdt→dthlp→_column('ville'); $data['cols'][$column['key']] = $column; $column = $pdt→dthlp→_column('web'); $data['cols'][$column['key']] = $column; $sql = $pdt→_buildSQL($data); $sqlite = $pdt→dthlp→_getDB(); $res = $sqlite→query($sql); $rows = $sqlite→res2arr($res); $rowsCount = count($rows);

echo '{ “type”:“FeatureCollection”, “features”: ['.“\n”; foreach( $rows as $n ⇒ $row ){ $rowsCount – ; list($pageid, $lat, $lon, $nom, $adr1, $adr2, $adr3, $cp, $ville, $web) = array_values($row); le plugin export_text vire tous les tags html donc pas possible de formater les informations $addresse = $adr1.' '.$adr2.' '.$adr3.' '.$cp.' '.$ville ; echo '{“type”:“Feature”,“properties”:{ “name”:“'.$nom.'”, “address”:“'.$addresse.'”,“web”:“'.$web.'”,“page”:“'.$pageid.'” }, “geometry”:{“type”:“Point”,“coordinates”:[“'.trim($lon).'”,“'.trim($lat).'”]} }'; if( $rowsCount>0 ) echo ','; } echo '] }'.“\n”; </php>