Commit a26935df authored by Loïc DAYOT's avatar Loïc DAYOT
Browse files

refactor(): Xml export integration

End of integration of all exports format with the last one : XML.
Update comment text for exports.
Remove old exports files.
parent c9822ce4
......@@ -67,7 +67,7 @@ $adl_ical_more = "<p>Quelques fonctionnalités additionnelles des calendriers iC
"exemple de récupérer un calendrier iCal des évènements organisés uniquement ".
"par votre association, à partir du moment où vous pensez à marquer ".
"tous vos évènements avec un mot-clés précis.<br/>\n".
"Exemple&nbsp;: <code>http://{$adl_uid_end}/ical.php?tag=formation</code>. ".
"Exemple&nbsp;: <code>http://{$adl_uid_end}/exportevents.php?format=ical&amp;tag=formation</code>. ".
"</li>\n".
"</ul>\n";
......@@ -102,11 +102,11 @@ $adl_rss_more = "<p>Quelques fonctionnalités intéressantes des flux RSS&nbsp;:
"mots-clés avec le paramètre <code>tag</code>'. Par exemple, en marquant ".
"tous les évènements d'un espace avec le même mot-clé, vous pouvez afficher le ".
"flux RSS des évènements organisés uniquement par cet espace.<br /> ".
"Exemple&nbsp;: <code>". calendar_absolute_url('rss.php?tag=formation'). "</code>. ".
"Exemple&nbsp;: <code>". calendar_absolute_url('exportevents.php?format=rss&amp;tag=formation'). "</code>. ".
"</li>\n ".
"<li>Vous pouvez modifier la limite aux 30 prochains jours des flux ".
"RSS en utilisant le paramètre <code>daylimit</code>.<br/> ".
"Exemple&nbsp;: <code>". calendar_absolute_url('rss.php?region=6&amp;daylimit=42'). "</code> ".
"Exemple&nbsp;: <code>". calendar_absolute_url('exportevents.php?format=rss&amp;region=6&amp;daylimit=42'). "</code> ".
"</li>\n</ul>\n";
// javascriptlist.php
......@@ -117,7 +117,7 @@ $adl_js_more = "<p>Quelques fonctionnalités intéressantes du widget Javascript
"<ul>\n".
"<li>Vous pouvez obtenir plus ou moins d'événements dans votre liste ".
" en ajoutant le paramètre <code>count</code><br /> ".
"Exemple&nbsp;: <code>". calendar_absolute_url('javascript.php?region=10&count=20'). "</code>. ".
"Exemple&nbsp;: <code>". calendar_absolute_url('exportevents.php?format=js&amp;region=10&amp;count=20'). "</code>. ".
"</li>\n</ul>\n".
"<h5>Ci-dessous, vous pouvez voir le résultat de votre sélection&nbsp;:</h5>";
......
......@@ -63,7 +63,7 @@ switch ($format) {
case 'kml' : {
echo $eventList->kmlStartCalendar();
//$list = $eventList->getEventsList();
while ($eventList->event->id = $db->getOne($list))
{
$eventList->event->get();
......@@ -91,6 +91,16 @@ switch ($format) {
}
// TODO : XML from old xmllistevents.php
case 'xml' : {
$xml = $eventList->XmlStartCalendar($xml = new xmlWriter());
while ($eventList->event->id = $db->getOne($list))
{
$eventList->event->get();
$eventList->event->toXml($xml);
}
echo $eventList->XmlEndCalendar($xml);
break;
}
default :
case 'georss' :
......
......@@ -41,14 +41,15 @@ $export->getTagList('tags');
echo "<ul class='fa-ul'>\n";
echo " <li><i class='fa fa-li fa-rss'></i>&nbsp;Flux RSS 1.0 : <a href=\"". $export->rssUrl(). "\">". $export->rssUrl(). "</a>\n";
echo " <li><i class='fa fa-li fa-rss'></i>&nbsp;Flux GeoRSS (sans les détails) : <a href=\"". $export->georssUrl(). "\">". $export->georssUrl(). "</a>\n";
echo " <li><i class='fa fa-li fa-external-link'></i>&nbsp;Flux KML : <a href=\"". $export->KmlUrl(). "\">". $export->KmlUrl(). "</a>\n";
echo " <li><i class='fa fa-li fa-external-link'></i>&nbsp;Flux GeoJSON : <a href=\"". $export->geoJsonUrl(). "\">". $export->geoJsonUrl(). "</a>\n";
echo " <li><i class='fa fa-li fa-calendar'></i>&nbsp;Calendrier iCal : <a href=\"". $export->iCalUrl(). "\">". $export->iCalUrl(). "</a>\n";
echo " <li><i class='fa fa-li fa-google'></i>&nbsp;Google calendar : <a href=\"". $export->calGoogleUrl(). "\">". $export->calGoogleUrl(). "</a>\n";
echo " <li><i class='fa fa-li fa-code'></i>&nbsp;widget (JavaScript) : <code><a href=\"". $export->jsUrl(). "\">". $export->jsCode(). "</a></code>\n";
echo " <li><i class='fa fa-li fa-share'></i>&nbsp;web (liste dans le navigateur) : <a href=\"". $export->webUrl(). "\">". $export->webUrl(). "</a>\n";
echo " <li><i class='fas fa-li fa-rss'></i>&nbsp;Flux RSS 1.0 : <a href=\"". $export->rssUrl(). "\">". $export->rssUrl(). "</a>\n";
echo " <li><i class='fas fa-li fa-rss'></i>&nbsp;Flux GeoRSS (sans les détails) : <a href=\"". $export->georssUrl(). "\">". $export->georssUrl(). "</a>\n";
echo " <li><i class='fas fa-li fa-code'></i>&nbsp;Flux XML : <a href=\"". $export->XmlUrl(). "\">". $export->XmlUrl(). "</a>\n";
echo " <li><i class='fas fa-li fa-code'></i>&nbsp;Flux KML : <a href=\"". $export->KmlUrl(). "\">". $export->KmlUrl(). "</a>\n";
echo " <li><i class='fab fa-li fa-jsfiddle'></i>&nbsp;Flux GeoJSON : <a href=\"". $export->geoJsonUrl(). "\">". $export->geoJsonUrl(). "</a>\n";
echo " <li><i class='fas fa-li fa-calendar'></i>&nbsp;Calendrier iCal : <a href=\"". $export->iCalUrl(). "\">". $export->iCalUrl(). "</a>\n";
echo " <li><i class='fab fa-li fa-google'></i>&nbsp;Google calendar : <a href=\"". $export->calGoogleUrl(). "\">". $export->calGoogleUrl(). "</a>\n";
echo " <li><i class='fab fa-li fa-js'></i>&nbsp;widget (JavaScript) : <code><a href=\"". $export->jsUrl(). "\">". $export->jsCode(). "</a></code>\n";
echo " <li><i class='fas fa-li fa-share'></i>&nbsp;web (liste dans le navigateur) : <a href=\"". $export->webUrl(). "\">". $export->webUrl(). "</a>\n";
echo "</ul>\n";
echo "</fieldset>\n";
......
......@@ -972,6 +972,28 @@ class event {
PARTOFKML;
}
function toXml($xml)
{
$xml->startElement("event");
$xml->writeElement("title", $this->title);
$xml->writeElement("start-time", $this->start_time);
$xml->writeElement("end-time", $this->end_time);
$xml->writeElement("city", $this->city);
$region = new region($this->db, $this->region);
$xml->writeElement("region", $region->name);
unset($region);
$xml->writeElement("locality", $this->locality);
$xml->writeElement("url", $this->url);
$xml->writeElement("tags", $this->tags);
$xml->writeElement("contact", $this->contact);
$xml->writeElement("adlurl", calendar_absolute_url("showevent.php?id=" . $this->id));
$xml->startElement("description");
$xml->writeCData($this->description);
$xml->endElement();
$xml->endElement();
return $xml;
}
// -------------------------------------------------------------------
function toGeojson()
......
......@@ -245,6 +245,13 @@ class exportEvent {
// -------------------------------------------------------------------
function XmlUrl()
{
return calendar_absolute_url("exportevents.php?format=xml&amp;". $this->partOfUrl());
}
// -------------------------------------------------------------------
function geoJsonUrl()
{
return calendar_absolute_url("exportevents.php?format=geojson&amp;". $this->partOfUrl());
......@@ -429,6 +436,26 @@ KMLSTART;
KMLEND;
}
// XML -------------------------------------------------------------
function XmlStartCalendar()
{
$xml = new xmlWriter();
$xml->openMemory();
$xml->startDocument("1.0", "UTF-8");
$xml->startElement("events");
return $xml;
}
function XmlEndCalendar($xml)
{
$xml->EndElement();
$xml->endDocument();
header("Content-type: text/xml");
return $xml->outputMemory(true);
}
// geoJSON ---------------------------------------------------------
function geoJsonStartCalendar()
......
<?php
/*
* Copyright 2008-2017
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
* This file is part of agenda-libre-php.
*
* agenda-libre-php is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* agenda-libre-ph is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with agenda-libre-php. If not, see <http://www.gnu.org/licenses/>.
*/
$privatePage = false;
include("inc/main.inc.php");
include("inc/class.localgroup.inc.php");
$localgroup_id = get_safe_integer('id', 0);
$region_id = get_safe_integer('region', 0);
$depart_id = get_safe_integer('depart', 0);
$partOfLocalgroupName = (isset($_GET['queryString']) ? $_GET['queryString'] : "");
$localgroups = new localgroups($db);
if ($localgroup_id>0)
{
$localgroups->getOne($localgroup_id);
}
elseif ($depart_id>0)
{
$localgroups->getFromDepartment($depart_id);
}
elseif ($region_id>0)
{
$localgroups->getFromRegion($region_id);
}
elseif (isset($_GET['queryString']))
{
if ($partOfLocalgroupName>"")
{ // -----------------------------------------------------------------
// Ajax query from Event form
$localgroups->getFromName($partOfLocalgroupName);
http_response_code(200);
header('Content-type: application/json');
echo $localgroups->formatJson();
} else {
http_response_code(500);
}
exit;
}
if (count($localgroups->localgroups)==0)
{
put_header(ucfirst($adl_localgroups));
echo returnWarning("Pas de $adl_localgroups_acronym avec ce filtre");
put_footer();
exit;
}
Header("Content-type: text/plain; charset: utf-8");
echo $localgroups->formatCsvOsm();
<?php
/*
* Copyright 2007-2015
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
*
* This file is part of agenda-libre-php.
*
* agenda-libre-php is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* agenda-libre-ph is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with agenda-libre-php. If not, see <http://www.gnu.org/licenses/>.
*/
$privatePage = false;
include("inc/main.inc.php");
include_once("inc/class.region.inc.php");
if (isset($_GET['tag']) && preg_match("~^[a-z0-9\-]*$~", $_GET['tag']))
$tag = $_GET['tag'];
else
$tag = '';
if (isset($_GET['start']) && $_GET['start'] == 'now')
$start = "now";
else
$start = '';
$limit = get_safe_integer('limit', 0);
/*$sql = "select * from {$GLOBALS['db_tablename_prefix']}events where (tags like '%" . $_GET['tag'] . "%') " .
"and (moderated=1) order by start_time";*/
$sql = "select * from {$GLOBALS['db_tablename_prefix']}events where (moderated=1)";
if ($start == 'now')
$sql .= " and (end_time >= '" . date_timestamp2mysql(time()) . "')";
if ($tag != '')
$sql .= " and (concat(' ', tags, ' ') like '% " . $tag . " %') ";
$sql .= " order by start_time asc";
if ($limit != 0)
$sql .= " limit " . $limit;
$events = $db->query($sql);
if (! $events)
{
echo "Erreur lors de la requête SQL.";
exit;
}
$xml = new xmlWriter();
$xml->openMemory();
$xml->startDocument("1.0", "UTF-8");
$xml->startElement("events");
while($event = mysql_fetch_object($events))
{
$xml->startElement("event");
$xml->writeElement("title", $event->title);
$xml->writeElement("start-time", $event->start_time);
$xml->writeElement("end-time", $event->end_time);
$xml->writeElement("city", $event->city);
$region = new region($db, $this->region);
$xml->writeElement("region", $region->name);
$xml->writeElement("locality", $event->locality);
$xml->writeElement("url", $event->url);
$xml->writeElement("tags", eventTagsList($event->id));
$xml->writeElement("contact", $event->contact);
$xml->writeElement("adlurl", calendar_absolute_url("showevent.php?id=" . $event->id));
$xml->startElement("description");
$xml->writeCData($event->description);
$xml->endElement();
$xml->endElement();
}
$xml->EndElement();
$xml->endDocument();
header("Content-type: text/xml");
echo $xml->outputMemory(true);
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment