Ajout import d'événements depuis l'Agenda du Libre
This commit is contained in:
parent
be7c68a8db
commit
c450d2d236
|
@ -0,0 +1,8 @@
|
||||||
|
LISAY-MOI
|
||||||
|
===
|
||||||
|
|
||||||
|
Installer PHP-XML
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt install php7.4-xml
|
||||||
|
```
|
|
@ -1,9 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('RADIUS', '100km');
|
session_start();
|
||||||
|
define('RADIUS', '100');
|
||||||
|
define('EVENT_RADIUS', '500');
|
||||||
define('BB_URL', 'https://framalistes.org/sympa/info/vannes.monnaielibre');
|
define('BB_URL', 'https://framalistes.org/sympa/info/vannes.monnaielibre');
|
||||||
|
define('CALENDAR_RSS', 'https://www.agendadulibre.org/events.rss?tag=monnaie-libre');
|
||||||
|
define('CALENDAR_URL', 'https://www.agendadulibre.org/events?tag=monnaie-libre');
|
||||||
|
|
||||||
require_once('functions.php');
|
require_once('functions.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
97
index.php
97
index.php
|
@ -1,25 +1,112 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once('lib/Gchange.class.php');
|
||||||
|
|
||||||
|
|
||||||
include('header.php');
|
include('header.php');
|
||||||
|
|
||||||
if (!isset($_POST['city'])) {
|
if (!isset($_POST['city'])) {
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<h2>Où êtes-vous ?</h2>
|
<h2>Ça se passe près de chez vous !</h2>
|
||||||
|
|
||||||
<form method="post" action="mytown.php">
|
<form method="get" action="mytown.php">
|
||||||
<p>
|
<p>
|
||||||
<label>Ville :
|
<label>Ville ou code postal :
|
||||||
<input type="text" name="city" />
|
<input type="text" name="location" />
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" value="Voir tout ce qui se passe de cool autour de chez moi" />
|
<input type="submit" value="Voir les annonces près de chez moi" />
|
||||||
</p>
|
</p>
|
||||||
</form>';
|
</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$gchange = new Gchange();
|
||||||
|
|
||||||
|
$offers = $gchange->getShippable();
|
||||||
|
|
||||||
|
echo '<h2>Livré à votre domicile</h2>';
|
||||||
|
|
||||||
|
echo '<p>Retrouvez ici toutes les annonces pour lesquelles le vendeur a mentionné "envoi possible" dans son annonce.</p>';
|
||||||
|
|
||||||
|
echo '<ol>';
|
||||||
|
foreach ($offers as $offer) {
|
||||||
|
|
||||||
|
$description = isset($offer->_source->description) ? ' title="'. substr($offer->_source->description, 0, 30) . '"' : '';
|
||||||
|
|
||||||
|
echo '
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="https://www.gchange.fr/#/app/market/view/'. $offer->_id . '/"'. $description .'>
|
||||||
|
' . $offer->_source->title . '
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
|
echo '</ol>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$offers = $gchange->getImmaterialOffers();
|
||||||
|
|
||||||
|
echo '<h2>Productions immatérielles</h2>';
|
||||||
|
|
||||||
|
echo '<p>Retrouvez ici formations à distance, coaching, cours, prestations... bref, tout ce qui ressemble plus à de l\'information qu\'à de la matière.</p>';
|
||||||
|
|
||||||
|
echo '<ol>';
|
||||||
|
foreach ($offers as $offer) {
|
||||||
|
|
||||||
|
$description = isset($offer->_source->description) ? ' title="'. substr($offer->_source->description, 0, 30) . '"' : '';
|
||||||
|
|
||||||
|
echo '
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="https://www.gchange.fr/#/app/market/view/'. $offer->_id . '/"'. $description .'>
|
||||||
|
' . $offer->_source->title . '
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
|
echo '</ol>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo '<h2>Prochains événements monnaie libre</h2>';
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<p>
|
||||||
|
Ces événements sont importés automatiquement depuis
|
||||||
|
<a href="'. htmlspecialchars(CALENDAR_URL) .'">
|
||||||
|
l\'Agenda du libre
|
||||||
|
</a>
|
||||||
|
</p>';
|
||||||
|
|
||||||
|
$content = file_get_contents(CALENDAR_RSS);
|
||||||
|
$x = new SimpleXmlElement($content);
|
||||||
|
|
||||||
|
echo '<ul>';
|
||||||
|
|
||||||
|
foreach($x->item as $entry) {
|
||||||
|
|
||||||
|
echo '
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="'. $entry->link .'"
|
||||||
|
title="'. substr(strip_tags($entry->description), 0, 30) . '">
|
||||||
|
|
||||||
|
'. $entry->title . '
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</ul>';
|
||||||
|
|
||||||
include('footer.php');
|
include('footer.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class CesiumPlus {
|
||||||
[
|
[
|
||||||
'geo_distance' => [
|
'geo_distance' => [
|
||||||
|
|
||||||
"distance" => $radius,
|
"distance" => $radius . 'km',
|
||||||
"geoPoint"=> [
|
"geoPoint"=> [
|
||||||
"lat" => $lat,
|
"lat" => $lat,
|
||||||
"lon" => $lon
|
"lon" => $lon
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Gchange {
|
||||||
$this->dao = DAO::getInstance();
|
$this->dao = DAO::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNearbyOffers ($lat, $lon, $max, $min = NULL) {
|
public function getNearbyOffers ($lat, $lon, $maxDistance, $minDistance = NULL) {
|
||||||
|
|
||||||
$n = 20;
|
$n = 20;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class Gchange {
|
||||||
[
|
[
|
||||||
'geo_distance' => [
|
'geo_distance' => [
|
||||||
|
|
||||||
"distance" => "50km",
|
"distance" => $maxDistance . 'km',
|
||||||
"geoPoint"=> [
|
"geoPoint"=> [
|
||||||
"lat" => $lat,
|
"lat" => $lat,
|
||||||
"lon" => $lon
|
"lon" => $lon
|
||||||
|
|
146
mytown.php
146
mytown.php
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
require_once('config.php');
|
require_once('config.php');
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,9 +10,9 @@ $gchange = new Gchange();
|
||||||
$cesiumPlus = new CesiumPlus();
|
$cesiumPlus = new CesiumPlus();
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST['city'])) {
|
if (isset($_GET['location'])) {
|
||||||
|
|
||||||
$_SESSION['city'] = $_POST['city'];
|
$_SESSION['location'] = $_GET['location'];
|
||||||
|
|
||||||
$streamContext = stream_context_create(
|
$streamContext = stream_context_create(
|
||||||
array(
|
array(
|
||||||
|
@ -24,14 +23,14 @@ if (isset($_POST['city'])) {
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$url = 'http://nominatim.openstreetmap.org/search?q='. urlencode($_POST['city']) . '&format=json';
|
$url = 'http://nominatim.openstreetmap.org/search?q='. urlencode($_GET['location']) . '&format=json';
|
||||||
|
|
||||||
$citiesJson = file_get_contents($url, false, $streamContext);
|
$citiesJson = file_get_contents($url, false, $streamContext);
|
||||||
$cities = json_decode($citiesJson);
|
$cities = json_decode($citiesJson);
|
||||||
|
|
||||||
$_SESSION['lat'] = $cities[0]->lat;
|
$_SESSION['lat'] = $cities[0]->lat;
|
||||||
$_SESSION['lon'] = $cities[0]->lon;
|
$_SESSION['lon'] = $cities[0]->lon;
|
||||||
$_SESSION['city'] = htmlspecialchars($_POST['city']);
|
$_SESSION['location'] = htmlspecialchars($_GET['location']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,25 +39,82 @@ if (isset($_POST['city'])) {
|
||||||
include('header.php');
|
include('header.php');
|
||||||
|
|
||||||
|
|
||||||
echo '<h2>Événements à venir près de '. $_SESSION['city'] . '</h2>';
|
echo '<h2>Événements à '. EVENT_RADIUS .' km autour de '. $_SESSION['location'] . '</h2>';
|
||||||
|
|
||||||
|
$feedUrl = 'https://www.agendadulibre.org/events.rss?tag=monnaie-libre&near[distance]='. EVENT_RADIUS . '&near[location]=['. $_SESSION['lat'] . ','. $_SESSION['lon'] . ']';
|
||||||
|
$content = @file_get_contents($feedUrl);
|
||||||
|
$x = new SimpleXmlElement($content);
|
||||||
|
|
||||||
echo '<p>Pas d\'événement prévu en ce moment.</p>';
|
echo '<ul>';
|
||||||
|
|
||||||
|
foreach($x->item as $entry) {
|
||||||
|
|
||||||
|
echo '
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="'. $entry->link .'"
|
||||||
|
title="'. substr(strip_tags($entry->description), 0, 60) . '">
|
||||||
|
|
||||||
|
'. $entry->title . '
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
|
||||||
echo '<h2>Contacter d\'autres junistes près de '. $_SESSION['city'] . '</h2>';
|
echo '</ul>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<p>
|
<p>
|
||||||
<a href="'. BB_URL . '">
|
Ces événements sont importés automatiquement depuis
|
||||||
Groupe de discussion par mail du groupe de '. $_SESSION['city']. '
|
<a href="'. CALENDAR_URL .'">
|
||||||
|
l\'Agenda du libre
|
||||||
</a>
|
</a>
|
||||||
</p>';
|
</p>';
|
||||||
|
|
||||||
|
|
||||||
|
echo '<h2>Contacter d\'autres junistes près de '. $_SESSION['location'] . '</h2>';
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<p>
|
||||||
|
Consulter la doc de OpenStreetMap API pour voir comment récupérer les descriptions des pins des groupes locaux de la Framacarte.
|
||||||
|
</p>';
|
||||||
|
|
||||||
|
echo '
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="'. BB_URL . '">
|
||||||
|
Groupe de discussion par mail du groupe de Vannes
|
||||||
|
</a>
|
||||||
|
</p>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$offers = $gchange->getNearbyOffers($_SESSION['lat'], $_SESSION['lon'], RADIUS);
|
||||||
|
|
||||||
|
echo '<h2>Annonces à '. RADIUS . ' km autour de '. $_SESSION['location'] .'</h2>';
|
||||||
|
echo '<ol>';
|
||||||
|
foreach ($offers as $offer) {
|
||||||
|
|
||||||
|
$description = isset($offer->_source->description) ? ' title="'. substr($offer->_source->description, 0, 30) . '"' : '';
|
||||||
|
|
||||||
|
echo '
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="https://www.gchange.fr/#/app/market/view/'. $offer->_id . '/"'. $description .'>
|
||||||
|
' . $offer->_source->title . '
|
||||||
|
</a>
|
||||||
|
('. $offer->_source->city . ')
|
||||||
|
</li>
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
|
echo '</ol>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$users = $cesiumPlus->getNearbyUsers($_SESSION['lat'], $_SESSION['lon'], RADIUS);
|
$users = $cesiumPlus->getNearbyUsers($_SESSION['lat'], $_SESSION['lon'], RADIUS);
|
||||||
|
|
||||||
echo '<h2>Nouveaux utilisateurs à '. RADIUS . ' autour de '. $_SESSION['city'] .'</h2>';
|
echo '<h2>Nouveaux utilisateurs à '. RADIUS . ' km autour de '. $_SESSION['location'] .'</h2>';
|
||||||
|
|
||||||
echo '<table>';
|
echo '<table>';
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
|
@ -82,74 +138,6 @@ echo '<table>';
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
|
|
||||||
$offers = $gchange->getNearbyOffers($_SESSION['lat'], $_SESSION['lon'], RADIUS);
|
|
||||||
|
|
||||||
echo '<h2>Annonces à '. RADIUS . ' autour de '. $_SESSION['city'] .'</h2>';
|
|
||||||
echo '<ol>';
|
|
||||||
foreach ($offers as $offer) {
|
|
||||||
|
|
||||||
$description = isset($offer->_source->description) ? ' title="'. substr($offer->_source->description, 0, 30) . '"' : '';
|
|
||||||
|
|
||||||
echo '
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<a href="https://www.gchange.fr/#/app/market/view/'. $offer->_id . '/"'. $description .'>
|
|
||||||
' . $offer->_source->title . '
|
|
||||||
</a>
|
|
||||||
('. $offer->_source->city . ')
|
|
||||||
</li>
|
|
||||||
|
|
||||||
';
|
|
||||||
}
|
|
||||||
echo '</ol>';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$offers = $gchange->getShippable();
|
|
||||||
|
|
||||||
echo '<h2>Envoi possible</h2>';
|
|
||||||
echo '<ol>';
|
|
||||||
foreach ($offers as $offer) {
|
|
||||||
|
|
||||||
$description = isset($offer->_source->description) ? ' title="'. substr($offer->_source->description, 0, 30) . '"' : '';
|
|
||||||
|
|
||||||
echo '
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<a href="https://www.gchange.fr/#/app/market/view/'. $offer->_id . '/"'. $description .'>
|
|
||||||
' . $offer->_source->title . '
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
';
|
|
||||||
}
|
|
||||||
echo '</ol>';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$offers = $gchange->getImmaterialOffers();
|
|
||||||
|
|
||||||
echo '<h2>Annonces d\'ordre "immatériel"</h2>';
|
|
||||||
echo '<ol>';
|
|
||||||
foreach ($offers as $offer) {
|
|
||||||
|
|
||||||
$description = isset($offer->_source->description) ? ' title="'. substr($offer->_source->description, 0, 30) . '"' : '';
|
|
||||||
|
|
||||||
echo '
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<a href="https://www.gchange.fr/#/app/market/view/'. $offer->_id . '/"'. $description .'>
|
|
||||||
' . $offer->_source->title . '
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
';
|
|
||||||
}
|
|
||||||
echo '</ol>';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
include('footer.php');
|
include('footer.php');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue